Esempio n. 1
0
        /// <summary>
        /// 解析设备类型
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private bool ParseControl(byte[] data, int state)
        {
            string msgType = "[解析控制类型字节异常]{0}:原始协议(" + Utility.ConvertBytesToString(data, " ") + ")";

            if (data.Length < 6)//12计算是协议到结果最小协议长度,这个数需要根据实际进行修改
            {
                Utility.WriteLog(string.Format(msgType, "协议长度不够"));
                return(false);
            }
            this.Control = new byte[2];
            Array.Copy(data, 4, this.Control, 0, 2);
            this.ControlType = ConvertControlType.ConvertString(Utility.byte2DeviceType(this.Control));
            if (this.ControlType == ControlType.UnKnown)
            {
                Utility.WriteLog(string.Format(msgType, "未找到对应的控制类型"));
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 报警消息处理记录
        /// </summary>
        /// <param name="TitleID">消息id</param>
        /// <param name="deviceType">设备类型</param>
        /// <param name="address">报警地址</param>
        /// <param name="FriendNames">关联好友</param>
        private static void AddPusUserFirst(string TitleID, int deviceType, string address, string FriendNames, string UserName)
        {
            List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
            FireControl_WarninsHandleBLL     WHandBLL    = new FireControl_WarninsHandleBLL();
            //初次报警记录
            FireControl_WarninsHandle Model = new FireControl_WarninsHandle();

            Model.Content    = address + $"的{ConvertControlType.ConvertNameString(deviceType)}发生报警";
            Model.CreateTime = DateTime.Now;
            Model.Deleted    = 0;
            Model.CreatedBy  = "0";
            Model.HandlD     = CommHelper.CreatePKID("hd");;
            Model.Hand_Date  = DateTime.Now;
            Model.Title      = $"{ConvertControlType.ConvertNameString(deviceType)}发生报警";;
            Model.TitleID    = TitleID;
            Model.UserID     = "0"; //初次报警 0代表系统
            Model.Hand_Mode  = 0;
            Model.Hand_Type  = 0;
            InsertModle.Add(Model);
            //报警推送记录
            FireControl_WarninsHandle SecondModel = new FireControl_WarninsHandle();

            SecondModel.Content    = $"报警已推送给{UserName},{(FriendNames != "" ? "和" + FriendNames : "")}";
            SecondModel.CreateTime = Model.Hand_Date.AddSeconds(1);
            SecondModel.Deleted    = 0;
            SecondModel.CreatedBy  = "0";
            SecondModel.HandlD     = CommHelper.CreatePKID("hd");;
            SecondModel.Hand_Date  = Model.Hand_Date.AddSeconds(1);
            SecondModel.Title      = $"报警推送";;
            SecondModel.TitleID    = TitleID;
            SecondModel.UserID     = "0"; //初次报警 0代表系统
            SecondModel.Hand_Mode  = 0;
            SecondModel.Hand_Type  = 2;
            InsertModle.Add(SecondModel);
            var ss = WHandBLL.AddAllObj(InsertModle);

            Utility.WriteLog("消息处理:" + ss.ResultContent);
        }