Beispiel #1
0
        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 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>()));
        }