public ActionResult GetTemplate(string projectGuid) { return(ActionUtils.Json(() => { CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空"); var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds(); var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid); CommUtils.Assert(authoritiedProjectIds.Any(x => x == project.ProjectId), "用户[{0}]没有上传文件模板到产品[{1}]的权限", CurrentUserName, project.Name); var docPatternTypes = GetDocPatternTypes(project); var result = docPatternTypes.ConvertAll(x => { var path = DocumentPattern.GetPath(project, x); var fileName = DocumentPattern.GetFileName(x); var exist = System.IO.File.Exists(path); return new { templateFileName = fileName.Remove(fileName.LastIndexOf(".")), docPatternType = x.ToString(), status = exist ? "Exist" : "NotExist", createTime = exist ? System.IO.File.GetCreationTime(path).ToString("yyyy-MM-dd HH:mm") : "", }; }); return ActionUtils.Success(result); })); }
public ActionResult DownloadTemplateTimeFile(string templateGuid) { string err = "未知的错误"; try { if (string.IsNullOrEmpty(templateGuid)) { return(RedirectToAction("CreateProjet", "MyProjects")); } var template = m_dbAdapter.Template.GetTemplate(templateGuid); var timeLists = m_dbAdapter.Template.GetTemplateTimeLists(templateGuid); TemplateTimePattern patternObj = new TemplateTimePattern(); patternObj.TemplateTimeList = timeLists.ConvertAll(x => new TemplateTimeItem { TemplateName = template.TemplateName, TemplateTimeName = x.TemplateTimeName, BeginTime = x.BeginTime, EndTime = x.EndTime, TimeSpan = x.TimeSpan, TimeSpanUnit = x.TimeSpanUnit, TemplateTimeType = x.TemplateTimeType, SearchDirection = x.SearchDirection, HandleReduplicate = x.HandleReduplicate }).ToList(); var excelPattern = new ExcelPattern(); var patternFilePath = DocumentPattern.GetPath(DocPatternType.TemplateTime); MemoryStream ms = new MemoryStream(); if (!excelPattern.Generate(patternFilePath, patternObj, ms)) { throw new ApplicationException("Generate file failed."); } string fileFullName = template.TemplateName + "_时间模板" + ".xlsx"; string mimeType = "application/xlsx"; ms.Seek(0, SeekOrigin.Begin); return(File(ms, mimeType, fileFullName)); } catch (ApplicationException ae) { err = ae.Message; return(RedirectToAction("NotFound", "Error")); } catch (Exception e) { err = "服务器错误:" + e.Message; return(RedirectToAction("NotFound", "Error")); } }
protected override string GetPatternFilePath() { return(DocumentPattern.GetPath(m_project, DocPatternType.IncomeDistributionReport)); }
protected override string GetPatternFilePath() { return DocumentPattern.GetPath(m_project, DocPatternType.CashInterestRateConfirmForm); }
protected override string GetPatternFilePath() { return(DocumentPattern.GetPath(m_project, DocPatternType.DemoJianYuanReport)); }
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()); })); }
public ActionResult DownloadTemplateTaskFile(string templateGuid) { string err = "未知的错误"; try { if (string.IsNullOrEmpty(templateGuid)) { return(RedirectToAction("CreateProjet", "MyProjects")); } var template = m_dbAdapter.Template.GetTemplate(templateGuid); var templateTasks = m_dbAdapter.Template.GetTemplateTasks(templateGuid); //使用1 2 3~N替代掉TemplateTaskId var templateTaskIdDict = new Dictionary <int, int>(); var templateTaskId = 1; templateTasks.ForEach(x => { templateTaskIdDict[x.TemplateTaskId] = templateTaskId; x.TemplateTaskId = templateTaskId; ++templateTaskId; }); //CommUtils.Assert(tasks.Count == 0,"当前模板"); TemplateTaskPattern patternObj = new TemplateTaskPattern(); patternObj.TemplateTaskList = templateTasks.ConvertAll(x => new TemplateTaskItem { TemplateName = template.TemplateName, TemplateTaskId = x.TemplateTaskId, TemplateTaskName = x.TemplateTaskName, BeginTime = x.BeginDate, EndTime = x.TriggerDate, PrevTemplateTaskIds = string.Join("|", x.PrevIds.Where(prevId => templateTaskIdDict.ContainsKey(prevId)).ToList() .ConvertAll(prevId => templateTaskIdDict[prevId].ToString()).ToArray()), TemplateTaskDetail = x.TemplateTaskDetail, TemplateTaskTarget = x.TemplateTaskTarget, TemplateTaskExtensionName = (x.TemplateTaskExtensionName == null ? "" : x.TemplateTaskExtensionName) }).ToList(); var excelPattern = new ExcelPattern(); var patternFilePath = DocumentPattern.GetPath(DocPatternType.TemplateTask); MemoryStream ms = new MemoryStream(); if (!excelPattern.Generate(patternFilePath, patternObj, ms)) { throw new ApplicationException("Generate file failed."); } string fileFullName = template.TemplateName + ".xlsx"; string mimeType = "application/xlsx"; ms.Seek(0, SeekOrigin.Begin); return(File(ms, mimeType, fileFullName)); } catch (ApplicationException ae) { err = ae.Message; return(RedirectToAction("NotFound", "Error")); } catch (Exception e) { err = "服务器错误:" + e.Message; return(RedirectToAction("NotFound", "Error")); } }
protected override string GetPatternFilePath() { return(DocumentPattern.GetPath(m_project, DocPatternType.InterestPaymentPlanApplication)); }
protected override string GetPatternFilePath() { return(DocumentPattern.GetPath(m_project, DocPatternType.SpecialPlanTransferInstruction)); }