wei
2020-12-24 22fcd0d263770c8371bd03ca53f097a6ec1678f7
20201224-2

一端口场景优化
6个文件已修改
215 ■■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Common/ApiUtlis.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpServerRequest.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/Function/Light.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/FunctionList.cs 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,9 +1,16 @@
<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-000404163432002E" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/1-HomePage/HomePage.cs">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.94B44E9C-E1BC-4BF7-812E-FC71E9B623B2" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/FunctionList.cs">
    <Files>
      <File FileName="HDL_ON/Common/ApiUtlis.cs" Line="305" Column="7" />
      <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePage.cs" Line="29" Column="18" />
      <File FileName="HDL_ON/Common/ApiUtlis.cs" Line="220" Column="73" />
      <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePage.cs" Line="922" Column="1" />
      <File FileName="HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs" Line="111" Column="123" />
      <File FileName="HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs" Line="91" Column="22" />
      <File FileName="HDL_ON/Entity/Function/Function.cs" Line="612" Column="29" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs" Line="90" Column="1" />
      <File FileName="HDL_ON/DAL/DriverLayer/Control.cs" Line="621" Column="1" />
      <File FileName="HDL_ON/Entity/Function/Light.cs" Line="206" Column="10" />
      <File FileName="HDL_ON/Entity/FunctionList.cs" Line="197" Column="22" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
@@ -18,12 +25,11 @@
              </Node>
              <Node name="Entity" expanded="True">
                <Node name="Function" expanded="True" />
                <Node name="FunctionList.cs" selected="True" />
              </Node>
              <Node name="UI" expanded="True">
                <Node name="UI2" expanded="True">
                  <Node name="1-HomePage" expanded="True">
                    <Node name="HomePage.cs" selected="True" />
                  </Node>
                  <Node name="1-HomePage" expanded="True" />
                  <Node name="2-Classification" expanded="True" />
                  <Node name="3-Intelligence" expanded="True">
                    <Node name="Scene" expanded="True" />
@@ -40,6 +46,16 @@
          </Node>
        </State>
      </Pad>
      <Pad Id="MonoDevelop.Debugger.WatchPad">
        <State>
          <Value>light.RedColor</Value>
          <Value>light.GreenColor</Value>
          <Value>light.BlueColor</Value>
          <Value>e2[0]</Value>
          <Value>e2[1]</Value>
          <Value>e2[2]</Value>
        </State>
      </Pad>
    </Pads>
  </MonoDevelop.Ide.Workbench>
  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
@@ -48,11 +64,13 @@
    <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String>
    <String>Shared.IOS/Shared.IOS.csproj</String>
  </DisabledProjects>
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" />
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
  <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.SelectDevice" />
  <MonoDevelop.Ide.DebuggingService.Breakpoints>
    <BreakpointStore>
      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs" line="315" column="1" />
      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs" relfile="HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs" line="90" column="1" />
      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/Entity/Function/Light.cs" relfile="HDL_ON/Entity/Function/Light.cs" line="180" column="1" />
    </BreakpointStore>
  </MonoDevelop.Ide.DebuggingService.Breakpoints>
  <MultiItemStartupConfigurations />
HDL_ON/Common/ApiUtlis.cs
@@ -217,8 +217,6 @@
                        if (sceneList == null)
                        {
                            sceneList = new List<Scene>();
                        }
                        {
                            for (int i = 0; i < FunctionList.List.scenes.Count;)
                            {
                                var localScene = FunctionList.List.scenes[i];
@@ -256,20 +254,28 @@
                        //如果是一端口需要提前下载场景数据,否则控制不了一端口场景
                        if (DB_ResidenceData.Instance.GatewayType == 0)
                        {
                            var sceneIds = new List<string>();
                            foreach (var tempScene in FunctionList.List.scenes)
                            {
                                var pcak = HttpRequest.GetSceneInfo(tempScene.userSceneId);
                                if (pack.Code == StateCode.SUCCESS)
                                sceneIds.Add(tempScene.userSceneId);
                            }
                            var packInfo = HttpRequest.GetSceneListInfo(sceneIds);
                            if (packInfo.Code == StateCode.SUCCESS)
                            {
                                var serverTempList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(packInfo.Data.ToString());
                                foreach (var localScene in FunctionList.List.scenes)
                                {
                                    var serverTempList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
                                    var serverTemp = serverTempList.Find((obj) => obj.userSceneId == tempScene.userSceneId);
                                    tempScene.functions = serverTemp.functions;
                                    tempScene.SaveSceneFile();
                                    var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId);
                                    if (serverTemp != null)
                                    {
                                        localScene.functions = serverTemp.functions;
                                        localScene.SaveSceneFile();
                                    }
                                }
                                else
                                {
                                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                                }
                            }
                            else
                            {
                                IMessageCommon.Current.ShowErrorInfoAlter(packInfo.Code);
                            }
                        }
                        endTime = DateTime.Now.AddSeconds(5);
HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -1946,6 +1946,21 @@
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
        }
        /// <summary>
        /// 获取场景详情列表
        /// </summary>
        /// <param name="seceneId">场景ID</param>
        /// <returns></returns>
        public ResponsePackNew GetSceneListInfo(List<string> seceneIds)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("userSceneIds", seceneIds);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
        }
        /// <summary>
        /// 添加场景
        /// </summary>
HDL_ON/Entity/Function/Light.cs
@@ -176,10 +176,10 @@
                }
                if (trait_color.curValue.ToString() == "{}")
                    trait_color.curValue = "255,255,255";
                int.TryParse(trait_color.curValue.ToString().Split(",")[0], out redColor);
                int.TryParse(trait_color.curValue.ToString().Split(",")[1], out greenColor);
                int.TryParse(trait_color.curValue.ToString().Split(",")[2], out blueColor);
            }
            int.TryParse(trait_color.curValue.ToString().Split(",")[0], out redColor);
            int.TryParse(trait_color.curValue.ToString().Split(",")[1], out greenColor);
            int.TryParse(trait_color.curValue.ToString().Split(",")[2], out blueColor);
            int recolor = redColor * 256 * 256 + greenColor * 256 + blueColor;
@@ -202,6 +202,7 @@
            redColor = color[0];
            greenColor = color[1];
            blueColor = color[2];
            trait_color.curValue = redColor + "," + greenColor + "," + blueColor;
        }
        [Newtonsoft.Json.JsonIgnore]
HDL_ON/Entity/FunctionList.cs
@@ -191,7 +191,7 @@
            }
            if (filePath.StartsWith("SceneData_"))
            {
                var sceneDataBytes = Common.FileUtlis.Files.ReadFile(filePath);
                var sceneDataBytes = FileUtlis.Files.ReadFile(filePath);
                var sceneDataString = System.Text.Encoding.UTF8.GetString(sceneDataBytes);
                var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene>(sceneDataString);
                List.scenes.Add(tempScene);
@@ -376,129 +376,6 @@
            }
            return pack.Code;
        }
        /// <summary>
        /// 下来云端设备数据
        /// </summary>
        public void DownloadFunctionList()
        {
            new Thread(() =>
            {
                var pm = new HttpServerRequest();
                var pack = pm.GetDeviceList();
                if (pack.Code == StateCode.SUCCESS)
                {
                    var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(pack.Data.ToString());
                    if (deviceList != null)
                    {
                        if (List.GetDeviceFunctionList().Count > 0)
                        {
                            for (int i = 0; i < List.GetDeviceFunctionList().Count;)
                            {
                                var localFunction = List.GetDeviceFunctionList()[i];
                                if (localFunction.functionCategory == FunctionCategory.Music)
                                {
                                    i++;
                                    continue;
                                }
                                var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
                                if (newFunction == null)//如果云端最新数据没有该条数据,则本地需要删掉该数据记录
                                {
                                    List.DeleteFunction(localFunction);
                                }
                                else
                                {
                                    MainPage.Log($"deviceType:{localFunction.spk} local:{localFunction.modifyTime} server:{newFunction.modifyTime}");
                                    i++;
                                    if (localFunction.modifyTime != newFunction.modifyTime)
                                    {
                                        localFunction.name = newFunction.name;
                                        localFunction.collect = newFunction.collect;
                                        localFunction.modifyTime = newFunction.modifyTime;
                                        localFunction.roomIds = newFunction.roomIds;
                                        localFunction.bus = newFunction.bus;
                                        localFunction.SaveFunctionFile();
                                    }
                                    deviceList.list.Remove(newFunction);//操作完的数据清理掉,剩下的就是新增的功能
                                }
                            }
                        }
                        //处理剩下的新增功能
                        foreach (var newFunction in deviceList.list)
                        {
                            newFunction.SaveFunctionFile();
                            List.IniFunctionList(newFunction.savePath);
                        }
                    }
                    //MainPage.Log($"读取云端设备数据:\r\n{ pack.Data.ToString()}");
                }
                else
                {
                    MainPage.Log($"读取云端设备数据失败:\r\nCode:{pack.Code};  Msg:{pack.message}");
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 下载云端场景数据
        /// </summary>
        public void DownloadSceneList()
        {
            new Thread(() =>
            {
                var pm = new HttpServerRequest();
                var pack = pm.GetSceneList();
                if(pack.Code == StateCode.SUCCESS)
                {
                    //MainPage.Log($"读取云端场景数据:\r\n{pack.Data.ToString()}");
                    var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
                    if (sceneList != null)
                    {
                        for (int i=0;i<List.scenes.Count;)
                        {
                            var localScene = List.scenes[i];
                            if (localScene == null)
                            {
                                List.scenes.Remove(localScene);
                                continue;
                            }
                            var newScene = sceneList.Find((obj) => obj.userSceneId == localScene.userSceneId);
                            if (newScene == null)//如果云端最新数据没有该条数据,则本地需要删掉该数据记录
                            {
                                List.DeleteScene(localScene,false);
                            }
                            else
                            {
                                i++;
                                if (localScene.modifyTime != newScene.modifyTime)
                                {
                                    localScene.name = newScene.name;
                                    localScene.collect = newScene.collect;
                                    localScene.modifyTime = newScene.modifyTime;
                                    localScene.roomIds = newScene.roomIds;
                                    localScene.SaveSceneFile();
                                }
                                sceneList.Remove(newScene);//操作完的数据清理掉,剩下的就是新增的功能
                            }
                        }
                        //处理剩下的新增功能
                        foreach (var newScene in sceneList)
                        {
                            newScene.SaveSceneFile();
                            List.scenes.Add(newScene);
                        }
                    }
                }
                else
                {
                    MainPage.Log($"读取云端场景数据失败:\r\nCode:{pack.Code};  Msg:{pack.message}");
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 删除场景
HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs
@@ -85,7 +85,9 @@
                    d.Add(FunctionAttributeKey.OnOff, function.trait_on_off.curValue.ToString());
                    if(fadeTime!= null)
                    {
                        d.Add(FunctionAttributeKey.FadeTime, fadeTime.curValue.ToString());
                        int result = 0;
                        int.TryParse(fadeTime.curValue.ToString(), out result);
                        d.Add(FunctionAttributeKey.FadeTime, result.ToString());
                    }
                    Control.Ins.SendWriteCommand(function, d);
                })