From dd7e4794fd611de967c6322dd0bb7ffda41c2f7b Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 29 十一月 2021 16:32:55 +0800
Subject: [PATCH] 增加了安防相关功能
---
HDL_ON/Entity/Function/SecurityAlarm.cs | 159 ++++++++++++++++++-----------------------------------
1 files changed, 54 insertions(+), 105 deletions(-)
diff --git a/HDL_ON/Entity/Function/SecurityAlarm.cs b/HDL_ON/Entity/Function/SecurityAlarm.cs
index 1ebe9f8..a460369 100644
--- a/HDL_ON/Entity/Function/SecurityAlarm.cs
+++ b/HDL_ON/Entity/Function/SecurityAlarm.cs
@@ -6,96 +6,14 @@
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>
@@ -113,7 +31,7 @@
/// <summary>
/// 瀹夐槻寤舵椂
/// </summary>
- public string delay;
+ public string delay ="0";
/// <summary>
/// 鐘舵��
/// 甯冮槻:enable
@@ -172,6 +90,17 @@
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>
/// 淇濆瓨瀹夐槻淇℃伅
@@ -179,8 +108,22 @@
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();
@@ -338,16 +281,16 @@
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;
@@ -436,11 +379,11 @@
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) + " ";
}
@@ -462,11 +405,11 @@
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) + " ";
}
@@ -475,11 +418,11 @@
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) + " ";
}
@@ -537,12 +480,18 @@
/// </summary>
public List<SecurityOutputStatus> status = new List<SecurityOutputStatus>();
+
/// <summary>
/// 鍔犲叆杈撳叆鏉′欢
/// 鏈湴鍒ゆ柇浣跨敤
/// </summary>
+ //[Newtonsoft.Json.JsonIgnore]
+ //public bool addCondition = false;
+
[Newtonsoft.Json.JsonIgnore]
- public bool addCondition = false;
+ public string name = "";
+ [Newtonsoft.Json.JsonIgnore]
+ public string RoomName = "";
[Newtonsoft.Json.JsonIgnore]
Function _function = null;
@@ -593,7 +542,7 @@
}
}else if(target_type == "1")
{
-
+ text = Language.StringByID(StringId.Open);
}
return text;
@@ -617,7 +566,7 @@
/// <summary>
/// 鏄惁寮�鍚�氱煡
/// </summary>
- public bool enable;
+ public bool enable = true;
/// <summary>
/// 閫氱煡鍐呭
/// </summary>
--
Gitblit v1.8.0