using ICSharpCode.SharpZipLib.Tar; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.IO.Compression; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using wispro.sp.utility; using SharpCompress.Archives; using SharpCompress.Archives.Rar; using SharpCompress.Common; using System.Collections; using wispro.sp.entity.CompareCase; using wispro.sp.share.webViewObject; using System.Net.Http; using System.Net.Http.Json; using wispro.sp.share; using OpenQA.Selenium.Support.UI; using System.Dynamic; using System.Diagnostics; using NPOI.Util; using NPOI.SS.Formula.Functions; using static wispro.sp.utility.CompareDocx; namespace wispro.sp.winClient { public partial class frmCaseFileCompare : Form { private CompareDocx draft_fristReturn; private CompareDocx fristReturn_Finally; public frmCaseFileCompare() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private CaseInfo getCaseInfo_files(string caseNo, out string draftFile, out string returnFile, out string finalFile) { draftFile = null; returnFile = null; finalFile = null; var retFiles = wispro.sp.utility.IPEasyUtility.DownloadCaseFiles(caseNo); if (retFiles != null) { CaseInfo caseInfo = new CaseInfo(); caseInfo.CaseNo = retFiles.CaseNo; IDictionary keyValuePairs = (IDictionary)retFiles; if (keyValuePairs.ContainsKey("CaseName")) { caseInfo.CaseName = retFiles.CaseName; } if (keyValuePairs.ContainsKey("Customer")) { caseInfo.Customer = new entity.Customer() { Name = retFiles.Customer }; } if (keyValuePairs.ContainsKey("FirstDraftDate")) { caseInfo.DraftDate = string.IsNullOrEmpty(retFiles.FirstDraftDate) ? null : DateTime.Parse(retFiles.FirstDraftDate); } if (keyValuePairs.ContainsKey("ReturnDate")) { caseInfo.ReturnDate = string.IsNullOrEmpty(retFiles.ReturnDate) ? null : DateTime.Parse(retFiles.ReturnDate); } if (keyValuePairs.ContainsKey("FinalizationDate")) { caseInfo.FinalVersionDate = string.IsNullOrEmpty(retFiles.FinalizationDate) ? null : DateTime.Parse(retFiles.FinalizationDate); } if (keyValuePairs.ContainsKey("FinishedDate")) { caseInfo.CreateTime = string.IsNullOrEmpty(retFiles.FinishedDate) ? null : DateTime.Parse(retFiles.FinishedDate); } if (keyValuePairs.ContainsKey("DoPersons")) { caseInfo.Handlers = retFiles.DoPersons; caseInfo.Handlers = caseInfo.Handlers.Trim(); if(caseInfo.Handlers.Substring(caseInfo.Handlers.Length - 1) == ";") { caseInfo.Handlers = caseInfo.Handlers.Substring(0, caseInfo.Handlers.Length - 1); } } if (keyValuePairs.ContainsKey("Reviewer")) { if (!string.IsNullOrEmpty(retFiles.Reviewer)) { caseInfo.Reviewer = new entity.Staff() { Name = retFiles.Reviewer }; } } if (keyValuePairs.ContainsKey("draftFile")) { draftFile = retFiles.draftFile; } if (keyValuePairs.ContainsKey("firstReturnFile")) { returnFile = retFiles.firstReturnFile; } if (keyValuePairs.ContainsKey("finallyFile")) { finalFile = retFiles.finallyFile; } return caseInfo; } else { return null; } } private async Task compareCaseFile(DateTime start,DateTime end) { DataTable table = wispro.sp.utility.IPEasyUtility.GetFinished3FilesCases(1,start,end); if (table != null) { int iIndex = 0; foreach (DataRow row in table.Rows) { iIndex++; string CaseNo = row["我方文号"].ToString(); if (row["申请类型"].ToString().Trim() == "外观设计") { string str = $"{DateTime.Now}\t{iIndex}/{table.Rows.Count}\t{CaseNo}\t外观设计"; DebugLog(str); continue; } string draftFile = string.Empty; string returnFile = string.Empty; string finalFile = string.Empty; if (!string.IsNullOrEmpty(CaseNo) && !CaseNo.StartsWith("PACN")) { DebugLog($"{DateTime.Now}\t{iIndex}/{table.Rows.Count}\t{CaseNo}\t非中国专利申请"); continue ; } var isExistResp = await new APIService().CaseExist(CaseNo); if (isExistResp || !CaseNo.StartsWith("PACN")) { DebugLog($"{DateTime.Now}\t{iIndex}/{table.Rows.Count}\t{CaseNo}\t已存在!"); continue; } int iTry = 0; tryAgain: try { CaseInfo caseInfo = getCaseInfo_files(CaseNo, out draftFile, out returnFile, out finalFile); int i = (string.IsNullOrEmpty(draftFile) ? 0 : 1) + (string.IsNullOrEmpty(returnFile) ? 0 : 1) + (string.IsNullOrEmpty(finalFile) ? 0 : 1); //continue; DebugLog($"{DateTime.Now}\t{iIndex}/{table.Rows.Count}\t{CaseNo}\t{(string.IsNullOrEmpty(draftFile) ? 0 : 1)}\t{(string.IsNullOrEmpty(returnFile) ? 0 : 1)}\t{(string.IsNullOrEmpty(finalFile) ? 0 : 1)}"); if (i > 1 && returnFile != null) { #region 将文件复制到保存文件夹中 //string strSavePath = "d:\\CaseFiles"; //string strCaseFilePath = Path.Combine(strSavePath, caseInfo.CaseNo); //if (!Directory.Exists(strCaseFilePath)) //{ // Directory.CreateDirectory(strCaseFilePath); //} //if (!string.IsNullOrEmpty(draftFile)) //{ // FileInfo file = new FileInfo(draftFile); // File.Copy(draftFile, Path.Combine(strCaseFilePath, $"草稿-{file.Name}"), true); //} //if (!string.IsNullOrEmpty(returnFile)) //{ // FileInfo file = new FileInfo(returnFile); // File.Copy(returnFile, Path.Combine(strCaseFilePath, $"返稿-{file.Name}"), true); //} //if (!string.IsNullOrEmpty(finalFile)) //{ // FileInfo file = new FileInfo(finalFile); // File.Copy(finalFile, Path.Combine(strCaseFilePath, $"定稿-{file.Name}"), true); //} #endregion CompareFiles(draftFile, returnFile, finalFile, caseInfo); if (!(caseInfo.DRRAll == null && caseInfo.RFRAll == null)) { await new APIService().SaveCompareResult(caseInfo); } } try { if (File.Exists(draftFile)) { File.Delete(draftFile); } if (File.Exists(returnFile)) { File.Delete(returnFile); } if (File.Exists(finalFile)) { File.Delete(finalFile); } } catch { } } catch(Exception ex) { if(iTry < 3) { iTry++; goto tryAgain; } DebugLog($"{DateTime.Now}\t{ iIndex}/{ table.Rows.Count}\t{CaseNo},{ ex.Message}"); } } } static void DebugLog(string str) { using (StreamWriter writer = new StreamWriter(@"c:\temp\caseFileInfo.txt", true)) { writer.WriteLine(str); } } } private void CompareFiles(string draftFile, string returnFile, string finalFile, CaseInfo caseInfo) { string strExtractPath = @"c:\temp"; string tmpdraftFile = ExtractFile(draftFile, 0, strExtractPath); string tmpreturnFile = ExtractFile(returnFile, 1, strExtractPath); string tmpfinalFile = ExtractFile(finalFile, 2, strExtractPath); if (!string.IsNullOrEmpty(tmpdraftFile) && !string.IsNullOrEmpty(tmpreturnFile)) { CompareDocx docx = new CompareDocx(); docx.Compare(tmpdraftFile, tmpreturnFile); if (docx.FulltextResult?.oldWordCount > 0) { caseInfo.DRRFulltext = docx.FulltextResult; } if (docx.AbstractResult?.oldWordCount > 0) { caseInfo.DRRAbstract = docx.AbstractResult; } if (docx.ClaimResult?.oldWordCount > 0) { caseInfo.DRRCalim = docx.ClaimResult; } if (docx.AllStringResult?.oldWordCount > 0) { caseInfo.DRRAll = docx.AllStringResult; } } if (!string.IsNullOrEmpty(tmpfinalFile) && !string.IsNullOrEmpty(tmpreturnFile)) { CompareDocx docx = new CompareDocx(); docx.Compare(tmpreturnFile, tmpfinalFile); if (docx.FulltextResult?.oldWordCount > 0) { caseInfo.RFRFulltext = docx.FulltextResult; } if (docx.AbstractResult?.oldWordCount > 0) { caseInfo.RFRAbstract = docx.AbstractResult; } if (docx.ClaimResult?.oldWordCount > 0) { caseInfo.RFRCalim = docx.ClaimResult; } if (docx.AllStringResult?.oldWordCount > 0) { caseInfo.RFRAll = docx.AllStringResult; } } #region 清除下载和解压缩后的文件 if (System.IO.File.Exists(returnFile)) { System.IO.File.Delete(returnFile); } if (System.IO.File.Exists(draftFile)) { System.IO.File.Delete(draftFile); } if (System.IO.File.Exists(finalFile)) { System.IO.File.Delete(finalFile); } if (System.IO.File.Exists(tmpdraftFile)) { System.IO.File.Delete(tmpdraftFile); } if (System.IO.File.Exists(tmpfinalFile)) { System.IO.File.Delete(tmpfinalFile); } if (System.IO.File.Exists(tmpreturnFile)) { System.IO.File.Delete(tmpreturnFile); } if (!string.IsNullOrEmpty(returnFile) && System.IO.Directory.Exists(Path.Combine(strExtractPath, returnFile.Substring(0, returnFile.Length - 4)))) { System.IO.Directory.Delete(Path.Combine(strExtractPath, returnFile.Substring(0, returnFile.Length - 4)), true); } if (!string.IsNullOrEmpty(draftFile) && System.IO.Directory.Exists(Path.Combine(strExtractPath, draftFile.Substring(0, draftFile.Length - 4)))) { System.IO.Directory.Delete(Path.Combine(strExtractPath, draftFile.Substring(0, draftFile.Length - 4)), true); } if (!string.IsNullOrEmpty(finalFile) && System.IO.Directory.Exists(Path.Combine(strExtractPath, finalFile.Substring(0, finalFile.Length - 4)))) { System.IO.Directory.Delete(Path.Combine(strExtractPath, finalFile.Substring(0, finalFile.Length - 4)), true); } #endregion } CaseInfo caseInfo; private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtCaseNo.Text)) { if (MessageBox.Show("获取前一天所有的完成案件,并比较文档?", "提示框", MessageBoxButtons.YesNo) == DialogResult.Yes) { compareCaseFile(DateTime.Parse("2025-01-01"),DateTime.Parse("2025-01-31")); return; } else { MessageBox.Show("请输入案号!", "提示框", MessageBoxButtons.OK); this.txtCaseNo.Focus(); return; } } else { #region 获取文本框中输入的案件,并比较三个文件 string draftFile = string.Empty; string finalFile = string.Empty; string returnFile = string.Empty; caseInfo = getCaseInfo_files(txtCaseNo.Text.Trim(), out draftFile, out returnFile, out finalFile); int i = (string.IsNullOrEmpty(draftFile) ? 0 : 1) + (string.IsNullOrEmpty(returnFile) ? 0 : 1) + (string.IsNullOrEmpty(finalFile) ? 0 : 1); #region 将文件复制到保存文件夹中 //string strSavePath = "d:\\CaseFiles"; //string strCaseFilePath = Path.Combine(strSavePath, caseInfo.CaseNo); //if (!Directory.Exists(strCaseFilePath)) //{ // Directory.CreateDirectory(strCaseFilePath); //} //if (!string.IsNullOrEmpty(draftFile)) //{ // FileInfo file = new FileInfo(draftFile); // File.Copy(draftFile, Path.Combine(strCaseFilePath, $"草稿-{file.Name}"), true); //} //if (!string.IsNullOrEmpty(returnFile)) //{ // FileInfo file = new FileInfo(returnFile); // File.Copy(returnFile, Path.Combine(strCaseFilePath, $"返稿-{file.Name}"), true); //} //if (!string.IsNullOrEmpty(finalFile)) //{ // FileInfo file = new FileInfo(finalFile); // File.Copy(finalFile, Path.Combine(strCaseFilePath, $"定稿-{file.Name}"), true); //} #endregion if (i > 1) { CompareFiles(draftFile, returnFile, finalFile, caseInfo); new APIService().SaveCompareResult(caseInfo); } comboBox1.SelectedIndex = 0; #endregion } } private static bool isValidFile(string strFile,int type) { if (string.IsNullOrEmpty(strFile)) { return false; } string strfileName = new FileInfo(strFile).Name; if(!new FileInfo(strfileName).Extension.Contains("doc")) { return false; } switch (type) { case 0: if (strfileName.ToUpper().IndexOf("检索报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("通知书", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("查新报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("对比文件", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("检索文档", StringComparison.OrdinalIgnoreCase) < 0 && (strfileName.ToUpper().IndexOf("申请文档", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("申请文件", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("权利要求", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("V1R", StringComparison.OrdinalIgnoreCase) > 0)) { return true; } break; case 1: if ((strfileName.ToUpper().IndexOf("申请文件", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("V1F", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("初稿", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("权利要求", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("申请文档", StringComparison.OrdinalIgnoreCase) > 0 || strfileName.ToUpper().IndexOf("说明书", StringComparison.OrdinalIgnoreCase) > 0) && strfileName.ToUpper().IndexOf("检索报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("查新报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("对比文件", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("通知书", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("检索文档", StringComparison.OrdinalIgnoreCase) < 0) { return true; } break; case 2: if (strfileName.ToUpper().IndexOf("检索报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("查新报告", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("对比文件", StringComparison.OrdinalIgnoreCase) < 0 && strfileName.ToUpper().IndexOf("检索文档", StringComparison.OrdinalIgnoreCase) < 0) { return true; } break; } return false; } private static string ExtractFile(string file, int type, string strExtractPath) { if (string.IsNullOrEmpty(file)) { return null; } if (file.ToLower().EndsWith(".zip") || file.ToLower().EndsWith(".rar")) { string temFileName = new FileInfo(file).Name; string extractPath = Path.Combine(strExtractPath, temFileName.Substring(0, temFileName.Length - 4)); if (file.ToLower().EndsWith(".zip")) { ExtractFileUtil.ExtractZip(file, extractPath); } else { ExtractFileUtil.ExtractRarFile(file, extractPath); } foreach (string f in Directory.GetFiles(extractPath, "*.*", SearchOption.AllDirectories)) { if (isValidFile(f, type)) { return f; } } return null; } else { if (file.ToLower().EndsWith(".eml")) { emlFileReader emlFile = new emlFileReader(file); if (emlFile.AttachFiles != null) { string retFile = null; foreach (var temfile in emlFile.AttachFiles) { string temExtractFile = ExtractFile(temfile, type, strExtractPath); if (isValidFile(temExtractFile,type)) { retFile = temExtractFile; break; } } if(retFile == null && emlFile.AttachFiles.Count ==1) { retFile = ExtractFile(emlFile.AttachFiles[0], type, strExtractPath); } foreach (var temfile in emlFile.AttachFiles) { if (temfile != retFile) { File.Delete(temfile); } } return retFile; } return null; } else { return file; } } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (caseInfo != null) { richTextBox1.Clear(); string strHtml = string.Empty; switch (comboBox1.SelectedIndex) { case 0: if (caseInfo.DRRAll != null) { strHtml = $"所有文字比较:

初稿与第一次返稿比较结果:

初稿文件字数:{caseInfo.DRRAll.oldWordCount}

删除文字数量:{caseInfo.DRRAll.DeleteCount}

插入文字数量:{caseInfo.DRRAll.InsertCount}

修改比率:{(caseInfo.DRRAll.diffRate * 100).ToString("0.0000")}%

文档语义相似度:{(caseInfo.DRRAll.TextSimilarity * 100).ToString("0.0000")}%

"; } if (caseInfo.RFRAll != null) { strHtml = strHtml + $"

第一次返稿与定稿比较结果:

第一次返稿文件字数:{caseInfo.RFRAll.oldWordCount}

删除文字数量:{caseInfo.RFRAll.DeleteCount}

插入文字数量:{caseInfo.RFRAll.InsertCount}

修改比率:{(caseInfo.RFRAll.diffRate * 100).ToString("0.0000")}%

文档语义相似度:{(caseInfo.RFRAll.TextSimilarity * 100).ToString("0.0000")}%

"; } richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(strHtml); break; case 1: if (caseInfo.DRRAll != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.DRRAll.CompareResultString); } break; case 2: if (caseInfo.RFRAll != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.RFRAll.CompareResultString); } break; case 3: if (caseInfo.DRRAbstract != null) { strHtml = $"摘要比较:

初稿与第一次返稿比较结果:

初稿文件字数:{caseInfo.DRRAbstract.oldWordCount}

删除文字数量:{caseInfo.DRRAbstract.DeleteCount}

插入文字数量:{caseInfo.DRRAbstract.InsertCount}

修改比率:{(caseInfo.DRRAbstract.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.DRRAbstract.TextSimilarity * 100).ToString("0.0000")}%

"; } if (caseInfo.RFRAbstract != null) { strHtml = strHtml + $"

第一次返稿与定稿比较结果:

第一次返稿文件字数:{caseInfo.RFRAbstract.oldWordCount}

删除文字数量:{caseInfo.RFRAbstract.DeleteCount}

插入文字数量:{caseInfo.RFRAbstract.InsertCount}

修改比率:{(caseInfo.RFRAbstract.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.RFRAbstract.TextSimilarity * 100).ToString("0.0000")}%

"; } richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(strHtml); break; case 4: if (caseInfo.DRRAbstract != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.DRRAbstract.CompareResultString); } break; case 5: if (caseInfo.RFRAbstract != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.RFRAbstract.CompareResultString); } break; case 6: if (caseInfo.DRRCalim != null) { strHtml = $"权力要求比较:

初稿与第一次返稿比较结果:

初稿文件字数:{caseInfo.DRRCalim.oldWordCount}

删除文字数量:{caseInfo.DRRCalim.DeleteCount}

插入文字数量:{caseInfo.DRRCalim.InsertCount}

修改比率:{(caseInfo.DRRCalim.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.DRRCalim.TextSimilarity * 100).ToString("0.0000")}%

"; } if (caseInfo.RFRCalim != null) { strHtml = strHtml + $"

第一次返稿与定稿比较结果:

第一次返稿文件字数:{caseInfo.RFRCalim.oldWordCount}

删除文字数量:{caseInfo.RFRCalim.DeleteCount}

插入文字数量:{caseInfo.RFRCalim.InsertCount}

修改比率:{(caseInfo.RFRCalim.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.RFRCalim.TextSimilarity * 100).ToString("0.0000")}%

"; } richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(strHtml); break; case 7: if (caseInfo.DRRCalim != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.DRRCalim.CompareResultString); } break; case 8: if (caseInfo.RFRCalim != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.RFRCalim.CompareResultString); } break; case 9: if (caseInfo.DRRFulltext != null) { strHtml = $"说明书比较:

初稿与第一次返稿比较结果:

初稿文件字数:{caseInfo.DRRFulltext.oldWordCount}

删除文字数量:{caseInfo.DRRFulltext.DeleteCount}

插入文字数量:{caseInfo.DRRFulltext.InsertCount}

修改比率:{(caseInfo.DRRFulltext.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.DRRFulltext.TextSimilarity * 100).ToString("0.0000")}%

"; } if (caseInfo.RFRFulltext != null) { strHtml = strHtml + $"

第一次返稿与定稿比较结果:

第一次返稿文件字数:{caseInfo.RFRFulltext.oldWordCount}

删除文字数量:{caseInfo.RFRFulltext.DeleteCount}

插入文字数量:{caseInfo.RFRFulltext.InsertCount}

修改比率:{(caseInfo.RFRFulltext.diffRate * 100).ToString("0.0000")}%

语义相似度:{(caseInfo.RFRFulltext.TextSimilarity * 100).ToString("0.0000")}%

"; } richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(strHtml); break; case 10: if (caseInfo.DRRFulltext != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.DRRFulltext.CompareResultString); } break; case 11: if (caseInfo.RFRFulltext != null) { richTextBox1.Rtf = new HtmlToRtfConverter().ConvertHtmlToRtf(caseInfo.RFRFulltext.CompareResultString); } break; } } } private void button2_Click(object sender, EventArgs e) { new Form1().ShowDialog(); #region 选择文档比较 //OpenFileDialog openFileDialog = new OpenFileDialog(); //if(openFileDialog.ShowDialog() == DialogResult.OK) //{ // string strPath = openFileDialog.FileName.ToLower().Replace(".rar", "").Replace(".zip",""); // if(openFileDialog.FileName.Contains(".rar")) // { // ExtractFileUtil.ExtractRarFile(openFileDialog.FileName, strPath); // } // else // { // ExtractFileUtil.ExtractZip(openFileDialog.FileName,strPath); // } // string[] files = Directory.EnumerateFiles(strPath, "*.*", SearchOption.AllDirectories).ToArray(); // Array.Sort(files); // Array.Reverse(files); // draft_fristReturn = new CompareDocx(); // draft_fristReturn.Compare(files[0], files[1]); // if (files.Length > 2) // { // fristReturn_Finally = new CompareDocx(); // fristReturn_Finally.Compare(files[1], files[2]); // } // SaveResult(strPath,draft_fristReturn); // SaveResult(strPath, fristReturn_Finally); //} #endregion } private void SaveResult(string strPath, CompareDocx draft_fristReturn) { string strHtml = @" 对比结果
{0}
{1}
全部对比 摘要 权利要求 说明书
原文字数 {2} {3} {4} {5}
删除字数 {6} {7} {8} {9}
插入字数 {10} {11} {12} {13}
修改比例 {14} {15} {16} {17}
语义相似度 {18} {19} {20} {21}
{22}
{23}
{24}
{25}
"; if (draft_fristReturn != null) { var temHtml = strHtml .Replace("{0}", new FileInfo(draft_fristReturn.oldDocument.FilePath).Name) .Replace("{1}", new FileInfo(draft_fristReturn.newDocument.FilePath).Name) .Replace("{2}", draft_fristReturn.AllStringResult.oldWordCount.ToString()) .Replace("{3}", draft_fristReturn.AbstractResult.oldWordCount.ToString()) .Replace("{4}", draft_fristReturn.ClaimResult.oldWordCount.ToString()) .Replace("{5}", draft_fristReturn.FulltextResult.oldWordCount.ToString()) .Replace("{6}", draft_fristReturn.AllStringResult.DeleteCount.ToString()) .Replace("{7}", draft_fristReturn.AbstractResult.DeleteCount.ToString()) .Replace("{8}", draft_fristReturn.ClaimResult.DeleteCount.ToString()) .Replace("{9}", draft_fristReturn.FulltextResult.DeleteCount.ToString()) .Replace("{10}", draft_fristReturn.AllStringResult.InsertCount.ToString()) .Replace("{11}", draft_fristReturn.AbstractResult.InsertCount.ToString()) .Replace("{12}", draft_fristReturn.ClaimResult.InsertCount.ToString()) .Replace("{13}", draft_fristReturn.FulltextResult.InsertCount.ToString()) .Replace("{14}", (draft_fristReturn.AllStringResult.diffRate * 100).ToString("0.0000") + "%") .Replace("{15}", (draft_fristReturn.AbstractResult.diffRate * 100).ToString("0.0000") + "%") .Replace("{16}", (draft_fristReturn.ClaimResult.diffRate * 100).ToString("0.0000") + "%") .Replace("{17}", (draft_fristReturn.FulltextResult.diffRate * 100).ToString("0.0000") + "%") .Replace("{18}", (draft_fristReturn.AllStringResult.TextSimilarity * 100).ToString("0.0000") + "%") .Replace("{19}", (draft_fristReturn.AbstractResult.TextSimilarity * 100).ToString("0.0000") + "%") .Replace("{20}", (draft_fristReturn.ClaimResult.TextSimilarity * 100).ToString("0.0000") + "%") .Replace("{21}", (draft_fristReturn.FulltextResult.TextSimilarity * 100).ToString("0.0000") + "%") .Replace("{22}", draft_fristReturn.AllStringResult.CompareResultString) .Replace("{23}", draft_fristReturn.AbstractResult.CompareResultString) .Replace("{24}", draft_fristReturn.ClaimResult.CompareResultString) .Replace("{25}", draft_fristReturn.FulltextResult.CompareResultString); string fileName = $"{new FileInfo(draft_fristReturn.oldDocument.FilePath).Name}_{new FileInfo(draft_fristReturn.newDocument.FilePath).Name}.html"; using (var f = File.CreateText(Path.Combine(strPath, fileName))) { f.Write(temHtml); } } } private void button3_Click(object sender, EventArgs e) { //new PatentDocument(@"C:\temp\PI2023CN1303-优先权分析(1).docx"); //var ret = new APIService().CalZScore(); new APIService().testMail(); //ret.Wait(); //emlFileReader reader = new emlFileReader(@"D:\Users\luowen\Downloads\2f7e92c1-e009-4b19-ba8d-332e8f6f2ffc.eml"); } private void txtCaseNo_TextChanged(object sender, EventArgs e) { } } }