From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs |  197 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 193 insertions(+), 4 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs
index 5068bba..2c0df35 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Safeguard.cs
@@ -877,7 +877,10 @@
             /// 鏈�灏�4涓瓧绗︼紝鏈�澶�32涓瓧绗�
             /// </summary>
             public string Password;
-
+            /// <summary>
+            /// 鐢ㄦ埛瀵嗙爜鎻愮ず璇�
+            /// </summary>
+            public string PassWordTips = string.Empty;
         }
         #endregion
 
@@ -886,10 +889,11 @@
         /// *鏂板鎴栭噸璁剧敤鎴峰瘑鐮侊紙闇�瑕佺鐞嗗憳鏉冮檺锛�
         /// <para>userId:鐢ㄦ埛id 濡傛灉鐢ㄦ埛id瀛樺湪锛屽垯淇敼瀵嗙爜銆傚鏋滅敤鎴穒d涓嶅瓨鍦紝鍒欎负璇d鏂板瀵嗙爜
         /// 涓�0鏃讹紝鑷姩鍒嗛厤鏂扮殑鐢ㄦ埛id銆備负5鏃讹紝鍒欎慨鏀硅儊杩瘑鐮併�傚彇鍊艰寖鍥�0-5銆�</para>
-        ///  <para>password:鏂扮鐞嗗憳瀵嗙爜</para>
+        /// <para>password:鏂扮鐞嗗憳瀵嗙爜</para>
+        /// <para>passWordTips:瀵嗙爜鎻愮ず</para>
         /// <para>loginToken:鐧婚檰鏍囪瘑锛屾渶澶�32涓瓧绗︺�傜敱app鑷姩鐢熸垚鐨勫敮涓�鏍囪瘑銆備笌绠$悊鍛樼櫥闄嗘寚浠ょ殑鈥淟oginToken鈥濅竴鑷达紝鍚﹀垯灏嗚繑鍥炩�淪ecurity/Error_Respon鈥濋敊璇��</para>
         /// </summary> 
-        public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetUserPasswordAsync(int userId, string password,string loginToken)
+        public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetUserPasswordAsync(int userId, string password, string passWordTips, string loginToken)
         {
             return await System.Threading.Tasks.Task.Run(async () =>
             {
@@ -980,6 +984,7 @@
                     {
                      { "UserId", userId  },
                      { "Password", password},
+                     { "PassWordTips", passWordTips},
                      { "LoginToken", loginToken}
                     };
                     jObject.Add("Data", data);
@@ -1002,6 +1007,129 @@
                 }
                 mainGateway.Actions -= action;
                 System.Console.WriteLine("Security/SetUserPassword_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+                return d;
+            });
+        }
+
+        /// <summary>
+        /// *鏂板鎴栭噸璁剧敤鎴峰瘑鐮侊紙闇�瑕佺鐞嗗憳鏉冮檺锛�
+        /// <para>userId:鐢ㄦ埛id 濡傛灉鐢ㄦ埛id瀛樺湪锛屽垯淇敼瀵嗙爜銆傚鏋滅敤鎴穒d涓嶅瓨鍦紝鍒欎负璇d鏂板瀵嗙爜
+        /// 涓�0鏃讹紝鑷姩鍒嗛厤鏂扮殑鐢ㄦ埛id銆備负5鏃讹紝鍒欎慨鏀硅儊杩瘑鐮併�傚彇鍊艰寖鍥�0-5銆�</para>
+        /// <para>password:鏂扮鐞嗗憳瀵嗙爜</para>
+        /// <para>passWordTips:瀵嗙爜鎻愮ず</para>
+        /// <para>loginToken:鐧婚檰鏍囪瘑锛屾渶澶�32涓瓧绗︺�傜敱app鑷姩鐢熸垚鐨勫敮涓�鏍囪瘑銆備笌绠$悊鍛樼櫥闄嗘寚浠ょ殑鈥淟oginToken鈥濅竴鑷达紝鍚﹀垯灏嗚繑鍥炩�淪ecurity/Error_Respon鈥濋敊璇��</para>
+        /// </summary> 
+        public static async System.Threading.Tasks.Task<SetUserPasswordResponseAllData> SetPassWordTipsAsync(int userId, string password, string passWordTips, string loginToken)
+        {
+            return await System.Threading.Tasks.Task.Run(async () =>
+            {
+                SetUserPasswordResponseAllData d = null;
+                var mainGateway = ZbGateway.MainGateWay;
+                if (mainGateway == null)
+                {
+                    d = new SetUserPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
+                    return d;
+                }
+
+                Action<string, string> action = (topic, message) =>
+                {
+                    var gatewayID = topic.Split('/')[0];
+                    var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+                    if (topic == gatewayID + "/" + "Error_Respon")
+                    {
+                        var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
+                        var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString());
+
+                        if (temp == null)
+                        {
+                            d = new SetUserPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+                        }
+                        else
+                        {
+                            d = new SetUserPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+                        }
+                    }
+
+                    if (topic == gatewayID + "/" + "Security/Error_Respon")
+                    {
+                        var securityTemp = new Safeguard() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.getGatewayBaseInfo.gwID };
+                        var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString());
+                        d = new SetUserPasswordResponseAllData { };
+                        if (temp == null)
+                        {
+                            d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
+                        }
+                        else
+                        {
+                            if (temp.Error == 1)
+                            {
+                                d.errorMessageBase = "缃戝叧涓嶆槸涓荤綉鍏筹紝鏃犳硶杩涜璇ユ搷浣溿��";
+                            }
+                            else if (temp.Error == 2)
+                            {
+                                d.errorMessageBase = "璇ユ搷浣滈渶瑕佸畨闃茬鐞嗗憳鏉冮檺锛岄渶鍏堜互绠$悊鍛樿韩浠借繘琛岀櫥闄嗐��";
+                            }
+                            d.errorResponData = temp;
+                        }
+                    }
+
+                    if (topic == gatewayID + "/" + "Security/AddPassWordTips_Respon")
+                    {
+                        var security = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = mainGateway.CurrentGateWayId };
+                        var result = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString());
+                        if (result == 0)
+                        {
+                            security.setUserPasswordResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetUserPasswordResponseData>(jobject["Data"].ToString());
+                            if (security.setUserPasswordResponseData != null)
+                            {
+                                d = new SetUserPasswordResponseAllData { setUserPasswordResponseData = security.setUserPasswordResponseData };
+                            }
+                        }
+                        else
+                        {
+                            d = new SetUserPasswordResponseAllData { };
+                            var r = new SetUserPasswordResponseData();
+                            r.Result = result;
+                            d.setUserPasswordResponseData = r;
+                        }
+                    }
+                };
+                mainGateway.Actions += action;
+                try
+                {
+                    var jObject = new Newtonsoft.Json.Linq.JObject() {
+                                    { "Cluster_ID", 0 },
+                                    { "Command", 4037}
+                                };
+                    var data = new JObject
+                    {
+                     { "UserId", userId  },
+                     { "Password", password},
+                     { "PassWordTips", passWordTips},
+                     { "LoginToken", loginToken}
+                    };
+                    jObject.Add("Data", data);
+                    mainGateway.Send("Security/AddPassWordTips", jObject.ToString());
+                }
+                catch
+                {
+                }
+                var dateTime = DateTime.Now;
+                while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+                {
+                    await System.Threading.Tasks.Task.Delay(10);
+                    if (d != null)
+                    {
+                        break;
+                    }
+                }
+                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+                {
+                    d = new SetUserPasswordResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+                }
+                mainGateway.Actions -= action;
 
                 return d;
             });
@@ -6485,7 +6613,65 @@
                 System.Console.WriteLine($"Security/AddZoneAction(璁剧疆鑳佽揩鐘舵�佷笅鐨勭數璇濆彿鐮侊級_Actions 閫�鍑篲{System.DateTime.Now.ToString()}");
                 return d;
             });
+        }
+
+        /// <summary>
+        /// *璁剧疆鑳佽揩鐘舵�佷笅琚�氱煡鐨勮仈绯诲彿鐮佺殑澶囨敞锛堥渶瑕佺鐞嗗憳鏉冮檺锛�. -2:涓荤綉鍏充涪澶�
+        /// </summary>
+        /// <param name="strPhone">鍦板尯鐮�-鑱旂郴鏂瑰紡</param>
+        /// <param name="strNote">澶囨敞,鏈�澶�63byte</param>
+        /// <returns></returns>
+        public static async System.Threading.Tasks.Task<SetCoercePhoneNumberResponseData> SetCoercePhoneNumberNoteAsync(string strPhone,string strNote)
+        {
+            SetCoercePhoneNumberResponseData d = null;
+            var mainGateway = ZbGateway.MainGateWay;
+            if (mainGateway == null)
+            {
+                d = new SetCoercePhoneNumberResponseData();
+                d.Result = -2;
+                return d;
+            }
+            Action<string, string> action = (topic, message) =>
+            {
+                var gatewayID = topic.Split('/')[0];
+                if (topic == gatewayID + "/" + "Security/AddPushNumberNote_Respon")
+                {
+                    var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+                    d = Newtonsoft.Json.JsonConvert.DeserializeObject<SetCoercePhoneNumberResponseData>(jobject["Data"].ToString());
+                }
+            };
+
+            mainGateway.Actions += action;
+            try
+            {
+                var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 4038 } };
+                var data = new JObject
+                    {
+                        { "ActionType", 253},
+                        { "LoginToken", Shared.Phone.UserCenter.HdlSafeguardLogic.Current.GetLoginToken()},
+                        { "PushNumber", strPhone},
+                        { "PushNumberNote", strNote}
+                    };
+                jObject.Add("Data", data);
+                mainGateway.Send("Security/AddPushNumberNote", jObject.ToString());
+            }
+            catch { }
+
+            int timeOut = 0;
+            while (timeOut <= 60)
+            {
+                await System.Threading.Tasks.Task.Delay(50);
+                if (d != null)
+                {
+                    break;
+                }
+                timeOut++;
+            }
+
+            mainGateway.Actions -= action;
+            return d;
         }
+
 
         /// <summary>
         /// 璁剧疆鑳佽揩鐘舵�佷笅琚�氱煡鐨勮仈绯诲彿鐮佺殑杩斿洖鏁版嵁 ,缃戝叧鍙嶉淇℃伅
@@ -6567,7 +6753,10 @@
             /// 鎺ㄩ�佷俊鎭殑鐩爣鎵嬫満鍙风爜
             ///</summary>
             public string PushNumber;
-
+            /// <summary>
+            /// 澶囨敞淇℃伅
+            /// </summary>
+            public string PushNumberNote;
         }
 
         /// <summary>

--
Gitblit v1.8.0