internal bool UpgradeArchitectureToRemote(out Exception ex) { ex = null; int errCount = 0; try { Architecture a = this.CurrentArchitecture; List <Action> atcs = a.Acts; List <Department> deps = a.Deps; List <Module> mods = a.Mods; List <Permission> perms = a.Pers; List <Role> roles = a.Roles; List <UserGroup> ugrps = a.Ugroups; List <User> users = a.Users; ActionLogic.GetInstance().UpgradeList(atcs); DepartmentLogic.GetInstance().UpgradeList(deps); ModuleLogic.GetInstance().UpgradeList(mods); PermissionLogic.GetInstance().UpgradeList(perms); RoleLogic.GetInstance().UpgradeList(roles); UserGroupLogic.GetInstance().UpgradeList(ugrps); UserLogic.GetInstance().UpgradeList(users); } catch (Exception e) { errCount++; ex = e; } return(errCount == 0); }
public List <Role> GetAllRoles() { List <Role> roles = new List <Role>(); string sql = "select * from TF_Role"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { PermissionLogic pl = PermissionLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { Role role = new Role(); role.ID = Convert.ToInt32(dt.Rows[i]["ID"]); role.Name = dt.Rows[i]["Name"].ToString(); role.Flag = Convert.ToBoolean(dt.Rows[i]["Flag"]); role.Permissions = Common.GetPermissions(dt.Rows[i]["Permissions"].ToString(), pl); if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value) { role.Remark = dt.Rows[i]["Remark"].ToString(); } else { role.Remark = ""; } roles.Add(role); } } return(roles); }
/// <summary> /// 界面中排除权限的判断 /// </summary> /// <param name="perms"></param> /// <param name="formName"></param> /// <param name="moduleName"></param> /// <param name="actionName"></param> /// <returns></returns> public static bool ExceptControl(this List <int> perms, string formName, string moduleName, string actionName = "") { try { PermissionLogic pl = PermissionLogic.GetInstance(); foreach (int per in perms) { Tuple <bool, Tuple <string, string>, Tuple <string, string> > excModAct = pl.GetExcModAct(per); if (excModAct.Item1) { if (excModAct.Item2 != null) { if (excModAct.Item3 != null) { if (excModAct.Item2.Item1.Equals(formName, StringComparison.InvariantCultureIgnoreCase) && excModAct.Item2.Item2.Equals(moduleName, StringComparison.InvariantCultureIgnoreCase) && excModAct.Item2.Item1.Equals(excModAct.Item3.Item1, StringComparison.InvariantCultureIgnoreCase) && excModAct.Item3.Item2.Equals(actionName, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } else { if (excModAct.Item2.Item1.Equals(formName, StringComparison.InvariantCultureIgnoreCase) && excModAct.Item2.Item2.Equals(actionName, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } } } } } catch { } return(false); }
private void btn_Perm_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Permission per = new Permission(); per.ID = data[comboBox1.SelectedIndex].ID; per.Name = textBox1.Text.Trim(); per.IsExcept = checkBox1.Checked; Module mod = comboBox9.SelectedItem as Module; if (mod != null) { per.TheModule = mod; Action act = comboBox10.SelectedItem as Action; per.TheAction = act; per.Remark = textBox2.Text; PermissionLogic pl = PermissionLogic.GetInstance(); if (pl.ExistsNameOther(per.Name, per.ID)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (pl.UpdatePermission(per)) { data[comboBox1.SelectedIndex].Name = per.Name; data[comboBox1.SelectedIndex].TheModule = per.TheModule; data[comboBox1.SelectedIndex].TheAction = per.TheAction; data[comboBox1.SelectedIndex].Remark = per.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { if (pl.UpdatePermission(per)) { data[comboBox1.SelectedIndex].Name = per.Name; data[comboBox1.SelectedIndex].TheModule = per.TheModule; data[comboBox1.SelectedIndex].TheAction = per.TheAction; data[comboBox1.SelectedIndex].Remark = per.Remark; RefreshInfo(); MessageBox.Show("修改成功!"); } } } else { MessageBox.Show("请选定模块!"); } } else { MessageBox.Show("先选定要修改的项目!"); } }
public static PermissionLogic GetInstance() { if (instance == null) { instance = new PermissionLogic(); } return(instance); }
private static Architecture GetRemoteArchitecture() { Architecture a = Architecture.Empty; a.Deps = DepartmentLogic.GetInstance().GetAllDepartments(); a.Ugroups = UserGroupLogic.GetInstance().GetAllUserGroups(); a.Users = UserLogic.GetInstance().GetAllUsers(); a.Mods = ModuleLogic.GetInstance().GetAllModules(); a.Acts = ActionLogic.GetInstance().GetAllActions(); a.Pers = PermissionLogic.GetInstance().GetAllPermissions(); a.Roles = RoleLogic.GetInstance().GetAllRoles(); return(a); }
private void button9_Click(object sender, EventArgs e) { Module mod = comboBox9.SelectedItem as Module; Action act = comboBox10.SelectedItem as Action; if (mod != null) { Permission per = new Permission(); per.Name = textBox1.Text.Trim(); per.IsExcept = checkBox1.Checked; per.TheModule = mod; per.TheAction = act; per.Remark = textBox2.Text; PermissionLogic pl = PermissionLogic.GetInstance(); if (pl.ExistsName(per.Name)) { if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int id = pl.AddPermission(per); if (id > 0) { per.ID = id; data.Add(per); RefreshInfo(); MessageBox.Show("添加成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { int id = pl.AddPermission(per); if (id > 0) { per.ID = id; data.Add(per); RefreshInfo(); MessageBox.Show("添加成功!"); } } } else { MessageBox.Show("请选定模块!"); } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该项目?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { Permission per = data[comboBox1.SelectedIndex]; if (PermissionLogic.GetInstance().DeletePermission(per)) { data.RemoveAt(comboBox1.SelectedIndex); RefreshInfo(); } } } else { MessageBox.Show("先选定要删除的项目!"); } }
public static List <int> GetPermissionIds(string pers, PermissionLogic pl = null) { List <int> perms = new List <int>(); string[] ids = pers.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (pl == null) { pl = PermissionLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { perms.Add(I); } } return(perms); }
public static PermissionCollection GetPermissions(string pers, PermissionLogic pl = null) { PermissionCollection perms = new PermissionCollection(); string[] ids = pers.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (pl == null) { pl = PermissionLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { Permission perm = pl.GetPermission(I); perms.Add(perm); } } return(perms); }