From 6de7f8a29b04737d80ad8cb17804fcc50d267bd9 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 20 十月 2023 14:21:28 +0800
Subject: [PATCH] 2.3版本
---
HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs | 261 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 193 insertions(+), 68 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
index b5a8776..1066e2f 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/CombinedDimming/AddGroupControlPage.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
+using HDL_ON.Common;
using HDL_ON.DAL.Server;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
@@ -50,7 +51,8 @@
/// <summary>
/// 鍥炶皟鍒锋柊
/// </summary>
- Action<GroupControl> backActon;
+ Action<GroupControl> addActon;
+ Action delAction;
/// <summary>
/// 鏄惁鏂板缇ゆ帶
/// </summary>
@@ -64,7 +66,7 @@
GroupControlType groupControlType = new GroupControlType();
- public AddGroupControlPage(GroupControl groupControl, Action<GroupControl> action)
+ public AddGroupControlPage(GroupControl groupControl, Action<GroupControl> addAction,Action delAction)
{
bodyView = this;
if(groupControl == null)
@@ -78,15 +80,82 @@
editDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
}
groupControlLightList = new List<Function>();
- backActon = action;
+ this.addActon = addAction;
+
+ this.delAction = delAction;
+
lightList = FunctionList.List.GetLightList();
}
public void LoadPage()
{
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
- new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView();
+ if (isAdd)
+ {
+ new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl)).LoadTopView();
+ }
+ else
+ {
+ new TopViewDiv(bodyView, "").LoadTopView_SettingText(()=> {
+ Action action = () => {
+ var waitPage = new Loading();
+ this.AddChidren(waitPage);
+ waitPage.Start("");
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ var pack = ApiUtlis.Ins.HttpRequest.DelGroupControl(groupControl.userDeviceGroupControlId);
+ if (pack != null)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ try
+ {
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ var delTemp = FunctionList.List.groupControls.Find((obj) => groupControl.sid == obj.sid);
+ FunctionList.List.groupControls.Remove(delTemp);
+ //list.Remove(groupControl);
+ this.RemoveFromParent();
+ delAction?.Invoke();
+ }
+ else
+ {
+ IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+ }
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"鍒锋柊缁勬帶鏁版嵁寮傚父:{ex.Message}");
+ }
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"鍒犻櫎缁勬帶寮傚父:{ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() => {
+ if (waitPage != null)
+ {
+ waitPage.Hide();
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+
+ };
+ new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DoYouWantDelCombinedDimming, action);
+
+ }, Language.StringByID(StringId.DelGroupControl),true);
+ }
var contentView = new FrameLayout()
{
Y = Application.GetRealHeight(64),
@@ -372,88 +441,137 @@
MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
}
}
- try
+ var waitPage = new Loading();
+ bodyView.AddChidren(waitPage);
+ waitPage.Start("");
+ new Thread(() =>
{
- groupControl.type = groupControlType.type;
- groupControl.sid = groupControl.NewGroupControlSid();
- var pack = Common.ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl });
- if (pack != null)
+ try
{
- if (pack.Code == StateCode.SUCCESS)
+ groupControl.type = groupControlType.type;
+ groupControl.sid = groupControl.NewGroupControlSid();
+ var pack = ApiUtlis.Ins.HttpRequest.AddGroupControl(new List<GroupControl>() { groupControl });
+ if (pack != null)
{
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ try
+ {
+ var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
+ if (addTemp != null && addTemp.Count > 0)
+ groupControl.userDeviceGroupControlId = addTemp[0].userDeviceGroupControlId;
+ FunctionList.List.groupControls.Add(groupControl);
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"娣诲姞缇ゆ帶寮傚父锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}");
+ }
+ Application.RunOnMainThread(() =>
+ {
+ addActon?.Invoke(groupControl);
+ this.RemoveFromParent();
+ });
+ }
+ else
+ {
+ IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() => {
try
{
- var addTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
- FunctionList.List.groupControls.AddRange(addTemp);
+ waitPage.Hide();
+ waitPage = null;
}
- catch (Exception ex)
- {
- MainPage.Log($"娣诲姞缇ゆ帶鎴愬姛锛岃浆璇戣繑鍥炴暟鎹け璐�:{ex.Message}");
- }
- backActon?.Invoke(groupControl);
- this.RemoveFromParent();
- }
- else
- {
- IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
- }
+ catch { }
+ });
}
- }
- catch (Exception ex)
- {
- MainPage.Log($"鏂板缇ゆ帶寮傚父:{ex.Message}");
- }
+ })
+ { IsBackground = true }.Start();
}
else
{
- try
+ var waitPage = new Loading();
+ bodyView.AddChidren(waitPage);
+ waitPage.Start("");
+ new Thread(() =>
{
- var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
- //娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑�
- if (newEditDataString == editDataString)
+ try
{
- this.RemoveFromParent();
- return;
- }
- groupControl.sids.Clear();
- foreach (var light in groupControlLightList)
- {
- try
+ //var newEditDataString = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl);
+ //var newEditDataString1 = Newtonsoft.Json.JsonConvert.SerializeObject(groupControlLightList);
+ //var newEditDataString2 = Newtonsoft.Json.JsonConvert.SerializeObject(this.groupControl.sids);
+ ////娌℃湁鏇存柊鏁版嵁鍒欑洿鎺ラ��鍑�
+ //if (newEditDataString == editDataString && newEditDataString1 == newEditDataString2)
+ //{
+ // this.RemoveFromParent();
+ // return;
+ //}
+ groupControl.sids.Clear();
+ foreach (var light in groupControlLightList)
{
- var gc = new GroupControlFunction();
- gc.sid = light.sid;
- gc.spk = light.spk;
- groupControl.sids.Add(gc);
- }
- catch (Exception ex)
- {
- MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
- }
- }
-
- var pack = Common.ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl });
- if (pack != null)
- {
- if (pack.Code == StateCode.SUCCESS)
- {
- var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId);
- if(temp!= null)
+ try
{
- temp = groupControl;
+ var gc = new GroupControlFunction();
+ gc.sid = light.sid;
+ gc.spk = light.spk;
+ groupControl.sids.Add(gc);
}
- backActon?.Invoke(temp);
- this.RemoveFromParent();
+ catch (Exception ex)
+ {
+ MainPage.Log($"鏂板缇ゆ帶杞崲鏁版嵁寮傚父:{ex.Message}");
+ }
}
- else
+
+ var pack = ApiUtlis.Ins.HttpRequest.EditGroupControl(new List<GroupControl>() { groupControl });
+ if (pack != null)
{
- IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ var temp = FunctionList.List.groupControls.Find((obj) => obj.userDeviceGroupControlId == groupControl.userDeviceGroupControlId);
+ if (temp != null)
+ {
+ temp = groupControl;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ addActon?.Invoke(temp);
+ this.RemoveFromParent();
+ });
+ }
+ else
+ {
+ IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+ }
}
}
- }
- catch (Exception ex)
- {
- MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}");
- }
+ catch (Exception ex)
+ {
+ MainPage.Log($"缂栬緫缇ゆ帶寮傚父:{ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ try
+ {
+ waitPage.Hide();
+ waitPage = null;
+ }
+ catch { }
+ });
+
+ }
+ })
+ { IsBackground = true }.Start();
}
}
@@ -479,6 +597,12 @@
var groupControlTypes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControlType>>(pack.Data.ToString());
if (groupControlTypes != null && groupControlTypes.Count > 0)
{
+ //groupControlType = new GroupControlType {
+ // type = "LIGHT",
+ // typeName ="鐏厜鎺у埗",
+ // spks = new List<string> { "light.switch" },
+ // spkAttrs = new List<string> { "on_off" }
+ //};
groupControlType = groupControlTypes[0];
Application.RunOnMainThread(() => {
LoadLightRow(lightList);
@@ -681,7 +805,7 @@
btnChooseAll.TextID = StringId.SelectAll;
btnConfrim.IsSelected = false;
btnChooseAll.MouseUpEventHandler = (sender2, e2) => {
- if (groupControlLightList.Count > 0)
+ if (groupControlLightList.Count == listFunc.Count)
{
groupControlLightList.Clear();
btnChooseAll.TextID = StringId.SelectAll;
@@ -689,6 +813,7 @@
}
else
{
+ groupControlLightList.Clear();
groupControlLightList.AddRange(listFunc);
btnChooseAll.TextID = StringId.Cancel;
btnConfrim.IsSelected = true;
--
Gitblit v1.8.0