浏览代码

word 导入

CrazyIter 5 年之前
父节点
当前提交
844842f2ee

+ 1 - 1
TEAMModelOS.SDK/Module/OpenXmlTool/WmlToHtmlConverter.cs

@@ -578,7 +578,7 @@ namespace OpenXmlPowerTools
         {
            
             XslCompiledTransform xslTransform = new XslCompiledTransform();
-            xslTransform.Load(BaseConfigModel.ContentRootPath + "/XslFiles/OMML2MML.XSL");
+            xslTransform.Load(BaseConfigModel.ContentRootPath + "/JsonFile/Core/OMML2MML.XSL");
             string mathXml = element.ToString();
             string officeML = string.Empty;
             using (TextReader tr = new StringReader(mathXml))

+ 18 - 27
TEAMModelOS.Service/Services/Evaluation/Implements/ImportExerciseService.cs

@@ -30,17 +30,8 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
 {
     public class ImportExerciseService : IImportExerciseService
     {
-        private static string SummaryTag = "【题文】";
-        private static string AnswerTag = "【答案】";
-        private static string AnalysisTag = "【解析】";
-        private static string EndedTag = "【结束】";
-        private static string Options = "ABCDEFGHIJ";
-        private static string CompleteStart = "【";
-        private static string CompleteEnd = "】";
-        Dictionary<string, string> TestType = new Dictionary<string, string> {
-            { "Single", "单选题|多选题" }, { "Multiple", "多选题|判断题" },
-            { "Judge", "判断题|填空题" }, { "Complete", "填空题|主观题" },
-            { "Subjective", "主观题|【完结】" } };
+      
+       
         private readonly IAzureBlobDBRepository azureBlobDBRepository;
         private readonly IAzureTableDBRepository azureTableDBRepository;
         public ImportExerciseService(IAzureBlobDBRepository _azureBlobDBRepository, IAzureTableDBRepository _azureTableDBRepository)
@@ -64,27 +55,27 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
             //    return resdict;
             //}
 
-            string folder = BaseConfigModel.ContentRootPath + "/Upload/" + IdWorker.getInstance().NextId();
-            System.IO.Directory.CreateDirectory(folder);
-            var filePath = folder + "\\" + file.FileName;
-            using (var stream = new FileStream(filePath, FileMode.Create))
-            {
-                await file.CopyToAsync(stream);
-            }
-            var htmlInfo = ConvertDocxToHtml(filePath, folder);
-            AzureBlobModel model = await azureBlobDBRepository.UploadPath(htmlInfo.blobPath);
+           string folder =    IdWorker.getInstance().NextId()+"";
+            //System.IO.Directory.CreateDirectory(folder);
+           // var filePath = folder + "\\" + file.FileName;
+            //using (var stream = new FileStream(filePath, FileMode.Create))
+            //{
+            //    await file.CopyToAsync(stream);
+            //}
+            var htmlInfo = ConvertDocxToHtml(file, folder);
+            AzureBlobModel model = await azureBlobDBRepository.UploadTextByFolder(htmlInfo.htmlString, "",htmlInfo.blobPath, "exercise",false);
             model.Sha1Code = shaCode;
             await azureTableDBRepository.Save<AzureBlobModel>(model);
-            FileHelper.DeleteDirAndFiles(BaseConfigModel.ContentRootPath + "/Upload");
+           // FileHelper.DeleteDirAndFiles(BaseConfigModel.ContentRootPath + "/Upload");
             resdict.Add("HtmlString", htmlInfo.htmlString);
             resdict.Add("Sha1Code", shaCode);
             return resdict;
         }
-        public dynamic ConvertDocxToHtml(string filePath, string folder)
+        public dynamic ConvertDocxToHtml(IFormFile file, string folder)
         {
-            string FolderName = DateTime.Now.ToString("yyyyMMdd");
-            byte[] byteArray = File.ReadAllBytes(filePath);
-
+            string FolderName =  DateTime.Now.ToString("yyyyMMdd")+"/"+ folder;
+            byte[] byteArray = new byte[file.OpenReadStream().Length];
+            file.OpenReadStream().Read(byteArray, 0, byteArray.Length);
             //byte[] bytes = new byte[stream.Length];
             using (MemoryStream memoryStream = new MemoryStream())
             {
@@ -191,8 +182,8 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
                     var htmlString = htmls.ToString(SaveOptions.DisableFormatting);
                     //引入MathJax插件
                     htmlString = htmlString + "<script type=\"text/javascript\" src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>";
-                    File.WriteAllText(folder + "/" + "index.html", htmlString);
-                    return new { htmlString, blobPath = folder + "/" + "index.html" };
+                    //File.WriteAllText(folder + "/" + "index.html", htmlString);
+                    return new { htmlString, blobPath = FolderName + "/" + "index.html" };
                 };
             }
         }

+ 1 - 1
TEAMModelOS/Controllers/Evaluation/ImportExerciseController.cs

@@ -15,7 +15,7 @@ namespace TEAMModelOS.Controllers.Evaluation
 {
     [Route("api/[controller]")]
     [ApiController]
-    public class ImportExerciseController: BaseController
+    public class ImportExerciseController : BaseController
     {
         private readonly IImportExerciseService importExerciseService;
         private readonly IHtmlAnalyzeService htmlAnalyzeService;

文件差异内容过多而无法显示
+ 3822 - 0
TEAMModelOS/JsonFile/Core/MML2OMML.XSL


文件差异内容过多而无法显示
+ 2068 - 0
TEAMModelOS/JsonFile/Core/OMML2MML.XSL