/// <summary>
        /// 组装MessageQueue数据 风电机组故障告警 WeChat
        /// </summary>
        public int BuilderMessageData_WeChatAlarmCrew(E故障事件历史库 alarm, VAlarmLevelUser user)
        {
            int resultId = 0;

            try
            {
                EMessageQueue mQueue = new EMessageQueue();

                mQueue.AlarmLevel     = alarm.等级;
                mQueue.CreateTime     = DateTime.Now;
                mQueue.MessageContent = BuilderSMSAlarmCrew(alarm).ToJson();
                mQueue.Status         = (int)eSendStatus.WaitSend;//等待发送
                mQueue.OpenId         = user.OpenId;
                mQueue.MessageType    = (int)eMessageType.WeChat;
                mQueue.Mobile         = user.Mobile;
                mQueue.AlarmType      = (int)eAlarmType.CrewAlarm;
                mQueue.FaultCount     = 0;
                mQueue.UserID         = user.UserID;
                mQueue.MessageData    = alarm.ToJson();

                resultId = JobDbAssist.Instance.InsertMessageQueue(mQueue);
            }
            catch (Exception ex)
            {
                Log.WriteFormat("C-【BuilderMessageData_WeChatAlarmCrew】Job异常:{0}", ex.Message);
                JobDispatch.UIDispalyTask("【风电机组故障告警Builder异常】JobDataBuilder.BuilderMessageData_WeChatAlarmCrew", ex.Message, (int)eJobStatus.Exception);
            }
            return(resultId);
        }
Beispiel #2
0
        public void Execute(IJobExecutionContext context)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    //获取所有待发送短信报警
                    var listSms = JobDbAssist.Instance.GetWaitSendMessageQueue((int)eMessageType.SMS);

                    if (listSms.Count() == 0)//Job新报警空闲时(暂无新告警)
                    {
                        //重发之前发送异常的数据
                        listSms = JobDbAssist.Instance.GetWaitAgainSendMessageQueue((int)eMessageType.SMS);
                    }

                    if (listSms.Count() > 0)
                    {
                        //更新短信发送数量
                        JobDispatch.UISMSCount?.Invoke(listSms.Count());

                        foreach (VMessageQueye item in listSms)
                        {
                            //设置状态为发送中
                            JobDbAssist.Instance.SetSMSMessageQueueStatus(item.ID, (int)eSendStatus.Sending);

                            //需要短信模板转换-> [发送]
                            string resultMsgJson = new SMSSender().Sender(item.Mobile, item.MessageContent);

                            EResultMessage resultMsg = resultMsgJson.ToObject <EResultMessage>();

                            //反馈码
                            string resultMsgCode = resultMsg.Code.ToLower();

                            //根据反馈消息设置MessageQueye 反馈字段ResultMessage  和 Send 状态
                            JobDbAssist.Instance.SetSMSResultSendMessageQueue(item.ID, resultMsgJson, resultMsgCode == "ok");

                            if (resultMsgCode == "ok")
                            {
                                JobDispatch.UISMSCount?.Invoke(1);
                                JobDispatch.UIDispalyTask("{0} 【短信发送】".Format(context.JobDetail.Key.Name), "发送成功", (int)eJobStatus.OK);
                            }
                            else
                            {
                                JobDispatch.UIDispalyTask("{0} 【短信发送】".Format(context.JobDetail.Key.Name), "发送失败", (int)eJobStatus.Fault);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteFormat("A-【SMSSendJob 短信发送异常】Job异常:{0}", ex.Message);
                    JobDispatch.UIDispalyTask("{0} 【短信发送异常】".Format(context.JobDetail.Key.Name), ex.Message, (int)eJobStatus.Exception);
                }
            });
        }
Beispiel #3
0
 public void Execute(IJobExecutionContext context)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             //获取所有待推送微信报警
             var listSms = JobDbAssist.Instance.GetWaitSendMessageQueue((int)eMessageType.WeChat);
         }
         catch (Exception ex)
         {
             Log.WriteFormat("A-【WXSendJob 企业微信推送异常】Job异常:{0}", ex.Message);
             JobDispatch.UIDispalyTask("{0} 【微信推送异常】".Format(context.JobDetail.Key.Name), ex.Message, (int)eJobStatus.Exception);
         }
     });
 }
Beispiel #4
0
        public void Execute(IJobExecutionContext context)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    //一次Job的告警数量
                    var listVarBitAlarm = JobDbAssist.Instance.GetNewAlarmVariableBit();

                    if (listVarBitAlarm.Count() > 0)
                    {
                        JobDbAssist.Instance.VBitAlarmLastTime = DateTime.Now;

                        //更新变位告警数量
                        JobDispatch.UIVBitCount?.Invoke(listVarBitAlarm.Count());

                        foreach (E遥信变位事件历史库 item in listVarBitAlarm)
                        {
                            //按等级获取不同用户【发送到对应等级用户】,插入到MessageQueue
                            var alarmLeveUsers = JobDbAssist.Instance.GetUserInfoByLevel(item.等级, (int)eAlarmType.VariableBitAlarm); //等级用户

                            foreach (VAlarmLevelUser itemUser in alarmLeveUsers)                                                     //几个用户几行报警
                            {
                                JobDataBuilder.Instance.BuilderMessageData_SMSAlarmVariableBit(item, itemUser);                      //短信报警
                                JobDataBuilder.Instance.BuilderMessageData_WeChatAlarmVariableBit(item, itemUser);                   //微信报警
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteFormat("D-【AlarmVariableBitJob】Job异常:{0}", ex.Message);
                    JobDispatch.UIDispalyTask("{0} 【获取变位告警Job异常】".Format(context.JobDetail.Key.Name), ex.Message, 2);
                    //throw;
                }
            });
        }
Beispiel #5
0
        public void Execute(IJobExecutionContext context)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    //一次Job的告警数量
                    var listStartAlarm = JobDbAssist.Instance.GetNewStartAlarmCrewLevel();   //故障开始报警时间

                    if (listStartAlarm.Count() > 0)
                    {
                        JobDbAssist.Instance.CrewLastStartTime = DateTime.Now;//最后报警开始时间更新为当前时间

                        //更新告警数量
                        JobDispatch.UIFaultAlarmCount?.Invoke(listStartAlarm.Count());

                        foreach (E故障事件历史库 item in listStartAlarm)
                        {
                            //更新UI告警
                            JobDispatch.UIExeAlarmData?.Invoke(item.ToAmarlData());

                            //按等级获取不同用户,插入到MessageQueue
                            var alarmLeveUsers = JobDbAssist.Instance.GetUserInfoByLevel(item.等级, (int)eAlarmType.CrewAlarm); //等级用户

                            foreach (VAlarmLevelUser itemUser in alarmLeveUsers)                                              //几个用户几行报警
                            {
                                JobDataBuilder.Instance.BuilderMessageData_SMSAlarmCrew(item, itemUser);                      //短信报警
                                JobDataBuilder.Instance.BuilderMessageData_WeChatAlarmCrew(item, itemUser);                   //微信报警
                            }
                        }
                    }

                    //一次Job的告警数量
                    var listEndAlarm = JobDbAssist.Instance.GetNewEndAlarmCrewLevel();   //故障结束报警时间

                    if (listEndAlarm.Count() > 0)
                    {
                        JobDbAssist.Instance.CrewLastEndTime = DateTime.Now;//最后报警结束时间更新为当前时间

                        //更新告警数量
                        JobDispatch.UIFaultAlarmCount?.Invoke(listEndAlarm.Count());

                        foreach (E故障事件历史库 item in listEndAlarm)
                        {
                            //更新UI告警
                            JobDispatch.UIExeAlarmData?.Invoke(item.ToAmarlData());

                            //按等级获取不同用户【发送到对应等级用户】,插入到MessageQueue
                            var alarmLeveUsers = JobDbAssist.Instance.GetUserInfoByLevel(item.等级, (int)eAlarmType.CrewAlarm); //等级用户

                            foreach (VAlarmLevelUser itemUser in alarmLeveUsers)                                              //几个用户几行报警
                            {
                                JobDataBuilder.Instance.BuilderMessageData_SMSAlarmCrew(item, itemUser);                      //短信报警
                                JobDataBuilder.Instance.BuilderMessageData_WeChatAlarmCrew(item, itemUser);                   //微信报警
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteFormat("A-【AlarmCrewJob】Job异常:{0}", ex.Message);
                    JobDispatch.UIDispalyTask("{0} 【获取故障告警Job异常】".Format(context.JobDetail.Key.Name), ex.Message, 2);
                    //throw ex;
                }
            });
        }