From 848dc3467aa22af89e6a4c0a8703ca83cb0b7b06 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 23 十二月 2020 17:23:44 +0800
Subject: [PATCH] 20000

---
 HDL_ON/Entity/Function/Function.cs |   96 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 85 insertions(+), 11 deletions(-)

diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 8e666a9..68d53ae 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -1,5 +1,7 @@
 锘縰sing System;
 using System.Collections.Generic;
+using HDL_ON.Common;
+using HDL_ON.DAL.Server;
 using HDL_ON.DriverLayer;
 using Shared;
 
@@ -207,6 +209,66 @@
         /// </summary>
         public int fixedSerialNumber = int.MaxValue;
 
+        /// <summary>
+        /// 鏀惰棌鍔熻兘
+        /// </summary>
+        public void CollectFunction()
+        {
+            var result = "";
+            //var waitPage = new Loading();
+
+            new System.Threading.Thread(() =>
+            {
+                if (collect)
+                {
+                    result = ApiUtlis.Ins.HttpRequest.CollectDevice(deviceId).Code;
+                }
+                else
+                {
+                    result = ApiUtlis.Ins.HttpRequest.CancelCollectDevice(deviceId).Code;
+                }
+                //鎻愮ず閿欒
+                if (result != StateCode.SUCCESS)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        collect = !collect;
+                        IMessageCommon.Current.ShowErrorInfoAlter(result);
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+        /// <summary>
+        /// 缂栬緫鍔熻兘缁戝畾鎴块棿淇℃伅
+        /// </summary>
+        public void EditBindRoomInfo(string roomId)
+        {
+            var result = "";
+
+            new System.Threading.Thread(() =>
+            {
+                if (collect)
+                {
+                    result = ApiUtlis.Ins.HttpRequest.BindDeviceToRoom(new List<string>() { deviceId }, new List<string>() { roomId }).Code;
+                }
+                else
+                {
+                    result = ApiUtlis.Ins.HttpRequest.UnbindDeviceToRoom(deviceId,roomId);
+                }
+                //鎻愮ず閿欒
+                if (result != StateCode.SUCCESS)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        collect = !collect;
+                        IMessageCommon.Current.ShowErrorInfoAlter(result);
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+
         public string GetBusId()
         {
             string busId = "";
@@ -254,6 +316,15 @@
                 return "FunctionData_" + sid;
             }
         }
+
+        /// <summary>
+        /// 淇濆瓨鍔熻兘鏂囦欢
+        /// </summary>
+        public void SaveFunctionFile()
+        {
+
+        }
+
         /// <summary>
         /// 淇濆瓨鍔熻兘鏁版嵁
         /// </summary>
@@ -261,22 +332,25 @@
         {
             if (upSevser)
             {
-                var pm = new DAL.Server.HttpServerRequest();
-                var pack = pm.UpdataDevcieInfo(this);
-                if (pack.Code == DAL.Server.StateCode.SUCCESS)
+                new System.Threading.Thread(() =>
                 {
-                    var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
-                    Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd);
-                }
-                else
-                {
-                    Utlis.ShowTip(Language.StringByID(StringId.EditFunctionInfoFail) + "\r\nCode:" + pack.Code);
-                }
+                    var pm = new HttpServerRequest();
+                    var pack = pm.UpdataDevcieInfo(this);
+                    if (pack.Code == StateCode.SUCCESS)
+                    {
+                        var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+                        FileUtlis.Files.WriteFileByBytes(savePath, ssd);
+                    }
+                    else
+                    {
+                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                    }
+                });
             }
             else
             {
                 var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
-                Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd);
+                FileUtlis.Files.WriteFileByBytes(savePath, ssd);
             }
         }
 

--
Gitblit v1.8.0