/// <summary> /// 异步方式进行数据的更新 /// </summary> private void StartUpdateDate() { ///创建同步历史记录 createUpdateRecordXml(); /// <summary> /// 新建WCF服务实例 /// </summary> try { wcfclient = new DeskTopServiceClient(); } catch (Exception ex) { LogHelper.LogWrite(ex.Message); } ///下载维护保养计划 try { byte[] bytes = wcfclient.GetPlanList(); if (!Directory.Exists(wcfdownloadpath)) { Directory.CreateDirectory(wcfdownloadpath); using (FileStream wcfFile = new FileStream(wcfdownloadpath + "planList.xml", FileMode.Create)) { wcfFile.Write(bytes, 0, bytes.Length); wcfFile.Flush(); } } else { //File.Delete(wcfdownloadpath + "planList.xml"); using (FileStream wcfFile = new FileStream(wcfdownloadpath + "planList.xml", FileMode.Create)) { wcfFile.Write(bytes, 0, bytes.Length); wcfFile.Flush(); } } Thread.Sleep(100); try { portableDevices[0].CopyFolderToPad(lastObjDown, wcfdownloadpath + "planList.xml"); } catch (Exception ex) { LogHelper.LogWrite(ex); } n = n + 1; Thread.Sleep(100); //MessageBox.Show("下载维护保养计划成功!"); } catch (Exception ex) { LogHelper.LogWrite(ex); } ///下载应急预案 //int a=int.Parse(DateTime.now) try { byte[] bytes = wcfclient.EmergencyDetail(DateTime.Now.ToString("yyyy"), 505); if (!Directory.Exists(wcfdownloadpath)) { Directory.CreateDirectory(wcfdownloadpath); using (FileStream wcfFile = new FileStream(wcfdownloadpath + "应急预案.pdf", FileMode.Create)) { wcfFile.Write(bytes, 0, bytes.Length); wcfFile.Flush(); } } else { //File.Delete(wcfdownloadpath + "planList.xml"); using (FileStream wcfFile = new FileStream(wcfdownloadpath + "应急预案.pdf", FileMode.Create)) { wcfFile.Write(bytes, 0, bytes.Length); wcfFile.Flush(); } } Thread.Sleep(100); try { portableDevices[0].CopyFolderToPad(lastObjDown, wcfdownloadpath + "应急预案.pdf"); } catch (Exception ex) { LogHelper.LogWrite(ex); } n = n + 1; Thread.Sleep(100); } catch (Exception ex) { LogHelper.LogWrite(ex); } ///异步方式下载备份备件信息 try { myBackupEquip = new AsycBackupEquip(wcfclient.GetProduct); myBackupEquip.BeginInvoke(new AsyncCallback(IsDownBackupEquipCom), null); } catch (Exception ex) { LogHelper.LogWrite(ex); } //异步方式下载应急计划 try { string currentYear = DateTime.Now.ToString("yyyy"); int departMentName = 505; myEmergencyPlan = new AsycEmergencyPlan(wcfclient.EmergencyDetail); myEmergencyPlan.BeginInvoke(currentYear, departMentName, new AsyncCallback(IsEmergencyPlanCom), null); } catch (Exception ex) { LogHelper.LogWrite(ex); } int CompressionLevel = 9; try { myZip = new AsycMyZipZipDir(new ICharpZip().ZipDir); myZip.BeginInvoke(DirToZip, ZipedFile, CompressionLevel, new AsyncCallback(IsZipComplete), null); } catch (Exception ex) { LogHelper.LogWrite(ex); } ///异步方法下载设备台账信息 try { myEquipInfo = new AsycEquipInfo(wcfclient.GetTZList); myEquipInfo.BeginInvoke(new AsyncCallback(IsDownEquipInfoComplete), null); } catch (Exception ex) { LogHelper.LogWrite(ex); } }