public ActionResult DownloadTemplate(string projectGuid, string templateFileName)
        {
            CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空");
            CommUtils.AssertHasContent(templateFileName, "templateFileName不能为空");

            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);

            templateFileName += ".docx";
            string sourcePath = Path.Combine(DocumentPattern.GetFolder(project), templateFileName);

            return(File(sourcePath, "application/octet-stream", templateFileName));
        }
        public ActionResult UploadTemplate(string projectGuid, string templateFileName)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(Request.Files.Count > 0, "请选择文件");

                var file = Request.Files[0];
                CommUtils.Assert(file.ContentLength > 0, "文件内容不能为空");

                CommUtils.AssertHasContent(projectGuid, "projectGuid不能为空");
                CommUtils.AssertHasContent(templateFileName, "templateFileName不能为空");

                //   var authoritiedProjectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds(AuthorityType.ModifyTask);
                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);

                templateFileName += ".docx";
                CommUtils.Assert(file.FileName.EndsWith(".docx", StringComparison.CurrentCultureIgnoreCase),
                                 "文件[{0}]格式错误,请选择.docx格式的文件", file.FileName);

                CommUtils.Assert(!CommUtils.IsWPS(file.InputStream), "不支持wps编辑过的.docx格式文件,仅支持office编辑的.docx文件");
                CommUtils.Assert(IsValidDocPatternName(project, templateFileName), "上传参数有误:templateFileName={0}", templateFileName);

                string sourcePath = Path.Combine(DocumentPattern.GetFolder(project), templateFileName);
                string backupPath = Path.Combine(DocumentPattern.GetFolder(project), "backup");
                if (!Directory.Exists(backupPath))
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(backupPath);
                    directoryInfo.Create();
                }

                string backupFilePath = Path.Combine(backupPath, templateFileName);

                if (System.IO.File.Exists(sourcePath))
                {
                    backupFilePath = FileUtils.InsertTimeStamp(backupFilePath);
                    System.IO.File.Copy(sourcePath, backupFilePath, true);
                }

                file.SaveAs(sourcePath);

                return ActionUtils.Success(1);
            }));
        }