using System; using System.Collections; using BP.Sys; using BP.DA; using BP.En; namespace BP.GPM { /// /// 系统 /// public class AppAttr : EntityNoNameAttr { /// /// 顺序 /// public const string Idx = "Idx"; /// /// 应用类型 /// public const string AppModel = "AppModel"; /// /// UrlExt /// public const string UrlExt = "UrlExt"; /// /// SubUrl /// public const string SubUrl = "SubUrl"; /// /// 是否启用. /// public const string IsEnable = "IsEnable"; /// /// FK_AppSort /// public const string FK_AppSort = "FK_AppSort"; /// /// 关联菜单编号 /// public const string RefMenuNo = "RefMenuNo"; /// /// 用户控件ID /// public const string UidControl = "UidControl"; /// /// 密码控件ID /// public const string PwdControl = "PwdControl"; /// /// 提交方式 /// public const string ActionType = "ActionType"; /// /// 登录方式 /// public const string SSOType = "SSOType"; /// /// 备注 /// public const string AppRemark = "AppRemark"; public const string OpenWay = "OpenWay"; } /// /// 系统 /// public class App : EntityNoName { #region 属性 /// /// 打开方式 /// public string OpenWay { get { int openWay = 0; switch (openWay) { case 0: return "_blank"; case 1: return this.No; default: return ""; } } } /// /// 路径 /// public string WebPath { get { return this.GetValStringByKey("WebPath"); } } /// /// ICON /// public string ICON { get { return this.WebPath; } set { this.SetValByKey("ICON", value); } } /// /// 连接 /// public string Url { get { string url = this.GetValStrByKey(AppAttr.UrlExt); if (DataType.IsNullOrEmpty(url)) return ""; if (this.SSOType.Equals("0"))//SID验证 { string SID = DBAccess.RunSQLReturnStringIsNull("SELECT SID FROM Port_Emp WHERE No='" + Web.WebUser.No + "'", null); if (url.Contains("?")) url += "&UserNo=" + Web.WebUser.No + "&Token=" + SID; else url += "?UserNo=" + Web.WebUser.No + "&Token=" + SID; } return url; } set { this.SetValByKey(AppAttr.UrlExt, value); } } /// /// 跳转连接 /// public string SubUrl { get { return this.GetValStrByKey(AppAttr.SubUrl); } set { this.SetValByKey(AppAttr.UrlExt, value); } } /// /// 是否启用 /// public bool IsEnable { get { return this.GetValBooleanByKey(AppAttr.IsEnable); } set { this.SetValByKey(AppAttr.IsEnable, value); } } /// /// 顺序 /// public int Idx { get { return this.GetValIntByKey(AppAttr.Idx); } set { this.SetValByKey(AppAttr.Idx, value); } } /// /// 用户控件ID /// public string UidControl { get { return this.GetValStrByKey(AppAttr.UidControl); } set { this.SetValByKey(AppAttr.UidControl, value); } } /// /// 密码控件ID /// public string PwdControl { get { return this.GetValStrByKey(AppAttr.PwdControl); } set { this.SetValByKey(AppAttr.PwdControl, value); } } /// /// 提交方式 /// public string ActionType { get { return this.GetValStrByKey(AppAttr.ActionType); } set { this.SetValByKey(AppAttr.ActionType, value); } } /// /// 登录方式@0=SID验证@1=连接@2=表单提交 /// public string SSOType { get { return this.GetValStrByKey(AppAttr.SSOType); } set { this.SetValByKey(AppAttr.SSOType, value); } } public string FK_AppSort { get { return this.GetValStringByKey(AppAttr.FK_AppSort); } set { this.SetValByKey(AppAttr.FK_AppSort, value); } } public string RefMenuNo { get { return this.GetValStringByKey(AppAttr.RefMenuNo); } set { this.SetValByKey(AppAttr.RefMenuNo, value); } } #endregion #region 按钮权限控制 public override UAC HisUAC { get { UAC uac = new UAC(); uac.OpenForAppAdmin(); return uac; } } #endregion #region 构造方法 /// /// 系统 /// public App() { } /// /// 系统 /// /// public App(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_App", "系统"); map.DepositaryOfEntity = Depositary.None; map.DepositaryOfMap = Depositary.Application; map.AddTBStringPK(AppAttr.No, null, "编号", true, false, 2, 30, 100); map.AddDDLSysEnum(AppAttr.AppModel, 0, "应用类型", true, true, AppAttr.AppModel, "@0=BS系统@1=CS系统"); map.AddTBString(AppAttr.Name, null, "名称", true, false, 0, 3900, 150, true); map.AddDDLEntities(AppAttr.FK_AppSort, null, "类别", new AppSorts(), false); map.AddBoolean(AppAttr.IsEnable, true, "启用?", true, true); //map.AddTBString(AppAttr.UrlExt, null, "默认连接", true, false, 0, 3900, 100, true); //map.AddTBString(AppAttr.SubUrl, null, "第二连接", true, false, 0, 3900, 100, true); //map.AddTBString(AppAttr.UidControl, null, "用户名控件", true, false, 0, 100, 100); //map.AddTBString(AppAttr.PwdControl, null, "密码控件", true, false, 0, 100, 100); //map.AddDDLSysEnum(AppAttr.ActionType, 0, "提交类型", true, true, AppAttr.ActionType, "@0=GET@1=POST"); //map.AddDDLSysEnum(AppAttr.SSOType, 0, "登录方式", true, true, AppAttr.SSOType, "@0=SID验证@1=连接@2=表单提交@3=不传值"); //map.AddDDLSysEnum(AppAttr.OpenWay, 0, "打开方式", true, true, AppAttr.OpenWay, // "@0=新窗口@1=本窗口@2=覆盖新窗口"); map.AddTBString(AppAttr.RefMenuNo, null, "关联菜单编号", true, false, 0, 300, 100); map.AddTBString(AppAttr.AppRemark, null, "备注", true, false, 0, 500, 100, true); map.AddTBInt(AppAttr.Idx, 0, "显示顺序", true, false); map.AddMyFile("ICON"); //增加查询条件. map.AddSearchAttr(AppAttr.FK_AppSort); RefMethod rm = new RefMethod(); rm.Title = "编辑菜单"; rm.ClassMethodName = this.ToString() + ".DoMenu"; rm.RefMethodType = RefMethodType.LinkeWinOpen; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "查看可访问该系统的人员"; rm.ClassMethodName = this.ToString() + ".DoWhoCanUseApp"; //map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "刷新设置"; rm.ClassMethodName = this.ToString() + ".DoRef"; //map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "第二连接"; //rm.Title = "第二连接:登录方式为不传值、连接不设置用户名密码转为第二连接。"; rm.ClassMethodName = this.ToString() + ".About"; // map.AddRefMethod(rm); this._enMap = map; return this._enMap; } } #endregion protected override bool beforeDelete() { Menu appMenu = new Menu(this.RefMenuNo); if (appMenu != null && appMenu.Flag.Contains("Flow")) throw new Exception("@删除失败,此项为工作流菜单,不能删除。"); // 删除该系统. Menu menu = new Menu(); menu.Delete(MenuAttr.FK_App, this.No); // 删除用户数据. EmpMenu em = new EmpMenu(); em.Delete(MenuAttr.FK_App, this.No); //EmpApp ea = new EmpApp(); //ea.Delete(MenuAttr.FK_App, this.No); return base.beforeDelete(); } protected override bool beforeUpdate() { if (DataType.IsNullOrEmpty(this.RefMenuNo) == false) { //系统类别 AppSort appSort = new AppSort(this.FK_AppSort); Menu menu = new Menu(this.RefMenuNo); menu.Name = this.Name; menu.ParentNo = appSort.RefMenuNo; menu.Update(); } return base.beforeUpdate(); } public void CheckPTable() { AppSort sort = new AppSort(); sort.CheckPhysicsTable(); App app = new App(); app.CheckPhysicsTable(); Menu en = new Menu(); en.CheckPhysicsTable(); } protected override bool beforeInsert() { CheckPTable(); if (DataType.IsNullOrEmpty(this.Name) == true) throw new Exception("err@系统名称不能为空."); AppSort sort = new AppSort(); sort.No = this.FK_AppSort; sort.Retrieve(); //求系统类别的菜单. Menu menu = new Menu(sort.RefMenuNo); // 创建子菜单. 系统的根目录. Menu appMenu = menu.DoCreateSubNode() as Menu; appMenu.FK_App = this.No; appMenu.Name = this.Name; appMenu.HisMenuType = MenuType.App; appMenu.Update(); //设置相关的菜单编号. this.RefMenuNo = appMenu.No; #region 为该系统创建几个空白菜单 Menu dir = appMenu.DoCreateSubNode() as Menu; dir.FK_App = this.No; dir.Name = "流程管理"; dir.MenuType = MenuType.Dir; dir.Update(); menu = dir.DoCreateSubNode() as Menu; menu.Name = "发起"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Start.htm"; menu.ParentNo = dir.No; menu.Update(); menu = dir.DoCreateSubNode() as Menu; menu.Name = "待办"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Todolist.htm"; menu.ParentNo = dir.No; menu.Update(); menu = dir.DoCreateSubNode() as Menu; menu.Name = "在途"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Runing.htm"; menu.ParentNo = dir.No; menu.Update(); #endregion Menu dir2 = appMenu.DoCreateSubNode() as Menu; dir2.FK_App = this.No; dir2.Name = "系统管理"; dir2.MenuType = MenuType.Dir; dir2.Update(); menu = dir2.DoCreateSubNode() as Menu; menu.Name = "部门"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Comm/Tree.htm?EnsName=BP.GPM.Depts"; menu.ParentNo = dir2.No; menu.Update(); menu = dir2.DoCreateSubNode() as Menu; menu.Name = "人员"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Comm/Search.htm?EnsName=BP.GPM.Emps"; menu.ParentNo = dir2.No; menu.Update(); menu = dir2.DoCreateSubNode() as Menu; menu.Name = "岗位"; menu.FK_App = this.No; menu.MenuType = MenuType.Menu; menu.UrlExt = "/WF/Comm/Search.htm?EnsName=BP.Port.Stations"; menu.ParentNo = dir2.No; menu.Update(); return base.beforeInsert(); } /// /// 为BPM初始化菜单. /// public static void InitBPMMenu() { AppSort sort = new AppSort(); sort.No = "01"; if (sort.RetrieveFromDBSources() == 0) { sort.Name = "应用系统"; sort.RefMenuNo = "2000"; sort.Insert(); } App app = new App(); app.No = "农芯BPM"; app.Name = "BPM系统"; app.FK_AppSort = "01"; app.Insert(); } /// /// 信息介绍 /// /// public string About() { return null; } /// /// 打开菜单 /// /// public string DoMenu() { return "../../../WF/Comm/Tree.htm?EnsName=BP.GPM.Menus&ParentNo=" + this.RefMenuNo; } /// /// 刷新数据. /// public void RefData() { //删除数据. EmpMenus mymes = new EmpMenus(); mymes.Delete(EmpMenuAttr.FK_App, this.No); //删除系统. EmpApps empApps = new EmpApps(); empApps.Delete(EmpMenuAttr.FK_App, this.No); //查询出来菜单. Menus menus = new Menus(); menus.Retrieve(EmpMenuAttr.FK_App, this.No); //查询出来人员. Emps emps = new Emps(); emps.RetrieveAllFromDBSource(); foreach (Emp emp in emps) { #region 初始化系统访问权限. EmpApp me = new EmpApp(); me.Copy(this); me.FK_Emp = emp.No; me.FK_App = this.No; me.setMyPK(this.No + "_" + me.FK_Emp); me.Insert(); #endregion 初始化系统访问权限. } } } /// /// 系统s /// public class Apps : EntitiesNoName { #region 构造 /// /// 系统s /// public Apps() { } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new App(); } } #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((App)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }