陈嘉乐
2020-12-02 74b7633fc57593542157e9d82513b5cfc4d5d8c4
2020-12-2-1

备份代码(实现与云端通信)
10个文件已修改
297 ■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,11 +1,17 @@
<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs">
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs">
    <Files>
      <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="188" Column="1" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs" Line="176" Column="37" />
      <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="419" Column="77" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs" Line="28" Column="64" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs" Line="21" Column="35" />
      <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="526" Column="18" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs" Line="40" Column="32" />
      <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="1" Column="1" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs" Line="235" Column="33" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs" Line="10" Column="1" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs" />
      <File FileName="HDL_ON/DAL/Server/HttpServerRequest.cs" Line="1" Column="1" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs" Line="18" Column="36" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs" Line="101" Column="30" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs" Line="13" Column="15" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="132" Column="13" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
@@ -15,24 +21,15 @@
              <Node name="DAL" 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="3-Intelligence" expanded="True">
                    <Node name="Automation" expanded="True">
                      <Node name="LogicView" expanded="True" />
                      <Node name="AddLogic.cs" selected="True" />
                    </Node>
                    <Node name="IntelligencePage.cs" selected="True" />
                  </Node>
                </Node>
              </Node>
            </Node>
            <Node name="HDL-ON_Android" expanded="True">
              <Node name="Assets" expanded="True" />
            </Node>
            <Node name="HDL-ON_iOS" expanded="True">
              <Node name="Resources" expanded="True">
                <Node name="Phone" expanded="True" />
              </Node>
            </Node>
          </Node>
.vs/HDL_APP_Project/xs/sqlite3/storage.ide
Binary files differ
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm
Binary files differ
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal
Binary files differ
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
@@ -188,8 +188,13 @@
                }
                else
                {
                    LogicMethod.RemoveAllView();
                    MainView.MainShow();
                    var responsePackNew = Send.updateLogic(Logic.currlogic);
                    if (responsePackNew.Code == "0")
                    {
                        LogicMethod.RemoveAllView();
                        MainView.MainShow();
                    }
                    //发送新加修改逻辑命令;
                }
HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs
@@ -7,6 +7,7 @@
    /// </summary>
    public class Logic
    {
        /// <summary>
        /// 逻辑列表
        /// </summary>
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/SingleLogicView.cs
@@ -10,7 +10,7 @@
        public FrameLayout frameLayout = new FrameLayout
        {
            X = Application.GetRealWidth(16),
            Y = Application.GetRealHeight(12),
            //Y = Application.GetRealHeight(12),
            Width = Application.GetRealWidth(343),
            Height = Application.GetRealHeight(102),
            BackgroundColor = CSS.CSS_Color.view,
HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs
@@ -2,6 +2,8 @@
using HDL_ON.UI.UI2.Intelligence.Automation.LogicView;
using Shared;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class MainView
@@ -16,14 +18,27 @@
        public static void MainShow()
        {
            automationPage.RemoveAll();
            VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
            VerticalRefreshLayout vv = new VerticalRefreshLayout();
            vv.Height = Application.GetRealHeight(667 - 64 - 49);//模拟高度
            automationPage.AddChidren(vv);
            vv.BeginHeaderRefreshingAction += () =>
            {
                //清除之前自动化列表;
                Logic.LogicList.Clear();
                //获取自动列表
                GetLogicList();
                //刷新自动化界面
                MainShow();
                //关闭刷新View;
                vv.EndHeaderRefreshing();
            };
            //获取自动化列表
            GetLogicList();
            for (int i = 0; i < Logic.LogicList.Count; i++)
            {
                var currLogic = Logic.LogicList[i];
                ///上下间隔12像素
                vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
                vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12)});
                LogicView.SingleLogicView logicView = new LogicView.SingleLogicView();
                vv.AddChidren(logicView.FLayoutView());
                logicView.btnLogicName.Text = currLogic.name;
@@ -42,12 +57,22 @@
                    if (logicView.btnSwitchIcon.IsSelected)
                    {
                        logicView.btnSwitchIcon.IsSelected = true;
                        currLogic.enable = "true";
                    }
                    else
                    {
                        logicView.btnSwitchIcon.IsSelected = false;
                        currLogic.enable = "false";
                    }
                   Send.switchLogic(currLogic);
                };
                if (Logic.LogicList.Count-1==i) {
                    ///最后一个距离最底部12,界面显示效果作用;
                    vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
                }
                if (currLogic.enable == "true")
                {
                    logicView.btnSwitchIcon.IsSelected = true;
@@ -189,5 +214,93 @@
            }
            return monTextName.TrimEnd(',');
        }
        /// <summary>
        /// 获取逻辑列表
        /// </summary>
        private static void GetLogicList()
        {
            if (Logic.LogicList.Count != 0)
            {
                //自动化列表为0才去获取自动化列表;
                return;
            }
            List<string> logicIdList = new List<string>();
            //获取逻辑ID列表
            var idStr = Send.getLogicIdList();
            if (idStr.Code == "0" && idStr.Data != null)
            {
                var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
                var dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Date>>(date);
                for (int i = 0; i < dateList.Count; i++)
                {
                    //添加逻辑ID
                    logicIdList.Add(dateList[i].userLogicId);
                }
            }
            //获取自动化列表
            var logicStr = Send.getLogic(logicIdList);
            if (logicStr.Code == "0" && logicStr.Data != null)
            {
                //获取逻辑详细返回是一个数组(object类型转换为数组);
                var jArray = JArray.Parse(logicStr.Data.ToString());
                for (int a = 0; a < jArray.Count; a++)
                {
                    var jay = jArray[a];
                    //数据返序列化为Logic对象
                    var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
                    var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str);
                    if (logic != null)
                    {
                        //查找是否已经存在该逻辑
                        var if_logic = Logic.LogicList.Find((c) => c.userLogicId == logic.userLogicId);
                        if (if_logic == null)
                        {
                            //添加逻辑
                            Logic.LogicList.Add(logic);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 判断JObject对象是存在健值
        /// </summary>
        /// <param name="jObject"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        private bool Exist(JObject jObject, string key)
        {
            if (jObject.Property(key) != null)
            {
                return true;
            }
            return false;
        }
    }
    class Date
    {
        /// <summary>
        /// 云端唯一id
        /// </summary>
        public string userLogicId = "";
        public string gatewayId = "";
        /// <summary>
        /// 逻辑唯一标识
        /// </summary>
        public string sid = "";
        public string name = "";
        public string enable = "";
        //public CycleA cycle;
        //public string modifyTime = "";
    }
    class CycleA
    {
        public string type = "";
        public string[] value;
    }
}
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
@@ -26,134 +26,6 @@
        /// 网关ID
        /// </summary>
        public static string gatewayId = "1333723647223775233";
        ///// <summary>
        ///// 获取逻辑ID列表
        ///// </summary>
        ///// <returns></returns>
        //public const string getLogicId = "获取逻辑ID";
        ///// <summary>
        ///// 获取逻辑
        ///// </summary>
        ///// <returns></returns>
        //public const string getLogic= "获取逻辑详细";
        ///// <summary>
        ///// 添加自动化命令
        ///// </summary>
        ///// <returns></returns>
        //public const string addLogic= "添加新逻辑";
        ///// <summary>
        ///// 编辑更新逻辑
        ///// </summary>
        ///// <returns></returns>
        //public const string updateLogic = "编辑逻辑";
        ///// <summary>
        ///// 删除逻辑
        ///// </summary>
        ///// <returns></returns>
        //public const string delLogic = "删除逻辑";
        ///// <summary>
        ///// 逻辑开关
        ///// </summary>
        ///// <returns></returns>
        //public const string switchLogic = "逻辑开关";
        //public static ResponsePackNew Logic(string type,Logic logic) {
        //    string url = "";
        //    var jObject = new JObject { };
        //    switch (type) {
        //        case getLogicId: {
        //                jObject.Add("homeId",homeId);
        //                url = NewAPI.API_POST_Logic_List;
        //            }
        //            break;
        //        case getLogic: {
        //                var jArray = new JArray { };
        //                jArray.Add(logic.userLogicId);
        //                jObject.Add("userLogicIds", jArray);
        //                url = NewAPI.API_POST_Logic_Info;
        //            } break;
        //        case addLogic: {
        //                try
        //                {
        //                    var cycleJObject = new JObject { };
        //                    var cyclevaluejArray = new JArray { };
        //                    cycleJObject.Add("type", logic.cycle.type);
        //                    foreach (var dictionary in logic.cycle.value)
        //                    {
        //                        cyclevaluejArray.Add(dictionary);
        //                    }
        //                    cycleJObject.Add("value", cyclevaluejArray);
        //                    var inputArray = new JArray { };
        //                    foreach (var dictionary in logic.input)
        //                    {
        //                        var inputTypeJOb = new JObject { };
        //                        inputTypeJOb.Add("sid", dictionary.sid);
        //                        inputTypeJOb.Add("condition_type", dictionary.condition_type);
        //                        var conditionArray = new JArray { };
        //                        foreach (var dic in dictionary.condition)
        //                        {
        //                            var conditionJOb = new JObject { };
        //                            conditionJOb.Add("key", dic["key"]);
        //                            conditionJOb.Add("comparator", dic["comparator"]);
        //                            conditionJOb.Add("data_type", dic["data_type"]);
        //                            conditionJOb.Add("value", dic["value"]);
        //                            conditionArray.Add(conditionJOb);
        //                        }
        //                        inputTypeJOb.Add("condition", conditionArray);
        //                        inputArray.Add(inputTypeJOb);
        //                    }
        //                    var outputArray = new JArray { };
        //                    foreach (var dictionary in logic.output)
        //                    {
        //                        var outputTypeJOb = new JObject { };
        //                        outputTypeJOb.Add("sid", dictionary.sid);
        //                        outputTypeJOb.Add("target_type", dictionary.target_type);
        //                        var statusArray = new JArray { };
        //                        foreach (var dic in dictionary.status)
        //                        {
        //                            var statusJOb = new JObject { };
        //                            statusJOb.Add("key", dic["key"]);
        //                            statusJOb.Add("value", dic["value"]);
        //                            statusArray.Add(statusJOb);
        //                        }
        //                        outputTypeJOb.Add("status", statusArray);
        //                        outputArray.Add(outputTypeJOb);
        //                    }
        //                    var logicjArray = new JArray { };
        //                    var logicIfon = new JObject { };
        //                    logicIfon.Add("sid", logic.sid);
        //                    logicIfon.Add("gatewayId", gatewayId);
        //                    logicIfon.Add("name", logic.name);
        //                    logicIfon.Add("relation", logic.relation);
        //                    logicIfon.Add("enable", logic.enable);
        //                    logicIfon.Add("cycle", cycleJObject);
        //                    logicIfon.Add("input", inputArray);
        //                    logicIfon.Add("output", outputArray);
        //                    logicjArray.Add(logicIfon);
        //                    var jObject = new JObject { { "homeId", homeId }, { "logics", logicjArray } };
        //                    responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add);
        //                }
        //                catch (Exception e)
        //                {
        //                    var dd = e.Message;
        //                }
        //            } break;
        //        case updateLogic: {
        //            } break;
        //        case delLogic: { } break;
        //        case switchLogic: { } break;
        //    }
        //    return RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add);
        //}
        /// <summary>
        /// 获取逻辑ID列表
@@ -168,11 +40,15 @@
        /// <summary>
        /// 获取逻辑
        /// </summary>
        /// <param name="userLogicId">逻辑ID</param>
        /// <returns></returns>
        public static ResponsePackNew getLogic(Logic logic)
        public static ResponsePackNew getLogic(List<string> listIdList)
        {
            var jArray = new JArray { };
            jArray.Add(logic.userLogicId);
            for (int i = 0; i < listIdList.Count; i++)
            {
                jArray.Add(listIdList[i]);
            }
            var jObject = new JObject { { "userLogicIds", jArray } };
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info);
            return responsePackNew;
HDL_ON/UI/UI2/3-Intelligence/Automation/Set.cs
@@ -98,6 +98,7 @@
                new LogicView.TipPopView().TipBox(StringId.tip, StringId.delAutomation, () =>
                {
                    Send.delLogic(Logic.currlogic);
                    LogicMethod.RemoveAllView();
                    Logic.LogicList.Remove(Logic.currlogic);
                    MainView.MainShow();