Parcourir la source

优化上次上传时间获取位置。优化同步服务设置获取同步时间。

develop
曾凯 il y a 4 mois
Parent
révision
574fabd3ec
3 fichiers modifiés avec 57 ajouts et 9 suppressions
  1. +7
    -8
      CNAS_RunSync/ucSynchrousMain.cs
  2. +4
    -0
      CNAS_SyncService/CNAS_SyncService.csproj
  3. +46
    -1
      CNAS_SyncService/SyncServiceOperation.cs

+ 7
- 8
CNAS_RunSync/ucSynchrousMain.cs Voir le fichier

@@ -73,6 +73,13 @@ namespace CNAS_RunSync
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();
dictSource.Clear();
@@ -129,14 +136,6 @@ namespace CNAS_RunSync
cmbColumns.ValueMember = "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>


+ 4
- 0
CNAS_SyncService/CNAS_SyncService.csproj Voir le fichier

@@ -42,6 +42,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\log4net.dll</HintPath>
</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.Configuration.Install" />
<Reference Include="System.Core" />


+ 46
- 1
CNAS_SyncService/SyncServiceOperation.cs Voir le fichier

@@ -2,9 +2,11 @@
using CnasSynchronousCommon;
using CnasSynchronusClient;
using CnasSynchrousModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
@@ -145,7 +147,12 @@ namespace CNAS_SyncService
if (query.Count == 1)
{
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";
if (strDateTime == "1899-1-1")
@@ -368,5 +375,43 @@ namespace CNAS_SyncService
}
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;
}
}
}

Chargement…
Annuler
Enregistrer