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

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

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