| | |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | | |
| | | public class SecurityCenter |
| | | { |
| | | static SecurityCenter _securityCenter; |
| | | |
| | | public static SecurityCenter Ins |
| | | { |
| | | get |
| | | { |
| | | if (_securityCenter == null) |
| | | { |
| | | _securityCenter = new SecurityCenter(); |
| | | } |
| | | return _securityCenter; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 布防中 |
| | | /// </summary> |
| | | public bool InDefense |
| | | { |
| | | get |
| | | { |
| | | foreach (var temp in FunctionList.List.securities) |
| | | { |
| | | if (temp.status == "enable") |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 报警中 |
| | | /// </summary> |
| | | public bool InAlarm |
| | | { |
| | | get |
| | | { |
| | | foreach (var temp in FunctionList.List.securities) |
| | | { |
| | | if (temp.alarm) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | SecurityAlarm _inDefenseMode; |
| | | /// <summary> |
| | | /// 当前布防模式 |
| | | /// </summary> |
| | | public SecurityAlarm InDefenseMode |
| | | { |
| | | get |
| | | { |
| | | if (_inDefenseMode == null) |
| | | { |
| | | foreach (var temp in FunctionList.List.securities) |
| | | { |
| | | if (temp.status == "enable") |
| | | { |
| | | _inDefenseMode = temp; |
| | | return _inDefenseMode; |
| | | } |
| | | } |
| | | } |
| | | return _inDefenseMode; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class SecurityAlarm |
| | | { |
| | | public SecurityAlarm() |
| | | { |
| | | pushConfigs.Add(new SecurityPushConfig() |
| | | { |
| | | pushMethod = "APP", |
| | | pushTarget = new List<string>() { UserInfo.Current.ID } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// 安防延时 |
| | | /// </summary> |
| | | public string delay; |
| | | public string delay ="0"; |
| | | /// <summary> |
| | | /// 状态 |
| | | /// 布防:enable |
| | |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | /// <summary> |
| | | /// 刷新本地数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public SecurityAlarm RefeshData() |
| | | { |
| | | var dataBytes = FileUtlis.Files.ReadFile(savePath); |
| | | var dataString = System.Text.Encoding.UTF8.GetString(dataBytes); |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityAlarm>(dataString); |
| | | return temp; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存安防信息 |
| | |
| | | public string SaveInfo() |
| | | { |
| | | HttpServerRequest hsr = new HttpServerRequest(); |
| | | this.noticeConfig.enable = true; |
| | | this.noticeConfig.noticeContent = Language.StringByID(StringId.SecurityAlarmTipString).Replace("{0}", name); |
| | | if (string.IsNullOrEmpty(this.noticeConfig.noticeContent)) |
| | | { |
| | | this.noticeConfig.noticeContent = Language.StringByID(StringId.SecurityAlarmTipString).Replace("{0}", name); |
| | | } |
| | | if (this.noticeConfig.enable) |
| | | { |
| | | if (this.pushConfigs.Count == 0) |
| | | { |
| | | pushConfigs.Add(new SecurityPushConfig() |
| | | { |
| | | pushMethod = "APP", |
| | | pushTarget = new List<string>() { UserInfo.Current.ID } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(sid)) |
| | | { |
| | | NewSid(); |
| | |
| | | public List<SecurityInputCondition> condition = new List<SecurityInputCondition>(); |
| | | |
| | | /// <summary> |
| | | /// 判断条件 |
| | | /// </summary> |
| | | public string comparator = "="; |
| | | |
| | | /// <summary> |
| | | /// 加入输入条件 |
| | | /// 本地判断使用 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public bool addCondition = false; |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public bool addCondition = false; |
| | | |
| | | /// <summary> |
| | | /// 判断条件 |
| | | /// </summary> |
| | | public string comparator = "="; |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | Function _function = null; |
| | |
| | | case SPK.SensorSmoke: |
| | | foreach (var con in condition) |
| | | { |
| | | if (con.value == "true") |
| | | if (con.value == "true" || con.value == "alarm") |
| | | { |
| | | text += Language.StringByID(StringId.InAlarm) + " "; |
| | | } |
| | | else if (con.value == "false") |
| | | else if (con.value == "false" || con.value == "normal") |
| | | { |
| | | text += Language.StringByID(StringId.Normal) + " "; |
| | | } |
| | |
| | | case SPK.SensorWater: |
| | | foreach (var con in condition) |
| | | { |
| | | if (con.value == "true") |
| | | if (con.value == "true" || con.value == "alarm") |
| | | { |
| | | text += Language.StringByID(StringId.WaterLeakage) + " "; |
| | | } |
| | | else if (con.value == "false") |
| | | else if (con.value == "false" || con.value == "normal") |
| | | { |
| | | text += Language.StringByID(StringId.Normal) + " "; |
| | | } |
| | |
| | | case SPK.SensorDoorWindow: |
| | | foreach (var con in condition) |
| | | { |
| | | if (con.value == "true") |
| | | if (con.value == "true" || con.value == "open") |
| | | { |
| | | text += Language.StringByID(StringId.Open) + " "; |
| | | } |
| | | else if (con.value == "false") |
| | | else if (con.value == "false" || con.value == "close") |
| | | { |
| | | text += Language.StringByID(StringId.Close) + " "; |
| | | } |
| | |
| | | /// 1:场景 |
| | | /// 2:自动化 |
| | | /// </summary> |
| | | public string target_type ="0"; |
| | | public string target_type = "0"; |
| | | /// <summary> |
| | | /// 输出目标的sid |
| | | /// </summary> |
| | |
| | | public List<SecurityOutputStatus> status = new List<SecurityOutputStatus>(); |
| | | |
| | | /// <summary> |
| | | /// 加入输入条件 |
| | | /// 本地判断使用 |
| | | /// 本地不存在数据(数据可能被删了) |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public bool addCondition = false; |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | Function _function = null; |
| | | /// <summary> |
| | | /// 对应的功能对象 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Function GetFunction() |
| | | public bool NoLocalData () |
| | | { |
| | | if (_function == null) |
| | | var function = FunctionList.List.GetLightList().Find((obj) => obj.sid == sid); |
| | | if (function != null) |
| | | { |
| | | _function = FunctionList.List.Functions.Find((obj) => obj.sid == sid); |
| | | return true; |
| | | } |
| | | return _function; |
| | | else |
| | | { |
| | | var scene = FunctionList.List.scenes.Find((obj) => obj.sid == sid); |
| | | if (scene != null) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | string _name; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string name |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(_name)) |
| | | { |
| | | |
| | | var function = FunctionList.List.GetLightList().Find((obj) => obj.sid == sid); |
| | | if (function != null) |
| | | { |
| | | _name = function.name; |
| | | } |
| | | else |
| | | { |
| | | var scene = FunctionList.List.scenes.Find((obj) => obj.sid == sid); |
| | | if (scene != null) |
| | | { |
| | | _name = scene.name; |
| | | } |
| | | } |
| | | } |
| | | return _name; |
| | | } |
| | | set |
| | | { |
| | | _name = value; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | string _roomName; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string RoomName |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(_roomName)) |
| | | { |
| | | |
| | | var function = FunctionList.List.GetLightList().Find((obj) => obj.sid == sid); |
| | | if (function != null) |
| | | { |
| | | _roomName = function.GetRoomListName(); |
| | | } |
| | | else |
| | | { |
| | | var scene = FunctionList.List.scenes.Find((obj) => obj.sid == sid); |
| | | if (scene != null) |
| | | { |
| | | _roomName = scene.GetRoomListName(); |
| | | } |
| | | } |
| | | } |
| | | return _roomName; |
| | | } |
| | | set |
| | | { |
| | | _roomName = value; |
| | | } |
| | | } |
| | | |
| | | string _spk; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string spk |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(_spk)) |
| | | { |
| | | var function = FunctionList.List.GetLightList().Find((obj) => obj.sid == sid); |
| | | if (function != null) |
| | | { |
| | | _spk = function.spk; |
| | | } |
| | | } |
| | | return _spk; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | string text = ""; |
| | | if (target_type == "0") |
| | | { |
| | | switch (GetFunction().spk) |
| | | switch (spk) |
| | | { |
| | | case SPK.LightDimming: |
| | | case SPK.LightCCT: |
| | |
| | | case SPK.LightSwitch: |
| | | foreach (var state in status) |
| | | { |
| | | if (state.key == FunctionAttributeKey.Brightness) |
| | | if(state.key == FunctionAttributeKey.OnOff) |
| | | { |
| | | if (state.value == "off") |
| | | { |
| | | text = Language.StringByID(StringId.Close); |
| | | } |
| | | else |
| | | { |
| | | text = Language.StringByID(StringId.Open); |
| | | } |
| | | } |
| | | else if (state.key == FunctionAttributeKey.Brightness) |
| | | { |
| | | if (state.value == "0") |
| | | { |
| | |
| | | } |
| | | }else if(target_type == "1") |
| | | { |
| | | |
| | | text = Language.StringByID(StringId.Open); |
| | | } |
| | | |
| | | return text; |
| | |
| | | /// <summary> |
| | | /// 是否开启通知 |
| | | /// </summary> |
| | | public bool enable; |
| | | public bool enable = true; |
| | | /// <summary> |
| | | /// 通知内容 |
| | | /// </summary> |
| | |
| | | /// APP:app push |
| | | /// SMS:短信 |
| | | /// </summary> |
| | | public string pushMethod; |
| | | public string pushMethod = "APP"; |
| | | /// <summary> |
| | | /// 推送目标 |
| | | /// </summary> |