修改BaseService Excel导出

master
xiaochanghai 1 year ago
parent f18f64172e
commit 2f56152fab
  1. 14
      Tiobon.Core.Api/Controllers/Base/BaseController.cs
  2. 7
      Tiobon.Core.Api/Tiobon.Core.xml
  3. 42
      Tiobon.Core.Common/Attribute/ExportDatatAttribute.cs
  4. 351
      Tiobon.Core.Common/Extensions/IQueryableExtensions.cs
  5. 32
      Tiobon.Core.Common/Helper/LoggerHelper.cs
  6. 1
      Tiobon.Core.Common/Tiobon.Core.Common.csproj
  7. 68
      Tiobon.Core.DataAccess/ReportHelper.cs
  8. 1
      Tiobon.Core.IServices/BASE/IBaseServices.cs
  9. 61
      Tiobon.Core.Repository/BASE/BaseRepository.cs
  10. 9
      Tiobon.Core.Services/BASE/BaseServices.cs
  11. 8
      Tiobon.Core.Services/CommonServices.cs
  12. 1
      Tiobon.Core.Services/Tiobon.Core.Services.csproj
  13. 5
      Tiobon.Core/Tiobon.Core.Model.xml
  14. 14
      Tiobon.Core/Tiobon.Core.xml

@ -193,6 +193,20 @@ public class BaseController<IServiceBase, TEntity, TEntityDto, TInsertDto, TEdit
#endregion #endregion
#region Excel导出
/// <summary>
/// Excel导出
/// </summary>
/// <param name="body"></param>
/// <returns></returns>
[HttpPost, Route("Export")]
public async Task<ServiceResult<long>> Export([FromBody] QueryBody body)
{
var data = (await InvokeServiceAsync("Export", [body])) as ServiceResult<long>;
return data;
}
#endregion
///// <summary> ///// <summary>
///// 反射调用service方法 ///// 反射调用service方法
///// </summary> ///// </summary>

@ -134,6 +134,13 @@
<param name="Ids">主键IDs</param> <param name="Ids">主键IDs</param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Tiobon.Core.Controllers.BaseController`5.Export(Tiobon.Core.Common.QueryBody)">
<summary>
Excel导出
</summary>
<param name="body"></param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Controllers.TiobonController"> <member name="T:Tiobon.Core.Controllers.TiobonController">
<summary> <summary>
博客管理 博客管理

@ -0,0 +1,42 @@
namespace Tiobon.Core.Common;
/// <summary>
/// 视图类属性是字典值时根据属性值获取字典值
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class ExportDatatAttribute : Attribute
{
/// <summary>
/// 数据源字段名
/// </summary>
public string ExportDataName { get; }
/// <summary>
/// 数据源的model类型
/// </summary>
public Type ExportDataType { get; }
/// <summary>
/// 数据类型,(1)序列 (2)嵌套model (3)数据项
/// </summary>
public string ExportDataFlag { get; }
/// <summary>
/// 动态数据的字段名和类型
/// </summary>
/// <param name="name">数据源字段名</param>
/// <param name="type">数据源的类型(typeof(类名))</param>
public ExportDatatAttribute(string name, Type type)
{
ExportDataName = name;
ExportDataType = type;
}
/// <summary>
/// 标识
/// </summary>
/// <param name="flag">(1)序列 (2)嵌套model (3)数据项</param>
public ExportDatatAttribute(string flag)
{
ExportDataFlag = flag;
}
}

@ -0,0 +1,351 @@
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using SixLabors.ImageSharp;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Common.Extensions;
public static class IQueryableExtensions
{
static int EXPORT_FILE_PAGESIZE = 10000;
/// <summary>
/// IQueryable数据写入文件(Excel)
/// </summary>
/// <param name="db"></param>
/// <param name="fname"></param>
/// <param name="splitstr"></param>
/// <param name="ExportFields"></param>
/// <param name="exportFieldsWidth"></param>
/// <param name="headText"></param>
/// <param name="totalText"></param>
/// <param name="isNeedItemNo"></param>
public static void IntoFileFromLinqExcel<T>(this IQueryable<T> db, string fname, string splitstr, List<string> exportFields, List<int> exportFieldsWidth, string headText = "", string totalText = "", bool isNeedItemNo = false) where T : class
{
if (db.IsNull())
return;
//查询文件状态
if (File.Exists(fname))
{
LoggerHelper.SendLog("文件已生成 " + fname);
return;
}
LoggerHelper.SendLog("正在生成文件 " + fname);
DateTime dt_start = DateTime.Now;
if (!File.Exists(fname))
File.Create(fname).Close();
//获取需要导出的字段
Dictionary<string, string> fieldDescs = GetFieldDesc<T>();
int dbCount = db.Count();
//列名排序,返回有序列表
var (fields, colunms) = Sort(fieldDescs, exportFields);
using (FileStream stream = File.Create(fname))
{
using (ExcelPackage package = new ExcelPackage(stream))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("sheet1");
var colunmsCount = colunms.Count;
var startCol = 0;
var startRow = 1; // 初始行数
if (isNeedItemNo)
startCol = 1;
if (!string.IsNullOrEmpty(headText))
{
worksheet.Cells[startRow, 1].Value = headText;
worksheet.Cells[startRow, 1, 1, colunmsCount + startCol].Merge = true;
worksheet.Cells[startRow, 1, 1, colunmsCount + startCol].Style.Font.Bold = true;
worksheet.Cells[startRow, 1, 1, colunmsCount + startCol].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; // Alignment is center
worksheet.Cells[startRow, 1, 1, colunmsCount + startCol].Style.Font.Size = 14;
startRow++;
}
if (isNeedItemNo)
{
worksheet.Cells[startRow, 1].Value = "序号";
worksheet.Cells[startRow, 1, startRow, 1].Style.Font.Bold = true;
worksheet.Cells[startRow, 1, startRow, 1].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
worksheet.Cells[startRow, 1, startRow, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
}
//写入列名
for (int i = 0; i < fields.Count; ++i)
{
worksheet.Cells[startRow, i + 1 + startCol].Value = fields[i];
worksheet.Cells[startRow, i + 1 + startCol, startRow, i + 1 + startCol].Style.Font.Bold = true;
worksheet.Cells[startRow, i + 1 + startCol, startRow, i + 1 + startCol].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
worksheet.Cells[startRow, i + 1 + startCol, startRow, i + 1 + startCol].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
}
startRow++;
//查看数据是否过大,需要分页
int totalPageNum = (dbCount + EXPORT_FILE_PAGESIZE - 1) / EXPORT_FILE_PAGESIZE;
//遍历每一页
for (int pageNum = 0; pageNum < totalPageNum; ++pageNum)
{
var list = db.Skip(pageNum * EXPORT_FILE_PAGESIZE).Take(EXPORT_FILE_PAGESIZE).ToList();
//遍历每行
for (int row = 0; row < list.Count; ++row)
{
if (isNeedItemNo)
{
worksheet.Cells[row + startRow, 1].Value = row + 1;
worksheet.Cells[row + startRow, 1, row + startRow, 1].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
worksheet.Cells[row + startRow, 1, row + startRow, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
}
//遍历需要写入文件的字段
for (int i = 0; i < colunms.Count; ++i)
{
worksheet.Cells[row + startRow, i + 1 + startCol].Value = ConvertData2String(list[row], colunms[i]);
worksheet.Cells[row + startRow, i + 1 + startCol, row + startRow, i + 1 + startCol].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
worksheet.Cells[row + startRow, i + 1 + startCol, row + startRow, i + 1 + startCol].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
}
}
}
if (!string.IsNullOrEmpty(totalText))
{
worksheet.Cells[dbCount + startRow, 1].Value = "总计:";
worksheet.Cells[dbCount + startRow, 1, dbCount + startRow, 1].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
worksheet.Cells[dbCount + startRow, 1, dbCount + startRow, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
worksheet.Cells[dbCount + startRow, 2, dbCount + startRow, colunms.Count + startCol].Value = totalText;
worksheet.Cells[dbCount + startRow, 2, dbCount + startRow, colunms.Count + startCol].Merge = true;
startRow++;
}
using (ExcelRange r = worksheet.Cells[1, 1, dbCount + startRow - 1, fields.Count + startCol])
{
r.Style.Border.Top.Style = ExcelBorderStyle.Thin;
r.Style.Border.Left.Style = ExcelBorderStyle.Thin;
r.Style.Border.Right.Style = ExcelBorderStyle.Thin;
r.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
r.Style.Border.Top.Color.SetColor(Color.Black);
r.Style.Border.Left.Color.SetColor(Color.Black);
r.Style.Border.Right.Color.SetColor(Color.Black);
r.Style.Border.Bottom.Color.SetColor(Color.Black);
}
if (isNeedItemNo)
{
worksheet.Column(1).Width = 20;//设置列宽为默认值
}
//设置列宽
if (exportFieldsWidth == null || exportFieldsWidth.Count < fields.Count)
{
for (int i = 0; i < fields.Count; ++i)
{
worksheet.Column(i + 1 + startCol).Width = 20;//设置列宽为默认值
}
}
else
{
for (int i = 0; i < fields.Count; ++i)
{
worksheet.Column(i + 1 + startCol).Width = exportFieldsWidth[i];//设置列宽为前段配置的值
}
}
package.Workbook.Properties.Title = "数据导出";
package.Workbook.Properties.Author = "SUZHOUEU";
package.Workbook.Properties.Comments = "苏州一优信息技术有限公司提供技术支持!";
package.Workbook.Properties.Company = "苏州一优信息技术有限公司";
package.Workbook.Properties.SetCustomPropertyValue("Checked by", "SimonHsiao");
package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "SUZHOUEU");
package.Save();
}
}
LoggerHelper.SendLog("生成文件 " + fname + " 完毕 " + dbCount + " 耗时 " + (int)(DateTime.Now - dt_start).TotalSeconds);
}
private static string ConvertData2String<T>(T t, string field) where T : class
{
if (t.FieldTypeIsDateTime(field))
{
DateTime? time = t.GetDateTimeValueFromField(field);
if (time != null)
{
if (time.Value.ToString("HH:mm:ss") == "00:00:00")
{
return time.Value.ToString("yyyy-MM-dd");
}
else
{
return time.Value.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else
{
return string.Empty;
}
}
else
{
return t.GetStringValueFromField(field);
}
}
/// <summary>
/// 列名按照前端显示顺序导出
/// </summary>
/// <param name="columns"></param>
/// <param name="ExportFields"></param>
/// <returns></returns>
public static (List<string>, List<string>) Sort(Dictionary<string, string> columns, List<string> ExportFields)
{
List<string> fields = new List<string>();
List<string> colunms = new List<string>();
if (ExportFields == null || ExportFields.Count == 0)
{
return (columns.Keys.ToList(), columns.Values.ToList());
}
foreach (var field in ExportFields)
{
foreach (var item in columns)
{
if (item.Key == field)
{
fields.Add(item.Key);
colunms.Add(item.Value);
}
}
}
return (fields, colunms);
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="obj">对象</param>
/// <param name="colunms"></param>
/// <returns></returns>
public static List<string> GetPropertyData<T>(T obj, List<string> colunms) where T : class
{
List<string> data = new List<string>();
//声明obj的类型
Type type = obj.GetType();
// 获取obj类型的所有属性信息
System.Reflection.PropertyInfo[] PropertyList = type.GetProperties();
//循环每一个属性
foreach (var item in PropertyList)
{
// 获取自定义特性
object[] export = item.GetCustomAttributes(typeof(ExportDatatAttribute), true);
object[] descript = item.GetCustomAttributes(typeof(DescriptionAttribute), true);
//判断是否需要导出
if (export.Length > 0)
{
//取值
var exdesc = ((ExportDatatAttribute)export[0]);
// 是否嵌套
if (exdesc != null)
{
//是否是序列
if (exdesc.ExportDataFlag == "1")
{
var tmp = item.GetValue(obj) as IEnumerable; //List<ItemDetail>
if (tmp != null)
{
foreach (var o in tmp)
{
data.AddRange(GetPropertyData(o, colunms));
}
}
}
// 如果是嵌套model
else if (exdesc.ExportDataFlag == "2")
{
var tmp = item.GetValue(obj);
if (tmp != null)
{
data.AddRange(GetPropertyData(tmp, colunms));
}
}
else if (exdesc.ExportDataFlag == "3")
{
if (colunms.Contains(item.Name))
{
data.Add(item.GetValue(obj).ToString());
}
}
}
}
else if (descript.Length > 0)
{
if (colunms.Contains(item.Name))
{
data.Add(item.GetValue(obj).ToString());
}
}
}
return data;
}
#region 获取字段描述
/// <summary>
/// 对象字段描述
/// </summary>
private static Dictionary<string, Dictionary<string, string>> m_FieldDesc = new Dictionary<string, Dictionary<string, string>>();
/// <summary>
/// 获取字段的描述(描述 - 列名)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static Dictionary<string, string> GetFieldDesc<T>()
{
var type = typeof(T).ToString();
lock (m_FieldDesc)
{
if (m_FieldDesc.ContainsKey(type))
return m_FieldDesc[type];
}
Dictionary<string, string> dic = new Dictionary<string, string>();
try
{
PropertyInfo[] peroperties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
if (peroperties != null)
{
foreach (PropertyInfo property in peroperties)
{
object[] objs = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
if (objs.Length > 0)
{
var desc = ((DescriptionAttribute)objs[0]).Description.Trim();
if (!dic.ContainsKey(desc))
{
dic.Add(desc, property.Name);
}
else
{
dic[desc] = property.Name;
}
}
}
}
}
catch //(Exception ex)
{
}
lock (m_FieldDesc)
{
if (!m_FieldDesc.ContainsKey(type))
m_FieldDesc.Add(type, dic);
}
return dic;
}
#endregion
}

@ -0,0 +1,32 @@
namespace Tiobon.Core.Common.Helper;
/// <summary>
/// 日志操作
/// </summary>
public static class LoggerHelper
{
/// <summary>
/// console日志
/// </summary>
/// <param name="msg"></param>
public static void Info(string msg)
{
Console.WriteLine($"{DateTime.Now:HH:mm:ss} {msg}");
}
/// <summary>
/// 正常日志
/// </summary>
/// <param name="msg"></param>
public static void SendLog(string msg)
{
Console.WriteLine($"{DateTime.Now:HH:mm:ss} {msg}");
}
/// <summary>
/// 错误日志
/// </summary>
/// <param name="msg"></param>
public static void SendLogError(string msg)
{
Console.WriteLine($"{DateTime.Now:HH:mm:ss} {msg}");
}
}

@ -43,6 +43,7 @@
<PackageReference Include="Serilog" Version="3.1.1" /> <PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup> </ItemGroup>

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using SqlSugar;
using Tiobon.Core.Common;
using Tiobon.Core.Common.DB;
using Tiobon.Core.Common.Extensions;
using Tiobon.Core.Model.Models;
namespace Tiobon.Core.DataAccess;
/// <summary>
/// 报表辅助类
/// </summary>
public static class ReportHelper
{
#region 文件下载
/// <summary>
/// 生成文件,并通知用户下载(IQueryable)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="modelName">导出模块名称(JobSetting.xxx)</param>
/// <param name="exportFields"></param>
/// <param name="exportFieldsWidth"></param>
/// <param name="user"></param>
/// <param name="sort"></param>
/// <param name="headText"></param>
/// <param name="totalText"></param>
/// <param name="isNeedItemNo"></param>
public static async Task<long> SendFile<T>(IQueryable<T> list, string modelName, List<string> exportFields, List<int> exportFieldsWidth, string sort = null, string headText = "", string totalText = "", bool isNeedItemNo = false) where T : class
{
if (list == null)
throw new Exception("生成文件失败");
//生成文件至文件服务器
var fid = SnowFlakeSingle.Instance.NextId();
var path = $"{$"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{fid}{Path.DirectorySeparatorChar}"}";
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var fname = $"{modelName}.xlsx";
list = string.IsNullOrEmpty(sort) ? list : list.OrderBy(sort);
list.IntoFileFromLinqExcel(path + fname, ",", exportFields, exportFieldsWidth, headText, totalText, isNeedItemNo);
using var _context = ContextFactory.CreateContext();
Ghre_Attachment fileAttachment = new Ghre_Attachment();
fileAttachment.Id = fid;
fileAttachment.AttachFileName = fname;
fileAttachment.CreateBy = App.User.ID;
fileAttachment.CreateTime = DateTime.Now;
fileAttachment.AttachmentName = fname;
fileAttachment.AttachFileExtension = "xlsx";
fileAttachment.AttachFileSize = 0;
fileAttachment.PhysicsPath = $"/files/export/{fid}/" + fname;
fileAttachment.AttachmentType = "xlsx";
await _context.Ghre_Attachment.AddAsync(fileAttachment);
await _context.SaveChangesAsync();
return fid;
}
#endregion
}

@ -141,6 +141,7 @@ namespace Tiobon.Core.IServices.BASE
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null); Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
Task<ServicePageResult<TEntityDto>> QueryFilterPage([FromBody] QueryBody body); Task<ServicePageResult<TEntityDto>> QueryFilterPage([FromBody] QueryBody body);
Task<ServiceResult<long>> Export([FromBody] QueryBody body);
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>( Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, object[]>> joinExpression,

@ -473,39 +473,42 @@ namespace Tiobon.Core.Repository.Base
var query = _db.Queryable<TEntity>(); var query = _db.Queryable<TEntity>();
string conditions = "1=1"; string conditions = "1=1";
foreach (JProperty jProperty in filter.jsonParam.Properties()) if (filter.jsonParam != null)
{ foreach (JProperty jProperty in filter.jsonParam.Properties())
var name = jProperty.Name;
var value = jProperty.Value.ToString();
if (!string.IsNullOrWhiteSpace(value))
{ {
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value); var name = jProperty.Name;
var value = jProperty.Value.ToString();
switch (jsonParam.operationKey) if (!string.IsNullOrWhiteSpace(value))
{ {
case "Include": var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
break; switch (jsonParam.operationKey)
case "NotInclude": {
conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'"; case "Include":
break; conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
case "IsNull": break;
conditions += $" AND {name} IS NULL"; case "NotInclude":
break; conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'";
case "NotNull": break;
conditions += $" AND {name} IS NOT NULL"; case "IsNull":
break; conditions += $" AND {name} IS NULL";
case "Equal": break;
conditions += $" AND {name} ='{jsonParam.columnValue}'"; case "NotNull":
break; conditions += $" AND {name} IS NOT NULL";
case "NotEqual": break;
conditions += $" AND {name} !='{jsonParam.columnValue}'"; case "Equal":
break; conditions += $" AND {name} ='{jsonParam.columnValue}'";
default: break;
break; case "NotEqual":
conditions += $" AND {name} !='{jsonParam.columnValue}'";
break;
default:
break;
}
} }
} }
} if (filter.pageSize == 0)
filter.pageSize = 10000;
query = query.Where(conditions); query = query.Where(conditions);
var list = await query var list = await query
.OrderByIF(!string.IsNullOrEmpty(filter.Sorting), filter.Sorting) .OrderByIF(!string.IsNullOrEmpty(filter.Sorting), filter.Sorting)

@ -4,6 +4,7 @@ using System.Reflection;
using AgileObjects.AgileMapper; using AgileObjects.AgileMapper;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MySqlX.XDevAPI.Common;
using SqlSugar; using SqlSugar;
using Tiobon.Core.Common; using Tiobon.Core.Common;
using Tiobon.Core.Common.DB.Dapper; using Tiobon.Core.Common.DB.Dapper;
@ -12,6 +13,7 @@ using Tiobon.Core.Common.Enums;
using Tiobon.Core.Common.Extensions; using Tiobon.Core.Common.Extensions;
using Tiobon.Core.Common.Helper; using Tiobon.Core.Common.Helper;
using Tiobon.Core.Common.UserManager; using Tiobon.Core.Common.UserManager;
using Tiobon.Core.DataAccess;
using Tiobon.Core.IRepository.Base; using Tiobon.Core.IRepository.Base;
using Tiobon.Core.IServices.BASE; using Tiobon.Core.IServices.BASE;
using Tiobon.Core.Model; using Tiobon.Core.Model;
@ -788,6 +790,13 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
return new ServicePageResult<TEntityDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, Mapper.Map(data.result.DT_TableDataT1).ToANew<List<TEntityDto>>()); return new ServicePageResult<TEntityDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, Mapper.Map(data.result.DT_TableDataT1).ToANew<List<TEntityDto>>());
}
public async Task<ServiceResult<long>> Export(QueryBody body)
{
var data = await BaseDal.QueryFilterPage(body);
var fileId = await ReportHelper.SendFile(data.result.DT_TableDataT1.AsQueryable(), $"测试测试", null, null, null, null);
return ServiceResult<long>.OprateSuccess("导出成功", fileId);
} }
public async Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new() public async Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new()

@ -276,6 +276,14 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
sql = string.Format(sql, param.menuName, App.User.ID, param.langId); sql = string.Format(sql, param.menuName, App.User.ID, param.langId);
result.JM_PageControlT1.Toolbar = DbAccess.QueryList<Toolbar>(sql); result.JM_PageControlT1.Toolbar = DbAccess.QueryList<Toolbar>(sql);
if (param.menuName == "F_QuestionBank")
{
var toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault();
if (toolbar != null) { toolbar.fnKey = "TBD1YN"; }
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault();
if (toolbar != null) { toolbar.fnKey = "TBD2YN"; }
}
#endregion #endregion
#region 定义表格页面的栏位, 含 表格栏位, 常用查询栏位, 高级查询栏位,可编辑栏位 #region 定义表格页面的栏位, 含 表格栏位, 常用查询栏位, 高级查询栏位,可编辑栏位

@ -26,6 +26,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Tiobon.Core.DataAccess\Tiobon.Core.DataAccess.csproj" />
<ProjectReference Include="..\Tiobon.Core.IServices\Tiobon.Core.IServices.csproj" /> <ProjectReference Include="..\Tiobon.Core.IServices\Tiobon.Core.IServices.csproj" />
<ProjectReference Include="..\Tiobon.Core.Repository\Tiobon.Core.Repository.csproj" /> <ProjectReference Include="..\Tiobon.Core.Repository\Tiobon.Core.Repository.csproj" />
</ItemGroup> </ItemGroup>

@ -3297,6 +3297,11 @@
题目(Dto.View) 题目(Dto.View)
</summary> </summary>
</member> </member>
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionDto.Answers">
<summary>
答案
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswerDto"> <member name="T:Tiobon.Core.Model.Models.Ghre_QuestionAnswerDto">
<summary> <summary>
题目答案(Dto.View) 题目答案(Dto.View)

@ -134,6 +134,13 @@
<param name="Ids">主键IDs</param> <param name="Ids">主键IDs</param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Tiobon.Core.Controllers.BaseController`5.Export(Tiobon.Core.Common.QueryBody)">
<summary>
Excel导出
</summary>
<param name="body"></param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Controllers.TiobonController"> <member name="T:Tiobon.Core.Controllers.TiobonController">
<summary> <summary>
博客管理 博客管理
@ -525,6 +532,13 @@
题目(Controller) 题目(Controller)
</summary> </summary>
</member> </member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.QueryById(System.Int64)">
<summary>
根据Id查询数据
</summary>
<param name="Id">主键ID</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.Insert(Tiobon.Core.Model.Models.InsertGhre_QuestionInput)"> <member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.Insert(Tiobon.Core.Model.Models.InsertGhre_QuestionInput)">
<summary> <summary>
新增数据 新增数据

Loading…
Cancel
Save