コード例 #1
0
ファイル: UploadallcdcSearch.php プロジェクト: inamjung/cdc
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Uploadallcdc::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 30], 'sort' => ['defaultOrder' => ['upload_date' => SORT_DESC, 'upload_time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'hospcode', $this->hospcode])->andFilterWhere(['like', 'file_name', $this->file_name])->andFilterWhere(['like', 'file_size', $this->file_size])->andFilterWhere(['like', 'upload_date', $this->upload_date])->andFilterWhere(['like', 'upload_time', $this->upload_time])->andFilterWhere(['like', 'note1', $this->note1])->andFilterWhere(['like', 'note2', $this->note2])->andFilterWhere(['like', 'note3', $this->note3])->andFilterWhere(['like', 'note4', $this->note4])->andFilterWhere(['like', 'note5', $this->note5]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: AjaxController_1.php プロジェクト: inamjung/cdc
 public function actionImport4($fortythree, $upload_date, $upload_time)
 {
     ini_set('max_execution_time', 0);
     //$ubuntu_path = "/var/lib/mysql/fortythree/";
     $rootpath = \Yii::getAlias('@webroot') . "/fortythree/";
     $filefortythree = $rootpath . $fortythree;
     $file_size = number_format(filesize($filefortythree) / (1024 * 1024), 3);
     $file_size = strval($file_size);
     $zip = new \ZipArchive();
     if ($zip->open($filefortythree) === TRUE) {
         $zip->extractTo($rootpath);
         $zip->close();
     }
     //rename($path . $oldname, $path . $fortythree);
     unlink("{$rootpath}{$fortythree}");
     $folder_with_ext = explode('.', $fortythree);
     $folder_without_ext = $folder_with_ext[0];
     $full_dir = "{$rootpath}/{$folder_without_ext}";
     $dir = opendir($full_dir);
     $cfmodel = new SysCountImport();
     $cfmodel->import_date = date('YmdHis');
     $cfmodel->filename = $fortythree;
     $cfmodel->upload_date = $upload_date;
     $cfmodel->upload_time = $upload_time;
     while (($file = readdir($dir)) !== false) {
         if ($file !== "." && $file !== "..") {
             $p = pathinfo($file);
             $ftxt = $p['filename'];
             $ftxt = strtolower($ftxt);
             $ext = $p['extension'];
             if (strtolower($ext) == 'txt' && $ftxt !== 'office') {
                 $transaction = \Yii::$app->db->beginTransaction();
                 try {
                     $sql = "LOAD DATA LOCAL INFILE '{$rootpath}{$folder_without_ext}/{$file}'";
                     $sql .= " REPLACE INTO TABLE {$ftxt}";
                     $sql .= " FIELDS TERMINATED BY '|'  LINES TERMINATED BY '\r\n' IGNORE 1 LINES";
                     $count = \Yii::$app->db->createCommand($sql)->execute();
                     $transaction->commit();
                 } catch (Exception $e) {
                     $transaction->rollBack();
                 }
                 if ($cfmodel->hasAttribute($ftxt)) {
                     $cfmodel->setAttribute($ftxt, $count);
                 }
             }
         }
     }
     $cfmodel->save();
     $upload = new Uploadallcdc();
     $upload->file_name = $fortythree;
     $upload->file_size = $file_size;
     $fff = explode('_', $fortythree);
     $upload->hospcode = $fff[1];
     $upload->upload_date = date('Ymd');
     $upload->upload_time = date('His');
     $upload->note2 = 'OK';
     $upload->note3 = 'import all';
     $upload->save();
     $up = Uploadallcdc::findOne(['file_name' => $fortythree]);
     if ($up) {
         $up->note2 = 'OK';
         $up->note3 = 'import all';
         $up->update();
     }
     closedir($dir);
     $dir = opendir($full_dir);
     while (($file = readdir($dir)) !== false) {
         if ($file !== "." && $file !== "..") {
             if ($file !== "." && $file !== "..") {
                 unlink("{$rootpath}{$folder_without_ext}/{$file}");
             }
         }
     }
     closedir($dir);
     rmdir("{$rootpath}{$folder_without_ext}");
     return $fortythree;
 }
コード例 #3
0
 /**
  * Finds the Uploadallcdc model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Uploadallcdc the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Uploadallcdc::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }