wei
2021-03-23 d3a9358843b9539017debde289fb38e4fdf26938
HDL_ON/Common/ApiUtlis.cs
@@ -172,28 +172,6 @@
                                    continue;
                                }
                                var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
                                //if (newFunction == null)//如果云端最新数据没有该条数据,则本地需要删掉该数据记录
                                //{
                                //    FunctionList.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();
                                //    //}
                                //    localFunction = newFunction;
                                //    localFunction.SaveFunctionFile();
                                //    deviceList.list.Remove(newFunction);//操作完的数据清理掉,剩下的就是新增的功能
                                //}
                                if (delFile == localFunction.savePath)
                                {
@@ -202,10 +180,7 @@
                                }
                                delFile = localFunction.savePath;
                                FunctionList.List.DeleteFunction(localFunction);
                            }
                        }
                        //处理剩下的新增功能
                        foreach (var newFunction in deviceList.list) 
@@ -369,5 +344,24 @@
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 获取功能信息
        /// </summary>
        public void GetFunctionInfo(string functionId)
        {
            var deviceResult = Ins.HttpRequest.GetDeviceInfo(functionId);
            if (deviceResult.Code == StateCode.SUCCESS)
            {
                MainPage.Log($"读取设备信息成功");
                var packList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
                foreach(var function in packList.list)
                {
                    function.SaveFunctionFile();
                    FunctionList.List.IniFunctionList(function.savePath,true);
                }
            }
        }
    }
}