public IEnumerable <IOguObject> GetChildren(IOrganization parent) { SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(SchemaInfo.FilterByCategory("Users", "Groups", "Organizations").ToSchemaNames(), new string[] { parent.ID }, false, true, false, DateTime.MinValue); relations.FillDetails(); var parentList = SCSnapshotAdapter.Instance.LoadAllParentsInfo(true, parent.ID)[parent.ID]; StringBuilder strB = new StringBuilder(parentList.Count * 15); for (int i = 0; i < parentList.Count; i++) { strB.Append(parentList[i].Name); strB.Append(""); } var parentPath = strB.ToString(); foreach (var item in relations) { OguBase ogu = (OguBase)item.Detail.ToPhantom(); ogu.FullPath = parentPath + ogu.Name; yield return(ogu); } }
public void QueryDirectChildrenTest() { SCUser user = SCObjectGenerator.PrepareUserObject(); string ticks = DateTime.Now.Ticks.ToString(); SCOrganization parent3 = SCObjectGenerator.PrepareOrganizationObject("第三组织" + ticks, "第三组织"); SCObjectOperations.Instance.AddOrganization(parent3, SCOrganization.GetRoot()); SCOrganization parent32 = SCObjectGenerator.PrepareOrganizationObject("第三.二组织" + ticks, "第三.二组织"); SCObjectOperations.Instance.AddOrganization(parent32, parent3); SCUser user3 = SCObjectGenerator.PrepareUserObject("李", "琪" + ticks, "liqi"); SCObjectOperations.Instance.AddUser(user3, parent32); string path = string.Format(@"第三组织{0}\第三.二组织{0}\李琪{0}", ticks); SCObjectAndRelationCollection result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(new string[0], new string[] { parent32.ID }, false, true, false, DateTime.MinValue); result.Sort((x, y) => (int)(x.InnerSort - y.InnerSort)); result.FillDetails(); Assert.IsTrue(result.Count > 0); Console.WriteLine(result[0].Detail.Properties.GetValue("Name", string.Empty)); Assert.AreEqual(user3.ID, result[0].Detail.ID); }
private static void FillOrganizationChildren <T>(string parentID, bool includeSideline, SearchLevel searchLevel, List <T> result) where T : IOguObject { SCObjectAndRelationCollection relations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(typeof(T).ToSchemaTypes(), new string[] { parentID }, false, includeSideline, Util.GetContextIncludeDeleted(), DateTime.MinValue); relations.Sort((x, y) => Math.Sign(x.InnerSort - y.InnerSort)); List <T> tempResult = relations.ConvertToOguObjects <T>(); tempResult.ForEach(obj => result.Add(obj)); if (searchLevel == SearchLevel.SubTree) { // 先将下级组织查询出来 SCObjectAndRelationCollection subRelations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(typeof(IOrganization).ToSchemaTypes(), new string[] { parentID }, false, includeSideline, Util.GetContextIncludeDeleted(), DateTime.MinValue); subRelations.Sort((x, y) => Math.Sign(x.InnerSort - y.InnerSort)); List <IOrganization> tempSubResult = subRelations.ConvertToOguObjects <IOrganization>(); foreach (IOrganization obj in tempSubResult) { FillOrganizationChildren(obj.ID, includeSideline, searchLevel, result); } } }
public DataSet GetUserRoles2(string userValue, string appCodeName, UserValueType userValueType, RightMaskType rightMask, DelegationMaskType delegationMask, bool includeMatrixUsers) { string[] schemaTypes = SchemaInfo.FilterByCategory("Roles").ToSchemaNames(); string[] userIDs = OGUReaderService.SplitObjectValues(userValue); SCObjectAndRelationCollection users = OGUReaderService.GetSearchAdapter(GetSearchOUIDType(userValueType), SchemaInfo.FilterByCategory("Users").ToSchemaNames(), userIDs, false).QueryObjectsAndRelations(); SchemaObjectCollection roles = SCSnapshotAdapter.Instance.QueryUserBelongToRoles(schemaTypes, appCodeName, users.ToIDArray(), false, DateTime.MinValue); if (includeMatrixUsers) { List <string> matachedRoleIDs = GetUserRoleIDsInMatrix(users.ToIDArray(), appCodeName); //过滤掉已经在之前查询过的角色 matachedRoleIDs = matachedRoleIDs.FindAll(rID => roles.ContainsKey(rID) == false); if (matachedRoleIDs.Count > 0) { InSqlClauseBuilder matrixRoleBuilder = new InSqlClauseBuilder("ID"); matrixRoleBuilder.AppendItem(matachedRoleIDs.ToArray()); SchemaObjectCollection rolesInMatrix = SchemaObjectAdapter.Instance.Load(matrixRoleBuilder, DateTime.MinValue); rolesInMatrix.ForEach(rMatrix => roles.AddNotExistsItem(rMatrix, (r) => string.Compare(r.ID, rMatrix.ID, true) == 0)); } } DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetAppObjectTableBuilder(schemaTypes).Convert(roles)); return(ds); }
/// <summary> /// 在子对象进行查询(所有级别深度) /// </summary> /// <typeparam name="T">期望的类型</typeparam> /// <param name="parent">父机构对象</param> /// <param name="matchString">模糊查询的字符串</param> /// <param name="includeSideLine">是否包含兼职的人员</param> /// <param name="level">查询的深度</param> /// <param name="returnCount">返回的记录数</param> /// <returns>得到查询的子对象</returns> public OguObjectCollection <T> QueryChildren <T>(IOrganization parent, string matchString, bool includeSideLine, SearchLevel level, int returnCount) where T : IOguObject { //SCObjectAndRelationCollection objRelations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByKeyword(parent.ID, matchString, null, returnCount, level == SearchLevel.SubTree, DateTime.MinValue); //TODO: 修改正确 SCObjectAndRelationCollection objRelations = PC.Adapters.SCSnapshotAdapter.Instance.QueryObjectAndRelationByKeywordAndParentIDs(new string[] { "Users", "Groups", "Organizations", "Applications", "Permissions", "Roles", "Conditions" }, new string[] { parent.ID }, matchString, returnCount, level == SearchLevel.SubTree, true, false, DateTime.MinValue); return(GetObjects <T>(SearchOUIDType.Guid, objRelations.ToIDArray())); }
protected void tree_GetChildrenData(MCS.Web.WebControls.DeluxeTreeNode parentNode, MCS.Web.WebControls.DeluxeTreeNodeCollection result, string callBackContext) { string[] schemaTypes = this.Request.QueryString.GetValues("schemaType") ?? DefaultSearchSchemas; HashSet <string> union = new HashSet <string>(schemaTypes); union.UnionWith(alwaysVisibleSchemaObjects); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(union.ToArray(), new string[] { parentNode.Value }, false, false, false, Util.GetTime()); BindObjectsToTreeNodes(relations, result, schemaTypes); }
private static void BindObjectsToTreeNodes(SCObjectAndRelationCollection relations, DeluxeTreeNodeCollection nodes) { relations.Sort((m, n) => m.InnerSort.CompareTo(n.InnerSort)); foreach (SCObjectAndRelation r in relations) { if (Util.IsOrganization(r.SchemaType)) { DeluxeTreeNode newTreeNode = CreateTreeNode(r.ID, r.Name, r.DisplayName, r.FullPath); nodes.Add(newTreeNode); } } }
public DataSet GetRootDSE() { SCObjectAndRelationCollection root = new SCObjectAndRelationCollection() { SCObjectAndRelation.GetRoot() }; DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetOguTableBuilder(new string[] { "Organizations" }).Convert(root)); return(ds); }
public DataSet GetUserPermissions(string userValue, string appCodeName, UserValueType userValueType, RightMaskType rightMask, DelegationMaskType delegationMask) { string[] schemaTypes = SchemaInfo.FilterByCategory("Roles").ToSchemaNames(); string[] userIDs = OGUReaderService.SplitObjectValues(userValue); SCObjectAndRelationCollection users = OGUReaderService.GetSearchAdapter(GetSearchOUIDType(userValueType), SchemaInfo.FilterByCategory("Users").ToSchemaNames(), userIDs, false).QueryObjectsAndRelations(); SchemaObjectCollection roles = SCSnapshotAdapter.Instance.QueryUserBelongToPermissions(schemaTypes, appCodeName, users.ToIDArray(), false, DateTime.MinValue); DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetAppObjectTableBuilder(schemaTypes).Convert(roles)); return(ds); }
/// <summary> /// 将SchemaObject转换为DataTable /// </summary> /// <param name="obj"></param> /// <returns></returns> public DataTable Convert(SCObjectAndRelationCollection relations) { DataTable table = CreateTable(); relations.FillDetails(); foreach (SCObjectAndRelation obj in relations) { DataRow row = table.NewRow(); FillPropertiesToTable(obj, row); table.Rows.Add(row); } return table; }
private static void BindObjectsToTreeNodes(SCObjectAndRelationCollection relations, DeluxeTreeNodeCollection nodes, string[] schemaTypes) { HashSet <string> filter = new HashSet <string>(schemaTypes); relations.Sort((m, n) => m.InnerSort.CompareTo(n.InnerSort)); foreach (SCObjectAndRelation r in relations) { DeluxeTreeNode newTreeNode = CreateTreeNode(r.ID, r.Name, r.DisplayName, r.FullPath, r.SchemaType); if (filter.Contains(r.SchemaType) == false) { newTreeNode.ShowCheckBox = false; newTreeNode.Checked = false; } nodes.Add(newTreeNode); } }
/// <summary> /// 将SchemaObject转换为DataTable /// </summary> /// <param name="obj"></param> /// <returns></returns> public DataTable Convert(SCObjectAndRelationCollection relations) { DataTable table = CreateTable(); relations.FillDetails(); foreach (SCObjectAndRelation obj in relations) { DataRow row = table.NewRow(); FillPropertiesToTable(obj, row); table.Rows.Add(row); } return(table); }
public DataSet GetChildrenInRoles(string orgRoot, string appCodeName, string roleCodeNames, bool doesMixSort, bool doesSortRank, bool includeDelegate) { string[] schemaTypes = SchemaInfo.FilterByCategory("Roles").ToSchemaNames(); string[] roleIDs = OGUReaderService.SplitObjectValues(roleCodeNames); bool removeDuplicateData = GetMethodSettingAttributeValue("GetChildrenInRoles", "removeDuplicateData", false); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryRolesContainsMembers(schemaTypes, appCodeName, roleIDs, removeDuplicateData, false, DateTime.MinValue); relations.FillDetails(); DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetOguTableBuilder(new string[] { "OguObject" }).Convert(relations)); return(ds); }
/// <summary> /// 填充矩阵中的角色成员 /// </summary> /// <param name="relations"></param> /// <param name="schemaTypes"></param> /// <param name="roleIDs"></param> private static void FillRoleMatrixRelations(SCObjectAndRelationCollection relations, string[] schemaTypes, string[] roleIDs) { SchemaObjectCollection roles = SchemaObjectAdapter.Instance.LoadByCodeNameAndSchema(schemaTypes, roleIDs, true, false, DateTime.MinValue); List <string> matrixUserIDs = SOARolePropertiesAdapter.Instance.RoleContainsOperatorIDsDirectly(roles.ToIDArray()); if (matrixUserIDs.Count > 0) { InSqlClauseBuilder matrixUserIDBuilder = new InSqlClauseBuilder("SC.ID"); matrixUserIDBuilder.AppendItem(matrixUserIDs.ToArray()); SCObjectAndRelationCollection matrixUserRelations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByBuilder(matrixUserIDBuilder, false, DateTime.MinValue, -1); matrixUserRelations.ForEach(mr => relations.AddNotExistsItem(mr, (r) => string.Compare(r.ID, mr.ID, true) == 0)); } }
public DataSet GetUserPermissions2(string userValue, string appCodeName, UserValueType userValueType, RightMaskType rightMask, DelegationMaskType delegationMask, bool includeMatrixUsers) { string[] schemaTypes = SchemaInfo.FilterByCategory("Roles").ToSchemaNames(); string[] userIDs = OGUReaderService.SplitObjectValues(userValue); SCObjectAndRelationCollection users = OGUReaderService.GetSearchAdapter(GetSearchOUIDType(userValueType), SchemaInfo.FilterByCategory("Users").ToSchemaNames(), userIDs, false).QueryObjectsAndRelations(); SchemaObjectCollection permissions = SCSnapshotAdapter.Instance.QueryUserBelongToPermissions(schemaTypes, appCodeName, users.ToIDArray(), false, DateTime.MinValue); if (includeMatrixUsers) { string[] permissionTypes = SchemaInfo.FilterByCategory("Permissions").ToSchemaNames(); List <string> roleIDsInMatrix = GetUserRoleIDsInMatrix(users.ToIDArray(), appCodeName); SCObjectAndRelationCollection permissionsInMatrixRelation = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(permissionTypes, roleIDsInMatrix.ToArray(), false, true, false, DateTime.MinValue); InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("ID"); List <string> permissionInMatrixIDs = new List <string>(); foreach (SCObjectAndRelation pim in permissionsInMatrixRelation) { if (permissions.ContainsKey(pim.ID) == false) { inBuilder.AppendItem(pim.ID); } } if (inBuilder.IsEmpty == false) { SchemaObjectCollection permissionsInMatrix = SchemaObjectAdapter.Instance.Load(inBuilder, DateTime.MinValue); permissions.CopyFrom(permissionsInMatrix); } } DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetAppObjectTableBuilder(schemaTypes).Convert(permissions)); return(ds); }
public void DeleteRoleTest() { SCApplication application = SCObjectGenerator.PrepareApplicationObject(); SCObjectOperations.Instance.AddApplication(application); SCRole role = SCObjectGenerator.PrepareRoleObject(); SCObjectOperations.Instance.AddRole(role, application); Console.WriteLine("RoleID: {0}", role.ID); SCUser user1 = SCObjectGenerator.PrepareUserObject("RU1", "User1", "RoleUser1"); SCUser user2 = SCObjectGenerator.PrepareUserObject("RU2", "User2", "RoleUser2"); SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot()); SCObjectOperations.Instance.AddUser(user2, SCOrganization.GetRoot()); SCObjectOperations.Instance.AddMemberToRole(user1, role); SCObjectOperations.Instance.AddMemberToRole(user2, role); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryRolesContainsMembers(new string[] { "Roles" }, new string[] { role.ID }, false, DateTime.MinValue); Assert.AreEqual(role.CurrentMembers.Count, relations.Count); SCObjectOperations.Instance.DeleteRole(role); Assert.AreEqual(0, application.CurrentRoles.Count); Assert.AreEqual(0, user1.CurrentRoles.Count); Assert.AreEqual(0, user2.CurrentRoles.Count); SCObjectAndRelationCollection relationDeleted = SCSnapshotAdapter.Instance.QueryRolesContainsMembers(new string[] { "Roles" }, new string[] { role.ID }, false, DateTime.MinValue); Assert.AreEqual(role.CurrentMembers.Count, relationDeleted.Count); SameContainerUserAndContainerSnapshotCollection containsUsers = UserAndContainerSnapshotAdapter.Instance.LoadByContainerID(role.ID); containsUsers.ForEach(u => Assert.AreEqual(SchemaObjectStatus.Deleted, u.Status)); }
protected override System.Collections.IEnumerable ExecuteSelect(System.Web.UI.DataSourceSelectArguments arguments) { // SchemaOrgQueryDataSource src = new SchemaOrgQueryDataSource(); // var view = src.GetChildrenView(SCOrganization.RootOrganizationID); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { SCOrganization.RootOrganizationID }, false, true, false, Util.GetTime()); foreach (var item in relations) { if (Util.IsOrganization(item.SchemaType)) { yield return(new SCSimpleObject() { DisplayName = item.DisplayName, Name = item.Name, ID = item.ID, SchemaType = item.SchemaType, Status = item.Status, }); } } }
public void QueryGroupMembersTest() { SCGroup group = SCObjectGenerator.PrepareGroupObject(); SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot()); SCUser user1 = SCObjectGenerator.PrepareUserObject(); SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot()); SCMemberRelation mr = SCObjectOperations.Instance.AddUserToGroup(user1, group); SCObjectAndRelationCollection result = SCSnapshotAdapter.Instance.QueryContainerContainsUsersByIDs(new string[] { "Groups" }, new string[] { group.ID }, false, DateTime.MinValue); Assert.IsTrue(result.Count > 0); result.FillDetails(); Console.WriteLine(result[0].Detail.Properties.GetValue("Name", string.Empty)); Console.WriteLine(result[0].ParentID); Assert.AreEqual(user1.ID, result[0].Detail.ID); }
public DataSet GetRolesUsers2(string orgRoot, string appCodeName, string roleCodeNames, DelegationMaskType delegationMask, SidelineMaskType sidelineMask, string extAttr, bool includeMatrixUsers) { string[] schemaTypes = SchemaInfo.FilterByCategory("Roles").ToSchemaNames(); string[] roleIDs = OGUReaderService.SplitObjectValues(roleCodeNames); bool removeDuplicateData = GetMethodSettingAttributeValue("GetChildrenInRoles", "removeDuplicateData", false); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryRolesContainsUsers(schemaTypes, appCodeName, roleIDs, removeDuplicateData, false, DateTime.MinValue); if (includeMatrixUsers) { FillRoleMatrixRelations(relations, schemaTypes, roleIDs); } relations.FillDetails(); DataSet ds = new DataSet(); ds.Tables.Add(QueryHelper.GetOguTableBuilder(SchemaInfo.FilterByCategory("Users").ToSchemaNames()).Convert(relations)); return(ds); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); SCOrganization root = SCOrganization.GetRoot(); DeluxeTreeNode rootTreeNode = CreateTreeNode(root.ID, root.Name, root.DisplayName, string.Empty, root.SchemaType); rootTreeNode.Expanded = true; rootTreeNode.ShowCheckBox = false; this.tree.Nodes.Add(rootTreeNode); rootTreeNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; string[] schemaTypes = this.Request.QueryString.GetValues("schemaType") ?? DefaultSearchSchemas; HashSet <string> union = new HashSet <string>(schemaTypes); union.UnionWith(alwaysVisibleSchemaObjects); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(union.ToArray(), new string[] { root.ID }, false, false, false, Util.GetTime()); BindObjectsToTreeNodes(relations, rootTreeNode.Nodes, schemaTypes); }
/// <summary> /// 查询角色所包含的成员 /// </summary> /// <param name="schemaTypes">成员的SchemaType</param> /// <param name="appCodeName"></param> /// <param name="roleCodeNames"></param> /// <param name="includingDeleted"></param> /// <param name="timePoint"></param> /// <returns></returns> public SCObjectAndRelationCollection QueryRolesContainsMembers(string[] schemaTypes, string appCodeName, string[] roleCodeNames, bool removeDuplicateData, bool includingDeleted, DateTime timePoint) { SCObjectAndRelationCollection result = new SCObjectAndRelationCollection(); InSqlClauseBuilder roleBuilder = new InSqlClauseBuilder("R.CodeName"); roleBuilder.AppendItem(roleCodeNames); if (roleBuilder.IsEmpty == false) { InSqlClauseBuilder schemaBuilder = new InSqlClauseBuilder("MA.MemberSchemaType"); schemaBuilder.AppendItem(schemaTypes); WhereSqlClauseBuilder appBuilder = new WhereSqlClauseBuilder(); appBuilder.AppendItem("A.CodeName", appCodeName); IConnectiveSqlClause extraBuilder = CreateStatusAndTimePointBuilder(includingDeleted, timePoint, "A.", "MA.", "R.", "UC.", "SR.", "SC."); string resourcePath = "QueryRolesContainsMembers_Current.sql"; if (timePoint != DateTime.MinValue && includingDeleted == true) { resourcePath = "QueryRolesContainsMembers.sql"; } string sqlTemplate = ResourceHelper.LoadStringFromResource(Assembly.GetExecutingAssembly(), string.Concat("MCS.Library.SOA.DataObjects.Security.Adapters.Templates.", resourcePath)); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(roleBuilder, schemaBuilder, appBuilder, extraBuilder); string sql = string.Format(sqlTemplate, connectiveBuilder.ToSqlString(TSqlBuilder.Instance)); DataTable table = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0]; result.LoadFromDataView(table.DefaultView, removeDuplicateData); } return(result); }
public OguObjectCollection <IOguObject> GetObjects(params string[] ids) { ids.NullCheck("ids"); SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByIDs(SchemaInfo.FilterByCategory("Users", "Groups", "Organizations").ToSchemaNames(), ids, false, DateTime.MinValue); relations.FillDetails(); List <IOguObject> list = new List <IOguObject>(relations.Count); foreach (var item in relations) { SchemaObjectBase obj = item.Detail; if (obj != null) { IOguObject oguObj = obj.ToSimpleObject().ToOguObject(); list.Add(oguObj); } } return(new OguObjectCollection <IOguObject>(list)); }
private static void PrepareTreeNodeRecursively(SCSimpleObject parentOrg, DeluxeTreeNode parentTreeNode, Dictionary <string, SCSimpleObject> parentsList, DateTime timePoint, string selectedNodeHint) { SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentOrg.ID }, false, true, false, timePoint); BindObjectsToTreeNodes(relations, parentTreeNode.Nodes); foreach (DeluxeTreeNode childNode in parentTreeNode.Nodes) { SCSimpleObject obj = null; if (childNode.Value == selectedNodeHint) { childNode.Checked = childNode.Selected = true; } if (parentsList.TryGetValue(childNode.Value, out obj)) { childNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; childNode.Expanded = true; PrepareTreeNodeRecursively(obj, childNode, parentsList, timePoint, selectedNodeHint); } } }
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); }
protected override DataTable ConvertToResult(SCObjectAndRelationCollection relations) { return(QueryHelper.GetOguTableBuilder(this.SchemaTypes).Convert(relations)); }
//public override SCObjectAndRelationCollection QueryObjectsAndRelations() //{ // SCObjectAndRelationCollection result = SCSnapshotAdapter.Instance.QueryByMultiFullPaths(this.IDs); // result.Remove(sor => Array.Exists(this.SchemaTypes, s => s == sor.SchemaType) == false); // return result; //} protected override OguObjectCollection <T> ConvertToResult(SCObjectAndRelationCollection relations) { return(new OguObjectCollection <T>(relations.ConvertToOguObjects <T>())); }
protected void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext) { SCObjectAndRelationCollection relations = SCSnapshotAdapter.Instance.QueryObjectAndRelationByParentIDs(PC.SchemaInfo.FilterByCategory("Organizations").ToSchemaNames(), new string[] { parentNode.Value }, false, true, false, Util.GetTime()); BindObjectsToTreeNodes(relations, result); }
/// <summary> /// 执行查询并且转换为所期待的结果类型 /// </summary> /// <returns></returns> public TResult Query() { SCObjectAndRelationCollection relations = this.QueryObjectsAndRelations(); return(this.ConvertToResult(relations)); }
/// <summary> /// 转换成所需要的结果 /// </summary> /// <param name="relations"></param> /// <returns></returns> protected abstract TResult ConvertToResult(SCObjectAndRelationCollection relations);
/// <summary> /// 根据角色ID查询出它的内容 /// </summary> /// <param name="schemaTypes">角色的SchemaType</param> /// <param name="roleIDs"></param> /// <param name="includingDeleted"></param> /// <param name="timePoint"></param> /// <returns></returns> public SCObjectAndRelationCollection QueryRolesContainsMembers(string[] schemaTypes, string[] roleIDs, bool includingDeleted, DateTime timePoint) { SCObjectAndRelationCollection result = new SCObjectAndRelationCollection(); InSqlClauseBuilder roleBuilder = new InSqlClauseBuilder("R.ID"); roleBuilder.AppendItem(roleIDs); if (roleBuilder.IsEmpty == false) { InSqlClauseBuilder schemaBuilder = new InSqlClauseBuilder("MA.MemberSchemaType"); schemaBuilder.AppendItem(schemaTypes); IConnectiveSqlClause extraBuilder = CreateStatusAndTimePointBuilder(includingDeleted, timePoint, "A.", "MA.", "R.", "UC.", "SR.", "SC."); string resourcePath = "QueryRolesContainsMembers_Current.sql"; if (timePoint != DateTime.MinValue && includingDeleted == true) resourcePath = "QueryRolesContainsMembers.sql"; string sqlTemplate = ResourceHelper.LoadStringFromResource(Assembly.GetExecutingAssembly(), string.Concat("MCS.Library.SOA.DataObjects.Security.Adapters.Templates.", resourcePath)); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(roleBuilder, schemaBuilder, extraBuilder); string sql = string.Format(sqlTemplate, connectiveBuilder.ToSqlString(TSqlBuilder.Instance)); DataTable table = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0]; result.LoadFromDataView(table.DefaultView); } return result; }
private static void BindObjectsToTreeNodes(SCObjectAndRelationCollection relations, DeluxeTreeNodeCollection nodes, string[] schemaTypes) { HashSet<string> filter = new HashSet<string>(schemaTypes); relations.Sort((m, n) => m.InnerSort.CompareTo(n.InnerSort)); foreach (SCObjectAndRelation r in relations) { DeluxeTreeNode newTreeNode = CreateTreeNode(r.ID, r.Name, r.DisplayName, r.FullPath, r.SchemaType); if (filter.Contains(r.SchemaType) == false) { newTreeNode.ShowCheckBox = false; newTreeNode.Checked = false; } nodes.Add(newTreeNode); } }