/// <summary> /// 根据ID类型得到Cache实例 /// </summary> /// <param name="idType"></param> /// <returns></returns> public static OguObjectCacheBase GetInstance(SearchOUIDType idType) { OguObjectCacheBase result = null; switch (idType) { case SearchOUIDType.Guid: result = OguObjectIDCache.Instance; break; case SearchOUIDType.FullPath: result = OguObjectFullPathCache.Instance; break; case SearchOUIDType.LogOnName: result = OguObjectLogOnNameCache.Instance; break; } return(result); }
public OguObjectCollection <T> GetObjects <T>(SearchOUIDType idType, params string[] ids) where T : IOguObject { ExceptionHelper.FalseThrow <ArgumentNullException>(ids != null, "ids"); SchemaType objType = OguObjectHelper.GetSchemaTypeFromInterface <T>(); ExceptionHelper.TrueThrow(idType == SearchOUIDType.LogOnName && (objType & ~(SchemaType.Users | SchemaType.Sideline)) != SchemaType.Unspecified, Resource.OnlyUserCanUserLogOnNameQuery); OguObjectCollection <T> result = null; if (ids.Length > 0) { string[] notInCacheIds = null; IList <T> objsInCache = null; if (ServiceBrokerContext.Current.UseLocalCache) { objsInCache = OguObjectCacheBase.GetInstance(idType).GetObjectsInCache <T>(ids, out notInCacheIds); } else { notInCacheIds = ids; objsInCache = new List <T>(); } if (notInCacheIds.Length > 0) { string multiIDString = BuildIDString(notInCacheIds); DataSet ds = OguReaderServiceBroker.Instance.GetObjectsDetail( SchemaTypeToString(objType), multiIDString, (int)idType, string.Empty, 0, Common.DefaultAttrs); //RemoveDeletedObject(ds.Tables[0]); //原来有这句话,现在去掉,可以查询已经逻辑删除的对象 OguObjectCollection <T> queryResult = new OguObjectCollection <T>(Common.BuildObjectsFromTable <T>(ds.Tables[0])); queryResult = queryResult.GetRemovedDuplicateDeletedObjectCollection(); if (ServiceBrokerContext.Current.UseLocalCache) { OguObjectCacheBase.GetInstance(idType).AddObjectsToCache <T>(queryResult); } foreach (T obj in queryResult) { objsInCache.Add(obj); } } result = new OguObjectCollection <T>(objsInCache); result.Sort(OrderByPropertyType.GlobalSortID, SortDirectionType.Ascending); } else { result = new OguObjectCollection <T>(); } return(result); }