@@ -73,6 +73,13 @@ namespace CNAS_RunSync | |||||
this.lblTitleMsg.Text= string.Format("类型:{0} 路径:{1}", syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType.ToString(),syncInstrumentItem.SyncInstrumentDSInfo.Path); | this.lblTitleMsg.Text= string.Format("类型:{0} 路径:{1}", syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType.ToString(),syncInstrumentItem.SyncInstrumentDSInfo.Path); | ||||
//获取目标表最近上传时间 | |||||
Dictionary<string, string> times = this.ReadSyncTime(); | |||||
if (true == times?.ContainsKey(this.syncInstrumentItem.Code)) | |||||
{ | |||||
this.lblTitleLastUpdateTime.Text = $"最近上传时间:{times[this.syncInstrumentItem.Code]}"; | |||||
} | |||||
//清空现有绑定 | //清空现有绑定 | ||||
DictComboBox.Clear(); | DictComboBox.Clear(); | ||||
dictSource.Clear(); | dictSource.Clear(); | ||||
@@ -129,14 +136,6 @@ namespace CNAS_RunSync | |||||
cmbColumns.ValueMember = "Key"; | cmbColumns.ValueMember = "Key"; | ||||
cmbColumns.DisplayMember = "Key"; | cmbColumns.DisplayMember = "Key"; | ||||
} | } | ||||
//4.初始化最近上传时间 | |||||
//4.1 获取目标表最近上传时间 | |||||
Dictionary<string, string> times = this.ReadSyncTime(); | |||||
if (true == times?.ContainsKey(this.syncInstrumentItem.Code)) | |||||
{ | |||||
this.lblTitleLastUpdateTime.Text = $"最近上传时间:{times[this.syncInstrumentItem.Code]}"; | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -42,6 +42,10 @@ | |||||
<SpecificVersion>False</SpecificVersion> | <SpecificVersion>False</SpecificVersion> | ||||
<HintPath>..\dll\log4net.dll</HintPath> | <HintPath>..\dll\log4net.dll</HintPath> | ||||
</Reference> | </Reference> | ||||
<Reference Include="Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | |||||
<SpecificVersion>False</SpecificVersion> | |||||
<HintPath>..\dll\Newtonsoft.Json.dll</HintPath> | |||||
</Reference> | |||||
<Reference Include="System" /> | <Reference Include="System" /> | ||||
<Reference Include="System.Configuration.Install" /> | <Reference Include="System.Configuration.Install" /> | ||||
<Reference Include="System.Core" /> | <Reference Include="System.Core" /> | ||||
@@ -2,9 +2,11 @@ | |||||
using CnasSynchronousCommon; | using CnasSynchronousCommon; | ||||
using CnasSynchronusClient; | using CnasSynchronusClient; | ||||
using CnasSynchrousModel; | using CnasSynchrousModel; | ||||
using Newtonsoft.Json; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Data; | using System.Data; | ||||
using System.Diagnostics; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -145,7 +147,12 @@ namespace CNAS_SyncService | |||||
if (query.Count == 1) | if (query.Count == 1) | ||||
{ | { | ||||
string strCompareTime = ""; | string strCompareTime = ""; | ||||
string strDateTime = CnasDataOperationFact.CnasDataOperation().GetMaxTimeByTableName(syncInstrumentItem.SyncTargetDBInfo, syncInstrumentItem.LstSyncPramas[0].TargetTable, query[0].TargetField, syncInstrumentItem.CnasInstrumentColumn, syncInstrumentItem.GUID); | |||||
string strDateTime = ""; | |||||
Dictionary<string, string> times = this.ReadSyncTime(); | |||||
if (true == times?.ContainsKey(syncInstrumentItem.Code)) | |||||
{ | |||||
strDateTime = $"{times[syncInstrumentItem.Code]}"; | |||||
} | |||||
//strDateTime = "2016-07-01 00:00:00"; | //strDateTime = "2016-07-01 00:00:00"; | ||||
if (strDateTime == "1899-1-1") | if (strDateTime == "1899-1-1") | ||||
@@ -368,5 +375,43 @@ namespace CNAS_SyncService | |||||
} | } | ||||
return config; | return config; | ||||
} | } | ||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
private Dictionary<string, string> ReadSyncTime() | |||||
{ | |||||
Dictionary<string, string> times = null; | |||||
if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache", $"SyncTime.bin"))) | |||||
{ | |||||
try | |||||
{ | |||||
using (StreamReader reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache", $"SyncTime.bin"), Encoding.UTF8)) | |||||
{ | |||||
try | |||||
{ | |||||
string json = reader.ReadToEnd(); | |||||
times = JsonConvert.DeserializeObject<Dictionary<string, string>>(json); | |||||
} | |||||
catch | |||||
{ | |||||
} | |||||
finally | |||||
{ | |||||
reader.Close(); | |||||
reader.Dispose(); | |||||
} | |||||
} | |||||
} | |||||
catch (Exception exception) | |||||
{ | |||||
Debug.WriteLine(exception.Message); | |||||
} | |||||
} | |||||
return times; | |||||
} | |||||
} | } | ||||
} | } |