Ver Fonte

OCR分包下载-调整下载逻辑,第一次使用OCR判断md5

liyijie há 1 ano atrás
pai
commit
ba6209621b

+ 9 - 1
PDF Office/Helper/FileComparisonHelper.cs

@@ -78,9 +78,17 @@ namespace PDF_Master.Helper
                 {
                     return false;
                 }
-                string folderMD5 = FileComparisonHelper.CalculateFolderMD5(folderPath);
+                string folderMD5 = "";
+                if (string.IsNullOrEmpty(OCRmodelMD5))
+                {
+                    folderMD5 = FileComparisonHelper.CalculateFolderMD5(folderPath);
+                }
+                else {
+                    folderMD5 = OCRmodelMD5;
+                }
                 if (folderMD5 == Settings.Default.AppProperties.OCRmodelMD5)
                 {
+                    OCRmodelMD5 = folderMD5;
                     return true;
                 }
             }

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterExcelDialogViewModel.cs

@@ -373,8 +373,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -390,8 +390,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterHTMLDialogViewModel.cs

@@ -195,8 +195,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -212,8 +212,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterPPTDialogViewModel.cs

@@ -223,8 +223,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -240,8 +240,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterRTFDialogViewModel.cs

@@ -195,8 +195,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -212,8 +212,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterTextDialogViewModel.cs

@@ -196,8 +196,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -213,8 +213,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 4 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterWordDialogViewModel.cs

@@ -229,8 +229,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                 if (folderMD5)
                 {
                     string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                    CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                    CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                    CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                    CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                 }
                 else
                 {
@@ -246,8 +246,8 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                             if (e.Result == Prism.Services.Dialogs.ButtonResult.OK)
                             {
                                 string folderPath = System.IO.Path.Combine(App.CurrentPath, "OCREngine");
-                                CPDFConverter.InitOcrLibrary(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "x64"));
-                                CPDFConverter.SetOCRModelPath(Path.Combine("C:\\Users\\kdanmobile\\Documents\\PDF Master\\OCREngine", "source", "models"));
+                                CPDFConverter.InitOcrLibrary(Path.Combine(folderPath, "x64"));
+                                CPDFConverter.SetOCRModelPath(Path.Combine(folderPath, "source", "models"));
                             }
                             else
                             {

+ 7 - 1
PDF Office/ViewModels/Dialog/ConverterDialogs/OCRDownloadProgressViewModel.cs

@@ -184,6 +184,13 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
         private void cancel()
         {
             isDownloadCancelled = true;
+            if (client != null)
+            {
+                //防止退出没释放
+                client.CancelAsync();
+                client.Dispose();
+                FileComparisonHelper.RemoveOCRModel();
+            }
             RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
         }
 
@@ -309,7 +316,6 @@ namespace PDF_Master.ViewModels.Dialog.ConverterDialogs
                         if (FileComparisonHelper.OCRModelItExist())
                         {
                             var dialogresult = new DialogResult(ButtonResult.OK);
-                            //dialogresult.Parameters.Add(ParameterNames.ConverterType, "Img");
                             RequestClose.Invoke(dialogresult);
                         }
                         else