private void buttonConvert_Click(object sender, EventArgs e) { using (AD2DBInitialParams initParams = AD2DBInitialParams.GetParams()) { textBoxLog.Text = string.Empty; ServiceLog log = new ServiceLog("ADToAccredit"); log.AddTextBoxTraceListener(textBoxLog); initParams.Log = log; this._ProcessedObjectsCount = 0; OutputStatus(); initParams.BeforeProcessADObject += new BeforeProcessADObjectDelegate(initParams_BeforeProcessADObject); AD2DBConvertion converter = new AD2DBConvertion(initParams); converter.DoConvert(); OutputStatus(); OguMechanismFactory.GetMechanism().RemoveAllCache(); PermissionMechanismFactory.GetMechanism().RemoveAllCache(); } }
private void GetApplicationRole() { List <AppRoles> allRoles = new List <AppRoles>(); OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, Data.ID); ExceptionHelper.FalseThrow(users.Count > 0, "不能找到ID为\"{0}\"的用户", Data.ID); ApplicationCollection result = PermissionMechanismFactory.GetMechanism().GetAllApplications(); foreach (IApplication app in result) { RoleCollection roles = users[0].Roles[app.CodeName]; if (roles.Count > 0) { AppRoles ar = new AppRoles(); ar.AppName = app.Name; ar.Roles = GetRoleNames(roles); allRoles.Add(ar); } } gridAppRoles.DataSource = allRoles; gridAppRoles.DataBind(); }
/// <summary> /// 根据描述得到一组角色集合 /// </summary> /// <param name="rolesDesp"></param> /// <returns></returns> public static IRole[] GetRoles(string rolesDesp) { List <IRole> result = new List <IRole>(); if (string.IsNullOrEmpty(rolesDesp) == false) { AppRolesDespsCollection allAppRolesDesps = GetAppRolesDesps(rolesDesp); ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(allAppRolesDesps.GetAppNames()); foreach (AppRolesDesps appRolesDesps in allAppRolesDesps) { if (apps.ContainsKey(appRolesDesps.AppName)) { IApplication app = apps[appRolesDesps.AppName]; foreach (string roleName in appRolesDesps.RolesDesp) { if (app.Roles.ContainsKey(roleName)) { result.Add(app.Roles[roleName]); } } } } } return(result.ToArray()); }
public void OguApplicationCollectionSerializationTest() { JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter)); ApplicationCollection originalApps = PermissionMechanismFactory.GetMechanism().GetAllApplications(); OguApplicationCollection apps = new OguApplicationCollection(originalApps); CheckOguApplicationCollectionItems(apps); //测试Set操作 for (int i = 0; i < apps.Count; i++) { apps[i] = originalApps[i]; } CheckOguApplicationCollectionItems(apps); string serializedData = JSONSerializerExecute.Serialize(apps); Console.WriteLine(serializedData); OguApplicationCollection deserializedData = JSONSerializerExecute.Deserialize <OguApplicationCollection>(serializedData); for (int i = 0; i < apps.Count; i++) { ValidatePermissionObject(apps[i], deserializedData[i]); } }
/// <summary> /// /// </summary> /// <param name="argument"></param> public override void Execute(string argument) { ApplicationCollection applications = PermissionMechanismFactory.GetMechanism().GetApplications(argument); ExceptionHelper.FalseThrow(applications.Count > 0, "不能查询到CodeName为\"{0}\"应用", argument); applications[0].Permissions.ForEach(p => OutputHelper.OutputPermissionInfo(p)); }
private static IApplication GetApplicationByCodeName(string codeName) { ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName); ExceptionHelper.FalseThrow(apps.Count > 0, Translator.Translate(Define.DefaultCulture, "不能在授权系统中找到CodeName为'{0}'的应用", codeName)); return(apps[0]); }
private static IApplication GetApplicationByID(string id) { ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetAllApplications(); IApplication app = apps.Find(a => string.Compare(a.ID, id, true) == 0); ExceptionHelper.FalseThrow(app != null, Translator.Translate(Define.DefaultCulture, "不能在授权系统中找到ID为'{0}'的应用", id)); return(app); }
public OguRoleCollection GetAppRoles(string codeName) { ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName); OguRoleCollection roles = new OguRoleCollection(); if (apps.Count > 0) { roles.CopyFrom(apps[0].Roles); } return(roles); }
public void OguApplicationSerializationTest() { OguApplication app = (OguApplication)OguApplication.CreateWrapperObject(PermissionMechanismFactory.GetMechanism().GetAllApplications().First()); JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter)); string serializedData = JSONSerializerExecute.Serialize(app); Console.WriteLine(serializedData); OguApplication deserializedData = JSONSerializerExecute.Deserialize <OguApplication>(serializedData); ValidatePermissionObject(app, deserializedData); }
public override void OnThreadTaskStart() { using (AD2DBInitialParams initParams = AD2DBInitialParams.GetParams()) { initParams.Log = this.Params.Log; AD2DBConvertion converter = new AD2DBConvertion(initParams); converter.DoConvert(); OguMechanismFactory.GetMechanism().RemoveAllCache(); PermissionMechanismFactory.GetMechanism().RemoveAllCache(); } }
/// <summary> /// /// </summary> /// <param name="argument"></param> public override void Execute(string argument) { string[] arguments = argument.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); ExceptionHelper.FalseThrow(arguments.Length > 1, "参数太少,必须提供两个参数,用逗号或空格分开"); ApplicationCollection applications = PermissionMechanismFactory.GetMechanism().GetApplications(arguments[0]); ExceptionHelper.FalseThrow(applications.Count > 0, "不能查询到CodeName为\"{0}\"应用", arguments[0]); ExceptionHelper.FalseThrow(applications[0].Permissions.ContainsKey(arguments[1]), "在应用\"{0}\"中不能查询到CodeName为\"{1}\"的权限", arguments[0], arguments[1]); applications[0].Permissions[arguments[1]].RelativeRoles.ForEach(r => OutputHelper.OutputPermissionInfo(r)); }
protected override void OnDialogContentControlLoaded(Control container) { base.OnDialogContentControlLoaded(container); if (string.IsNullOrEmpty(this.DialogTitle)) { this.DialogTitle = RoleGraphControlParams.DefaultDialogTitle; } this._ApplicationSelector = (HtmlSelect)container.FindControl("applications"); this._RoleSelector = (HtmlSelect)container.FindControl("roles"); this._LoadingTag = (HtmlGenericControl)container.FindControl("loadingTag"); this._RelativeLink = (HtmlAnchor)container.FindControl("relativeLink"); HtmlGenericControl img = (HtmlGenericControl)container.FindControl("loadingImg"); if (img != null) { img.Style["background-image"] = string.Format("url({0})", ControlResources.HourglassLogoUrl); } OguApplicationCollection apps = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetAllApplications()); this._ApplicationsData = apps; if (apps.Count > 0) { string appCodeName = GetAppCodeNameFromFullCodeName(this.SelectedFullCodeName); IApplication selectedApp = null; if (string.IsNullOrEmpty(appCodeName) == false) { selectedApp = apps.Find(app => app.CodeName == appCodeName); } if (selectedApp == null) { selectedApp = apps[0]; } this._RolesData = new OguRoleCollection(selectedApp.Roles); } }
/* * protected override string GetDialogFeature() * { * WindowFeature feature = new WindowFeature(); * * feature.Width = 420; * feature.Height = 320; * feature.Center = true; * feature.Resizable = false; * feature.ShowScrollBars = false; * feature.ShowStatusBar = false; * * return feature.ToDialogFeatureClientString(); * } * */ private static OguApplicationCollection InitApplicationsData(string fullCodeName) { OguApplicationCollection result = null; string appCodeName = GetAppCodeNameFromFullCodeName(fullCodeName); if (string.IsNullOrEmpty(appCodeName)) { result = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetAllApplications()); } else { result = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetApplications(appCodeName)); if (result.Count == 0) { result = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetAllApplications()); } } return(result); }
private static ApplicationCollection GetAppCollection() { return(PermissionMechanismFactory.GetMechanism().GetAllApplications()); }
/// <summary> /// /// </summary> /// <param name="argument"></param> public override void Execute(string argument) { PermissionMechanismFactory.GetMechanism().RemoveAllCache(); Console.WriteLine("Permission cache cleared"); }
protected void ButtonRemovePermissionCache_Click(object sender, EventArgs e) { PermissionMechanismFactory.GetMechanism().RemoveAllCache(); Successful(); }
/// <summary> /// /// </summary> /// <param name="argument"></param> public override void Execute(string argument) { PermissionMechanismFactory.GetMechanism().GetAllApplications().ToList().ForEach( obj => OutputHelper.OutputPermissionInfo(obj)); }