/// <summary> /// 다운로드 파일 이동 /// </summary> private void FileMove() { try { Thread.Sleep(500); //원본폴더 확인 if (!CoFAS_FileManager.FolderExists(strPathUpdate)) { return; } CoFAS_FileManager.FolderFileMove(strPathUpdate, strTargetPath); } catch { } finally { if (CoFAS_FileManager.FileExists(strStartFile)) { try { System.Diagnostics.Process pro = new System.Diagnostics.Process(); pro.StartInfo.FileName = strStartFile; pro.Start(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
private void Setting_Init() { dsSetting = new DataSet(); if (CoFAS_FileManager.FileExists(strDSFileName)) { dsSetting.ReadXml(strDSFileName); iucEngCnt = dsSetting.Tables["P_SET"].Rows.Count; foreach (DataTable dt in dsSetting.Tables) { dt.PrimaryKey = new DataColumn[] { dt.Columns["RESOURCE_CODE"] }; } dsSetting.AcceptChanges(); } else { dsSetting = new DataSet(); DataTable dt = new DataTable("P_SET"); dt.Columns.Add(new DataColumn("CORP_CODE", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("GATHERING_DUBN", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_CODE", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_NAME", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_IP", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_PORT", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_INTERVAL", Type.GetType("System.String"))); dt.Columns.Add(new DataColumn("RESOURCE_TYPE", Type.GetType("System.String"))); dt.PrimaryKey = new DataColumn[] { dt.Columns["RESOURCE_CODE"] }; dsSetting.Tables.Add(dt); } }
/// <summary> /// 파일 다운로드 /// </summary> private void FileDownload() { try { DoEvent(false, "Chack Download File..."); pAutoDownloadEntity.FILE_TYPE = strFileType; using (DataTable dt = new AutoDownloadBusiness().FileInfo_GetList(pAutoDownloadEntity)) { int intUpdateTotalCount = dt.Rows.Count; int intUpdateCount = 0; DoEvent(false, string.Format("Update File List {0} Files - Start File Download...", intUpdateTotalCount.ToString())); foreach (DataRow dr in dt.Rows) { intUpdateCount++; CoFAS_ControlManager.InvokeIfNeeded(_lbFileCount, () => _lbFileCount.Text = string.Format("{0:D0}% {1:D2}/{2:D2}", 100 * intUpdateCount / intUpdateTotalCount, intUpdateCount, intUpdateTotalCount)); CoFAS_ControlManager.InvokeIfNeeded(_pgrAutodownloadAll, () => { _pgrAutodownloadAll.Properties.Maximum = intUpdateTotalCount; _pgrAutodownloadAll.Properties.Minimum = 0; _pgrAutodownloadAll.PerformStep(); _pgrAutodownloadAll.Update(); }); string strFileName = strTargetPath + @"\" + CoFAS_ConvertManager.obj2String(dr["FILENAME"]); string strTempFileName = strPathUpdate + CoFAS_ConvertManager.obj2String(dr["FILENAME"]); string strVersion = CoFAS_ConvertManager.obj2String(dr["VERSION"]); DateTime dtFileDate = (DateTime)dr["FILE_DATE"]; string strCrc = CoFAS_ConvertManager.obj2String(dr["CRC"]); int intFileSize = Convert.ToInt32(dr["FILE_SIZE"]); bool isUpdate = false; string strFileVersion = string.Empty; DateTime dtFileFileDate = DateTime.Now; isUpdate = false; DoEvent(false, string.Format("Check the file '{0}'", dr["FILENAME"])); if (CoFAS_FileManager.FileExists(strFileName)) { System.IO.FileInfo fi = new System.IO.FileInfo(strFileName); strFileVersion = CoFAS_ConvertManager.obj2String(CoFAS_FileManager.FileGetVersion(fi.FullName)); dtFileFileDate = fi.LastWriteTime; if (strFileVersion != strVersion || CoFAS_ConvertManager.obj2String(dtFileFileDate) != CoFAS_ConvertManager.obj2String(dtFileDate)) { isUpdate = true; } } else { isUpdate = true; } int intErrCnt = 0; while (isUpdate) { pAutoDownloadEntity.FILE_TYPE = "MES"; pAutoDownloadEntity.FILENAME = CoFAS_ConvertManager.obj2String(dr["FILENAME"]); pAutoDownloadEntity.FILE_PATH = strPathUpdate; string strFileCrc = new AutoDownloadBusiness().FileInfo_GetFileData(pAutoDownloadEntity); GC.Collect(); Application.DoEvents(); GC.WaitForPendingFinalizers(); //crc검사 if (strCrc != strFileCrc) { intErrCnt++; CoFAS_FileManager.FileDelete(strPathUpdate + CoFAS_ConvertManager.obj2String(dr["FILENAME"])); //3회까지 시도한다. if (intErrCnt > 2) { isUpdate = false; } else { isUpdate = true; } } else { isUpdate = false; System.IO.FileInfo fi = new System.IO.FileInfo(strTempFileName); fi.LastWriteTime = dtFileDate; } } } } DoEvent(false, string.Format("Completed downloading files from server")); } catch { throw; } finally { } }