陈嘉乐
2021-03-11 ff472d6300cd86eb9c014d43cae51d79438718d7
2021-3-11-1
2个文件已修改
325 ■■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs 291 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,14 +1,14 @@
<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-001674E61438002E" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs">
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs">
    <Files>
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="77" Column="36" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs" Line="305" Column="66" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="205" Column="8" />
      <File FileName="HDL-ON_Android/Assets/Language.ini" Line="1326" Column="5" />
      <File FileName="HDL_ON/Common/R.cs" Line="812" Column="33" />
      <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="301" Column="35" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="103" Column="40" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="10" Column="23" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="84" Column="43" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="98" Column="54" />
      <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="299" Column="32" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs" Line="1" Column="1" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" Line="137" Column="63" />
      <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs" Line="271" Column="25" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
@@ -17,23 +17,26 @@
            <Node name="HDL_ON" expanded="True">
              <Node name="Common" expanded="True" />
              <Node name="DAL" expanded="True">
                <Node name="DriverLayer" expanded="True" />
                <Node name="Mqtt" expanded="True" />
                <Node name="Server" expanded="True" />
              </Node>
              <Node name="Entity" expanded="True" />
              <Node name="UI" expanded="True">
                <Node name="UI2" expanded="True">
                  <Node name="4-PersonalCenter" expanded="True">
                    <Node name="PirDevice" expanded="True">
                      <Node name="Method.cs" selected="True" />
                  <Node name="3-Intelligence" expanded="True">
                    <Node name="Automation" expanded="True">
                      <Node name="LogicView" expanded="True" />
                    </Node>
                  </Node>
                  <Node name="4-PersonalCenter" expanded="True">
                    <Node name="PirDevice" expanded="True" />
                    <Node name="PersonalCenterPageBLL.cs" selected="True" />
                  </Node>
                </Node>
              </Node>
            </Node>
            <Node name="HDL-ON_Android" expanded="True">
              <Node name="Assets" expanded="True" />
            </Node>
            <Node name="HDL-ON_Android" expanded="True" />
          </Node>
        </State>
      </Pad>
@@ -50,8 +53,7 @@
  <MonoDevelop.Ide.DebuggingService.Breakpoints>
    <BreakpointStore>
      <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="323" column="1" />
      <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/DAL/Mqtt/MqttClient.cs" relfile="HDL_ON/DAL/Mqtt/MqttClient.cs" line="310" column="1" />
      <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/DAL/Mqtt/MqttClient.cs" relfile="HDL_ON/DAL/Mqtt/MqttClient.cs" line="301" column="1" />
      <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" line="138" column="1" />
    </BreakpointStore>
  </MonoDevelop.Ide.DebuggingService.Breakpoints>
  <MultiItemStartupConfigurations />
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -24,13 +24,13 @@
        /// <summary>
        /// 修改名称
        /// </summary>
        /// <param name="tipText">提示文本</param>
        /// <param name="tipText">提示标题文本</param>
        /// <param name="list">当前存在名称列表</param>
        /// <param name="currName">当前名称</param>
        /// <param name="action">回调函数</param>
        public void EditControlName(int tipText ,List<string> list, string currName, Action<string, Dialog> action,Action actionCancel, bool tag=false)
        {
            new View.TipView().InputBox(StringId.editName, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view
            new View.TipView().InputBox(tipText, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view
                ) =>
            {
                action(text,view);
@@ -71,7 +71,7 @@
        /// <param name="action">回调函数</param>
        public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action)
        {
            DAL.Server.ResponsePackNew responsePackNew = null;
            Cloud mqttdate = null;
            Loading loading = new Loading();
            frame.AddChidren(loading);
            loading.Start();
@@ -80,10 +80,16 @@
                try
                {
                    //发送添加命令
                    responsePackNew = PirSend.Add(control);
                    var responsePackNew = PirSend.Add(control);
                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                    {
                        string sid = responsePackNew.Data.ToString();
                        mqttdate = MqttDate(sid);
                        if (mqttdate != null)
                        {
                            control.sid = sid;
                        }
                    }
                }
                catch { }
@@ -92,55 +98,47 @@
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                        ///这里:监听MTTP推送下来主题;
                        if (mqttdate != null)
                        {
                            string sid = responsePackNew.Data.ToString();
                            var mqttdate =MqttDate(sid);
                            ///这里:监听MTTP推送下来主题,才知道是否添加成功
                            if (mqttdate != null)
                            //休眠500毫秒,为等待云端创建deviceid;
                            System.Threading.Thread.Sleep(500);
                            //读取添加遥控器deviceID,才知道是否添加成功;
                            GetControl(frame, control, (device) =>
                            {
                                control.sid = sid;
                                //休眠500毫秒,为等待云端创建deviceid;
                                System.Threading.Thread.Sleep(500);
                                GetControl(frame, control, (device) =>
                                if (device != null)
                                {
                                    if (device != null)
                                    {
                                        control.deviceId = device.deviceId;
                                        frame.RemoveFromParent();//添加成功关闭弹窗
                                        action(control);
                                    }
                                    else
                                    {
                                        //读取deviceid返回错误提示
                                        View.FailView failView = new View.FailView();
                                        failView.ShouError((view) =>
                                        {
                                            view.Close();
                                            ThreadAddControl(control, frame, action);
                                        });
                                    }
                                });
                            }
                            else
                            {
                                //监听Mqtt推送下来状态码做提示
                                View.FailView failView = new View.FailView();
                                failView.ShouError((view) =>
                                    control.deviceId = device.deviceId;
                                    frame.RemoveFromParent();//添加成功关闭弹窗
                                    action(control);
                                }
                                else
                                {
                                    view.Close();
                                    ThreadAddControl(control, frame, action);
                                });
                            }
                                    //监听Mqtt推送下来状态码做提示
                                    View.FailView failView = new View.FailView();
                                    failView.ShouError((view) =>
                                    {
                                        view.Close();
                                        ThreadAddControl(control, frame, action);
                                    });
                                }
                            });
                        }
                        else
                        {
                            ErrorShow(responsePackNew);
                            //监听Mqtt推送下来状态码做提示
                            View.FailView failView = new View.FailView();
                            failView.ShouError((view) =>
                            {
                                view.Close();
                                ThreadAddControl(control, frame, action);
                            });
                        }
                    });
                    });
                }
            })
@@ -159,13 +157,43 @@
            //加载log
            Loading loading = new Loading();
            frame.AddChidren(loading);
            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
            loading.Start();
            new System.Threading.Thread(() =>
            {
                try
                {
                    responsePackNew = PirSend.GetDeviceList("ir.module");
                    var responsePackNew = PirSend.GetDeviceList("ir.module");
                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                    {
                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString());
                        string list = jobject["list"].ToString();
                        var jArray = Newtonsoft.Json.Linq.JArray.Parse(list);
                        for (int a = 0; a < jArray.Count; a++)
                        {
                            var jay = jArray[a];
                            string spk = jay["spk"].ToString();
                            if (spk == "ir.module")
                            {
                                //数据返序列化为Logic对象
                                var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
                                var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str);
                                if (pirJosn != null)
                                {
                                    if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
                                    {
                                        Pir.pirDeviceList.Add(pirJosn);
                                    }
                                }
                            }
                        }
                        //GetControlList(frame, action);
                       // GetControlList();
                    }
                }
                catch { }
                finally
@@ -173,42 +201,19 @@
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                       // action();
                        try
                        {
                            if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                            if (Pir.pirDeviceList.Count != 0)
                            {
                                var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString());
                                string list = jobject["list"].ToString();
                                var jArray = Newtonsoft.Json.Linq.JArray.Parse(list);
                                for (int a = 0; a < jArray.Count; a++)
                                {
                                    var jay = jArray[a];
                                    string spk = jay["spk"].ToString();
                                    if (spk == "ir.module")
                                    {
                                        //数据返序列化为Logic对象
                                        var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
                                        var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str);
                                        if (pirJosn != null)
                                        {
                                            if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
                                            {
                                                Pir.pirDeviceList.Add(pirJosn);
                                            }
                                        }
                                    }
                                }
                                GetControlList(frame, action);
                                GetControlList1(frame, action);
                                var list = Pir.pirDeviceList;
                            }
                            else
                            {
                                Method method = new Method();
                                method.ErrorShow(responsePackNew);
                                //Method method = new Method();
                                //method.ErrorShow(responsePackNew);
                            }
                        }
                        catch { }
@@ -223,9 +228,54 @@
        /// <summary>
        /// 获取遥控器列表
        /// </summary>
        public static void GetControlList()
        {
            new System.Threading.Thread(() =>
            {
                for (int i = 0; i < Pir.pirDeviceList.Count; i++)
                {
                    var pirDevice = Pir.pirDeviceList[i];
                    try
                    {
                        var responsePackNew = PirSend.ControlList(pirDevice);
                        if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                        {
                            var jArray = JArray.Parse(responsePackNew.Data.ToString());
                            for (int a = 0; a < jArray.Count; a++)
                            {
                                var jay = jArray[a];
                                //数据返序列化为Logic对象
                                var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
                                var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str);
                                if (pirJosn != null)
                                {
                                    if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid))
                                    {
                                        pirDevice.FunctioList.Add(pirJosn);
                                    }
                                }
                            }
                        }
                    }
                    catch { }
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 获取遥控器列表
        /// </summary>
        /// <param name="frame">log图标加载界面</param>
        /// <param name="action">回调函数</param>
        public static void GetControlList(FrameLayout frame, Action action)
        public static void GetControlList1(FrameLayout frame, Action action)
        {
            //加载log
            Loading loading = new Loading();
@@ -270,11 +320,7 @@
                                        }
                                    }
                                    else
                                    {
                                        //Method method = new Method();
                                        //method.ErrorShow(responsePackNew);
                                    }
                                }
                                catch { }
@@ -307,43 +353,26 @@
            //加载log
            Loading loading = new Loading();
            frame.AddChidren(loading);
            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
            loading.Start();
            new System.Threading.Thread(() =>
            {
                try
                {
                    // 获取设备详情通过(spk,sid)
                    responsePackNew = PirSend.GetinfoBySid(control);
                    var responsePackNew = PirSend.GetinfoBySid(control);
                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                    {
                        //var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString());
                        function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString());
                    }
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        try
                        {
                            if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                            {
                                var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString());
                                function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str);
                            }
                            else
                            {
                                Method method = new Method();
                                method.ErrorShow(responsePackNew);
                            }
                        }
                        catch { }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                loading.Hide();
                                action(function);
                            });
                        }
                        loading.Hide();
                        action(function);
                    });
                }
@@ -377,10 +406,14 @@
                            if (sid == objects.sid)
                            {
                                cloud = cloudjson;
                                mqttdata = "";
                                break;
                            }
                        }
                        break;
                        if (cloud!=null)
                        {
                            break;
                        }
                    }
                    catch { }
                }
@@ -393,23 +426,40 @@
        /// </summary>
        /// <param name="responsePackNew"></param>
        /// <param name="str"></param>
        public void ErrorShow(ResponsePackNew responsePackNew,string str="")
        public void ErrorShow(ResponsePackNew responsePackNew, string str = "")
        {
            if (str == "删除遥控器") {
            if (str == "删除遥控器")
            {
                new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail));
            }
            else
            {
                if (responsePackNew != null && responsePackNew.Code == "14005")
                {
                    new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
                }
                else
                if (responsePackNew != null)
                {
                    new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
                    switch (responsePackNew.Code)
                    {
                        case "14005":
                            {
                                new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
                            }
                            break;
                        case "10807":
                            {
                                //红外宝下遥控器超过最大(10个)数量限制
                                new Intelligence.Automation.LogicView.TipPopView().FlashingBox("红外宝下遥控器超过最大(10个)数量限制");
                            }
                            break;
                        default:
                            {
                                new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
                            }
                            break;
                    }
                }
            }
        }
@@ -417,9 +467,6 @@
    [Serializable]
    public class Cloud
    {
        /// <summary>
        /// 设备id
        /// </summary>
        public string id = "";
        public List<Objects> objects = new List<Objects>();
        public string time_stamp = string.Empty;