Commit 08b752ad authored by 姜春辉's avatar 姜春辉

完成识别记录上传服务迁移

parent fb343727
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#endregion #endregion
using GS.EnterpriseIdentification.ServiceModel; using GS.EnterpriseIdentification.ServiceModel;
using GS.Terminal.Common.LocalSetting;
using GS.Terminal.Identification.Enterprise.Logic.Core; using GS.Terminal.Identification.Enterprise.Logic.Core;
using GS.Unitive.Framework.Core; using GS.Unitive.Framework.Core;
using IdentificationViewModels; using IdentificationViewModels;
......
...@@ -112,7 +112,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -112,7 +112,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic
} }
}).ContinueWith((task) => }).ContinueWith((task) =>
{ {
Program.uploader.Do(id); Program.uploader?.Do(id);
}); });
} }
...@@ -154,7 +154,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -154,7 +154,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic
} }
}).ContinueWith((task) => }).ContinueWith((task) =>
{ {
Program.uploader.Do(id); Program.uploader?.Do(id);
}); });
} }
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
</Declare> </Declare>
<Datas> <Datas>
<Data ServiceKey="SaveIdentityBatch" ServiceName="批量上传员工识别记录" ServiceUrl="/Services/EnterpriseIdentification/SaveIdentityInfoBatch/json"/> <Data ServiceKey="SaveIdentityBatch" ServiceName="批量上传员工识别记录" ServiceUrl="/api/GS.WebApi.Terminal.Identification.Enterprise/Record/EmployeeUpload"/>
<Data ServiceKey="SaveVisitorIdentifyBatch" ServiceName="批量上传访客识别记录" ServiceUrl="/Services/EnterpriseIdentification/SaveVisitorIdentifyBatch/json"/> <Data ServiceKey="SaveVisitorIdentifyBatch" ServiceName="批量上传访客识别记录" ServiceUrl="/api/GS.WebApi.Terminal.Visitor/Identification/UploadRecord"/>
</Datas> </Datas>
</Structure> </Structure>
</Structures> </Structures>
......
using GS.Terminal.Common.LocalSetting; using GS.Terminal.Frame.Configuration;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -18,12 +18,12 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config ...@@ -18,12 +18,12 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config
_webpath = webpath; _webpath = webpath;
} }
private Uri _SaveIdentityBatch; private string _SaveIdentityBatch;
/// <summary> /// <summary>
/// 批量上传识别记录 /// 批量上传识别记录
/// </summary> /// </summary>
public Uri SaveIdentityBatch public string SaveIdentityBatch
{ {
get get
{ {
...@@ -35,9 +35,9 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config ...@@ -35,9 +35,9 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config
} }
} }
private Uri _SaveVisitorIdentifyBatch; private string _SaveVisitorIdentifyBatch;
public Uri SaveVisitorIdentifyBatch public string SaveVisitorIdentifyBatch
{ {
get get
{ {
...@@ -50,21 +50,17 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config ...@@ -50,21 +50,17 @@ namespace GS.Terminal.Identification.Enterprise.Logic.Config
} }
private Uri getConfigUrlByKey(string key, string defaultUrl) private string getConfigUrlByKey(string key, string defaultUrl)
{ {
if (_ServiceListingConfig != null && _ServiceListingConfig.Datas != null) if (_ServiceListingConfig != null && _ServiceListingConfig.Datas != null)
{ {
var config = _ServiceListingConfig.Datas.FirstOrDefault(ss => ss.ServiceKey == key); var config = _ServiceListingConfig.Datas.FirstOrDefault(ss => ss.ServiceKey == key);
if (config != null && !string.IsNullOrEmpty(config.ServiceUrl)) if (config != null && !string.IsNullOrEmpty(config.ServiceUrl))
{ {
var url = $"{_webpath}/{config.ServiceUrl}"; return config.ServiceUrl;
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
return new Uri(url, UriKind.Absolute);
}
} }
} }
return new Uri($"{_webpath}/{defaultUrl}", UriKind.Absolute); return defaultUrl;
} }
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
//----------------------------------------------------------------*/ //----------------------------------------------------------------*/
#endregion #endregion
using GS.Terminal.Common.LocalSetting; using GS.Terminal.Frame.Configuration;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
......
using GS.EnterpriseIdentification.ServiceModel; using GS.EnterpriseIdentification.ServiceModel;
using GS.Terminal.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
......
...@@ -4,7 +4,6 @@ using System.Collections.Generic; ...@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using GS.Terminal.Common.WebService;
using GS.Unitive.Framework.Core; using GS.Unitive.Framework.Core;
using System.IO; using System.IO;
using GS.Terminal.Identification.DbHandler; using GS.Terminal.Identification.DbHandler;
...@@ -68,25 +67,16 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -68,25 +67,16 @@ namespace GS.Terminal.Identification.Enterprise.Logic
IdentifyMethod = ss.是否刷卡识别 ? 0 : 1, IdentifyMethod = ss.是否刷卡识别 ? 0 : 1,
FaceResult = ss.面部识别对比结果, FaceResult = ss.面部识别对比结果,
Tag = ss.进出标识, Tag = ss.进出标识,
}); }).ToList();
if (visitData != null) if (visitData.Count > 0)
{ {
var visitBody = new var visitResult = Program.WebApiClient.Post<List<ResultPostVisitor>>(Program.serviceListing.SaveVisitorIdentifyBatch, visitData);
{
tCode = tCode,
datas = visitData
};
var visitResult = new WebServiceCenter(AddonRuntime.Instance.LogWriter,
"",
"")
.Post<WebServiceResult<List<ResultPost>>>(Program.serviceListing.SaveVisitorIdentifyBatch, visitBody);
if (!visitResult.HasError()) if (visitResult != null)
{ {
List<识别历史> updateList = new List<识别历史>(visitResult.result.Count); List<识别历史> updateList = new List<识别历史>(visitResult.Count);
foreach (var res in visitResult.result) foreach (var res in visitResult)
{ {
var data = new DbContext<识别历史>().Db.Queryable<识别历史>().Single(ss => ss.识别ID == res.localid); var data = new DbContext<识别历史>().Db.Queryable<识别历史>().Single(ss => ss.识别ID == res.localid);
if (data != null) if (data != null)
...@@ -109,37 +99,31 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -109,37 +99,31 @@ namespace GS.Terminal.Identification.Enterprise.Logic
{ {
localid = ss.识别ID, localid = ss.识别ID,
EmplyId = ss.人员ID, EmplyId = ss.人员ID,
EmplyName = ss.人员姓名,
DptId = ss.部门ID,
DptName = ss.部门名称,
CardNum = ss.卡号, CardNum = ss.卡号,
CardTime = ss.识别时间, CardTime = ss.识别时间,
SitePhoto = Tools.ReadFile(ss.现场照片), SitePhoto = Tools.ReadFile(ss.现场照片),
Tag = ss.进出标识, Tag = ss.进出标识,
IdentifyMethod = ss.是否刷卡识别 ? 0 : 1, IdentifyMethod = ss.是否刷卡识别 ? 0 : 1,
FaceResult = ss.面部识别对比结果 FaceResult = ss.面部识别对比结果
}); }).ToList();
if (emplyData != null) if (emplyData.Count > 0)
{ {
var emplyBody = new var emplyResult = Program.WebApiClient.Post<List<ResultPostEmployee>>(Program.serviceListing.SaveIdentityBatch, emplyData);
{
tCode = tCode,
datas = emplyData
};
var emplyResult = new WebServiceCenter(AddonRuntime.Instance.LogWriter,
"",
"")
.Post<WebServiceResult<List<ResultPost>>>(Program.serviceListing.SaveIdentityBatch, emplyBody);
if (!emplyResult.HasError()) if (emplyResult != null)
{ {
List<识别历史> updateList = new List<识别历史>(emplyResult.result.Count); List<识别历史> updateList = new List<识别历史>(emplyResult.Count);
foreach (var res in emplyResult.result) foreach (var res in emplyResult)
{ {
var data = new DbContext<识别历史>().Db.Queryable<识别历史>().Single(ss => ss.识别ID == res.localid); var data = new DbContext<识别历史>().Db.Queryable<识别历史>().Single(ss => ss.识别ID == res.localid);
if (data != null) if (data != null)
{ {
data.是否已上传 = true; data.是否已上传 = true;
data.远程ID = res.remoteid; data.员工远程ID = res.remoteid;
updateList.Add(data); updateList.Add(data);
} }
} }
...@@ -203,9 +187,15 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -203,9 +187,15 @@ namespace GS.Terminal.Identification.Enterprise.Logic
} }
} }
public class ResultPost public class ResultPostVisitor
{ {
public Guid localid { get; set; } public Guid localid { get; set; }
public int remoteid { get; set; } public int remoteid { get; set; }
} }
public class ResultPostEmployee
{
public Guid localid { get; set; }
public Guid remoteid { get; set; }
}
} }
...@@ -75,9 +75,6 @@ ...@@ -75,9 +75,6 @@
<Reference Include="GS.Remote.Synchronize.EasyTask"> <Reference Include="GS.Remote.Synchronize.EasyTask">
<HintPath>..\..\release\Addons\GS.Remote.Synchronize\GS.Remote.Synchronize.EasyTask.dll</HintPath> <HintPath>..\..\release\Addons\GS.Remote.Synchronize\GS.Remote.Synchronize.EasyTask.dll</HintPath>
</Reference> </Reference>
<Reference Include="GS.Terminal.Common">
<HintPath>..\..\release\Tools\GS.Terminal.Common.dll</HintPath>
</Reference>
<Reference Include="GS.Terminal.Frame, Version=1.0.0.21, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="GS.Terminal.Frame, Version=1.0.0.21, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GS.Terminal.Frame.1.0.0.21\lib\net452\GS.Terminal.Frame.dll</HintPath> <HintPath>..\packages\GS.Terminal.Frame.1.0.0.21\lib\net452\GS.Terminal.Frame.dll</HintPath>
</Reference> </Reference>
......
using GalaSoft.MvvmLight.Ioc; using GalaSoft.MvvmLight.Ioc;
using GS.EnterpriseIdentification.ServiceModel; using GS.EnterpriseIdentification.ServiceModel;
using GS.Remote.Synchronize.EasyTask; using GS.Remote.Synchronize.EasyTask;
using GS.Terminal.Common;
using GS.Terminal.Frame.AddonServices; using GS.Terminal.Frame.AddonServices;
using GS.Terminal.Frame.Logic; using GS.Terminal.Frame.Logic;
using GS.Terminal.Frame.Network; using GS.Terminal.Frame.Network;
...@@ -65,7 +64,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -65,7 +64,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic
InitSqliteDb(); InitSqliteDb();
uploader = new Uploader(config.GlobalConfig.tCode);
} }
/// <summary> /// <summary>
...@@ -169,6 +168,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -169,6 +168,7 @@ namespace GS.Terminal.Identification.Enterprise.Logic
addonContext.IntercativeData("TERMINAL_STATUS", terminal_status); addonContext.IntercativeData("TERMINAL_STATUS", terminal_status);
TerminalConsole.StartHeart(config.GlobalConfig.ServerIP, 0, 10 * 1000); TerminalConsole.StartHeart(config.GlobalConfig.ServerIP, 0, 10 * 1000);
WebApiClient = new Frame.Network.WebApiClient(config.GlobalConfig.WebPath, config.GlobalConfig.tCode); WebApiClient = new Frame.Network.WebApiClient(config.GlobalConfig.WebPath, config.GlobalConfig.tCode);
WebApiClient.OnSignatured += WebApiClient_OnSignatured;
RefreshToken(); RefreshToken();
AutoRefreshTokenTask(); AutoRefreshTokenTask();
UpdateLocalTime(); UpdateLocalTime();
...@@ -184,6 +184,11 @@ namespace GS.Terminal.Identification.Enterprise.Logic ...@@ -184,6 +184,11 @@ namespace GS.Terminal.Identification.Enterprise.Logic
}); });
} }
private void WebApiClient_OnSignatured()
{
uploader = new Uploader(config.GlobalConfig.tCode);
}
/// <summary> /// <summary>
/// 注册ViewModel /// 注册ViewModel
/// </summary> /// </summary>
......
...@@ -415,10 +415,6 @@ ...@@ -415,10 +415,6 @@
<Link>Addons\GS.Terminal.Identification.Enterprise.Logic\GS.EnterpriseIdentification.ServiceModel.dll</Link> <Link>Addons\GS.Terminal.Identification.Enterprise.Logic\GS.EnterpriseIdentification.ServiceModel.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="..\GS.Terminal.Identification.Enterprise.Logic\bin\Debug\GS.Terminal.Common.dll">
<Link>Addons\GS.Terminal.Identification.Enterprise.Logic\GS.Terminal.Common.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\GS.Terminal.Identification.Enterprise.Logic\bin\Debug\GS.Terminal.Identification.DbHandler.dll"> <Content Include="..\GS.Terminal.Identification.Enterprise.Logic\bin\Debug\GS.Terminal.Identification.DbHandler.dll">
<Link>Addons\GS.Terminal.Identification.Enterprise.Logic\GS.Terminal.Identification.DbHandler.dll</Link> <Link>Addons\GS.Terminal.Identification.Enterprise.Logic\GS.Terminal.Identification.DbHandler.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
......
...@@ -22,6 +22,8 @@ namespace GS.Terminal.Identification.LocalDbModel ...@@ -22,6 +22,8 @@ namespace GS.Terminal.Identification.LocalDbModel
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int 远程ID { get; set; } public int 远程ID { get; set; }
[SugarColumn(IsNullable = true)]
public Guid 员工远程ID { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public Guid 人员ID { get; set; } public Guid 人员ID { get; set; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment