using System; using System.Collections; using System.Data; using BP.DA; using BP.En; using System.Text.RegularExpressions; namespace BP.GPM { /// /// 信息块 /// public class BarAttr : EntityNoNameAttr { /// /// 信息块类型 /// public const string BarType = "BarType"; /// /// 顺序 /// public const string Idx = "Idx"; /// /// 标题 /// public const string Title = "Title"; /// /// tag1 /// public const string Tag1 = "Tag1"; /// /// Tag2 /// public const string Tag2 = "Tag2"; /// /// Tag3 /// public const string Tag3 = "Tag3"; /// /// 是否可删除 /// public const string IsDel = "IsDel"; /// /// 控制方式 /// public const string CtrlWay = "CtrlWay"; /// /// 打开方式 /// public const string OpenWay = "OpenWay"; /// /// 更多标签 /// public const string MoreLab = "MoreLab"; /// /// MoreUrl /// public const string MoreUrl = "MoreUrl"; /// /// Doc /// public const string Doc = "Doc"; /// /// 产生时间 /// public const string DocGenerRDT = "DocGenerRDT"; /// /// 显示宽度 /// public const string Width = "Width"; /// /// 显示高度 /// public const string Height = "Height"; /// /// 是否独占一行 /// public const string IsLine = "IsLine"; } /// /// 信息块 /// public class Bar : EntityNoName { /// /// 控制权限 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.IsInsert = false; return uac; } } #region 属性 /// /// 更多的URL /// public string MoreUrl { get { return this.GetValStrByKey(BarAttr.MoreUrl); } set { this.SetValByKey(BarAttr.MoreUrl, value); } } /// /// 更多标签 /// public string MoreLab { get { return this.GetValStrByKey(BarAttr.MoreLab); } set { this.SetValByKey(BarAttr.MoreLab, value); } } /// /// 标题 /// public string Title { get { return this.GetValStrByKey(BarAttr.Title); } set { this.SetValByKey(BarAttr.Title, value); } } /// /// 用户是否可以删除 /// public bool IsDel { get { return this.GetValBooleanByKey(BarAttr.IsDel); } set { this.SetValByKey(BarAttr.IsDel, value); } } /// /// 类型 /// public int BarType { get { return this.GetValIntByKey(BarAttr.BarType); } set { this.SetValByKey(BarAttr.BarType, value); } } /// /// 打开方式 /// public int OpenWay { get { return this.GetValIntByKey(BarAttr.OpenWay); } set { this.SetValByKey(BarAttr.OpenWay, value); } } /// /// 顺序号 /// public int Idx { get { return this.GetValIntByKey(BarAttr.Idx); } set { this.SetValByKey(BarAttr.Idx, value); } } /// /// Tag1 /// public string Tag1 { get { return this.GetValStrByKey(BarAttr.Tag1); } set { this.SetValByKey(BarAttr.Tag1, value); } } /// /// Tag /// public string Tag2 { get { return this.GetValStrByKey(BarAttr.Tag2); } set { this.SetValByKey(BarAttr.Tag2, value); } } public string Tag3 { get { return this.GetValStrByKey(BarAttr.Tag3); } set { this.SetValByKey(BarAttr.Tag3, value); } } public string DocGenerRDT { get { return this.GetValStrByKey(BarAttr.DocGenerRDT); } set { this.SetValByKey(BarAttr.DocGenerRDT, value); } } public string Width { get { return this.GetValStrByKey(BarAttr.Width); } set { this.SetValByKey(BarAttr.Width, value); } } public string Height { get { return this.GetValStrByKey(BarAttr.Height); } set { this.SetValByKey(BarAttr.Height, value); } } public string Doc { get { string html = ""; switch (this.BarType) { case 0: html += "\t\n"; return html; case 1: return this.Tag1; default: break; } return this.GetValStrByKey(BarAttr.Doc); } } /// /// 获取参数化的字符串 /// /// /// /// private string GetParameteredString(string stringInput, DataRow dr) { String regE = "@[a-zA-Z]([\\w-]*[a-zA-Z0-9])?"; //字母开始,字母+数字结尾,字母+数字+下划线+中划线中间 //String regE = "@[\\w-]+"; //字母+数字+下划线+中划线 MatchCollection mc = Regex.Matches(stringInput, regE, RegexOptions.IgnoreCase); foreach (Match m in mc) { string v = m.Value; string f = m.Value.Substring(1); stringInput = stringInput.Replace(v, String.Format("{0}", dr[f])); } return stringInput; } #endregion #region 构造方法 /// /// 信息块 /// public Bar() { } /// /// 信息块 /// /// public Bar(string no) { this.No = no; this.Retrieve(); } /// /// EnMap /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("GPM_Bar", "信息块"); map.setEnType(EnType.Sys); map.AddTBStringPK(BarAttr.No, null, "编号", true, false, 100, 200, 200); map.AddTBString(BarAttr.Name, null, "名称", true, false, 100, 3900, 20); map.AddTBString(BarAttr.Title, null, "标题", true, false, 0, 3900, 20); //map.AddDDLSysEnum(BarAttr.BarType, 0, "信息块类型", true, true, //BarAttr.BarType, "@0=标题消息列表(Tag1=SQL语句)@1=其它"); //map.AddTBString(BarAttr.Tag1, null, "Tag1", true, false, 0, 3900, 300,true); //map.AddTBString(BarAttr.Tag2, null, "Tag2", true, false, 0, 3900, 300, true); //map.AddTBString(BarAttr.Tag3, null, "Tag3", true, false, 0, 3900, 300, true); //map.AddBoolean(BarAttr.IsDel, true, "用户是否可删除",true,true); map.AddDDLSysEnum(BarAttr.OpenWay, 0, "打开方式", true, true, BarAttr.OpenWay, "@0=新窗口@1=本窗口@2=覆盖新窗口"); map.AddBoolean(BarAttr.IsLine, false, "是否独占一行", true, true); ////map.AddDDLSysEnum(AppAttr.CtrlWay, 0, "控制方式", true, true, //// AppAttr.CtrlWay, "@0=游客@1=所有人员@2=按岗位@3=按部门@4=按人员@5=按SQL"); //map.AddTBInt(BarAttr.Idx, 0, "显示顺序", false, true); // map.AddTBString(BarAttr.MoreLab, "更多...", "更多标签", true, false, 0, 900, 20); map.AddTBString(BarAttr.MoreUrl, null, "更多标签Url", true, false, 0, 3900, 300,true); //map.AddTBString(BarAttr.Doc, null, "Doc", false, false, 0, 3900, 20, false); //map.AddTBDateTime(BarAttr.DocGenerRDT, null, "Doc生成日期", false, false); //map.AddTBInt(BarAttr.Width, 200, "显示宽度", false, true); //map.AddTBInt(BarAttr.Height, 100, "显示高度", false, true); //map.AttrsOfOneVSM.Add(new ByStations(), new Stations(), ByStationAttr.RefObj, ByStationAttr.FK_Station, StationAttr.Name, StationAttr.No, "可访问的岗位"); //map.AttrsOfOneVSM.Add(new ByDepts(), new Depts(), ByStationAttr.RefObj, ByDeptAttr.FK_Dept, DeptAttr.Name, DeptAttr.No, "可访问的部门"); //map.AttrsOfOneVSM.Add(new ByEmps(), new Emps(), ByStationAttr.RefObj, ByEmpAttr.FK_Emp, EmpAttr.Name, EmpAttr.No, "可访问的人员"); map.AddSearchAttr(BarAttr.OpenWay); this._enMap = map; return this._enMap; } } #endregion public string GetDocument() { BarBase barBase = (BarBase)ClassFactory.GetObject_OK(this.No); if (barBase == null) { this.Delete(); return "err@已经删除."; } return barBase.Documents; } protected override void afterDelete() { string sql = "DELETE FROM GPM_BarEmp WHERE FK_Bar='" + this.No + "'"; DBAccess.RunSQL(sql); base.afterDelete(); } } /// /// 信息块s /// public class Bars : EntitiesNoName { #region 构造 /// /// 信息块s /// public Bars() { } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new Bar(); } } #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((Bar)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. public override int RetrieveAll() { //初始化数据到,表里面去. ArrayList als = ClassFactory.GetObjects("BP.GPM.BarBase"); foreach (var item in als) { if (item == null) continue; BP.GPM.BarBase en = (BP.GPM.BarBase)item; if (en == null) continue; BP.GPM.Bar bar = new Bar(); bar.No = en.No; bar.Name = en.Name; bar.Title = en.Title; bar.MoreUrl = en.More; bar.Height = en.Height; bar.Width = en.Width; bar.Save(); if (en.IsCanView == false) continue; BP.GPM.BarEmp barEmp = new BarEmp(); barEmp.setMyPK(en.No+"_"+Web.WebUser.No); int i= barEmp.RetrieveFromDBSources(); barEmp.FK_Bar = en.No; barEmp.FK_Emp = Web.WebUser.No; barEmp.IsShow = true; barEmp.Title = en.Name; if (i==0) barEmp.Insert(); } return base.RetrieveAll(); } } }