using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareExcel.ORM; using System.Collections.Generic; namespace iWareExcel.EXCEL.Entity { public class WorkBookEntity : ICommonEntity { /// /// 主键 /// public int Id { get; set; } /// /// 工作簿名称 /// public string Name { get; set; } /// /// 备注 /// public string Remark { get; set; } /// /// 模板地址 /// public string TemplatePath { get; set; } /// /// 是否需要模板 /// public int NeedTemplate { get; set; } /// /// 服务器保存路径 /// public string ServerPath { get; set; } /// /// 服务器保存文件名 /// public string ServerFileName { get; set; } /// /// 表头写入开始行 从1开始 /// public int HeadStartLine { get; set; } /// /// 数据写入开始行 从1开始 /// public int DataStartLine { get; set; } /// /// 工作表列表 /// public List WorkSheets { get; set; } /// /// 无参构造 /// public WorkBookEntity() { WorkSheets = new List(); } /// /// 有参构造 /// /// orm印射的类 public WorkBookEntity(EXCELWorkBook workBook) { EntityPropHelper.CopyProp(workBook, this, GetColumnMap()); WorkSheets = new List(); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的BASEShift类型 public EXCELWorkBook ToOrm() { EXCELWorkBook workBook = new EXCELWorkBook(); EntityPropHelper.CopyProp(this, workBook, GetColumnMap()); return workBook; } /// /// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"Name", "name"}, {"Remark", "remark"}, {"TemplatePath", "templatepath"}, {"NeedTemplate", "needtemplate"}, {"ServerPath", "serverpath"}, {"ServerFileName", "serverfilename"}, {"HeadStartLine","headstartline"}, {"DataStartLine","datastartline"} }; } /// /// 根据ShiftEntity的字段转BASEShift的字段 /// /// ShiftEntity的字段 /// BASEShift public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取ShiftEntity对应的表名 /// /// 表名 public static string GetTableName() { return "[dbo].[EXCELWorkBook]"; } } }