using BP.DA; using BP.En; using BP.Sys; namespace BP.WF.Template.Frm { /// /// 打印模板属性 /// public class FrmPrintTemplateAttr : BP.En.EntityMyPKAttr { /// /// 路径 /// public const string Name = "Name"; /// /// 路径 /// public const string TempFilePath = "TempFilePath"; /// /// NodeID /// public const string NodeID = "NodeID"; /// /// 流程编号 /// public const string FlowNo = "FlowNo"; /// /// 字段名称 /// public const string KeyOfEn = "KeyOfEn"; /// /// 为生成单据使用 /// public const string Idx = "Idx"; /// /// 单据类型 /// public const string TemplateFileModel = "TemplateFileModel"; /// /// 是否生成PDF /// public const string PrintFileType = "PrintFileType"; /// /// 二维码生成方式 /// public const string QRModel = "QRModel"; /// /// 文件打开方式 /// public const string PrintOpenModel = "PrintOpenModel"; /// /// 表单的ID /// public const string FrmID = "FrmID"; } /// /// 打印模板 /// public class FrmPrintTemplate : EntityMyPK { #region 属性 /// /// UI界面上的访问控制 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.OpenForSysAdmin(); return uac; } } /// /// 编号 /// public new string MyPK { get { string no = this.GetValStrByKey("MyPK"); no = no.Replace("\n", ""); no = no.Replace(" ", ""); return no; } set { this.SetValByKey("MyPK", value); this.SetValByKey(FrmPrintTemplateAttr.TempFilePath, value); } } /// /// 生成的单据类型 /// public PrintFileType HisPrintFileType { get { return (PrintFileType)this.GetValIntByKey(FrmPrintTemplateAttr.PrintFileType); } set { this.SetValByKey(FrmPrintTemplateAttr.PrintFileType, (int)value); } } /// /// 二维码生成方式 /// public QRModel QRModel { get { return (QRModel)this.GetValIntByKey(FrmPrintTemplateAttr.QRModel); } set { this.SetValByKey(FrmPrintTemplateAttr.QRModel, (int)value); } } public TemplateFileModel TemplateFileModel { get { return (TemplateFileModel)this.GetValIntByKey(FrmPrintTemplateAttr.TemplateFileModel); } set { this.SetValByKey(FrmPrintTemplateAttr.TemplateFileModel, (int)value); } } /// /// 生成的单据打开方式 /// public PrintOpenModel PrintOpenModel { get { return (PrintOpenModel)this.GetValIntByKey(FrmPrintTemplateAttr.PrintOpenModel); } set { this.SetValByKey(FrmPrintTemplateAttr.PrintOpenModel, (int)value); } } /// /// 打开的连接 /// public string TempFilePath { get { string s = this.GetValStrByKey(FrmPrintTemplateAttr.TempFilePath); if (DataType.IsNullOrEmpty(s) == true) return this.MyPK; return s; } set { this.SetValByKey(FrmPrintTemplateAttr.TempFilePath, value); } } /// /// 节点名称 /// public string NodeName { get { Node nd = new Node(this.NodeID); return nd.Name; } } /// /// 节点ID /// public int NodeID { get { return this.GetValIntByKey(FrmPrintTemplateAttr.NodeID); } set { this.SetValByKey(FrmPrintTemplateAttr.NodeID, value); } } public string Name { get { return this.GetValStringByKey(FrmPrintTemplateAttr.Name); } set { this.SetValByKey(FrmPrintTemplateAttr.Name, value); } } public string FrmID { get { return this.GetValStringByKey(FrmPrintTemplateAttr.FrmID); } set { this.SetValByKey(FrmPrintTemplateAttr.FrmID, value); } } #endregion #region 构造函数 /// /// 打印模板 /// public FrmPrintTemplate() { } /// /// 打印模板 /// /// 主键 public FrmPrintTemplate(string mypk) : base(mypk.Replace("\n", "").Trim()) { } /// /// 获得单据文件流 /// /// /// public byte[] GenerTemplateFile() { byte[] bytes = DBAccess.GetByteFromDB(this.EnMap.PhysicsTable, "MyPK", this.MyPK, "DBFile"); if (bytes != null) return bytes; //如果没有找到,就看看默认的文件是否有. string tempExcel = BP.Difference.SystemConfig.PathOfDataUser + "CyclostyleFile/" + this.MyPK + ".rtf"; if (System.IO.File.Exists(tempExcel) == false) tempExcel = BP.Difference.SystemConfig.PathOfDataUser + "CyclostyleFile/Word单据模版定义演示.docx"; bytes = DataType.ConvertFileToByte(tempExcel); return bytes; } /// /// 重写基类方法 /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Sys_FrmPrintTemplate", "打印模板"); map.IndexField = FrmPrintTemplateAttr.FrmID; map.AddMyPK(); map.AddTBString(FrmPrintTemplateAttr.Name, null, "名称", true, false, 0, 200, 20); map.AddTBString(FrmPrintTemplateAttr.TempFilePath, null, "模板路径", true, false, 0, 200, 20); map.AddTBInt(FrmPrintTemplateAttr.NodeID, 0, "节点ID", true, false); map.AddTBString(FrmPrintTemplateAttr.FlowNo, null, "流程编号", true, false, 0, 200, 20); map.AddTBString(FrmPrintTemplateAttr.FrmID, null, "表单ID", false, false, 0, 60, 60); map.AddDDLSysEnum(FrmPrintTemplateAttr.TemplateFileModel, 0, "模版模式", true, false, FrmPrintTemplateAttr.TemplateFileModel, "@0=rtf模版@1=VSTO模式的word模版@2=VSTO模式的Excel模版@3=Wps模板"); map.AddDDLSysEnum(FrmPrintTemplateAttr.PrintFileType, 0, "生成的文件类型", true, false, "PrintFileType", "@0=Word@1=PDF@2=Excel@3=Html"); map.AddDDLSysEnum(FrmPrintTemplateAttr.PrintOpenModel, 0, "生成的文件打开方式", true, false, "PrintOpenModel", "@0=下载本地@1=在线打开"); map.AddDDLSysEnum(FrmAttachmentAttr.AthSaveWay, 0, "实例的保存方式", true, true, FrmAttachmentAttr.AthSaveWay, "@0=保存到web服务器@1=保存到数据库@2=ftp服务器@3=保存到对象存储OSS"); map.AddDDLSysEnum(FrmPrintTemplateAttr.QRModel, 0, "二维码生成方式", true, false, FrmPrintTemplateAttr.QRModel, "@0=不生成@1=生成二维码"); map.AddTBInt("Idx", 0, "Idx", false, false); this._enMap = map; return this._enMap; } } #endregion protected override bool beforeInsert() { if (DataType.IsNullOrEmpty(this.MyPK) == true) this.MyPK = DBAccess.GenerGUID(); return base.beforeInsert(); } } /// /// 打印模板s /// public class FrmPrintTemplates : EntitiesMyPK { #region 构造 /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new FrmPrintTemplate(); } } /// /// 打印模板 /// public FrmPrintTemplates() { } public FrmPrintTemplates(int nodeID) { this.Retrieve(FrmPrintTemplateAttr.NodeID, nodeID); } public FrmPrintTemplates(string flowNo) { this.Retrieve(FrmPrintTemplateAttr.FlowNo, flowNo); } #endregion #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成 java list,C#不能调用. /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } /// /// 转化成list /// /// List public System.Collections.Generic.List Tolist() { System.Collections.Generic.List list = new System.Collections.Generic.List(); for (int i = 0; i < this.Count; i++) { list.Add((FrmPrintTemplate)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }