コード例 #1
0
        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);
            }));
        }
コード例 #2
0
 private bool IsValidDocPatternName(ABSManagement.Models.Project project, string docPatternName)
 {
     return(GetDocPatternTypes(project).ConvertAll(x => DocumentPattern.GetFileName(x))
            .Any(x => x.Equals(docPatternName, StringComparison.CurrentCultureIgnoreCase)));
 }