Пример #1
0
 public static RetargetUSM Retarget(TaskPattern state, params string[] targets) => Retarget(new ReflectableLASM(state), targets);
Пример #2
0
 public ReflectableLASM(TaskPattern func)
 {
     this.func = func;
 }
Пример #3
0
        public ActionResult ExportTasks(string projectGuid, string paymentDay, string timeRange,
                                        string taskStatusList)
        {
            return(ActionUtils.Json(() =>
            {
                var projectId = -1;
                var authorizedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds();
                var projects = m_dbAdapter.Project.GetProjects(authorizedProjectIds);
                var dictProjects = projects.ToDictionary(x => x.ProjectId);
                var upperLimitDate = DateTime.Parse("9999-12-31");
                var lowerLimitDate = DateTime.Parse("1753-01-02");

                if (!string.IsNullOrWhiteSpace(projectGuid))
                {
                    var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                    projectId = project.ProjectId;

                    CommUtils.Assert(authorizedProjectIds.Contains(projectId), "当前用户没有读取产品[{0}]偿付期列表的权限", project.Name);
                    if (!string.IsNullOrWhiteSpace(paymentDay))
                    {
                        GetLimitDates(projectGuid, paymentDay, ref upperLimitDate, ref lowerLimitDate);
                    }
                }

                var taskStatusValues = new List <TaskStatus>();
                if (taskStatusList != null)
                {
                    taskStatusValues = CommUtils.ParseEnumList <TaskStatus>(taskStatusList);
                }
                else
                {
                    taskStatusValues = new List <TaskStatus>()
                    {
                        TaskStatus.Waitting,
                        TaskStatus.Running,
                        TaskStatus.Finished,
                        TaskStatus.Skipped,
                        TaskStatus.Overdue,
                        TaskStatus.Error
                    };
                }

                DateTime?endTime = null;
                if (!string.IsNullOrWhiteSpace(timeRange))
                {
                    var enumTime = CommUtils.ParseEnum <TaskFilterTime>(timeRange);
                    if (enumTime != TaskFilterTime.All)
                    {
                        endTime = ParseFilterTime(enumTime);
                    }
                }

                var tasks = m_dbAdapter.Task.GetTasks(1, 1000000, endTime, projectId,
                                                      taskStatusValues, authorizedProjectIds, Toolkit.DateToString(upperLimitDate),
                                                      Toolkit.DateToString(lowerLimitDate), paymentDay ?? "1753-01-02");

                TaskPattern patternObj = new TaskPattern();

                patternObj.Tasks = tasks.Items.ConvertAll(x => new TaskItem
                {
                    ProjectName = dictProjects[x.ProjectId].Name,
                    TaskName = x.Description,
                    BeginTime = Toolkit.DateToString(x.StartTime),
                    EndTime = Toolkit.DateToString(x.EndTime),
                    TaskDetail = x.TaskDetail,
                    TaskTarget = x.TaskTarget,
                    TaskExtensionName = (x.TaskExtension != null &&
                                         !string.IsNullOrWhiteSpace(x.TaskExtension.TaskExtensionName)
                        ? x.TaskExtension.TaskExtensionName : string.Empty)
                }).ToList();

                var excelPattern = new ExcelPattern();
                string patternFilePath = DocumentPattern.GetPath(DocPatternType.TaskList);

                MemoryStream ms = new MemoryStream();
                if (!excelPattern.Generate(patternFilePath, patternObj, ms))
                {
                    CommUtils.Assert(false, "Generate file failed.");
                }
                ms.Seek(0, SeekOrigin.Begin);

                string fileFullName = projectId == -1 ? "工作列表.xlsx"
                    : dictProjects[projectId].Name + "_工作列表.xlsx";
                var resource = ResourcePool.RegisterMemoryStream(CurrentUserName, fileFullName, ms);
                return ActionUtils.Success(resource.Guid.ToString());
            }));
        }