- Timestamp:
- Jan 30, 2015 2:46:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php
r714 r721 12 12 if($this->input->is_cli_request()){ 13 13 error_reporting(E_ALL); 14 15 14 $this->load->model('Services_model'); 16 17 //$totalpage = 10213;18 19 // get total page20 15 $totalpage = 1; 21 16 22 $default = $this->Services_model->getCollaborator(2,1,100); 23 //var_dump($default); 17 $default = $this->Services_model->getCollaborator(2,1,5000); 24 18 $data = mb_convert_encoding($default, 'UTF-8', 'ISO-8859-1'); 25 19 if($data){ 26 20 $xml = simplexml_load_string($data); 27 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 28 21 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 29 22 $xml = $xml->xpath('//S:Body'); 30 23 $xml = $xml[0]; 31 32 24 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/"); 33 34 25 $totalpage = $xml->xpath('//return//totalpage'); 35 26 $totalpage = (int)$totalpage[0]; … … 37 28 38 29 for ($i=1; $i<=$totalpage; $i++){ 39 $result = $this->Services_model->getCollaborator(2,$i, 100);30 $result = $this->Services_model->getCollaborator(2,$i,500); 40 31 $data = mb_convert_encoding($result, 'UTF-8', 'ISO-8859-1'); 41 32 if($data && $data != -1){ … … 72 63 } 73 64 } 65 }else{ 66 show_404(); 74 67 } 75 68 } 69 70 public function deleteCollaborator () 71 { 72 73 if($this->input->is_cli_request()){ 74 error_reporting(E_ALL); 75 $this->load->model('Services_model'); 76 $totalpage = 1; 77 78 $default = $this->Services_model->getCollaborator(2,1,5000); 79 $data = mb_convert_encoding($default, 'UTF-8', 'ISO-8859-1'); 80 if($data){ 81 $xml = simplexml_load_string($data); 82 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 83 $xml = $xml->xpath('//S:Body'); 84 $xml = $xml[0]; 85 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/"); 86 $totalpage = $xml->xpath('//return//totalpage'); 87 $totalpage = (int)$totalpage[0]; 88 } 89 90 $collaboratorIds = array(); 91 92 $logMsg = "Start XML Process: " . date('Y-m-d H:i:s') . "\n"; 93 write_file('./log/delete_collaborator.log', $logMsg, FOPEN_WRITE_CREATE); 94 95 for ($i=1; $i<$totalpage; $i++){ 96 $result = $this->Services_model->getCollaborator(2,$i,5000); 97 $data = mb_convert_encoding($result, 'UTF-8', 'ISO-8859-1'); 98 if($data && $data != -1){ 99 $xml = simplexml_load_string($data); 100 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 101 $xml = $xml->xpath('//S:Body'); 102 $xml = $xml[0]; 103 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/"); 104 $lst = $xml->xpath('//return//lst'); 105 foreach($lst as $item){ 106 $item = (array)$item; 107 if ((string)$item['phone']){ 108 array_push($collaboratorIds, (int)$item['id']); 109 } 110 } 111 }else{ 112 $logMsg = date('Y-m-d H:i:s') . " Result is null \n"; 113 write_file('./log/delete_collaborator.log', $logMsg, FOPEN_WRITE_CREATE); 114 } 115 } 116 117 $logMsg = "Finish XML Process: " . date('Y-m-d H:i:s') . "\n"; 118 write_file('./log/delete_collaborator.log', $logMsg, FOPEN_WRITE_CREATE); 119 120 $collaboratorIdsSync = $this->Services_model->getAllCollaboratorID(); 121 122 if ($collaboratorIdsSync){ 123 foreach($collaboratorIdsSync as $collaborator){ 124 $id = (int)$collaborator->id; 125 if (in_array($id, $collaboratorIds) == false){ 126 $this->Services_model->deleteCollaborator($id); 127 } 128 } 129 } 130 }else{ 131 show_404(); 132 } 133 134 } 76 135 }
Note: See TracChangeset
for help on using the changeset viewer.