using System; using System.Collections.Generic; using HDL_ON.Common; using HDL_ON.DAL.Server; using Shared; namespace HDL_ON.Entity { public class GroupControl : Function { public GroupControl() { spk = "GroupControl"; } /// /// 群控ID /// public string userDeviceGroupControlId = string.Empty; /// /// 群控sid /// //public string sid = string.Empty; /// /// 生成群控sid /// public string NewGroupControlSid() { string sceneId = ""; try { string sOidBeginsWith = "000101";//厂商 + 通讯方式 DateTime dt = DateTime.Now; DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1)); long m = (long)((dt - startTime).TotalMilliseconds / 10); string sTimeSpan = "00000000"; byte[] arry = new byte[4]; arry[0] = (byte)(m & 0xFF); arry[1] = (byte)((m & 0xFF00) >> 8); arry[2] = (byte)((m & 0xFF0000) >> 16); arry[3] = (byte)((m >> 24) & 0xFF); sTimeSpan = arry[0].ToString("X2") + arry[1].ToString("X2") + arry[2].ToString("X2") + arry[3].ToString("X2"); if (sTimeSpan.Length >= 8) { sTimeSpan = sTimeSpan.Substring(0, 8); } else { sTimeSpan = Guid.NewGuid().ToString().Substring(0, 8); //sTimeSpan = "00000000"; } sceneId = sOidBeginsWith + sTimeSpan; sceneId += "AA"; sceneId += "AA01"; int maxId = 1; Random random = new Random(Guid.NewGuid().GetHashCode()); maxId = random.Next(10); sceneId += (maxId + 1).ToString("X4"); sceneId += "0000"; } catch { return sceneId; } return sceneId; } /// /// 群控名称 /// //public string name = string.Empty; /// /// 群控类型 /// public string type = string.Empty; /// /// 房间uid /// public List uids = new List(); //public List roomIds = new List(); /// /// 群控功能sid配置 /// public List sids = new List(); ///// ///// 获取设备添加到房间的房间名称 ///// ///// //public string GetRoomListName() //{ // string roomNameList = ""; // foreach (var roomId in roomIds) // { // var findRoom = SpatialInfo.CurrentSpatial.RoomList.Find(obj => obj.roomId == roomId); // if (findRoom == null) // { // continue; // } // if (roomNameList != "") // { // roomNameList += ","; // } // roomNameList += findRoom.floorName + "-" + findRoom.roomName; // } // if (roomNameList == "") // { // roomNameList = Language.StringByID(StringId.WholeZone); // } // return roomNameList; //} /// /// 群控控制 /// /// public void Control(Dictionary pairs) { try { var controlValues = new Dictionary(); foreach(var p in pairs) { controlValues.Add("key", p.Key); controlValues.Add("value", p.Value); } var pack = ApiUtlis.Ins.HttpRequest.ControlGroupControl(userDeviceGroupControlId, controlValues); if (pack != null) { if (pack.Code == StateCode.SUCCESS) { //DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl. } else { MainPage.Log($"群控控制失败,Code: {pack.Code}"); } } } catch (Exception ex){ MainPage.Log($"群控控制失败: {ex.Message}"); } } } public class GroupControlFunction { /// /// 功能sid /// public string sid = string.Empty; /// /// 功能spk /// public string spk = string.Empty; } public class GroupControlType { /// /// 类型 /// public string type = string.Empty; /// /// 类型名称 /// public string typeName = string.Empty; /// /// 群控支持的spk /// public List spks = new List(); /// /// 群控支持的spk属性 /// public List spkAttrs = new List(); } }