public override void Submit_OnClick(object sender, EventArgs e)
        {
            var fileNames = Request.Form["fileNames"];

            if (!string.IsNullOrEmpty(fileNames))
            {
                fileNames = fileNames.Trim('|');
                var builder = new StringBuilder();

                foreach (var fileName in fileNames.Split('|'))
                {
                    var filePath    = PathUtils.GetTemporaryFilesPath(fileName);
                    var wordContent = WordUtils.Parse(SiteId, filePath, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked);
                    wordContent = ContentUtility.TextEditorContentDecode(SiteInfo, wordContent, true);
                    builder.Append(wordContent);
                    FileUtils.DeleteFileIfExists(filePath);
                }
                var script = "parent." + UEditorUtils.GetInsertHtmlScript(_attributeName, builder.ToString());
                LayerUtils.CloseWithoutRefresh(Page, script);
            }
            else
            {
                FailMessage("请选择Word文件上传!");
            }
        }
        public LibraryTextInfo Create()
        {
            var auth = new AuthenticatedRequest();

            if (!auth.IsAdminLoggin ||
                !auth.AdminPermissionsImpl.HasSitePermissions(auth.SiteId,
                                                              ConfigManager.SitePermissions.Library))
            {
                return(Request.Unauthorized <LibraryTextInfo>());
            }

            var library = new LibraryTextInfo
            {
                GroupId = auth.GetQueryInt("groupId")
            };

            var fileName  = auth.HttpRequest["fileName"];
            var fileCount = auth.HttpRequest.Files.Count;

            if (fileCount == 0)
            {
                return(Request.BadRequest <LibraryTextInfo>("请选择有效的文件上传"));
            }

            var file = auth.HttpRequest.Files[0];

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = Path.GetFileName(file.FileName);
            }

            var sExt = PathUtils.GetExtension(fileName);

            if (!StringUtils.EqualsIgnoreCase(sExt, ".doc") && !StringUtils.EqualsIgnoreCase(sExt, ".docx") && !StringUtils.EqualsIgnoreCase(sExt, ".wps"))
            {
                return(Request.BadRequest <LibraryTextInfo>("文件只能是 Word 格式,请选择有效的文件上传!"));
            }

            var libraryFileName      = PathUtils.GetLibraryFileName(fileName);
            var virtualDirectoryPath = PathUtils.GetLibraryVirtualPath(EUploadType.Image, libraryFileName);

            var directoryPath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, virtualDirectoryPath);
            var filePath      = PathUtils.Combine(directoryPath, libraryFileName);

            DirectoryUtils.CreateDirectoryIfNotExists(filePath);
            file.SaveAs(filePath);

            var wordContent = WordUtils.Parse(auth.SiteId, filePath, true, true, true, true, false);

            FileUtils.DeleteFileIfExists(filePath);

            library.Title   = fileName;
            library.Content = wordContent;
            library.Id      = DataProvider.LibraryTextDao.Insert(library);

            return(library);
        }
        public GenericResult <string> Submit([FromBody] SubmitRequest request)
        {
            var req = new AuthenticatedRequest();

            if (!req.IsAdminLoggin ||
                !req.AdminPermissionsImpl.HasSitePermissions(request.SiteId,
                                                             ConfigManager.SitePermissions.Library))
            {
                return(Request.Unauthorized <GenericResult <string> >());
            }

            var site = SiteManager.GetSiteInfo(request.SiteId);

            if (site == null)
            {
                return(Request.BadRequest <GenericResult <string> >("无法确定内容对应的站点"));
            }

            var builder = new StringBuilder();

            foreach (var fileName in request.FileNames)
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    continue;
                }

                var filePath    = PathUtils.GetTemporaryFilesPath(fileName);
                var wordContent = WordUtils.Parse(request.SiteId, filePath, request.IsClearFormat, request.IsFirstLineIndent, request.IsClearFontSize, request.IsClearFontFamily, request.IsClearImages);
                wordContent = ContentUtility.TextEditorContentDecode(site, wordContent, true);
                builder.Append(wordContent);
                FileUtils.DeleteFileIfExists(filePath);
            }

            return(new GenericResult <string>
            {
                Value = builder.ToString()
            });
        }