using System; using System.Data; using System.Collections; using BP.DA; using BP.En; using BP; namespace BP.Sys { /// /// 数据版本 /// public class FrmDBVerAttr { /// /// 名称 /// public const string FrmID = "FrmID"; /// /// 用户名 /// public const string Ver = "Ver"; /// /// 主键值 /// public const string RefPKVal = "RefPKVal"; /// /// 记录人 /// public const string RecNo = "RecNo"; /// /// 记录人姓名 /// public const string RecName = "RecName"; /// /// 记录日期 /// public const string RDT = "RDT"; /// /// 轨迹ID /// public const string TrackID = "TrackID"; /// /// 修改的字段 /// public const string ChangeFields = "ChangeFields"; /// /// 修改的字段数量 /// public const string ChangeNum = "ChangeNum"; /// /// 字段(章节表单有效) /// public const string KeyOfEn = "KeyOfEn"; } /// /// 数据版本 /// public class FrmDBVer : EntityMyPK { #region 基本属性 /// /// 权限控制 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.Readonly(); uac.IsView = false; return uac; } } public string TrackID { get { return this.GetValStringByKey(FrmDBVerAttr.TrackID); } set { this.SetValByKey(FrmDBVerAttr.TrackID, value); } } public string KeyOfEn { get { return this.GetValStringByKey(FrmDBVerAttr.KeyOfEn); } set { this.SetValByKey(FrmDBVerAttr.KeyOfEn, value); } } public string FrmID { get { return this.GetValStringByKey(FrmDBVerAttr.FrmID); } set { this.SetValByKey(FrmDBVerAttr.FrmID, value); } } /// /// 主键值键 /// public string RefPKVal { get { return this.GetValStringByKey(FrmDBVerAttr.RefPKVal); } set { this.SetValByKey(FrmDBVerAttr.RefPKVal, value); } } /// /// FK_Emp /// public string RecNo { get { return this.GetValStringByKey(FrmDBVerAttr.RecNo); } set { this.SetValByKey(FrmDBVerAttr.RecNo, value); } } public string RecName { get { return this.GetValStringByKey(FrmDBVerAttr.RecName); } set { this.SetValByKey(FrmDBVerAttr.RecName, value); } } public string RDT { get { return this.GetValStringByKey(FrmDBVerAttr.RDT); } set { this.SetValByKey(FrmDBVerAttr.RDT, value); } } public int Ver { get { return this.GetValIntByKey(FrmDBVerAttr.Ver); } set { this.SetValByKey(FrmDBVerAttr.Ver, value); } } #endregion #region 构造方法 /// /// 数据版本 /// public FrmDBVer() { } public FrmDBVer(string mypk) { this.MyPK = mypk; this.Retrieve(); } /// /// EnMap /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Sys_FrmDBVer", "数据版本"); map.AddMyPK(); map.AddTBString(FrmDBVerAttr.FrmID, null, "表单ID", true, true, 0, 100, 20); map.AddTBString(FrmDBVerAttr.RefPKVal, null, "主键值", true, true, 0, 40, 20); map.AddTBString(FrmDBVerAttr.ChangeFields, null, "修改的字段", true, true, 0, 3900, 20); map.AddTBInt(FrmDBVerAttr.ChangeNum, 0, "修改的字段数量", true, true); map.AddTBString(FrmDBVerAttr.TrackID, null, "TrackID", true, true, 0, 40, 20); map.AddTBString(FrmDBVerAttr.RecNo, null, "记录人", true, true, 0, 30, 20); map.AddTBString(FrmDBVerAttr.RecName, null, "用户名", true, true, 0, 30, 20); map.AddTBDateTime(FrmDBVerAttr.RDT, null, "记录时间", true, true); map.AddTBInt(FrmDBVerAttr.Ver, 0, "版本号", true, true); map.AddTBString(FrmDBVerAttr.KeyOfEn, null, "章节字段有效", true, true, 0, 100, 20); this._enMap = map; return this._enMap; } } #endregion #region 增加版本. /// /// 增加主表、从表的数据 /// /// 表单ID /// 关联值 /// /// /// /// /// 是否章节表单? public static void AddFrmDBTrack(int ver,string frmID, string refPKVal, string trackID, string jsonOfFrmDB, string frmDtlDB,string frmAthDB, bool isChartFrm = false) { if (jsonOfFrmDB == null && isChartFrm == false) return; FrmDBVer en = new FrmDBVer(); en.FrmID = frmID; en.RefPKVal = refPKVal; en.TrackID = trackID; en.Ver = ver; en.Insert(); //保存主表数据. if (DataType.IsNullOrEmpty(jsonOfFrmDB) == false) DBAccess.SaveBigTextToDB(jsonOfFrmDB, "Sys_FrmDBVer", "MyPK", en.MyPK, "FrmDB"); //保存从表数据 if(DataType.IsNullOrEmpty(frmDtlDB)==false) DBAccess.SaveBigTextToDB(frmDtlDB, "Sys_FrmDBVer", "MyPK", en.MyPK, "FrmDtlDB"); //保存附件数据 if (DataType.IsNullOrEmpty(frmAthDB) == false) DBAccess.SaveBigTextToDB(frmAthDB, "Sys_FrmDBVer", "MyPK", en.MyPK, "FrmAthDB"); } /// /// 保存章节表单的字段数据 /// /// /// /// /// /// public static void AddKeyOfEnDBTrack(int ver,string frmID, string refPKVal, string trackID, string chartValue, string keyOfEn) { FrmDBVer en = new FrmDBVer(); en.FrmID = frmID; en.RefPKVal = refPKVal; en.TrackID = trackID; en.KeyOfEn=keyOfEn; en.Ver = ver; en.Insert(); //保存章节表单字段的数据. DBAccess.SaveBigTextToDB(chartValue, "Sys_FrmDBVer", "MyPK", en.MyPK, "FrmDB"); } protected override bool beforeInsert() { this.setMyPK(DBAccess.GenerGUID()); this.SetValByKey(FrmDBVerAttr.RDT, DataType.CurrentDateTime); if (DataType.IsNullOrEmpty(this.RecNo) == true) { this.RecNo = BP.Web.WebUser.No; this.RecName = BP.Web.WebUser.Name; } return base.beforeInsert(); } #endregion 增加版本. #region 重写 public override Entities GetNewEntities { get { return new FrmDBVers(); } } #endregion 重写 } /// /// 数据版本s /// public class FrmDBVers : EntitiesMyPK { /// /// 获得章节表单的版本. /// /// /// /// public string ChapterFrmDBVers(string frmID, string workID) { string sql = " SELECT DISTINCT Ver,RDT,RecName FROM Sys_FrmDBVer WHERE FrmID = '" + frmID + "' AND RefPKVal='" + workID + "' Group BY Ver,RDT,RecName ORDER BY RDT"; DataTable dt = DBAccess.RunSQLReturnTable(sql); // dt.Columns.Add("MaxVer"); //最大版本. if (BP.Difference.SystemConfig.AppCenterDBFieldCaseModel != FieldCaseModel.None) { dt.Columns[0].ColumnName = "Ver"; //版本号 dt.Columns[1].ColumnName = "RDT"; dt.Columns[2].ColumnName = "RecName"; } return BP.Tools.Json.ToJson(dt); } #region 构造 public FrmDBVers() { } #endregion #region 重写 /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new FrmDBVer(); } } #endregion #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成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((FrmDBVer)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. #region 为了适应自动翻译成java的需要,把实体转换成IList, c#代码调用会出错误。 /// /// 转化成list /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } #endregion 为了适应自动翻译成java的需要,把实体转换成IList, c#代码调用会出错误。 } }