public override void Run()
 {
     var tempinfo = this.OpenOperator.GetDataBaseTempData<TaskManageErrorSendTaskTempInfo>();
     if (tempinfo == null)
     {
         tempinfo = new TaskManageErrorSendTaskTempInfo();
         tempinfo.LastLogID = 0;
     }
     //扫描
     List<tb_senderror_model> senderrormodels = new List<tb_senderror_model>();
     List<tb_user_model> usermodels = new List<tb_user_model>();
     SqlHelper.ExcuteSql(this.SystemRuntimeInfo.TaskConnectString, (c) =>
     {
         tb_error_dal errordal = new tb_error_dal();
         senderrormodels = errordal.GetErrors(c, tempinfo.LastLogID);
         tb_user_dal userdal = new tb_user_dal();
         usermodels = userdal.GetAllUsers(c);
     });
     foreach (var u in usermodels)
     {
         if (string.IsNullOrEmpty(u.useremail))
             continue;
         if (u.userrole == (int)EnumUserRole.Admin)
             SendEmail(senderrormodels, u.useremail);
         else
             SendEmail(senderrormodels.Where(c => c.taskcreateuserid == u.id).ToList(), u.useremail);
     }
     if (senderrormodels.Count > 0)
     {
         int maxid = senderrormodels.Max(c => c.error_model.id);
         tempinfo.LastLogID = maxid;
         this.OpenOperator.Log(string.Format("本次处理错误日志{0}条", senderrormodels.Count));
     }
     this.OpenOperator.SaveDataBaseTempData(tempinfo);
 }
Пример #2
0
        public override void Run()
        {
            var tempinfo = this.OpenOperator.GetDataBaseTempData <TaskManageErrorSendTaskTempInfo>();

            if (tempinfo == null)
            {
                tempinfo           = new TaskManageErrorSendTaskTempInfo();
                tempinfo.LastLogID = 0;
            }
            //扫描
            List <tb_senderror_model> senderrormodels = new List <tb_senderror_model>();
            List <tb_user_model>      usermodels      = new List <tb_user_model>();

            SqlHelper.ExcuteSql(this.SystemRuntimeInfo.TaskConnectString, (c) =>
            {
                tb_error_dal errordal = new tb_error_dal();
                senderrormodels       = errordal.GetErrors(c, tempinfo.LastLogID);
                tb_user_dal userdal   = new tb_user_dal();
                usermodels            = userdal.GetAllUsers(c);
            });
            foreach (var u in usermodels)
            {
                if (string.IsNullOrEmpty(u.useremail))
                {
                    continue;
                }
                if (u.userrole == (int)EnumUserRole.Admin)
                {
                    SendEmail(senderrormodels, u.useremail);
                }
                else
                {
                    SendEmail(senderrormodels.Where(c => c.taskcreateuserid == u.id).ToList(), u.useremail);
                }
            }
            if (senderrormodels.Count > 0)
            {
                int maxid = senderrormodels.Max(c => c.error_model.id);
                tempinfo.LastLogID = maxid;
                this.OpenOperator.Log(string.Format("本次处理错误日志{0}条", senderrormodels.Count));
            }
            this.OpenOperator.SaveDataBaseTempData(tempinfo);
        }