修改解决方案依赖
parent
5de4745303
commit
888dfbcafb
|
@ -78,6 +78,9 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Hangfire" Version="1.7.31">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Hangfire.Tags.SqlServer" Version="1.8.1" />
|
||||
<PackageReference Include="Invio.Extensions.Authentication.JwtBearer" Version="2.0.1" />
|
||||
<PackageReference Include="LogDashboard" Version="1.4.8" />
|
||||
|
@ -85,7 +88,6 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
|
||||
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.6.2" />
|
||||
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.6.2" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
|
||||
|
|
|
@ -9,7 +9,6 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static BeetleX.Redis.Commands.HSCAN;
|
||||
using static IRaCIS.Core.Application.Service.Common.SystemMonitor;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.OpenXmlFormats.Wordprocessing;
|
||||
using NPOI.XWPF.UserModel;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
public static class NpoiWordHelper
|
||||
{
|
||||
public static async Task<IActionResult> TemplateExportWordAsync(string code, object data, IRepository<CommonDocument>? _commonDocumentRepository, IWebHostEnvironment _hostEnvironment)
|
||||
{
|
||||
//var (physicalPath, fileNmae) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code);
|
||||
|
||||
var physicalPath = code;
|
||||
|
||||
|
||||
using (FileStream stream = File.OpenRead(physicalPath))
|
||||
{
|
||||
XWPFDocument doc = new XWPFDocument(stream);
|
||||
//遍历段落
|
||||
foreach (var para in doc.Paragraphs)
|
||||
{
|
||||
ReplaceKey(para, data);
|
||||
}
|
||||
//遍历表格
|
||||
var tables = doc.Tables;
|
||||
foreach (var table in tables)
|
||||
{
|
||||
//ReplaceTableKey(table, data, "Data");
|
||||
}
|
||||
|
||||
foreach (var table in tables)
|
||||
{
|
||||
foreach (var row in table.Rows)
|
||||
{
|
||||
foreach (var cell in row.GetTableCells())
|
||||
{
|
||||
foreach (var para in cell.Paragraphs)
|
||||
{
|
||||
ReplaceKey(para, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileStream out1 = new FileStream("table.docx", FileMode.Create);
|
||||
doc.Write(out1);
|
||||
out1.Close();
|
||||
return new FileStreamResult(stream, "application/msword")
|
||||
{
|
||||
FileDownloadName = $"replaced_{DateTime.Now.ToString("yyyyMMddHHmmss")}.docx"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void ReplaceKey(XWPFParagraph para, object model)
|
||||
{
|
||||
string text = para.ParagraphText;
|
||||
|
||||
Type t = model.GetType();
|
||||
PropertyInfo[] pi = t.GetProperties();
|
||||
foreach (PropertyInfo p in pi)
|
||||
{
|
||||
//$$与模板中$$对应,也可以改成其它符号,比如{$name},务必做到唯一
|
||||
if (text.Contains("$" + p.Name + "$"))
|
||||
{
|
||||
text = text.Replace("$" + p.Name + "$", p.GetValue(model)?.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//var runs = para.Runs;
|
||||
//string styleid = para.Style;
|
||||
//for (int i = 0; i < runs.Count; i++)
|
||||
//{
|
||||
// var run = runs[i];
|
||||
// text = run.ToString();
|
||||
// Type t = model.GetType();
|
||||
// PropertyInfo[] pi = t.GetProperties();
|
||||
// foreach (PropertyInfo p in pi)
|
||||
// {
|
||||
// //$$与模板中$$对应,也可以改成其它符号,比如{$name},务必做到唯一
|
||||
// if (text.Contains("$" + p.Name + "$"))
|
||||
// {
|
||||
// text = text.Replace("$" + p.Name + "$", p.GetValue(model)?.ToString());
|
||||
// }
|
||||
// }
|
||||
// runs[i].SetText(text, 0);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 替换表格Key
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="field"></param>
|
||||
|
||||
private static void ReplaceTableKey(XWPFTable table, IList list, String field)
|
||||
{
|
||||
List<XWPFParagraph> paras = new List<XWPFParagraph>();
|
||||
// 获取最后一行数据,最后一行设置值
|
||||
Int32 iLastRowIndex = 0;
|
||||
for (int iIndex = 0; iIndex < table.Rows.Count; iIndex++)
|
||||
{
|
||||
if (iIndex == table.Rows.Count - 1)
|
||||
{
|
||||
iLastRowIndex = iIndex;
|
||||
foreach (var cell in table.Rows[iIndex].GetTableCells())
|
||||
{
|
||||
foreach (var para in cell.Paragraphs)
|
||||
{
|
||||
paras.Add(para);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除最后一行
|
||||
table.RemoveRow(iLastRowIndex);
|
||||
|
||||
for (int iIndex = 0; iIndex < list.Count; iIndex++)
|
||||
{
|
||||
object data = list[iIndex];
|
||||
Type t = data.GetType();
|
||||
PropertyInfo[] pi = t.GetProperties();
|
||||
// 表增加行
|
||||
XWPFTableRow m_row = table.CreateRow();
|
||||
CT_Row m_NewRow = new CT_Row();
|
||||
String text = String.Empty;
|
||||
Int32 jIndex = 0;
|
||||
paras.ForEach(para =>
|
||||
{
|
||||
text = para.ParagraphText;
|
||||
foreach (PropertyInfo p in pi)
|
||||
{
|
||||
if (text.Contains("$" + field + "." + p.Name + "$"))
|
||||
{
|
||||
m_row.GetCell(jIndex).SetText(p.GetValue(data, null).ToString());
|
||||
}
|
||||
}
|
||||
jIndex++;
|
||||
});
|
||||
m_row = new XWPFTableRow(m_NewRow, table);
|
||||
table.AddRow(m_row);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="BeetleX.BNR" Version="1.0.1" />
|
||||
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.1" />
|
||||
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.AspectCore" Version="1.7.0" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
||||
|
@ -75,9 +75,6 @@
|
|||
<PackageReference Include="fo-dicom.Drawing" Version="4.0.8" />
|
||||
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.0.3" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="10.8.0" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.31">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Magicodes.IE.Core" Version="2.7.4.2" />
|
||||
<PackageReference Include="Magicodes.IE.Csv" Version="2.7.4.2">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
|
|
|
@ -85,14 +85,6 @@
|
|||
<param name="type"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.NpoiWordHelper.ReplaceTableKey(NPOI.XWPF.UserModel.XWPFTable,System.Collections.IList,System.String)">
|
||||
<summary>
|
||||
替换表格Key
|
||||
</summary>
|
||||
<param name="table"></param>
|
||||
<param name="list"></param>
|
||||
<param name="field"></param>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.Service.TaskAllocationRuleService">
|
||||
<summary>
|
||||
分配规则
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using BeetleX.BNR;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EntityFrameworkCore.Projectables" Version="2.3.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.Projectables.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.10" />
|
||||
<PackageReference Include="NewId" Version="3.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
{
|
||||
|
|
|
@ -18,12 +18,14 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="6.5.6" />
|
||||
<PackageReference Include="AutoMapper" Version="12.0.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="6.0.3.1" />
|
||||
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="7.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.Projectables" Version="2.3.0" />
|
||||
<PackageReference Include="NewId" Version="3.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.0" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.669" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.10" />
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
Loading…
Reference in New Issue