示例#1
0
        /// <summary>
        /// P1新版极光推送
        /// </summary>
        /// <param name="UserModel">用户基础信息</param>
        /// <param name="TitleID">消息ID</param>
        /// <param name="NewType">消息类型 1 燃起烟感报警 6电气报警</param>
        /// <param name="DevName"></param>
        public static void APPPush(People UserModel, string TitleID, string NewType, string DevName, string DevID)
        {//目前推送智慧给自己推送
         //添加推送记录
            var content = $"紧急通知!您的{DevName}设备发生报警,地址{UserModel.Province + UserModel.City + UserModel.Area + UserModel.VillageName},请尽快处理";
            FireControl_PushRecordBLL pushReBLL = new FireControl_PushRecordBLL();
            FireControl_PushRecord    pushRe    = new FireControl_PushRecord();

            pushRe.DevID    = DevID;
            pushRe.Message  = content;
            pushRe.Phone    = UserModel.Phone;
            pushRe.PRID     = CommHelper.CreatePKID("fr");
            pushRe.SendType = 1;
            pushRe.TitleID  = TitleID;
            pushRe.UserID   = UserModel.UserID;
            pushReBLL.AddObj(pushRe);
            Dictionary <string, string> dic1 = new Dictionary <string, string>();

            dic1.Add("content", content);
            dic1.Add("title", "设备报警");
            dic1.Add("type", NewType); //1为烟感燃气 6为电气
            dic1.Add("msgid", TitleID);
            dic1.Add("cucode", UserModel.UserID);
            dic1.Add("application", "8");
            dic1.Add("platformType", "3");
            dic1.Add("isCustomMsg", "0");
            Utility.WriteLog("极光--1推----" + UserModel.UserID + UserModel.Phone);
            new Task(() =>
            {
                HttpSend.GetByRequest(JGApi, dic1, null, true);
            }).Start();
            //添加极光推送记录
            if (NewType == "6")
            {
                FireControl_WarninsHandleBLL WHandBLL = new FireControl_WarninsHandleBLL();
                //报警推送记录
                List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
                FireControl_WarninsHandle        SecondModel = new FireControl_WarninsHandle();
                SecondModel.Content    = $"报警已推送给{(string.IsNullOrWhiteSpace(UserModel.Name) ? UserModel.Phone : UserModel.Name)}";
                SecondModel.CreateTime = DateTime.Now;
                SecondModel.Deleted    = 0;
                SecondModel.CreatedBy  = "0";
                SecondModel.HandlD     = CommHelper.CreatePKID("hd");
                SecondModel.Hand_Date  = DateTime.Now.AddSeconds(1);
                SecondModel.Title      = $"报警推送";;
                SecondModel.TitleID    = TitleID;
                SecondModel.UserID     = "0"; //初次报警 0代表系统
                SecondModel.Hand_Mode  = 0;
                SecondModel.Hand_Type  = 0;
                InsertModle.Add(SecondModel);
                var ss = WHandBLL.AddAllObj(InsertModle);
                Utility.WriteLog("消息处理:" + ss.ResultContent);
            }
        }
示例#2
0
 /// <summary>
 /// 推送
 /// </summary>
 /// <param name="Phone"></param>
 /// <param name="userName"></param>
 /// <param name="type">类型 1业主打电话 2给互助联系人 </param>
 /// <param name="address"></param>
 /// NewType 消息类型 1 燃起烟感报警 6电气报警
 public static void PublicPush(string Phone, string userName, string type, string address, string DivName, string title, string content, string cucode, string BeUserID = "", string titleID = "", string NewType = "1")
 {//目前推送智慧给自己推送
     if (type == "1")
     {
         FireControl_WarninsHandleBLL WHandBLL = new FireControl_WarninsHandleBLL();
         Utility.WriteLog("极光--1----");
         Dictionary <string, string> dic1 = new Dictionary <string, string>();
         dic1.Add("content", content);
         dic1.Add("title", title);
         dic1.Add("type", NewType);
         dic1.Add("msgid", titleID);
         dic1.Add("cucode", BeUserID);
         dic1.Add("application", "8");
         dic1.Add("platformType", "3");
         dic1.Add("isCustomMsg", "0");
         Utility.WriteLog("极光--1推----" + BeUserID);
         new Task(() =>
         {
             HttpSend.GetByRequest(JGApi, dic1, null, true);
         }).Start();
         if (NewType == "6")
         {
             //报警推送记录
             List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
             FireControl_WarninsHandle        SecondModel = new FireControl_WarninsHandle();
             SecondModel.Content    = $"报警已推送给{(string.IsNullOrWhiteSpace(userName) ? Phone : userName)}";
             SecondModel.CreateTime = DateTime.Now;
             SecondModel.Deleted    = 0;
             SecondModel.CreatedBy  = "0";
             SecondModel.HandlD     = CommHelper.CreatePKID("hd");
             SecondModel.Hand_Date  = DateTime.Now.AddSeconds(1);
             SecondModel.Title      = $"报警推送";;
             SecondModel.TitleID    = titleID;
             SecondModel.UserID     = "0"; //初次报警 0代表系统
             SecondModel.Hand_Mode  = 0;
             SecondModel.Hand_Type  = 0;
             InsertModle.Add(SecondModel);
             var ss = WHandBLL.AddAllObj(InsertModle);
             Utility.WriteLog("消息处理:" + ss.ResultContent);
         }
     }
 }
示例#3
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);
        }
示例#4
0
        public ResponseJson <bool> GetCallThePoliceData([FromBody] sdfsdfsdf jitem)//JObject jObject
        {
            string userIP;
            // HttpRequest Request = HttpContext.Current.Request;
            HttpRequest Request = System.Web.HttpContext.Current.Request; // 如果使用代理,获取真实IP

            if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
            {
                userIP = Request.ServerVariables["REMOTE_ADDR"];
            }
            else
            {
                userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            }
            if (userIP == null || userIP == "")
            {
                userIP = Request.UserHostAddress;
            }

            string userIP1 = HttpContext.Current.Request.UserHostAddress;

            Utility.WriteLog("请求GetCallThePoliceData的访问者ip------------" + userIP + "----------------------------" + userIP1);

            ResponseJson <bool> json   = null;
            ResultDis <bool>    result = null;

            try
            {
                //1.根据设备编号获取设备基本信息(判断该设备是否是我们的设备)
                FireControl_DeviceBLL      dll        = new FireControl_DeviceBLL();
                FireControl_DevBindUserBLL devUserdll = new FireControl_DevBindUserBLL();
                FireControl_WarninsPush    model      = new FireControl_WarninsPush();
                //JToken jitem = "";
                //foreach (var a in jObject.Children())
                //{

                //    //if (string.IsNullOrEmpty(a.Next.n))
                //    //{
                //    //    jitem = a.Value;
                //    //}
                //    //else
                //    //{
                //    //    jitem = a.Key;
                //    //}
                //}
                //Utility.WriteLog(jitem.ToString());

                string  jsons = JsonConvert.SerializeObject(jitem);
                JObject jo    = JObject.Parse(jsons);

                //添加记录
                AddMpArTable(jitem.ToString(), jo["DevNum"].ToString());
                model.SeqNum           = 0;
                model.TitleID          = "";
                model.NewTitle         = "";
                model.NewContent       = "";
                model.PushDate         = DateTime.Now;
                model.DevID            = "";
                model.WarInAdress      = "";
                model.WarIn_Type       = 0;
                model.CreateTime       = DateTime.Now;
                model.CreatedBy        = "";
                model.Deleted          = 0;
                model.PushState        = string.IsNullOrEmpty(jo["PushState"].ToString()) ? "" : jo["PushState"].ToString();
                model.WarninsState     = "1";
                model.WarninsRepresent = string.IsNullOrEmpty(jo["WarninsRepresent"].ToString()) ? "" : jo["WarninsRepresent"].ToString();
                model.WarninsVoltage   = string.IsNullOrEmpty(jo["WarninsVoltage"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsVoltage"].ToString()));
                model.WarninsCurrent   = string.IsNullOrEmpty(jo["WarninsCurrent"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsCurrent"].ToString()));
                model.WarninsTemper    = string.IsNullOrEmpty(jo["WarninsTemper"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsTemper"].ToString()));
                model.WarninsTemper2   = string.IsNullOrEmpty(jo["WarninsTemper2"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsTemper2"].ToString()));
                model.WarninsArc       = string.IsNullOrEmpty(jo["WarninsArc"].ToString()) ? "" : jo["WarninsArc"].ToString();
                model.Warninsleakage   = string.IsNullOrEmpty(jo["Warninsleakage"].ToString()) ? "" : jo["Warninsleakage"].ToString();
                model.DevNum           = string.IsNullOrEmpty(jo["DevNum"].ToString()) ? "" : jo["DevNum"].ToString();
                if (!string.IsNullOrEmpty(model.DevNum))
                {
                    string AddressID  = "";
                    string recordID   = string.Empty;
                    string DevTypeNum = string.Empty;
                    #region 将告警信息插入到数据库
                    ResultDis <FireControl_Device> item = dll.GetDevIDByDevNum(model.DevNum);

                    if (item.ResultData != null && item.ResultCode == ResultCode.Succ)
                    {
                        FireControl_DeviceTypeBLL          _DeviceTypeBLL = new FireControl_DeviceTypeBLL();
                        ResultDis <FireControl_DeviceType> dis            = _DeviceTypeBLL.GetObjByDeviceID(item.ResultData.DevID);
                        if (dis.ResultCode == ResultCode.Succ)
                        {
                            DevTypeNum = dis.ResultData.TypeNum;
                        }
                        if (item.ResultData.ValidDate < DateTime.Now)//过期时间大于当前时间)
                        {
                            Utility.WriteLog("设备已过期,设备编号为:" + model.DevNum);
                            json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                            return(json);
                        }
                        //判断设备是否正在报警
                        FireControl_WarninsPushBLL pushBll = new FireControl_WarninsPushBLL();
                        //  model.DevNum
                        var OldData = pushBll.SelectNotCloseState(item.ResultData.DevID, "1", model.PushState);
                        if (OldData.ResultCode == ResultCode.Succ && !string.IsNullOrWhiteSpace(OldData.ResultData.DevID))
                        {
                            if (item.ResultData.DeviceState == 1)
                            {
                                Utility.WriteLog("设备继续报警:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "继续报警");
                                return(json);
                            }
                            else
                            {
                                item.ResultData.DeviceState = 1;
                                FireControl_DeviceBLL devdlle = new FireControl_DeviceBLL();
                                ResultDis <bool>      dis1    = devdlle.ModObj(item.ResultData);
                                if (dis1.ResultCode == ResultCode.Succ)
                                {
                                    Utility.WriteLog("设备继续报警,但状态刚才是正常----修改状态成功:" + model.DevNum);
                                }
                                Utility.WriteLog("设备继续报警,但状态刚才是正常:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "继续报警");
                                return(json);
                            }
                        }
                        FireControl_FaultSolution_BLL         fabll = new FireControl_FaultSolution_BLL();
                        ResultDis <FireControl_FaultSolution> list  = fabll.GetListByCode(model.PushState);
                        //1.接收故障信息存入数据库
                        model.NewTitle   = list.ResultData.FaultName;
                        model.NewContent = list.ResultData.Causes;
                        model.PushDate   = DateTime.Now;
                        model.DevID      = item.ResultData.DevID;
                        model.TitleID    = CommHelper.CreatePKID("tit");
                        //根据设备ID获取我的设备绑定地址
                        ResultDis <GetDevPeopleUser> usermodel = devUserdll.GetDevPeople(model.DevID);
                        //修改设备状态为报警状态
                        item.ResultData.DeviceState = 1;
                        FireControl_DeviceBLL devdll = new FireControl_DeviceBLL();
                        devdll.ModObj(item.ResultData);

                        if (!string.IsNullOrWhiteSpace(usermodel.ResultData.AddressID))
                        {
                            AddressID = usermodel.ResultData.AddressID;
                            #region 添加处理流程数据
                            FireControl_WarninsHandleBLL clbll  = new FireControl_WarninsHandleBLL();
                            FireControl_WarninsHandle    handle = new FireControl_WarninsHandle();
                            handle.HandlD     = CommHelper.CreatePKID("han");
                            handle.Title      = "电气设备发生报警";
                            handle.Content    = usermodel.ResultData.Address + "的电气设备发生报警";
                            handle.TitleID    = model.TitleID;
                            handle.Hand_Type  = 0;
                            handle.UserID     = usermodel.ResultData.UserID;
                            handle.Hand_Mode  = 0;
                            handle.Hand_Date  = DateTime.Now;
                            handle.CreateTime = DateTime.Now;
                            handle.CreatedBy  = "System";
                            handle.Deleted    = 0;
                            clbll.AddObj(handle);
                            #endregion
                            if (usermodel.ResultData != null)
                            {
                                model.WarInAdress = usermodel.ResultData.Address;
                            }
                            model.WarIn_Type = 1;
                            model.CreateTime = DateTime.Now;
                            model.CreatedBy  = "System";
                            model.Deleted    = 0;
                            model.AddressID  = usermodel.ResultData.AddressID;
                            FireControl_WarninsPushBLL push = new FireControl_WarninsPushBLL();
                            result = push.AddObj(model, out recordID);
                            if (result.ResultCode == ResultCode.Succ)
                            {
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                            }
                            else
                            {
                                Utility.WriteLog("设备报警记录添加失败:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Err, result.ResultContent);
                            }

                            #region 向客户发推送故障消息
                            var PeopleModel = usermodel.ResultData;
                            #region 推送入库
                            FireControl_PushProcess FireControl_PushProcessModel = new FireControl_PushProcess();
                            FireControl_PushProcessModel.CreateTime = DateTime.Now;
                            FireControl_PushProcessModel.DevID      = model.DevID;
                            FireControl_PushProcessModel.DevName    = "电气";
                            FireControl_PushProcessModel.isPush     = 0;
                            FireControl_PushProcessModel.PPID       = CommHelper.CreatePKID("pp");
                            FireControl_PushProcessModel.TitleID    = model.TitleID;
                            FireControl_PushProcessBLL proBll = new FireControl_PushProcessBLL();
                            var proResult = proBll.AddObj(FireControl_PushProcessModel);
                            if (proResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                Utility.WriteLog("消息保存推送成功---------------------xxxxx--------");
                            }
                            else
                            {
                                Utility.WriteLog("保存推送失败-----------------------------");
                            }

                            #endregion
                            #endregion

                            #region 将推送消息添加到推送记录表
                            //添加推送记录表
                            //FireControl_WarninsPUserBLL puBll = new FireControl_WarninsPUserBLL();
                            //var Model = new FireControl_WarninsPUser();
                            //Model.CreatedBy = "0";
                            //Model.CreateTime = DateTime.Now;
                            //Model.Deleted = 0;
                            //Model.PUID = CommHelper.CreatePKID("pu");
                            //Model.TitleID = model.TitleID;// TitleID;
                            //Model.UserID = usermodel.ResultData.UserID;
                            //Model.UserPhone = usermodel.ResultData.Phone;
                            //puBll.AddObj(Model);
                            #endregion

                            #region //同步到设备管理api
                            EMModel eMModel = new EMModel();
                            eMModel.deviceNumber     = model.DevNum;
                            eMModel.deviceTypeNumber = DevTypeNum;
                            eMModel.recordID         = string.IsNullOrEmpty(recordID) ? "1111111111111" : recordID;
                            if (!string.IsNullOrEmpty(AddressID))
                            {
                                eMModel.unitID = EMApi.GetCommunityIDByADID(AddressID);
                            }
                            EMApi.SendEM_Alert(eMModel);
                            #endregion
                        }
                        else
                        {
                            Utility.WriteLog("地址不存在,设备编号为:" + model.DevNum);
                            json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                        }
                    }
                    else
                    {
                        Utility.WriteLog("在获取装备告警信息时,未能在全民消防数据库中查到该设备,设备编号为:" + model.DevNum);
                        json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                    }
                    #endregion
                }
                else
                {
                    Utility.WriteLog("在获取装备告警信息时,未能在全民消防数据库中查到该设备,设备编号为:" + model.DevNum);
                    json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                }
            }
            catch (Exception ex)
            {
                ex.WriteErrLog();
                Utility.WriteLog(ex.Message);
                json = new ResponseJson <bool>(ResponseCode.Err, ex.Message);
                //log.Error("", ex);
            }
            return(json);
        }