修改导出逻辑
parent
d62562149c
commit
2f1cfc3e67
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -12,8 +13,9 @@ namespace IRaCIS.Core.API
|
|||
{
|
||||
var supportedCultures = new List<CultureInfo>
|
||||
{
|
||||
new CultureInfo("en-US"),
|
||||
new CultureInfo("zh-CN")
|
||||
|
||||
new CultureInfo(StaticData.CultureInfo.en_US),
|
||||
new CultureInfo(StaticData.CultureInfo.zh_CN)
|
||||
};
|
||||
|
||||
var options = new RequestLocalizationOptions
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
using IRaCIS.Core.Domain.Share;
|
||||
using NPOI.XWPF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xceed.Document.NET;
|
||||
using Xceed.Words.NET;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 利用DocX 库 处理word国际化模板
|
||||
/// </summary>
|
||||
public static class WordTempleteHelper
|
||||
{
|
||||
public static void DocX_GetInternationalTempleteStream(string filePath, Stream memoryStream)
|
||||
{
|
||||
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
|
||||
using (DocX document = DocX.Load(filePath))
|
||||
{
|
||||
// 查找书签
|
||||
var bookmarkEn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == StaticData.CultureInfo.en_US_bookMark);
|
||||
|
||||
if (bookmarkEn_Start != null)
|
||||
{
|
||||
// 获取书签的起始位置
|
||||
//int bookmarkCNStartPos = bookmarkCn_Start.Paragraph.StartIndex;
|
||||
|
||||
var bookmarkENStartPos = bookmarkEn_Start.Paragraph.StartIndex;
|
||||
|
||||
// 创建一个要删除段落的列表
|
||||
List<Paragraph> paragraphsToRemove = new List<Paragraph>();
|
||||
|
||||
foreach (var item in document.Paragraphs)
|
||||
{
|
||||
//中文模板在前,英文在后,英文模板,就删除英文之前的,中文模板就删除英文之后的
|
||||
|
||||
if (isEn_US ? item.EndIndex < bookmarkENStartPos : item.StartIndex >= bookmarkENStartPos)
|
||||
{
|
||||
paragraphsToRemove.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var paragraph in paragraphsToRemove)
|
||||
{
|
||||
document.RemoveParagraph(paragraph);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 保存修改
|
||||
document.SaveAs(memoryStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void Npoi_GetInternationalTempleteStream(string filePath, Stream memoryStream)
|
||||
{
|
||||
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
XWPFDocument doc = new XWPFDocument(fs);
|
||||
|
||||
// 查找包含指定书签的段落及其索引
|
||||
var bookmarkParagraph = doc.Paragraphs
|
||||
.FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == StaticData.CultureInfo.en_US_bookMark));
|
||||
|
||||
if (bookmarkParagraph != null)
|
||||
{
|
||||
int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
||||
|
||||
if (isEn_US)
|
||||
{
|
||||
// 从书签所在段落开始,删除之前的所有段落
|
||||
for (int i = bookmarkIndex - 1; i >= 0; i--)
|
||||
{
|
||||
doc.RemoveBodyElement(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 删除书签之后的所有段落
|
||||
for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
||||
{
|
||||
doc.RemoveBodyElement(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.Write(memoryStream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@
|
|||
<ItemGroup>
|
||||
<None Remove="IRaCIS.Core.Application.xml" />
|
||||
<None Remove="Resources\en-US.json" />
|
||||
<None Remove="Resources\zh-CN.json" />
|
||||
<None Remove="Resources\zh_ch.json" />
|
||||
<None Remove="Service\Allocation\TaskConsistentRuleService.cs~RF1603d47.TMP" />
|
||||
<None Remove="Service\Reading\ReadingImageTask\ReadingImageTaskService.cs~RF2f9323.TMP" />
|
||||
<None Remove="Service\Reading\ReadingImageTask\ReadingJudgeTaskService.cs~RF198afd23.TMP" />
|
||||
|
@ -50,11 +50,6 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\zh-CN.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\en-US.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
|
|
|
@ -117,6 +117,11 @@
|
|||
<returns>解密后的字符串</returns>
|
||||
</member>
|
||||
<!-- Badly formed XML comment ignored for member "M:IRaCIS.Core.Application.Helper.RSAHelper.Encrypt(System.String,System.String)" -->
|
||||
<member name="T:IRaCIS.Core.Application.Helper.WordTempleteHelper">
|
||||
<summary>
|
||||
利用DocX 库 处理word国际化模板
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.Service.TaskAllocationRuleService">
|
||||
<summary>
|
||||
分配规则
|
||||
|
|
|
@ -1522,20 +1522,18 @@ namespace IRaCIS.Core.Application.Service.Common
|
|||
//两个都不为null 肯定是不同的裁判
|
||||
|
||||
//在完成裁判之后的,和未完成裁判之前的
|
||||
if (visitItem.VisitTaskNum < maxNotFinishedJudge.VisitTaskNum && visitItem.VisitTaskNum > maxFinishedJudge.VisitTaskNum)
|
||||
if (/*visitItem.VisitTaskNum < maxNotFinishedJudge.VisitTaskNum &&*/ visitItem.VisitTaskNum > maxFinishedJudge.VisitTaskNum)
|
||||
{
|
||||
visitItem.IsGenerateJudge = null;
|
||||
}
|
||||
|
||||
else if (visitItem.ArmEnum == maxFinishedJudge.JudgeArmEnum && visitItem.VisitTaskNum < maxFinishedJudge.VisitTaskNum)
|
||||
{
|
||||
visitItem.IsGenerateJudge = true;
|
||||
}
|
||||
|
||||
else if (visitItem.ArmEnum == Arm.DoubleReadingArm1)
|
||||
{
|
||||
visitItem.IsGenerateJudge = true;
|
||||
}
|
||||
//else if (visitItem.ArmEnum == Arm.DoubleReadingArm1)
|
||||
//{
|
||||
// visitItem.IsGenerateJudge = true;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Aliyun.OSS;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using IP2Region.Net.XDB;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
|
@ -18,12 +19,14 @@ using Microsoft.Extensions.Options;
|
|||
using MiniExcelLibs;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
using NPOI.XWPF.UserModel;
|
||||
using SharpCompress.Common;
|
||||
using Spire.Doc;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Xceed.Document.NET;
|
||||
using Xceed.Words.NET;
|
||||
|
||||
|
||||
|
@ -114,7 +117,7 @@ namespace IRaCIS.Application.Services
|
|||
public async Task<IResponseOutput> TestMinIO([FromServices] IOSSService oSSService)
|
||||
{
|
||||
|
||||
var str= await oSSService.GetSignedUrl("/01000000-c0a8-0242-1c98-08dc7ebcd37d/Read/01000000-c0a8-0242-1c98-08dc7ebcd37d/Visit/1716872544006_1716872544003.png");
|
||||
var str = await oSSService.GetSignedUrl("/01000000-c0a8-0242-1c98-08dc7ebcd37d/Read/01000000-c0a8-0242-1c98-08dc7ebcd37d/Visit/1716872544006_1716872544003.png");
|
||||
|
||||
|
||||
//await oSSService.UploadToOSSAsync("C:\\Users\\Administrator\\Desktop\\TrialSiteUserImportTemplate.xlsx", "myfolder");
|
||||
|
@ -188,11 +191,11 @@ namespace IRaCIS.Application.Services
|
|||
Console.WriteLine("\nOriginal Data: " + dataToEncrypt);
|
||||
|
||||
// Encrypt the data
|
||||
var encryptedData = RSAHelper.Encrypt( publicKey, dataToEncrypt);
|
||||
var encryptedData = RSAHelper.Encrypt(publicKey, dataToEncrypt);
|
||||
Console.WriteLine("\nEncrypted Data: " + encryptedData);
|
||||
|
||||
// Decrypt the data
|
||||
string decryptedData = RSAHelper.Decrypt( privateKey, encryptedData);
|
||||
string decryptedData = RSAHelper.Decrypt(privateKey, encryptedData);
|
||||
Console.WriteLine("\nDecrypted Data: " + decryptedData);
|
||||
|
||||
|
||||
|
@ -202,38 +205,111 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task<string> testEmail([FromServices] IWebHostEnvironment env ,string email)
|
||||
public async Task<string> testDoc([FromServices] IWebHostEnvironment env, string email)
|
||||
{
|
||||
|
||||
//using (DocX document = DocX.Load("C:\\Users\\hang\\Desktop\\"))
|
||||
#region DocX 测试
|
||||
//using (DocX document = DocX.Load("C:\\Users\\hang\\Desktop\\test.docx"))
|
||||
//{
|
||||
// // 查找书签对应的段落
|
||||
// var bookmark = document.Bookmarks.FirstOrDefault(b => b.Name == bookmarkName);
|
||||
// // 查找书签
|
||||
// var bookmarkCn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "zh_cn");
|
||||
// var bookmarkEn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "en_us");
|
||||
|
||||
// if (bookmark != null)
|
||||
// if (bookmarkCn_Start != null && bookmarkEn_Start != null)
|
||||
// {
|
||||
// // 获取书签所在的段落位置
|
||||
// int paragraphIndex = document.Paragraphs.IndexOf(bookmark.Paragraph);
|
||||
// // 获取书签的起始位置
|
||||
// int bookmarkCNStartPos = bookmarkCn_Start.Paragraph.StartIndex;
|
||||
|
||||
// // 如果书签所在的段落在文档中
|
||||
// if (paragraphIndex >= 0)
|
||||
// var bookmarkENStartPos = bookmarkEn_Start.Paragraph.StartIndex;
|
||||
|
||||
// // // 创建一个要删除段落的列表
|
||||
// List<Paragraph> paragraphsToRemove = new List<Paragraph>();
|
||||
|
||||
// foreach (var item in document.Paragraphs)
|
||||
// {
|
||||
// // 删除书签所在的段落
|
||||
// document.RemoveParagraphAt(paragraphIndex);
|
||||
|
||||
// //中文模板在前,英文在后,英文模板,就删除英文之前的,中文模板就删除英文之后的
|
||||
// //_userInfo.IsEn_Us? item.EndIndex< bookmarkENStartPos :item.StartIndex>= bookmarkENStartPos
|
||||
// if (item.StartIndex>= bookmarkENStartPos)
|
||||
// {
|
||||
// paragraphsToRemove.Add(item);
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (var paragraph in paragraphsToRemove)
|
||||
// {
|
||||
// document.RemoveParagraph(paragraph);
|
||||
// }
|
||||
|
||||
// // 删除书签(只删除书签标记,不删除内容)
|
||||
// document.Bookmarks.Remove(bookmark);
|
||||
// }
|
||||
|
||||
// // 保存修改
|
||||
// document.Save();
|
||||
// document.SaveAs("C:\\Users\\hang\\Desktop\\test1.docx");
|
||||
//}
|
||||
#endregion
|
||||
|
||||
using (FileStream fs = new FileStream("C:\\Users\\hang\\Desktop\\test.docx", FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
XWPFDocument doc = new XWPFDocument(fs);
|
||||
|
||||
|
||||
var hiddenEmail = EmailMaskHelper.MaskEmail(email);
|
||||
// 查找包含指定书签的段落及其索引
|
||||
var bookmarkParagraph = doc.Paragraphs
|
||||
.FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == "en_us"));
|
||||
|
||||
return hiddenEmail;
|
||||
|
||||
if (bookmarkParagraph != null)
|
||||
{
|
||||
int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
||||
|
||||
// 删除书签之后的所有段落
|
||||
for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
||||
{
|
||||
doc.RemoveBodyElement(i);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BusinessValidationFailedException("word 模板没有英文书签");
|
||||
}
|
||||
|
||||
// 创建一个要删除段落的列表
|
||||
|
||||
//XWPFParagraph bookmarkParagraph = null;
|
||||
|
||||
//foreach (var paragraph in doc.Paragraphs)
|
||||
//{
|
||||
|
||||
// foreach (var bookmark in paragraph.GetCTP().GetBookmarkStartList())
|
||||
// {
|
||||
// if (bookmark.name == "en_us")
|
||||
// {
|
||||
// bookmarkParagraph = paragraph;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
//// 从书签所在段落开始,删除之前的所有段落
|
||||
//for (int i = bookmarkIndex - 1; i >= 0; i--)
|
||||
//{
|
||||
// doc.RemoveBodyElement(i);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
using (FileStream outStream = new FileStream("C:\\Users\\hang\\Desktop\\test1.docx", FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
doc.Write(outStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return "hiddenEmail";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,14 @@ public static class StaticData
|
|||
public static readonly string Zh_CN_Json = "zh-CN.json";
|
||||
|
||||
|
||||
public static class CultureInfo
|
||||
{
|
||||
public static readonly string zh_CN = "zh-CN";
|
||||
public static readonly string en_US = "en-US";
|
||||
|
||||
public static readonly string en_US_bookMark = "en_us";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取国际化
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue