Browse Source

更新程序

zhangliwen 1 năm trước cách đây
mục cha
commit
e9633ba8d3
10 tập tin đã thay đổi với 781 bổ sung105 xóa
  1. 366 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SqlDB.cs
  2. 59 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/ReceiveModel.cs
  3. 0 70
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/SendModel.cs
  4. 188 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/UsersModel.cs
  5. 33 14
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/Controllers/HttpForFaceController.cs
  6. 40 15
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFace.cs
  7. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFaceConfig.cs
  8. 12 2
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml
  9. 81 3
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml.cs
  10. 1 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

+ 366 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SqlDB.cs

@@ -332,6 +332,85 @@ namespace SqlSchema
                 /// </summary>
                  public const string @OperationNo_Str=nameof(@OperationNo_Str);
                     
+             }
+             /// <summary> 
+             /// App_HongShi_Users
+             /// </summary>
+             public class App_HongShi_Users
+             {
+             	/// <summary>
+                /// 用户编号
+                /// </summary>
+                 public const string @UserId_Str=nameof(@UserId_Str);
+                    /// <summary>
+                /// 姓名
+                /// </summary>
+                 public const string @Name_Str=nameof(@Name_Str);
+                    /// <summary>
+                /// 指定识别成功时,播放的用户名。需要在设备设置,启用播放用户名
+                /// </summary>
+                 public const string @TtsName_Str=nameof(@TtsName_Str);
+                    /// <summary>
+                /// 彩色照片
+                /// </summary>
+                 public const string @Photo_Str=nameof(@Photo_Str);
+                    /// <summary>
+                /// 身份证号码
+                /// </summary>
+                 public const string @IdCard_Str=nameof(@IdCard_Str);
+                    /// <summary>
+                /// ic卡号
+                /// </summary>
+                 public const string @IcCard_Str=nameof(@IcCard_Str);
+                    /// <summary>
+                /// 密码
+                /// </summary>
+                 public const string @Password_Str=nameof(@Password_Str);
+                    /// <summary>
+                /// 0:正常用户2:访客(访客到期后会自动从设备中删除)10:黑名单用户,识别后设备会报警,并产生黑名单识别记录20:只测温,不开门人员(只识别,测体温,亮绿灯,不通行)。可以不传,不传默认为正常用户
+                /// </summary>
+                 public const string @UserType_Int=nameof(@UserType_Int);
+                    /// <summary>
+                /// 相似度阈值
+                /// </summary>
+                 public const string @ConfidenceLevel_Flo=nameof(@ConfidenceLevel_Flo);
+                    /// <summary>
+                /// 手机号
+                /// </summary>
+                 public const string @Phone_Str=nameof(@Phone_Str);
+                    /// <summary>
+                /// 人员有效期
+                /// </summary>
+                 public const string @IdValid_Dt=nameof(@IdValid_Dt);
+                    /// <summary>
+                /// 指定识别成功时,播放的语音
+                /// </summary>
+                 public const string @Voice_Str=nameof(@Voice_Str);
+                    /// <summary>
+                /// 创建者
+                /// </summary>
+                 public const string @CreateUser_Str=nameof(@CreateUser_Str);
+                    /// <summary>
+                /// 创建时间
+                /// </summary>
+                 public const string @CreateTime_Dt=nameof(@CreateTime_Dt);
+                    /// <summary>
+                /// 修改时间
+                /// </summary>
+                 public const string @ModifyTime_Dt=nameof(@ModifyTime_Dt);
+                    /// <summary>
+                /// 修改者
+                /// </summary>
+                 public const string @ModifyUser_Str=nameof(@ModifyUser_Str);
+                    /// <summary>
+                /// 备注
+                /// </summary>
+                 public const string @Remark_Str=nameof(@Remark_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ID=nameof(@ID);
+                    
              }
              
                           }
@@ -1452,6 +1531,283 @@ namespace SqlSchema
             }
             
              }
+             /// <summary> 
+             /// 
+             /// </summary>
+             public class App_HongShi_Users:ObservableObject
+             {
+             	  private string _UserId_Str;
+                /// <summary>
+                /// 用户编号
+                /// </summary>
+                 public string UserId_Str
+                {
+                get {return _UserId_Str;}
+                set{
+                    if(value!=(_UserId_Str))
+                    {
+                        _UserId_Str=value;
+                        OnPropertyChanged(nameof( UserId_Str));
+                    }
+                }
+            }
+              private string _Name_Str;
+                /// <summary>
+                /// 姓名
+                /// </summary>
+                 public string Name_Str
+                {
+                get {return _Name_Str;}
+                set{
+                    if(value!=(_Name_Str))
+                    {
+                        _Name_Str=value;
+                        OnPropertyChanged(nameof( Name_Str));
+                    }
+                }
+            }
+              private string _TtsName_Str;
+                /// <summary>
+                /// 指定识别成功时,播放的用户名。需要在设备设置,启用播放用户名
+                /// </summary>
+                 public string TtsName_Str
+                {
+                get {return _TtsName_Str;}
+                set{
+                    if(value!=(_TtsName_Str))
+                    {
+                        _TtsName_Str=value;
+                        OnPropertyChanged(nameof( TtsName_Str));
+                    }
+                }
+            }
+              private string _Photo_Str;
+                /// <summary>
+                /// 彩色照片
+                /// </summary>
+                 public string Photo_Str
+                {
+                get {return _Photo_Str;}
+                set{
+                    if(value!=(_Photo_Str))
+                    {
+                        _Photo_Str=value;
+                        OnPropertyChanged(nameof( Photo_Str));
+                    }
+                }
+            }
+              private string _IdCard_Str;
+                /// <summary>
+                /// 身份证号码
+                /// </summary>
+                 public string IdCard_Str
+                {
+                get {return _IdCard_Str;}
+                set{
+                    if(value!=(_IdCard_Str))
+                    {
+                        _IdCard_Str=value;
+                        OnPropertyChanged(nameof( IdCard_Str));
+                    }
+                }
+            }
+              private string _IcCard_Str;
+                /// <summary>
+                /// ic卡号
+                /// </summary>
+                 public string IcCard_Str
+                {
+                get {return _IcCard_Str;}
+                set{
+                    if(value!=(_IcCard_Str))
+                    {
+                        _IcCard_Str=value;
+                        OnPropertyChanged(nameof( IcCard_Str));
+                    }
+                }
+            }
+              private string _Password_Str;
+                /// <summary>
+                /// 密码
+                /// </summary>
+                 public string Password_Str
+                {
+                get {return _Password_Str;}
+                set{
+                    if(value!=(_Password_Str))
+                    {
+                        _Password_Str=value;
+                        OnPropertyChanged(nameof( Password_Str));
+                    }
+                }
+            }
+              private int? _UserType_Int;
+                /// <summary>
+                /// 0:正常用户2:访客(访客到期后会自动从设备中删除)10:黑名单用户,识别后设备会报警,并产生黑名单识别记录20:只测温,不开门人员(只识别,测体温,亮绿灯,不通行)。可以不传,不传默认为正常用户
+                /// </summary>
+                 public int? UserType_Int
+                {
+                get {return _UserType_Int;}
+                set{
+                    if(value!=(_UserType_Int))
+                    {
+                        _UserType_Int=value;
+                        OnPropertyChanged(nameof( UserType_Int));
+                    }
+                }
+            }
+              private double? _ConfidenceLevel_Flo;
+                /// <summary>
+                /// 相似度阈值
+                /// </summary>
+                 public double? ConfidenceLevel_Flo
+                {
+                get {return _ConfidenceLevel_Flo;}
+                set{
+                    if(value!=(_ConfidenceLevel_Flo))
+                    {
+                        _ConfidenceLevel_Flo=value;
+                        OnPropertyChanged(nameof( ConfidenceLevel_Flo));
+                    }
+                }
+            }
+              private string _Phone_Str;
+                /// <summary>
+                /// 手机号
+                /// </summary>
+                 public string Phone_Str
+                {
+                get {return _Phone_Str;}
+                set{
+                    if(value!=(_Phone_Str))
+                    {
+                        _Phone_Str=value;
+                        OnPropertyChanged(nameof( Phone_Str));
+                    }
+                }
+            }
+              private DateTime? _IdValid_Dt;
+                /// <summary>
+                /// 人员有效期
+                /// </summary>
+                 public DateTime? IdValid_Dt
+                {
+                get {return _IdValid_Dt;}
+                set{
+                    if(value!=(_IdValid_Dt))
+                    {
+                        _IdValid_Dt=value;
+                        OnPropertyChanged(nameof( IdValid_Dt));
+                    }
+                }
+            }
+              private string _Voice_Str;
+                /// <summary>
+                /// 指定识别成功时,播放的语音
+                /// </summary>
+                 public string Voice_Str
+                {
+                get {return _Voice_Str;}
+                set{
+                    if(value!=(_Voice_Str))
+                    {
+                        _Voice_Str=value;
+                        OnPropertyChanged(nameof( Voice_Str));
+                    }
+                }
+            }
+              private string _CreateUser_Str;
+                /// <summary>
+                /// 创建者
+                /// </summary>
+                 public string CreateUser_Str
+                {
+                get {return _CreateUser_Str;}
+                set{
+                    if(value!=(_CreateUser_Str))
+                    {
+                        _CreateUser_Str=value;
+                        OnPropertyChanged(nameof( CreateUser_Str));
+                    }
+                }
+            }
+              private DateTime? _CreateTime_Dt;
+                /// <summary>
+                /// 创建时间
+                /// </summary>
+                 public DateTime? CreateTime_Dt
+                {
+                get {return _CreateTime_Dt;}
+                set{
+                    if(value!=(_CreateTime_Dt))
+                    {
+                        _CreateTime_Dt=value;
+                        OnPropertyChanged(nameof( CreateTime_Dt));
+                    }
+                }
+            }
+              private DateTime? _ModifyTime_Dt;
+                /// <summary>
+                /// 修改时间
+                /// </summary>
+                 public DateTime? ModifyTime_Dt
+                {
+                get {return _ModifyTime_Dt;}
+                set{
+                    if(value!=(_ModifyTime_Dt))
+                    {
+                        _ModifyTime_Dt=value;
+                        OnPropertyChanged(nameof( ModifyTime_Dt));
+                    }
+                }
+            }
+              private string _ModifyUser_Str;
+                /// <summary>
+                /// 修改者
+                /// </summary>
+                 public string ModifyUser_Str
+                {
+                get {return _ModifyUser_Str;}
+                set{
+                    if(value!=(_ModifyUser_Str))
+                    {
+                        _ModifyUser_Str=value;
+                        OnPropertyChanged(nameof( ModifyUser_Str));
+                    }
+                }
+            }
+              private string _Remark_Str;
+                /// <summary>
+                /// 备注
+                /// </summary>
+                 public string Remark_Str
+                {
+                get {return _Remark_Str;}
+                set{
+                    if(value!=(_Remark_Str))
+                    {
+                        _Remark_Str=value;
+                        OnPropertyChanged(nameof( Remark_Str));
+                    }
+                }
+            }
+              private int _ID;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public int ID
+                {
+                get {return _ID;}
+                set{
+                    if(value!=(_ID))
+                    {
+                        _ID=value;
+                        OnPropertyChanged(nameof( ID));
+                    }
+                }
+            }
+            
+             }
              
             
     }
@@ -1481,6 +1837,10 @@ public BaseTable App_HongShi_PropertyManagement{get;private set;}
  ///  
  /// </summary> 
 public BaseTable App_HongShi_TaskInfo{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
+public BaseTable App_HongShi_Users{get;private set;}
 public DILDB(string server, string service, string username, string password):base(server, service, username, password)
 {
 App_HongShi_ManagerItem=CreateTable("ID","App_HongShi_ManagerItem");
@@ -1488,6 +1848,7 @@ App_HongShi_MotorState=CreateTable("ID","App_HongShi_MotorState");
 App_HongShi_PropertyItem=CreateTable("ID","App_HongShi_PropertyItem");
 App_HongShi_PropertyManagement=CreateTable("ID","App_HongShi_PropertyManagement");
 App_HongShi_TaskInfo=CreateTable("ID","App_HongShi_TaskInfo");
+App_HongShi_Users=CreateTable("ID","App_HongShi_Users");
 }
 #endregion
 }
@@ -1514,6 +1875,10 @@ public BaseTable App_HongShi_PropertyManagement{get;private set;}
  ///  
  /// </summary> 
 public BaseTable App_HongShi_TaskInfo{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
+public BaseTable App_HongShi_Users{get;private set;}
 private BaseDB innerDb = null;
 public DILDBV1(BaseDB db )
 {
@@ -1526,6 +1891,7 @@ App_HongShi_MotorState=innerDb.CreateTable("ID","App_HongShi_MotorState");
 App_HongShi_PropertyItem=innerDb.CreateTable("ID","App_HongShi_PropertyItem");
 App_HongShi_PropertyManagement=innerDb.CreateTable("ID","App_HongShi_PropertyManagement");
 App_HongShi_TaskInfo=innerDb.CreateTable("ID","App_HongShi_TaskInfo");
+App_HongShi_Users=innerDb.CreateTable("ID","App_HongShi_Users");
 }
 
             public override BaseTable CreateTable(string id)

+ 59 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/ReceiveModel.cs

@@ -66,5 +66,64 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
         }
         private string _Timestamp;
 
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Form
+        {
+            get { return _Form; }
+            set
+            {
+                if (value != _Form)
+                {
+                    _Form = value;
+                    OnPropertyChanged(nameof(Form));
+                }
+            }
+        }
+        private string _Form;
+
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string To
+        {
+            get { return _To; }
+            set
+            {
+                if (value != _To)
+                {
+                    _To = value;
+                    OnPropertyChanged(nameof(To));
+                }
+            }
+        }
+        private string _To;
+
+
+
+        /// <summary>
+        /// 数据
+        /// </summary>
+        public Dictionary<string, object> Data
+        {
+            get { return _Data; }
+            set
+            {
+                if (value != _Data)
+                {
+                    _Data = value;
+                    OnPropertyChanged(nameof(Data));
+                }
+            }
+        }
+        private Dictionary<string, object> _Data;
+
+
+
     }
 }

+ 0 - 70
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/SendModel.cs

@@ -1,70 +0,0 @@
-using SCADA.CommonLib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SCADA_DAQ.Customer.Models.FaceRecognition
-{
-    /// <summary>
-    /// 
-    /// </summary>
-    public class SendModel : ObservableObject
-    {
-        /// <summary>
-        /// 命令
-        /// </summary>
-        public string Cmd
-        {
-            get { return _Cmd; }
-            set
-            {
-                if (value != _Cmd)
-                {
-                    _Cmd = value;
-                    OnPropertyChanged(nameof(Cmd));
-                }
-            }
-        }
-        private string _Cmd;
-
-
-        /// <summary>
-        /// 设备号
-        /// </summary>
-        public string Sn
-        {
-            get { return _Sn; }
-            set
-            {
-                if (value != _Sn)
-                {
-                    _Sn = value;
-                    OnPropertyChanged(nameof(Sn));
-                }
-            }
-        }
-        private string _Sn;
-
-
-
-        /// <summary>
-        /// 时间戳
-        /// </summary>
-        public string Timestamp
-        {
-            get { return _Timestamp; }
-            set
-            {
-                if (value != _Timestamp)
-                {
-                    _Timestamp = value;
-                    OnPropertyChanged(nameof(Timestamp));
-                }
-            }
-        }
-        private string _Timestamp;
-
-    }
-}

+ 188 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/UsersModel.cs

@@ -0,0 +1,188 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.FaceRecognition
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class UsersModel : ObservableObject
+    {
+
+
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int ID
+        {
+            get { return _ID; }
+            set
+            {
+                if (value != _ID)
+                {
+                    _ID = value;
+                    OnPropertyChanged(nameof(ID));
+                }
+            }
+        }
+        private int _ID;
+
+
+
+        /// <summary>
+        /// 用户编号
+        /// </summary>
+        public string UserId
+        {
+            get { return _UserId; }
+            set
+            {
+                if (value != _UserId)
+                {
+                    _UserId = value;
+                    OnPropertyChanged(nameof(UserId));
+                }
+            }
+        }
+        private string _UserId;
+
+
+
+        /// <summary>
+        /// 姓名
+        /// </summary>
+        public string Name
+        {
+            get { return _Name; }
+            set
+            {
+                if (value != _Name)
+                {
+                    _Name = value;
+                    OnPropertyChanged(nameof(Name));
+                }
+            }
+        }
+        private string _Name;
+
+
+
+
+        /// <summary>
+        /// 播报名字
+        /// </summary>
+        public string TtsName
+        {
+            get { return _TtsName; }
+            set
+            {
+                if (value != _TtsName)
+                {
+                    _TtsName = value;
+                    OnPropertyChanged(nameof(TtsName));
+                }
+            }
+        }
+        private string _TtsName;
+
+
+
+        /// <summary>
+        /// 照片
+        /// </summary>
+        public string Photo
+        {
+            get { return _Photo; }
+            set
+            {
+                if (value != _Photo)
+                {
+                    _Photo = value;
+                    OnPropertyChanged(nameof(Photo));
+                }
+            }
+        }
+        private string _Photo;
+
+
+
+        /// <summary>
+        /// 身份证号
+        /// </summary>
+        public string IdCard
+        {
+            get { return _IdCard; }
+            set
+            {
+                if (value != _IdCard)
+                {
+                    _IdCard = value;
+                    OnPropertyChanged(nameof(IdCard));
+                }
+            }
+        }
+        private string _IdCard;
+
+
+
+        /// <summary>
+        /// IC卡号
+        /// </summary>
+        public string IcCard
+        {
+            get { return _IcCard; }
+            set
+            {
+                if (value != _IcCard)
+                {
+                    _IcCard = value;
+                    OnPropertyChanged(nameof(IcCard));
+                }
+            }
+        }
+        private string _IcCard;
+
+
+
+        /// <summary>
+        /// 人员有效期
+        /// </summary>
+        public DateTime IdValid
+        {
+            get { return _IdValid; }
+            set
+            {
+                if (value != _IdValid)
+                {
+                    _IdValid = value;
+                    OnPropertyChanged(nameof(IdValid));
+                }
+            }
+        }
+        private DateTime _IdValid;
+
+
+
+        /// <summary>
+        /// 置信度
+        /// </summary>
+        public float ConfidenceLevel
+        {
+            get { return _ConfidenceLevel; }
+            set
+            {
+                if (value != _ConfidenceLevel)
+                {
+                    _ConfidenceLevel = value;
+                    OnPropertyChanged(nameof(ConfidenceLevel));
+                }
+            }
+        }
+        private float _ConfidenceLevel;
+
+    }
+}

+ 33 - 14
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/Controllers/HttpForFaceController.cs

@@ -3,9 +3,11 @@ using SCADA.CommonLib;
 using SCADA.CommonLib.Data;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
+using SCADA_DAQ.Customer.Models.FaceRecognition;
 using SCADA_DAQ.Customer.Models.HttpModel;
 using SCADA_DAQ.Customer.Models.HttpPayloadMode;
 using SCADA_DAQ.Customer.Models.HttpResponseMode;
+using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
@@ -53,12 +55,15 @@ namespace SCADA_DAQ.Customer.Service.Controllers
         [Route("verify_user")]
         public object VerifyUser([FromBody] Dictionary<string, object> payload)
         {
-            string x = "";
-            if (payload.TryGetValue("user_id", out object userId))
-            {
-                x = userId.ToString();
-            }
-            return new { Result = "0", Msg = x };
+            payload.TryGetValue("user_id", out object userId);
+            payload.TryGetValue("confidence", out object confidence);
+
+            var user = Env.SgIDAL.App_HongShi_Users.GetData<UsersModel>().Where(t => t.UserId == userId.ToString()).LastOrDefault();
+            var res = user.ConfidenceLevel <= Convert.ToDouble(confidence) 
+                ? new { Result = 0, Msg = "验证通过" } 
+                : new { Result = 3, Msg = "验证失败" };
+
+            return res;
         }
 
 
@@ -66,14 +71,28 @@ namespace SCADA_DAQ.Customer.Service.Controllers
         [Route("addFace")]
         public object AddFace([FromBody] Dictionary<string, object> payload)
         {
-            var base64 = payload["photo"].ToString();
-            base64 = base64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
-            //base64 = "data:image/jgp;base64," + base64;
-            byte[] bytes = Convert.FromBase64String(base64);
-            MemoryStream memStream = new MemoryStream(bytes);
-            Image mImage = Image.FromStream(memStream);
-            Bitmap bp = new Bitmap(mImage);
-            bp.Save("C:/Users/Administrator/Desktop/" + DateTime.Now.ToString("yyyyMMddHHss") + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//注意保存路径
+            //var base64 = payload["photo"].ToString();
+            //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);
+            //Image mImage = Image.FromStream(memStream);
+            //Bitmap bp = new Bitmap(mImage);
+            //bp.Save("C:/Users/Administrator/Desktop/" + DateTime.Now.ToString("yyyyMMddHHss") + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//注意保存路径
+
+            payload.TryGetValue("user_id", out object userId);
+            payload.TryGetValue("name", out object name);
+            payload.TryGetValue("ic_card", out object icCard);
+            payload.TryGetValue("photo", out object photo);
+            payload.TryGetValue("validity_period", out object idValid);
+
+            Env.SgIDAL.App_HongShi_Users.Insert(
+                new UpdateItem(T_Col_Name.App_HongShi_Users.UserId_Str, userId?.ToString()),
+                new UpdateItem(T_Col_Name.App_HongShi_Users.Name_Str, name?.ToString()),
+                new UpdateItem(T_Col_Name.App_HongShi_Users.IdValid_Dt, Convert.ToDateTime(idValid)),
+                new UpdateItem(T_Col_Name.App_HongShi_Users.IcCard_Str, icCard?.ToString()),
+                new UpdateItem(T_Col_Name.App_HongShi_Users.Photo_Str, photo?.ToString()),
+                new UpdateItem(T_Col_Name.App_HongShi_Users.ConfidenceLevel_Flo, 50.0)
+            );
 
             return new { Result = 0, Msg = "" };
         }

+ 40 - 15
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFace.cs

@@ -14,13 +14,15 @@ using SCADA_DAQ.Plugin.Core.Service;
 using System.Net.Sockets;
 using System.Windows.Forms;
 using SCADA_DAQ.Customer.Models.FaceRecognition;
+using System.Windows.Interop;
+//using static Mysqlx.Datatypes.Scalar.Types;
 
-namespace SCADA_DAQ.Customer.Service.websocket
+namespace SCADA_DAQ.Customer.Service.Websocket
 {
     /// <summary>
     /// WebSocket服务器
     /// </summary>
-    [DisplayName("WebSocket服务器")]
+    [DisplayName("FaceRecognitionWs")]
     [Description("提供WebSocket服务器服务,可供第三方通过WebSocket访问")]
     public class WssForFace : BaseService
     {
@@ -29,14 +31,25 @@ namespace SCADA_DAQ.Customer.Service.websocket
         private Fleck.WebSocketServer server;
 
         /// <summary>
-        /// 
+        /// 所有的socket链接
+        /// </summary>
+        public readonly ConcurrentDictionary<string, IWebSocketConnection> Sockets = new ConcurrentDictionary<string, IWebSocketConnection>();
+
+        /// <summary>
+        /// 接收消息事件
+        /// </summary>
+        public event EventHandler<WebSocketClientMessage> ClientMessage;
+
+        /// <summary>
+        /// 连接事件
         /// </summary>
         public event EventHandler<WebSocketClientConnected> ClientConnected;
 
         /// <summary>
-        /// 
+        /// 断开事件
         /// </summary>
         public event EventHandler<WebSocketClientDisconnected> ClientDisconnected;
+
         /// <summary>
         /// 
         /// </summary>
@@ -98,6 +111,7 @@ namespace SCADA_DAQ.Customer.Service.websocket
                             SocketConnection = socket,
                         });
                         AllSockets.TryAdd(socket, socket);
+                        Sockets.TryAdd(socket.ConnectionInfo.Id.ToString(), socket);
                     };
                     socket.OnClose = () =>
                     {
@@ -108,6 +122,7 @@ namespace SCADA_DAQ.Customer.Service.websocket
                             SocketConnection = socket
                         });
                         AllSockets.TryRemove(socket, out var _);
+                        Sockets.TryRemove(socket.ConnectionInfo.Id.ToString(), out var _);
                     };
                     socket.OnMessage = message =>
                     {
@@ -116,17 +131,18 @@ namespace SCADA_DAQ.Customer.Service.websocket
                         //{
                         //    socket.Send(JsonHelper.JsonSerialize(RpcService.GetInstance().RpcCall(requestInfo)));
                         //}
-                        //socket.Send(message);
-                        //var requestInfo = JsonHelper.JsonDeserialize(message);
 
                         FleckLog.Info($"{message}");
-                        //pong(socket);
 
                         var requestInfo = JsonHelper.JsonDeserialize<ReceiveModel>(message);
-                        //var sendmsg = ReceiveHandler(requestInfo);
-                        //socket.Send(JsonHelper.JsonSerialize(sendmsg));
+                        // 接收事件
+                        ClientMessage?.Invoke(this, new WebSocketClientMessage()
+                        {
+                            Guid = socket.ConnectionInfo.Id,
+                            Message = requestInfo
+                        });
+
                         ReceiveHandler(socket, requestInfo);
-                        
                     };
                     socket.OnPing = ping =>
                     {
@@ -136,11 +152,10 @@ namespace SCADA_DAQ.Customer.Service.websocket
                     {
 
                     };
+                    
                 });
                 server.RestartAfterListenError = true;
-              
             }).Start();
-            
             return base.Start();
         }
 
@@ -179,12 +194,12 @@ namespace SCADA_DAQ.Customer.Service.websocket
         /// </summary>
         public void Test()
         {
-           // ClientConnected.Invoke();
+            
         }
 
 
         /// <summary>
-        /// 
+        /// 公共消息回复
         /// </summary>
         /// <param name="socket"></param>
         /// <param name="msg"></param>
@@ -194,7 +209,6 @@ namespace SCADA_DAQ.Customer.Service.websocket
             switch (msg.Cmd)
             {
                 case "ping":
-                    //sendmsg.Cmd = "pong";
                     socket.Send(JsonHelper.JsonSerialize(new { cmd = "pong"}));
                     break;
                 case "declare":
@@ -206,4 +220,15 @@ namespace SCADA_DAQ.Customer.Service.websocket
         }
         
     }
+
+
+    /// <summary>
+    /// 接收消息事件模型
+    /// </summary>
+    public class WebSocketClientMessage : EventArgs
+    {
+        //public IWebSocketConnection SocketConnection { get; set; }
+        public Guid Guid { get; set; }
+        public object Message { get; set; }
+    }
 }

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFaceConfig.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace SCADA_DAQ.Customer.Service.websocket
+namespace SCADA_DAQ.Customer.Service.Websocket
 {
     /// <summary>
     /// 配置文件

+ 12 - 2
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml

@@ -25,10 +25,16 @@
             </Grid.ColumnDefinitions>
             <TextBlock Grid.Column="1" VerticalAlignment="Center" TextAlignment="Center" 
                        Text="人脸识别管理" FontWeight="Bold" FontSize="30" Margin="16"></TextBlock>
-            <wpfcontrol:IconButton Grid.Column="2" ButtonKind="ReloadButton"
-                                ButtonStyle="Primary" Title="测试" Margin="15" 
+            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
+                <wpfcontrol:IconButton ButtonKind="ReloadButton" 
+                                ButtonStyle="Primary" Title="测试" Margin="10" 
                                 Width="80" Height="30" HorizontalAlignment="Right" FontSize="20"
                                 Click="IconButton_Click" Cursor="Hand"/>
+                <wpfcontrol:IconButton ButtonKind="AddButton"
+                                ButtonStyle="Primary" Title="新增" Margin="10" 
+                                Width="80" Height="30" HorizontalAlignment="Right" FontSize="20"
+                                Click="IconButton_Click_Add" Cursor="Hand"/>
+            </StackPanel>
         </Grid>
         <Rectangle Height="2" Width="10000" Fill="Gray" Grid.Row="1"/>
         <Grid Grid.Row="2">
@@ -36,6 +42,10 @@
                 <ColumnDefinition />
                 <ColumnDefinition />
             </Grid.ColumnDefinitions>
+            <Image x:Name="FaceImg" Grid.Column="0"/>
+            <wpfcontrol:Card Grid.Column="1">
+                <TextBlock x:Name="MsgText" Text="test" FontSize="20" Foreground="Black" FontStretch="Normal"/>
+            </wpfcontrol:Card>
         </Grid>
     </Grid>
 </wpfcontrol:BaseUctFrm>

+ 81 - 3
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml.cs

@@ -1,26 +1,38 @@
 using DBNames;
+using Fleck;
+using log4net;
+using Microsoft.DwayneNeed.Win32.Gdi32;
+using NPOI.SS.Formula.Functions;
+using Opc.Ua.Gds;
 using SCADA.CommonCtrl.WpfControl;
 using SCADA.CommonLib;
 using SCADA.CommonLib.CommonModel;
+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.PropertyManagement;
 using SCADA_DAQ.Customer.Models.TaskManagement;
 using SCADA_DAQ.Customer.Service;
-using SCADA_DAQ.Customer.Service.websocket;
+using SCADA_DAQ.Customer.Service.Websocket;
 using System;
 using System.Collections.Generic;
+using System.IO;
 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
 {
@@ -30,6 +42,8 @@ namespace SCADA_DAQ.Customer
     [UctMenu("人脸识别管理", Icon = "看板")]
     public partial class UctFrmFaceRecognition : BaseUctFrm
     {
+        private WssForFace wssForFace = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
+
         /// <summary>
         /// 
         /// </summary>
@@ -37,10 +51,36 @@ namespace SCADA_DAQ.Customer
         {
             InitializeComponent();
             ToolBar.Visibility = Visibility.Collapsed; // 屏蔽顶部工具栏
-            //var a = ServiceHost.Instance.GetService<WssForFace>("WebSocket服务器");
+            wssForFace.ClientMessage += WssForFace_ClientMessage;
         }
 
-
+        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")
+            {
+                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);
+                });
+                
+            }
+        }
 
         private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
         {
@@ -59,6 +99,44 @@ namespace SCADA_DAQ.Customer
         }
 
         private void IconButton_Click(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
+            //        }
+            //    }));
+            //});
+
+
+
+        }
+
+        private void IconButton_Click_Add(object sender, RoutedEventArgs e)
         {
 
         }

+ 1 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

@@ -234,6 +234,7 @@
       <HintPath>..\Lib\System.ValueTuple.dll</HintPath>
       <Private>False</Private>
     </Reference>
+    <Reference Include="System.Web" />
     <Reference Include="System.Web.Cors">
       <HintPath>..\Lib\System.Web.Cors.dll</HintPath>
     </Reference>