|
@@ -1,42 +1,17 @@
|
|
|
-using Fleck;
|
|
|
-using log4net;
|
|
|
-using Microsoft.DwayneNeed.Win32.Gdi32;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
-using NPOI.SS.UserModel;
|
|
|
-using Opc.Ua.Gds;
|
|
|
-using SCADA.CommonCtrl.WpfControl;
|
|
|
+using SCADA.CommonCtrl.WpfControl;
|
|
|
using SCADA.CommonLib;
|
|
|
-using SCADA.CommonLib.CommonModel;
|
|
|
using SCADA.CommonLib.Data.DIL;
|
|
|
using SCADA.CommonLib.Helper;
|
|
|
-using SCADA.Drive.Mitsubishi.QPLC;
|
|
|
-using SCADA_DAQ.Customer.Models;
|
|
|
using SCADA_DAQ.Customer.Models.FaceRecognition;
|
|
|
-using SCADA_DAQ.Customer.Models.ProcessingManagement;
|
|
|
-using SCADA_DAQ.Customer.Models.PropertyManagement;
|
|
|
-using SCADA_DAQ.Customer.Models.TaskManagement;
|
|
|
-using SCADA_DAQ.Customer.Service;
|
|
|
using SCADA_DAQ.Customer.Service.Websocket;
|
|
|
using SCADA_DAQ.Customer.Views.Uct;
|
|
|
using SqlSchema.DBNames;
|
|
|
using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.IO;
|
|
|
+using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
using System.Web;
|
|
|
using System.Windows;
|
|
|
-using System.Windows.Controls;
|
|
|
-using System.Windows.Data;
|
|
|
-using System.Windows.Documents;
|
|
|
-using System.Windows.Forms;
|
|
|
-using System.Windows.Input;
|
|
|
-using System.Windows.Media;
|
|
|
-using System.Windows.Media.Imaging;
|
|
|
-using System.Windows.Navigation;
|
|
|
-using System.Windows.Shapes;
|
|
|
-using static Mono.Security.X509.X520;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer
|
|
|
{
|
|
@@ -47,7 +22,7 @@ namespace SCADA_DAQ.Customer
|
|
|
public partial class UctFrmFaceRecognition : BaseUctFrm
|
|
|
{
|
|
|
// 服务示实例
|
|
|
- private WssForFace wssForFace = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
|
|
|
+ private WssForFace WssForFaceService = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -56,40 +31,46 @@ namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
//ToolBar.Visibility = Visibility.Collapsed; // 屏蔽顶部工具栏
|
|
|
+
|
|
|
FrmQuery.QueryModel = new QueryUsersModel();
|
|
|
var cloumn = SmartGridHeaderMapping.CreateMapping<UsersModel>();
|
|
|
cloumn.Remove(T_Col_Name.App_HongShi_Users.Photo_Str);
|
|
|
MainGrid.DataTableColumnLables = cloumn;
|
|
|
+ MainGrid.ExportSheetName = "人员信息"; // 导出表的名称
|
|
|
|
|
|
- //wssForFace.ClientMessage += WssForFace_ClientMessage;
|
|
|
+ WssForFaceService.ClientMessage += WssForFace_ClientMessage;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// ws消息接收事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
private void WssForFace_ClientMessage(object sender, WebSocketClientMessage e)
|
|
|
{
|
|
|
- var id = e.Guid;
|
|
|
- var msg = e.Message as ReceiveModel;
|
|
|
- //Dispatcher.Invoke(() =>
|
|
|
- //{
|
|
|
- // MsgText.Text = $"{id} \r\n {msg.Cmd}";
|
|
|
- //});
|
|
|
- object cmd = null;
|
|
|
- msg.Data?.TryGetValue("cmd", out cmd);
|
|
|
- if (cmd == null) return;
|
|
|
- if (cmd.ToString() == "onlineAuthorizationRet")
|
|
|
+ //var id = e.Guid;
|
|
|
+ var message = e.Message as ReceiveModel;
|
|
|
+ if (message.Data != null)
|
|
|
{
|
|
|
- object photo = null;
|
|
|
- msg.Data?.TryGetValue("vl_face_template", out photo);
|
|
|
- string base64 = HttpUtility.UrlDecode(photo.ToString(), Encoding.UTF8);
|
|
|
- base64 = base64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
|
|
|
- byte[] bytes = Convert.FromBase64String(base64);
|
|
|
- MemoryStream memStream = new MemoryStream(bytes);
|
|
|
- ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
|
|
|
- //Dispatcher.Invoke(() =>
|
|
|
- //{
|
|
|
- // FaceImg.Source = (ImageSource)imageSourceConverter.ConvertFrom(memStream);
|
|
|
- //});
|
|
|
-
|
|
|
+ message.Data.TryGetValue("cmd", out object cmd);
|
|
|
+ if (cmd == null) return;
|
|
|
+ if (cmd.ToString() == "addUserRet")
|
|
|
+ {
|
|
|
+ message.Data.TryGetValue("user_id", out object userId);
|
|
|
+ message.Data.TryGetValue("code", out object code);
|
|
|
+ message.Data.TryGetValue("msg", out object msg);
|
|
|
+ if (code.ToString() == "0")
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast($"{userId} - " + msg.ToString(), ControlStyle.Success);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast($"{userId} - " + msg.ToString(), ControlStyle.Warning);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
@@ -108,84 +89,156 @@ namespace SCADA_DAQ.Customer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void IconButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ /// <summary>
|
|
|
+ /// 下发用户按钮事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void Bt_Click_Set(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- // 抓拍
|
|
|
- //var keys = wssForFace.Sockets.Keys.ToList();
|
|
|
- //keys.ForEach(n => {
|
|
|
- // wssForFace.Sockets[n]?.Send(JsonHelper.JsonSerialize(new
|
|
|
- // {
|
|
|
- // cmd = "to_device",
|
|
|
- // form = n,
|
|
|
- // to = "T68318",
|
|
|
- // data = new { cmd = "onlineAuthorization" }
|
|
|
- // }));
|
|
|
- //});
|
|
|
-
|
|
|
- // 下发用户
|
|
|
- //var user = Env.SgIDAL.App_HongShi_Users.GetData<UsersModel>().FirstOrDefault();
|
|
|
- //var keys = wssForFace.Sockets.Keys.ToList();
|
|
|
- //keys.ForEach(n => {
|
|
|
- // wssForFace.Sockets[n]?.Send(JsonHelper.JsonSerialize(new
|
|
|
- // {
|
|
|
- // cmd = "to_device",
|
|
|
- // form = n,
|
|
|
- // to = "T68318",
|
|
|
- // data = new {
|
|
|
- // cmd = "addUser",
|
|
|
- // user_id = user.UserId,
|
|
|
- // name = user.Name,
|
|
|
- // id_valid = user.IdValid.ToString().Substring(0, 9).Replace("/", "-"),
|
|
|
- // face_template = HttpUtility.UrlEncode(user.Photo, Encoding.UTF8),
|
|
|
- // confidence_level = user.ConfidenceLevel
|
|
|
- // }
|
|
|
- // }));
|
|
|
- //});
|
|
|
- //
|
|
|
+ var deviceMode = new DevicesModel();
|
|
|
+
|
|
|
+ ShowChildWindow(new AutoView(deviceMode), true, true, "选择在线设备", () => {
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ // 下发用户
|
|
|
+ for (int i = 0; i < MainGrid.SelectedItems.Count; i++)
|
|
|
+ {
|
|
|
+ var item = MainGrid.SelectedItems[i] as DataRowView;
|
|
|
+ if (item == null)
|
|
|
+ continue;
|
|
|
+ var device = WssForFaceService.Sockets.Values.Where(t => t.DeviceName == deviceMode.DeviceName)?.LastOrDefault();
|
|
|
+ device.SocketConnection.Send(JsonHelper.JsonSerialize(new
|
|
|
+ {
|
|
|
+ cmd = "to_device",
|
|
|
+ form = device.Guid.ToString(),
|
|
|
+ to = device.DeviceName,
|
|
|
+ data = new
|
|
|
+ {
|
|
|
+ cmd = "addUser",
|
|
|
+ user_id = item[T_Col_Name.App_HongShi_Users.UserId_Str]?.ToString(),
|
|
|
+ name = item[T_Col_Name.App_HongShi_Users.Name_Str]?.ToString(),
|
|
|
+ id_valid = Convert.ToDateTime(item[T_Col_Name.App_HongShi_Users.IdValid_Dt] is DBNull
|
|
|
+ ? DateTime.Now.AddYears(1) : item[T_Col_Name.App_HongShi_Users.IdValid_Dt]).Format("yyyy-MM-dd"),
|
|
|
+ face_template = HttpUtility.UrlEncode(item[T_Col_Name.App_HongShi_Users.Photo_Str]?.ToString(), Encoding.UTF8),
|
|
|
+ confidence_level = Convert.ToDouble(item[T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo] is DBNull
|
|
|
+ ? 0.0 : item[T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo])
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private void AddAndUpdate_Click(object sender, RoutedEventArgs e)
|
|
|
+ /// <summary>
|
|
|
+ /// 增删改按钮事件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void Bt_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
string btTag = (sender as IconButton).Tag.ToString(); // 获取Tag
|
|
|
- //var childWindow = new UctAddUserInfo();
|
|
|
- UctAddUserInfo childWindow = null;
|
|
|
- if (btTag == "add")
|
|
|
+ UctAddUserInfo childWindow = null; // 子窗口
|
|
|
+ int id = 0; // 选择项id
|
|
|
+
|
|
|
+ if (btTag == "delete")
|
|
|
{
|
|
|
- childWindow = new UctAddUserInfo();
|
|
|
+ // 获取选中项信息
|
|
|
+ var item = MainGrid.CurrentItem as DataRowView;
|
|
|
+ id = Convert.ToInt32(item[T_Col_Name.App_HongShi_Users.ID]);
|
|
|
+ var uid = item[T_Col_Name.App_HongShi_Users.UserId_Str]?.ToString();
|
|
|
+ if (MessageBox.Show($"是否确认删除{uid}?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
|
|
|
+ return;
|
|
|
+ var res = Env.SgIDAL.App_HongShi_Users.Delete($"ID={id}");
|
|
|
+ if (res)
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("删除成功!", ControlStyle.Success);
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ // 不用委托会报错
|
|
|
+ Query();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("删除失败,请重试!", ControlStyle.Warning);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(btTag == "add")
|
|
|
+ {
|
|
|
+ childWindow = new UctAddUserInfo(new UsersModel());
|
|
|
}
|
|
|
else if (btTag == "update")
|
|
|
{
|
|
|
- childWindow.UsersModelValues = new UsersModel()
|
|
|
+ // 获取选中项信息
|
|
|
+ var item = MainGrid.CurrentItem as DataRowView;
|
|
|
+ var userInfo = new UsersModel()
|
|
|
{
|
|
|
- UserId = "1"
|
|
|
+ UserId = item[T_Col_Name.App_HongShi_Users.UserId_Str]?.ToString(),
|
|
|
+ Name = item[T_Col_Name.App_HongShi_Users.Name_Str]?.ToString(),
|
|
|
+ Photo = item[T_Col_Name.App_HongShi_Users.Photo_Str]?.ToString(),
|
|
|
+ IdCard = item[T_Col_Name.App_HongShi_Users.IdCard_Str]?.ToString(),
|
|
|
+ IcCard = item[T_Col_Name.App_HongShi_Users.IcCard_Str]?.ToString(),
|
|
|
+ IdValid = Convert.ToDateTime(item[T_Col_Name.App_HongShi_Users.IdValid_Dt] is DBNull
|
|
|
+ ? DateTime.Now.AddYears(1) : item[T_Col_Name.App_HongShi_Users.IdValid_Dt]),
|
|
|
+ ConfidenceLevel = Convert.ToDouble(item[T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo] is DBNull
|
|
|
+ ? 0.0 : item[T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo])
|
|
|
};
|
|
|
+ id = Convert.ToInt32(item[T_Col_Name.App_HongShi_Users.ID]);
|
|
|
+
|
|
|
+ childWindow = new UctAddUserInfo(userInfo);
|
|
|
}
|
|
|
|
|
|
// 显示子窗口
|
|
|
- ShowChildWindow(childWindow, true, true, "新增用户", () => {
|
|
|
+ ShowChildWindow(childWindow, true, true, "", () => {
|
|
|
var userInfo = childWindow.UsersModelValues;
|
|
|
-
|
|
|
- bool res = Env.SgIDAL.App_HongShi_Users.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.UserId_Str, userInfo.UserId),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.Name_Str, userInfo.Name),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.IcCard_Str, userInfo.IcCard),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.IdCard_Str, userInfo.IdCard),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.Photo_Str, userInfo.Photo),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.IdValid_Dt, userInfo.IdValid),
|
|
|
- new UpdateItem(T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo, userInfo.ConfidenceLevel)
|
|
|
- );
|
|
|
+ bool res = false;
|
|
|
+ if (btTag == "add")
|
|
|
+ {
|
|
|
+ res = Env.SgIDAL.App_HongShi_Users.Insert(
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.UserId_Str, userInfo.UserId),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.Name_Str, userInfo.Name),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IcCard_Str, userInfo.IcCard),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IdCard_Str, userInfo.IdCard),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.Photo_Str, userInfo.Photo),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IdValid_Dt, userInfo.IdValid),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo, userInfo.ConfidenceLevel)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ res = Env.SgIDAL.App_HongShi_Users.Update($"ID={id}",
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.UserId_Str, userInfo.UserId),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.Name_Str, userInfo.Name),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IcCard_Str, userInfo.IcCard),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IdCard_Str, userInfo.IdCard),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.Photo_Str, userInfo.Photo),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IdValid_Dt, userInfo.IdValid),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo, userInfo.ConfidenceLevel),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.ModifyTime_Dt, DateTime.Now.Format())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
if (res)
|
|
|
{
|
|
|
- ((IApp)System.Windows.Application.Current).ShowShortToast("添加成功!", ControlStyle.Success);
|
|
|
- Query();
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("保存成功!", ControlStyle.Success);
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ // 不用委托会报错
|
|
|
+ Query();
|
|
|
+ });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ((IApp)System.Windows.Application.Current).ShowShortToast("添加失败,请重试!", ControlStyle.Warning);
|
|
|
+ ((IApp)System.Windows.Application.Current).ShowShortToast("保存失败,请重试!", ControlStyle.Warning);
|
|
|
}
|
|
|
return res;
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -198,7 +251,15 @@ namespace SCADA_DAQ.Customer
|
|
|
base.Query();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 关闭页面
|
|
|
+ /// </summary>
|
|
|
+ protected override void CloseThis()
|
|
|
+ {
|
|
|
+ WssForFaceService.ClientMessage -= WssForFace_ClientMessage;
|
|
|
+ base.CloseThis();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|