static void Main(string[] args) { AsposeConvert.AsposeConvertTest(); //OoxmlConvert.OoxmlConvertTest(); //OK //var service = new Service(); //var result = service.GetContentDetailList(new ListModel { Keyword = "中央", ParentId= "83A1C060-5AA7-4BE3-BCE9-0B7CAEA099EB" }); //Log.Info("日志测试2223333--"); //Docx2Html.ConvertToHtml(@"D:\Download\系统统计功能.docx", "Docx to Html"); //OnStart(); Console.WriteLine("------------------------------------------------"); Console.WriteLine("终止服务请按任意键!"); Console.ReadLine(); }
private void UploadContentFile(HttpContext context) { #region 请求参数集 var contentId = Guid.Empty; if (context.Request.Form["ContentId"] != null) { Guid.TryParse(context.Request.Form["ContentId"], out contentId); } if (contentId.Equals(Guid.Empty)) { throw new ArgumentException(MC.Request_Params_InvalidError); } var appCode = context.Request.Form["AppCode"]; if (string.IsNullOrWhiteSpace(appCode)) { throw new ArgumentException(MC.Request_Params_InvalidError); } var userId = WebCommon.GetUserId(); if (userId.Equals(Guid.Empty)) { throw new ArgumentException(MC.L_InvalidError); } var currTime = DateTime.Now; var effect = 0; #endregion HttpFileCollection files = context.Request.Files; if (files.Count > 0) { var ufh = new UploadFilesHelper(); ImagesHelper ih = new ImagesHelper(); foreach (string item in files.AllKeys) { HttpPostedFile file = files[item]; if (file == null || file.ContentLength == 0) { continue; } var ext = Path.GetExtension(file.FileName); FileValidated(file); string originalUrl = ufh.UploadOriginalFile(file, "ContentFiles", currTime); var originalPath = UploadFilesHelper.ToFullPath(originalUrl); var htmlFullPath = string.Empty; if (ext == ".doc" || ext == ".docx") { htmlFullPath = OoxmlConvert.WordToHtml(originalPath, Path.GetFileNameWithoutExtension(file.FileName)); } else if (ext == ".xls" || ext == ".xlsx") { htmlFullPath = AsposeConvert.ExcelToHtml(originalPath, Path.GetFileNameWithoutExtension(file.FileName)); } var cfInfo = new ContentFileInfo(Guid.Empty, appCode.Trim(), userId, contentId, file.FileName, file.ContentLength, VirtualPathUtility.GetExtension(file.FileName).ToLower(), originalUrl.Trim('~'), UploadFilesHelper.ToVirtualPath(htmlFullPath), currTime); var cfBll = new ContentFile(); effect += cfBll.Insert(cfInfo); //if (ufh.IsImage(file)) // CreateThumbnailImage(context, ih, context.Server.MapPath(originalUrl)); } } if (effect > 0) { context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, null)); } else { context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, "")); } }