Пример #1
0
        /// <summary>
        /// 记载其它对象数据
        /// </summary>
        /// <param name="triggers">执行计划数据</param>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        static List <Trigger> LoadOtherObjectData(IEnumerable <Trigger> triggers, IQuery query)
        {
            if (triggers.IsNullOrEmpty() || query == null)
            {
                return(triggers.ToList());
            }

            #region 工作任务

            List <Job> jobList = null;
            if (query.AllowLoad <Trigger>(t => t.Job))
            {
                var jobIds = triggers.Select(c => c.Job?.Id).Distinct().ToList();
                jobList = JobDomainService.GetJobList(jobIds);
            }

            #endregion

            #region 附加条件

            List <TriggerCondition> conditionList = null;
            if (query.AllowLoad <Trigger>(c => c.Condition))
            {
                var triggerIds = triggers.Select(c => c.Id).Distinct().ToList();
                conditionList = TriggerConditionDomainService.GetTriggerConditionList(triggers.ToArray());
            }

            #endregion

            foreach (var trigger in triggers)
            {
                if (!jobList.IsNullOrEmpty())
                {
                    trigger.SetJob(jobList.FirstOrDefault(c => c.Id == trigger.Job?.Id), true);
                }
                if (!conditionList.IsNullOrEmpty())
                {
                    trigger.SetCondition(conditionList.FirstOrDefault(c => c.TriggerId == trigger.Id), true);
                }
            }
            return(triggers.ToList());
        }
Пример #2
0
        /// <summary>
        /// 数据列表加载额外的对象数据
        /// </summary>
        /// <param name="datas">数据信息</param>
        /// <param name="query">查询对象</param>
        static List <ErrorLog> LoadOtherObjectData(IEnumerable <ErrorLog> datas, IQuery query)
        {
            #region 参数判断

            if (datas.IsNullOrEmpty())
            {
                return(new List <ErrorLog>(0));
            }
            if (query == null || query.LoadPropertys == null || query.LoadPropertys.Count <= 0)
            {
                return(datas.ToList());
            }

            #endregion

            #region  务信息

            List <ServerNode> serverList = null;
            if (query.AllowLoad <ErrorLog>(c => c.Server))
            {
                List <string> serverIds = datas.Select(c => c.Server?.Id).Distinct().ToList();
                serverList = ServerNodeDomainService.GetServerNodeList(serverIds);
            }

            #endregion

            #region 工作信息

            List <Job> jobList = null;
            if (query.AllowLoad <ErrorLog>(c => c.Job))
            {
                List <string> jobIds = datas.Select(c => c.Job?.Id).Distinct().ToList();
                jobList = JobDomainService.GetJobList(jobIds);
            }

            #endregion

            #region 执行计划

            List <Trigger> triggerList = null;
            if (query.AllowLoad <ErrorLog>(c => c.Trigger))
            {
                List <string> triggerIds = datas.Select(c => c.Trigger?.Id).Distinct().ToList();
                triggerList = TriggerDomainService.GetTriggerList(triggerIds);
            }

            #endregion

            foreach (var log in datas)
            {
                if (!serverList.IsNullOrEmpty())
                {
                    log.SetServer(serverList.FirstOrDefault(c => c.Id == log.Server?.Id));
                }
                if (!jobList.IsNullOrEmpty())
                {
                    log.SetJob(jobList.FirstOrDefault(c => c.Id == log.Job?.Id));
                }
                if (!triggerList.IsNullOrEmpty())
                {
                    log.SetTrigger(triggerList.FirstOrDefault(c => c.Id == log.Trigger?.Id));
                }
            }
            return(datas.ToList());
        }