diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs index b2d6c6b9..f8e7a683 100644 --- a/BPASmartClient.IoT/DataVClient.cs +++ b/BPASmartClient.IoT/DataVClient.cs @@ -35,14 +35,13 @@ namespace BPASmartClient.IoT public DataVClient() { DataVApiAddress = InternetInfo.DataVApiAddress; - //DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString(); StartupMode = System.Configuration.ConfigurationManager.AppSettings["StartupMode"].ToString(); BroadcastPubTopic = InternetInfo.BroadcastPubTopic; - //BroadcastPubTopic = System.Configuration.ConfigurationManager.AppSettings["BroadcastPubTopic"].ToString(); + BroadcastMaintainPubTopic = $"{InternetInfo.BroadcastPubTopic}Maintain"; } #endregion @@ -52,6 +51,7 @@ namespace BPASmartClient.IoT public string ProductKey { set; get; } public string DeviceSecret { set; get; } public string BroadcastPubTopic { set; get; } + public string BroadcastMaintainPubTopic { set; get; } /// /// DataV 服务地址 /// @@ -97,6 +97,37 @@ namespace BPASmartClient.IoT } return alarmTable.KeyID; } + /// + /// 增加维保信息 + /// + /// + /// + public string HttpAddMaintain(MaintainTable maintainTable) + { + try + { + if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null) + { + // AlarmTime = GetPropertyValue(obj, "Time").ToString(), + //AlarmType = GetPropertyValue(obj, "Type").ToString(), + //AlarmMessage = GetPropertyValue(obj, "Text").ToString(), + //AlarmVla = "告警", + //DeviceId = Devid.ToString(), + //KeyID = id, + maintainTable.MaintainTime = DateTime.Now.ToString(); + maintainTable.MaintainType = "一般"; + maintainTable.MaintainVla = "维修"; + maintainTable.ClientId = ClientId; + maintainTable.devicename = DeviceDataV.deviceTable.devicename; + DeviceDataV.IOT_Publish(BroadcastMaintainPubTopic, Tools.JsonConvertTools(maintainTable)); + } + } + catch (Exception ex) + { + MessageLog.GetInstance.Show(ex.Message); + } + return maintainTable.KeyID; + } /// /// 增加日志信息 @@ -254,7 +285,6 @@ namespace BPASmartClient.IoT }); keyValues[GetPropertyValue(obj, "Time").ToString() + GetPropertyValue(obj, "Type").ToString() + GetPropertyValue(obj, "Text").ToString()] = id; //MessageLog.GetInstance.AddDeviceAlarmLogShow(GetPropertyValue(obj, "Time").ToString() + GetPropertyValue(obj, "Type").ToString() + GetPropertyValue(obj, "Text").ToString(),id); - } /// @@ -277,7 +307,6 @@ namespace BPASmartClient.IoT State = "n" }); //MessageLog.GetInstance.DeleteDeviceAlarmLogShow(message, keyValues[message]); - } } diff --git a/BPASmartClient.IoT/Model/MaintainTable.cs b/BPASmartClient.IoT/Model/MaintainTable.cs new file mode 100644 index 00000000..566edb98 --- /dev/null +++ b/BPASmartClient.IoT/Model/MaintainTable.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.IoT.Model +{ + /// + /// 维保 + /// + public class MaintainTable : BaseEntity + { + /// + /// 维修时间 + /// + public string MaintainTime { get; set; } + /// + /// 维修类型:1 轻微 2:一般 3 严重 + /// + public string MaintainType { get; set; } + /// + /// 维修消息 + /// + public string MaintainMessage { get; set; } + /// + /// 维修值 + /// + public string MaintainVla { get; set; } + /// + /// IP 地址 + /// + public string IP { get; set; } + /// + /// 状态描述 + /// + public string StatusMS { get; set; } + /// + /// 状态颜色 + /// + public object StatusColor { get; set; } + } +}