/// <summary> /// 设置系统时间 /// </summary> /// <param name="result"></param> private static void UpdateSystemTime(ResultModelOfstring result, double s) { if (result.Code != 0) { throw new Exception(result.Message); } try { DateTime now = DateTime.Parse(result.Data).AddSeconds(s); SetSysTime(now); RegistSyncEvent("时间同步成功:" + now.ToString("M/d HH:mm.ss")); } catch (Exception ex) { throw new Exception("设置系统时钟失败:" + ex.Message); } }
/// <summary> /// 线程执行 /// </summary> private static void DoWork() { try { //string lastTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); RegistSyncEvent("正在获取服务器时间......"); DateTime dtStart = DateTime.Now; ResultModelOfstring timeResult = Common._PdaServer.GetServerTimeStr(); DateTime dtEnd = DateTime.Now; UpdateSystemTime(timeResult, (dtEnd - dtStart).TotalSeconds); RegistSyncEvent("正在获取PDA信息......"); ResultModelOfModel_PDAInfod4FqxSXX pdaInfoResult = Common._PdaServer.GetPDAInfo(Common._PDANumber); UpdatePDAInfo(pdaInfoResult); RegistSyncEvent("正在获取目的地信息......"); ResultModelOfArrayOfstringuHEDJ7Dj destinsResult = Common._PdaServer.GetDestins(pdaInfoResult.Data.Idk__BackingField, true); UpdateDestins(destinsResult); RegistSyncEvent("正在获取冷藏载体信息......"); ResultModelOfArrayOfModel_ColdStoraged4FqxSXX storagesResult = Common._PdaServer.GetStorages(pdaInfoResult.Data.Idk__BackingField, true); UpdateStorages(storagesResult); ResultModelOfArrayOfModel_ColdStoraged4FqxSXX storageScanResult = Common._PdaServer.GetStorageScan(); UpdateStorageScan(storageScanResult); RegistSyncEvent("正在获取对接供应商......"); ResultModelOfArrayOfModel_ThirdCustomerd4FqxSXX consignorResult = Common._PdaServer.GetThirdCustomers(); UpdateConsignor(consignorResult); RegistSyncEvent("正在获取客户信息......"); UpdateCustomer(pdaInfoResult.Data.Idk__BackingField, 0, 0); RegistSyncEvent("正在获取区域信息......"); //ResultModelOfArrayOfPDA_Model_Regiond4FqxSXX regionResult = Common._PdaServer.GetRegions(pdaInfoResult.Data.Idk__BackingField, true); //UpdateRegion(regionResult); UpdateRegion(pdaInfoResult.Data.Idk__BackingField, 0, 0); //DictionaryServer.SetPDAInfo(Enum_DicKey.lastSyncTime, lastTime); Common._LastSyncTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (_isReLoadLocalInfo > 0) { RegistSyncEvent("客户与区域信息变更,正在重新构造缓存......"); FrmParent.ParentForm.LoadLocalData(); RegistSyncEvent("重新缓存完毕"); } if (SyncFinish != null) { SyncFinish("同步已完成!"); } } catch (Exception ex) { if (ex.Message.Contains("ThreadAbortException")) { RegistSyncEvent("您已终止同步!"); } else { RegistSyncEvent("同步终止[" + ex.Message + "]"); } if (SyncFinish != null) { SyncFinish("同步未完成!"); } } finally { _isReLoadLocalInfo = 0; _isRuning = false; //_runLog = new StringBuilder(); } }