private void InitRootTreeNode() { IOrganization innerRoot = this.Root; ServiceBrokerContext.Current.SaveContextStates(); try { if (ShowDeletedObjects) { ServiceBrokerContext.Current.UseLocalCache = false; ServiceBrokerContext.Current.ListObjectCondition = ListObjectMask.All; } if (innerRoot == null) { var tmpRootPath = this.RootPath; if (string.IsNullOrEmpty(tmpRootPath)) { tmpRootPath = OguPermissionSettings.GetConfig().RootOUPath; } innerRoot = UserOUControlSettings.GetConfig().UserOUControlQuery.GetOrganizationByPath(tmpRootPath); // OguMechanismFactory.GetMechanism().GetRoot(); } DeluxeTreeNode rootNode = new DeluxeTreeNode(); BindOguObjToTreeNode((IOrganization)OguBase.CreateWrapperObject(innerRoot), rootNode, MultiSelect, SelectMask); rootNodesData.Add(rootNode); if (RootExpanded) { rootNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; rootNode.Expanded = true; BindChildren(rootNode.Nodes, OnGetChildren(innerRoot), MultiSelect, ListMask, SelectMask); } } finally { ServiceBrokerContext.Current.RestoreSavedStates(); } }
public static List <T> ConvertToOguObjects <T>(this SCObjectAndRelationCollection relations) where T : IOguObject { relations.FillDetails(); IOguObjectFactory factory = OguPermissionSettings.GetConfig().OguObjectFactory; //Dictionary<string, SCSimpleObjectCollection> allParentsInfo = SCSnapshotAdapter.Instance.LoadAllParentsInfo(true, relations.ToParentIDArray()); List <T> objList = new List <T>(relations.Count); foreach (SCObjectAndRelation relation in relations) { SchemaObjectBase obj = relation.Detail; if (obj != null) { SchemaType schemaType = SchemaType.Unspecified; if (Enum.TryParse(obj.SchemaType, out schemaType)) { T opObj = (T)factory.CreateObject(schemaType); //SCSimpleObjectCollection parentsInfo = null; //allParentsInfo.TryGetValue(relation.ParentID, out parentsInfo); OguPropertyAdapterBase.GetConverter(opObj).Fill(opObj, obj, relation); ((IOguPropertyAccessible)opObj).FullPath = relation.FullPath; objList.Add(opObj); } } } return(objList); }
public static IOrganizationMechanism GetOrganizationMechanism() { return(OguPermissionSettings.GetConfig().OguFactory); }
public static IPermissionObjectFactory GetPermissionObjectFactory() { return(OguPermissionSettings.GetConfig().PermissionObjectFactory); }
/// <summary> /// 根据类型创建对应的对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="resultType"></param> /// <returns></returns> public static T CreateObject <T>(OP.SchemaType resultType) { return((T)OguPermissionSettings.GetConfig().OguObjectFactory.CreateObject(resultType)); }
private OguDataCollection <IOguObject> InnerCheckInputOuUser(string chkString) { //ServiceBrokerContext.Current.Timeout = QueryUserTimeout; IOrganization dept = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, OguPermissionSettings.GetConfig().RootOUPath)[0]; OguDataCollection <IOguObject> users = QueryChildrenBySelectMask(dept, chkString); OguDataCollection <IOguObject> forSelected = new OguDataCollection <IOguObject>(); for (int i = 0; i < users.Count; i++) { forSelected.Add(OguBase.CreateWrapperObject(users[i])); } if (dept.DisplayName.IndexOf(chkString) == 0) { forSelected.Add(OguBase.CreateWrapperObject(dept)); } IOrganization root = OguMechanismFactory.GetMechanism().GetRoot(); foreach (OguBase obj in forSelected) { string path = string.Empty; if (obj.Parent != null) { path = obj.Parent.FullPath; } if (path.IndexOf(root.FullPath) == 0) { path = path.Substring(root.FullPath.Length); path = path.Trim('\\'); } if (obj is IUser) { ((OguUser)obj).Description = string.Format("{0} {1}", ((OguUser)obj).Occupation, path); } else if (obj is OguOrganization) { ((OguOrganization)obj).Description = path; } else { ((OguUser)obj).Description = path; } } return(forSelected); }