Esempio n. 1
0
        /// <summary>
        /// 获取已通知的人员信息
        /// </summary>
        /// <param name="LogId"></param>
        /// <returns></returns>
        public List <ErrorLogPerson> GetErrorLogPersonList(int LogId)
        {
            List <ErrorLogPerson>   list    = new List <ErrorLogPerson>();
            List <error_log_person> logList = errorLogPersonManager.GetErrorLogPersonByLogId(LogId);

            foreach (var item in logList)
            {
                person p = personManager.SelectSingleByID(item.person_id);
                if (p != null)
                {
                    ErrorLogPerson LogPersonObj = new ErrorLogPerson();
                    LogPersonObj.eLogPerson = item;
                    LogPersonObj.ePerson    = p;
                    list.Add(LogPersonObj);
                }
            }
            return(list);
        }
        /// <summary>
        /// 获取发送通知的人员列表
        /// </summary>
        /// <param name="errorObject">异常对象</param>
        /// <param name="Level">等级</param>
        /// <param name="EventFlow">事件流程点</param>
        /// <param name="FinishedMode">完成模式</param>
        /// <returns></returns>
        public List <person> GetMsgedPersonList(ErrorObject errorObject, int Level, EventHandleFlowEnum EventFlow,
                                                bool FinishedMode = false)
        {
            List <person>         persons  = new List <person>();
            List <string>         infoList = new List <string>();
            List <ErrorCfgPerson> ePersons = new List <ErrorCfgPerson>();
            string classNo = classInfoManager.GetCurrentClassNo();//当前班次

            if (FinishedMode == false)
            {
                if (EventFlow == EventHandleFlowEnum.Event_Timeout)//超时加载人员为当前级别以及向下一级
                {
                    ePersons = errorObject.eCfgPersonList.Where(x => (x.eCfgPerson.person_level == Level || x.eCfgPerson.person_level == (Level - 1)) &&
                                                                x.eCfgPerson.class_no.Equals(classNo)).ToList();//获取多级配置人员列表
                }
                else
                {
                    if (errorObject.eConfig.message_multilevel == 1 && Level < (int)MessageLevel.Level3)//多级人员发送模式
                    {
                        ePersons = errorObject.eCfgPersonList.Where(x => (x.eCfgPerson.person_level == Level || x.eCfgPerson.person_level == Level + 1) &&
                                                                    x.eCfgPerson.class_no.Equals(classNo)).ToList();//获取多级配置人员列表
                    }
                    else
                    {
                        ePersons = errorObject.eCfgPersonList.Where(x => x.eCfgPerson.person_level == Level &&
                                                                    x.eCfgPerson.class_no.Equals(classNo)).ToList();     //获取当前级别配置人员列表
                    }
                }

                foreach (var item in ePersons)
                {
                    if (item.ePerson != null)
                    {
                        //判断此人员是否已经通知过,通知过则去除不重复通知
                        if (errorObject.eMsgedPersonList.Any(x => x.eLogPerson.error_log_id == errorObject.ELog.id &&
                                                             x.eLogPerson.person_id == item.ePerson.id &&
                                                             x.eLogPerson.message_flow == EventFlow.ToString() &&
                                                             x.eLogPerson.message_level == item.eCfgPerson.person_level) == false)
                        {
                            persons.Add(item.ePerson);
                            ErrorLogPerson eLogPersonObject = new ErrorLogPerson();
                            //记录已通知人员
                            error_log_person ePerson = errorLogPersonManager.InsertMessagePerson(errorObject.ELog.id, item.ePerson.id, item.eCfgPerson.person_level, EventFlow);
                            eLogPersonObject.ePerson    = item.ePerson;
                            eLogPersonObject.eLogPerson = ePerson;
                            errorObject.eMsgedPersonList.Add(eLogPersonObject);
                        }
                    }
                }
            }
            else
            {
                //结束模式需去除已经为事件确认标识的人员
                foreach (var item in errorObject.eMsgedPersonList.Where(x => x.eLogPerson.message_flow != EventFlow.ToString())) //为结束模式,则取出已通知的人员
                {
                    if (!persons.Any(x => x.id == item.ePerson.id))                                                              //去除重复项
                    {
                        errorLogPersonManager.InsertMessagePerson(errorObject.ELog.id, item.ePerson.id, item.eLogPerson.message_level, EventFlow);
                        persons.Add(item.ePerson);
                    }
                }
            }
            return(persons);
        }