| | |
| | | } |
| | | |
| | | var count = 0; |
| | | var logString = open ? "打开\r\n" : "关闭\r\n"; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, open ? "on" : "off"); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | foreach (var temp in functions) |
| | | //一端口全开全关需要延时发送 |
| | | if (DB_ResidenceData.Instance.GatewayType == 0) |
| | | { |
| | | logString += temp.spk + ":" + temp.sid + "\r\n"; |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | MainPage.Log(logString); |
| | | logString = ""; |
| | | } |
| | | foreach (var temp in functions) |
| | | { |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | var result = pm.ControlDevice(new List<ApiAlinkControlActionObj>() { apiControlData }); |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | MainPage.Log(logString); |
| | | else |
| | | { |
| | | foreach (var temp in functions) |
| | | { |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | } |
| | | } |
| | | |
| | | public void SendApiReadCommand(List<string> functionIds) |