예제 #1
0
        public JsonResult Index(LoadTaskListRequest request)
        {
            ViewBag.NodeId = request.NodeId.ToString();
            ViewBag.TaskCreateTimeRange = request.TaskCreateTimeRange.ToString();
            ViewBag.TaskName            = request.TaskName == null?"":request.TaskName.ToString();
            ViewBag.TaskExecuteStatus   = request.TaskExecuteStatus.ToString();
            ViewBag.TaskSchduleStatus   = request.TaskSchduleStatus.ToString();
            ViewBag.TaskId              = request.TaskId.ToString();
            ViewBag.TaskType            = request.TaskType.ToString();
            request.TaskCreateTimeRange = request.TaskId <= 0 ? request.TaskCreateTimeRange : "1900-01-01/2099-12-30";

            ResponseBase <PageInfoResponse <List <TaskListDto> > > tasklist = PostToServer <PageInfoResponse <List <TaskListDto> >, LoadTaskListRequest>(ClientProxy.LoadTaskList_Url, request);

            if (tasklist.Status != ResponesStatus.Success)
            {
                return(Json(new
                {
                    sEcho = 0,
                    iTotalRecords = 0,
                    iTotalDisplayRecords = 0,
                    aaData = new List <string>()
                }));
            }
            return(Json(tasklist.Data));
        }
예제 #2
0
        public List <TaskListDto> LoadTaskPageList(out int totalCount, LoadTaskListRequest req, System.Linq.Expressions.Expression <Func <tb_task, string> > orderby = null)
        {
            DateTime starttime = Convert.ToDateTime(req.TaskCreateTimeRange.Split('/')[0]);
            DateTime endtime   = Convert.ToDateTime(req.TaskCreateTimeRange.Split('/')[1]).AddDays(1);
            int      pageIndex = (req.iDisplayStart / req.iDisplayLength) + 1;

            totalCount = 0;
            var table2 = (
                from c in Context.tb_task
                join p in Context.tb_taskversion
                on c.id equals p.taskid
                where c.createtime >= starttime && c.createtime < endtime &&
                c.taskschedulestatus == (req.TaskSchduleStatus < 0 ? c.taskschedulestatus : req.TaskSchduleStatus)
                // && c.taskname.Contains(string.IsNullOrEmpty(req.TaskName) ? c.taskname:req.TaskName)
                && p.nodeid == (req.NodeId <= 0 ? p.nodeid : req.NodeId) &&
                p.taskrunstatus == (req.TaskExecuteStatus < 0 ? p.taskrunstatus : req.TaskExecuteStatus) &&
                c.id == (req.TaskId <= 0 ?c.id:req.TaskId) &&
                c.createby == (req.CreateBy <= 0 ?c.createby:req.CreateBy) &&
                c.alarmtype == (req.AlarmType < 0?c.alarmtype:req.AlarmType) &&
                c.tasktype == (req.TaskType < 0?c.tasktype:req.TaskType)
                select new TaskListDto()
            {
                Task = c,
                TaskVersion = p
            }
                );

            if (orderby == null)
            {
                table2 = table2.OrderByDescending(x => x.Task.id);
            }
            else
            {
                table2 = table2.OrderByDescending(x => orderby);
            }

            List <TaskListDto> table = table2.ToList();

            totalCount = table.Count();
            List <TaskListDto> tasklist = table.Skip(req.iDisplayLength * (pageIndex - 1)).Take(req.iDisplayLength).ToList();

            tasklist.ForEach(x =>
            {
                x.TaskVersion.zipfile = null;
                x.Node = Context.tb_node.FirstOrDefault(m => m.id == x.TaskVersion.nodeid);
            });
            return(tasklist);
        }
        public ResponseBase <PageInfoResponse <List <TaskListDto> > > LoadTaskList(LoadTaskListRequest req)
        {
            #region old code
            //DateTime starttime = Convert.ToDateTime(req.TaskCreateTimeRange.Split('/')[0]);
            //DateTime endtime = Convert.ToDateTime(req.TaskCreateTimeRange.Split('/')[1]).AddDays(1);
            //int pageIndex = (req.iDisplayStart / req.iDisplayLength) + 1;
            //int totalCount = 0;
            //List<int> taskidlist = taskrep.Find(out totalCount, pageIndex, req.iDisplayLength, "id",
            //    x => x.taskschedulestatus == (req.TaskSchduleStatus < 0 ? x.taskschedulestatus : req.TaskSchduleStatus)
            //        && x.taskname.Contains(string.IsNullOrEmpty(req.TaskName) ? x.taskname : req.TaskName)
            //    ).Select(x => x.id).ToList();
            //var taskversionlist = taskversionrep.Find(x =>
            //                                x.nodeid == (req.NodeId <= 0 ? x.nodeid : req.NodeId)
            //                                && taskidlist.Contains(x.taskid)
            //                                && x.taskrunstatus == (req.TaskExecuteStatus < 0 ? x.taskrunstatus : req.TaskExecuteStatus)
            //    );

            //if (taskidlist.Count <= 0)
            //{
            //    return ResponseToClient<LoadTaskListResponse>(ResponesStatus.Failed, "任务列表为空");
            //}
            //List<TaskListDto> TaskList = new List<TaskListDto>();
            //taskidlist.ForEach(x =>
            //{
            //    var taskversion = taskversionlist.FirstOrDefault(m => m.taskid == x);
            //    TaskList.Add(new TaskListDto()
            //    {
            //        Task = taskrep.FindSingle(m => m.id == x),
            //        TaskVersion = taskversion,
            //        Node = noderepository.FindSingle(m => m.id == taskversion.nodeid)
            //    });
            //});
            //return ResponseToClient<LoadTaskListResponse>(ResponesStatus.Success, "", new LoadTaskListResponse() { TaskList = TaskList });
            #endregion
            int totalCount = 0;
            List <TaskListDto> TaskList = taskrep.LoadTaskPageList(out totalCount, req);
            if (TaskList.Count <= 0)
            {
                return(ResponseToClient <PageInfoResponse <List <TaskListDto> > >(ResponesStatus.Failed, ""));
            }
            return(ResponseToClient <PageInfoResponse <List <TaskListDto> > >(ResponesStatus.Success, "", new PageInfoResponse <List <TaskListDto> >()
            {
                aaData = TaskList, sEcho = req.sEcho, iTotalDisplayRecords = totalCount, iTotalRecords = totalCount
            }));
        }