public override IConfigurable[] Find <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy) { MailboxDataProvider.Tracer.TraceDebug <QueryFilter>((long)this.GetHashCode(), "Finding search object that match filter '{0}'", filter); if (filter != null && !(filter is TextFilter)) { throw new ArgumentException("filter"); } IEnumerable <T> enumerable = null; using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { enumerable = mailboxDataStore.FindPaged <T>(filter as TextFilter, 0); } LinkedList <IConfigurable> linkedList = new LinkedList <IConfigurable>(); foreach (T t in enumerable) { IConfigurable value = t; linkedList.AddLast(value); if (linkedList.Count >= 1000) { break; } } IConfigurable[] array = new IConfigurable[linkedList.Count]; linkedList.CopyTo(array, 0); return(array); }
public override IConfigurable Read <T>(ObjectId identity) { MailboxDataProvider.Tracer.TraceDebug <ObjectId>((long)this.GetHashCode(), "Reading search object with identity {0}", identity); IConfigurable result; using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { result = mailboxDataStore.Read <T>(identity as SearchObjectId); } return(result); }
public bool Exists <T>(string name) where T : IConfigurable, new() { MailboxDataProvider.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Querying existence of search object {0}", name); bool result; using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { result = mailboxDataStore.Exists <T>(name); } return(result); }
public bool Exists(SearchObjectId identity) { MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Querying existence of search object {0}", identity); bool result; using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { result = mailboxDataStore.Exists(identity); } return(result); }
public MailboxDataStore(ADUser adUser) { using (DisposeGuard disposeGuard = this.Guard()) { if (adUser == null) { throw new ArgumentNullException("adUser"); } this.disposeTracker = this.GetDisposeTracker(); this.mailboxSession = MailboxDataStore.OpenMailboxSession(adUser); MailboxDataStore.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "Instantiating search object data store in discovery mailbox {0}.", this.mailboxSession.MailboxOwner); disposeGuard.Success(); } }
public override IEnumerable <T> FindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { MailboxDataProvider.Tracer.TraceDebug <QueryFilter>((long)this.GetHashCode(), "Finding search object that match filter {0}", filter); if (filter != null && !(filter is TextFilter)) { throw new ArgumentException("filter"); } IEnumerable <T> result; using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { result = mailboxDataStore.FindPaged <T>(filter as TextFilter, pageSize); } return(result); }
internal void Delete(SearchObjectBase instance) { if (instance == null) { throw new ArgumentNullException("instance"); } MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Deleting search object {0}", instance.Id); if (instance.ObjectState == ObjectState.Deleted) { throw new InvalidOperationException("The object has already been deleted"); } using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { mailboxDataStore.Delete(instance); } instance.MarkAsDeleted(); }
private void Save(SearchObjectBase instance) { if (instance == null) { throw new ArgumentNullException("instance"); } MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Saving search object {0}", instance.Id); if (instance.ObjectState == ObjectState.Deleted) { throw new InvalidOperationException("Calling Save() on a deleted object is not permitted. Delete() should be used instead."); } if (instance.ObjectState == ObjectState.Unchanged) { return; } bool flag = false; if (instance.ObjectState == ObjectState.New && (instance.Id == null || instance.Id.IsEmpty)) { instance.SetId(base.ADUser.Id, Guid.NewGuid()); flag = true; } ValidationError[] array = instance.Validate(); if (array.Length > 0) { throw new DataValidationException(array[0]); } using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore()) { if (flag) { while (mailboxDataStore.Exists(instance.Id)) { instance.SetId(base.ADUser.Id, Guid.NewGuid()); } } instance.OnSaving(); mailboxDataStore.Save(instance); } instance.ResetChangeTracking(true); this.LogSaveEvent(instance); }