ASP.NET MVC 5 实现基于Quartz.net 的任务调度管理平台(三)

标签: asp.net  mvc  任务调度  管理

BLL层类图:

这里写图片描述

TaskBLL.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TaskManager.DAL;
using TaskManager.Models;

namespace TaskManager.BLL
{
    public class TaskBLL
    {
        private readonly TaskDAL dal = new TaskDAL();

        /// <summary>
        /// 获取任务列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PageOf<TaskModel> GetTaskList(int pageIndex, int pageSize)
        {
            return dal.GetTaskList(pageIndex, pageSize);
        }

        /// <summary>
        /// 读取数据库中全部的任务
        /// </summary>
        /// <returns></returns>
        public List<TaskModel> GetAllTaskList()
        {
            return dal.GetAllTaskList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public TaskModel GetById(string taskId)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public bool DeleteById(string taskId)
        {
            return dal.UpdateTaskStatus(taskId, -1);
        }

        /// <summary>
        /// 修改任务
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool UpdateTaskStatus(string taskId, int status)
        {
            return dal.UpdateTaskStatus(taskId, status);
        }

        /// <summary>
        /// 修改任务的下次启动时间
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="nextFireTime"></param>
        /// <returns></returns>
        public bool UpdateNextFireTime(string taskId, DateTime nextFireTime)
        {
            return dal.UpdateNextFireTime(taskId, nextFireTime);
        }

        /// <summary>
        /// 根据任务Id 修改 上次运行时间
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="recentRunTime"></param>
        /// <returns></returns>
        public bool UpdateRecentRunTime(string taskId, DateTime recentRunTime)
        {
            return dal.UpdateRecentRunTime(taskId, recentRunTime);
        }

        /// <summary>
        /// 根据任务Id 获取任务
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public TaskModel GetTaskById(string taskId)
        {
            return dal.GetTaskById(taskId);
        }

        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public bool Add(TaskModel task)
        {
            return dal.Add(task);
        }

        /// <summary>
        /// 修改任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public bool Edit(TaskModel task)
        {
            return dal.Edit(task);
        }
    }
}

UserBLL.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaskManager.DAL;
using TaskManager.Models;

namespace TaskManager.BLL
{
    public class UserBLL
    {
        private UserDAL dal = new UserDAL();

        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PageOf<UserModel> GetUserList(int pageNo, int pageSize)
        {
            return dal.GetUserList(pageNo, pageSize);
        }

        /// <summary>
        /// 根据用户名和密码获取管理员用户信息
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public UserModel GetUserModel(string userName, string pwd)
        {
            return dal.GetUserModel(userName, pwd);
        }
    }
}

LogBLL.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TaskManager.DAL;
using TaskManager.Models;

namespace TaskManager.BLL
{
    public class LogBLL
    {
        private readonly LogDAL dal = new LogDAL();

        /// <summary>
        /// 记录运行日志
        /// </summary>
        /// <param name="taskName"></param>
        /// <param name="taskId"></param>
        /// <param name="result"></param>
        public void WriteRunInfo(string taskName, string taskId, string result)
        {
            dal.WriteRunInfo(taskName, taskId, result);
        }

        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="sLevel"></param>
        /// <param name="sMessage"></param>
        /// <param name="sException"></param>
        /// <param name="sName"></param>
        public void WriteErrorInfo(string sLevel, string sMessage, string sException, string sName)
        {
            dal.WriteErrorInfo(sLevel,sMessage, sException, sName);
        }

        /// <summary>
        /// 读取错误日志列表
        /// </summary>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PageOf<ErrorLogModel> GetErrorLogList(int pageNo, int pageSize)
        {
            return dal.GetErrorLogList(pageNo, pageSize);
        }

        /// <summary>
        /// 读取运行日志列表
        /// </summary>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PageOf<RunLogModel> GetRunLogList(int pageNo, int pageSize)
        {
            return dal.GetRunLogList(pageNo, pageSize);
        }
    }
}
版权声明:本文为WuLex原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/WuLex/article/details/74069543