16
Data Import From the Server of The Central Bank of the Russian Federation: How To Olga Smolyankina

Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Embed Size (px)

Citation preview

Page 1: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import From the Server of The Central Bank of the Russian Federation: How ToOlga Smolyankina

Page 2: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

2 Ways Integration .NET Framework

Page 3: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

2 Ways Integration. SOAP

Page 4: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

2 Ways Integration. SOAP

php.ini

[soap]

soap.wsdl_cache_enabled = 1soap.wsdl_cache_dir = "/tmp"soap.wsdl_cache_ttl = 86400soap.wsdl_cache_limit = 5

php.ini

;extension=php_shmop.dll;extension=php_snmp.dll extension=php_soap.dll;extension=php_sockets.dll;extension=php_sqlite.dll

Page 5: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import

Page 6: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. Credit Organizationshttp://www.cbr.ru/CreditInfoWebServ/CreditOrgInfo.asmx

Page 7: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. Credit Organizationshttp://www.cbr.ru/CreditInfoWebServ/CreditOrgInfo.asmx?WSDL

Page 8: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. Credit Organizations

Page 9: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. Credit Organizationsclass CreditOrganizationsCBRF { var $credit_organizations; var $client;

function __construct() { $this->client = new SoapClient('http://www.cbr.ru/CreditInfoWebServ/CreditOrgInfo.asmx?WSDL'); $data_xml = $this->client->EnumBIC_XML(); $result = simplexml_load_string($data_xml->EnumBIC_XMLResult->any); foreach ($result as $item) { $item = json_decode(json_encode((array) $item), 1); $intcode = $this->client->BicToIntCode(array( 'BicCode' => $item['BIC'] )); $offices_xml = $this->client->GetOfficesXML(array( 'IntCode' => $intcode->BicToIntCodeResult )); $offices = simplexml_load_string($offices_xml->GetOfficesXMLResult->any); $info_xml = $this->client->CreditInfoByIntCodeXML(array( 'InternalCode' => $intcode->BicToIntCodeResult )); $info = simplexml_load_string($info_xml->CreditInfoByIntCodeXMLResult->any);...

Page 10: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. Credit Organizations...

$data = array( 'BIC' => $item['BIC'], 'RC' => $item['RC'], 'NM' => $item['NM'], 'RB' => $item['RB'], 'OFFICES' => json_decode(json_encode((array) $offices), 1), 'INTCODE' => $intcode->BicToIntCodeResult, 'INFO' => json_decode(json_encode((array) $info), 1), ); $this->credit_organizations[] = $data; } }}

Page 11: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. The Problem

Page 12: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. The Problem

Page 13: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. The Hope

http://www.cbr.ru/mcirabis/PluginInterface/GetBicCatalog.aspx?type=db

Page 14: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. The Solution/** * Implements hook_cron(). */function custom_module_cron() { $filepath = custom_module_get_last_dbf_filepath(); $options = custom_module_update_db_from_dbf($filepath); $queue = DrupalQueue::get('credit_org_update'); $queue->createQueue(); $queue->createItem($options);}

/** * Implements hook_cron_queue_info(). */function custom_module_cron_queue_info() { $queues = array(); $queues['credit_org_update'] = array( 'worker callback' => 'credit_org_update_callback', 'time' => UPDATE_WORKER_CALLBACK_TIME, ); return $queues;}

/** * Load credit organizations from .dbf file. * @paramstring $path * @return array */function custom_module_update_db_from_dbf($path) { $library_path = libraries_get_path('XBase'); require_once($library_path . '/Table.php'); require_once($library_path . '/Column.php'); require_once($library_path . '/Record.php'); $table = new Table($path); $columns = array_keys($table->getColumns()); $options = array(); while ($record = $table->nextRecord()) { $row = array(); foreach ($columns as $column) { $row[$column] = iconv('cp866', 'UTF-8', $record->{$column}); } $options[] = $row; } return $options;}

Page 15: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Data Import. The Solution

Page 16: Data Import From the Server of The Central Bank of the Russian Federation: How To. Olga Smolyankina

Thank you!