protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator) { using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, context.FolderId, CalendarFolderSchema.ConsumerCalendarProperties)) { Guid a = calendarFolder.ConsumerCalendarGuid; Guid consumerCalendarPrivateFreeBusyId = calendarFolder.ConsumerCalendarPrivateFreeBusyId; Guid consumerCalendarPrivateDetailId = calendarFolder.ConsumerCalendarPrivateDetailId; if (a == Guid.Empty) { a = (calendarFolder.ConsumerCalendarGuid = Guid.NewGuid()); } if (consumerCalendarPrivateFreeBusyId == Guid.Empty) { Guid guid = calendarFolder.ConsumerCalendarPrivateFreeBusyId = Guid.NewGuid(); } if (consumerCalendarPrivateDetailId == Guid.Empty) { Guid guid2 = calendarFolder.ConsumerCalendarPrivateDetailId = Guid.NewGuid(); } if (calendarFolder.IsDirty) { FolderSaveResult folderSaveResult = calendarFolder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { throw folderSaveResult.ToException(new LocalizedString("TODO: LOC: Failed to share the calendar.")); } } context.FolderEwsId = a.ToString(); context.MailboxId = ((IUserPrincipal)mailboxSession.MailboxOwner).NetId.ToByteArray(); context.FolderName = (context.IsPrimary ? string.Format("TODO: LOC: {0}'s Calendar", context.InitiatorName) : calendarFolder.DisplayName); context.IsPrimary = false; } return(new PerformInvitationResults(recipients)); }
protected override void InternalSave(ConfigurableObject instance) { if (instance == null) { throw new ArgumentNullException("instance"); } MailboxFolder mailboxFolder = instance as MailboxFolder; if (mailboxFolder == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } FolderSaveResult folderSaveResult = null; switch (mailboxFolder.ObjectState) { case ObjectState.New: try { using (Folder folder = Folder.Create(base.MailboxSession, mailboxFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(mailboxFolder.FolderClass), mailboxFolder.Name, CreateMode.CreateNew)) { mailboxFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { MailboxFolderSchema.Name, MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(mailboxFolder.Name, folder, mailboxFolder.Schema); folderSaveResult = folder.Save(); } goto IL_FD; } catch (ObjectExistedException innerException) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(mailboxFolder.Name), innerException); } break; case ObjectState.Unchanged: goto IL_FD; case ObjectState.Changed: break; case ObjectState.Deleted: throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted); default: goto IL_FD; } throw new NotImplementedException("Save.Changed"); IL_FD: if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded) { throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString())); } }
private StoreId CreateFolder(MailboxSession mailboxSession, StoreId parentId, string displayName, bool sourceBasedFolder) { StoreId result = null; using (Folder folder = Folder.Create(mailboxSession, parentId, StoreObjectType.Folder, displayName, CreateMode.OpenIfExists)) { if (sourceBasedFolder) { folder[FolderSchema.OwaViewStateSortColumn] = "DeliveryTime"; } FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { SearchMailboxAction.Tracer.TraceError <string, FolderSaveResult>((long)this.GetHashCode(), "Folder.Save operation failed on mailbox {0} with operation result {1} ", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, folderSaveResult); throw folderSaveResult.ToException(Strings.CreateFolderFailed(displayName)); } folder.Load(); result = folder.Id; } return(result); }
protected override void InternalSave(ConfigurableObject instance) { PublicFolder publicFolder = instance as PublicFolder; if (publicFolder == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } FolderSaveResult folderSaveResult = null; switch (publicFolder.ObjectState) { case ObjectState.New: try { using (Folder folder = Folder.Create(this.PublicFolderSession, publicFolder.InternalParentFolderIdentity, ObjectClass.GetObjectType(publicFolder.FolderClass), publicFolder.Name, CreateMode.CreateNew)) { publicFolder.SaveDataToXso(folder, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { PublicFolderSchema.Name, MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder, publicFolder.Schema); folderSaveResult = folder.Save(); publicFolder.OrganizationId = this.PublicFolderSession.OrganizationId; } goto IL_157; } catch (ObjectExistedException innerException) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name), innerException); } break; case ObjectState.Unchanged: goto IL_157; case ObjectState.Changed: break; case ObjectState.Deleted: goto IL_147; default: goto IL_157; } using (Folder folder2 = Folder.Bind(this.PublicFolderSession, publicFolder.InternalFolderIdentity, null)) { publicFolder.SaveDataToXso(folder2, new ReadOnlyCollection <XsoDriverPropertyDefinition>(new List <XsoDriverPropertyDefinition> { MailboxFolderSchema.InternalParentFolderIdentity })); MailboxFolderDataProvider.ValidateXsoObjectAndThrowForError(publicFolder.Name, folder2, publicFolder.Schema); folderSaveResult = folder2.Save(); goto IL_157; } IL_147: throw new InvalidOperationException(ServerStrings.ExceptionObjectHasBeenDeleted); IL_157: if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded && folderSaveResult.PropertyErrors.Length > 0) { foreach (PropertyError propertyError in folderSaveResult.PropertyErrors) { if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict) { throw new ObjectExistedException(ServerStrings.ErrorFolderAlreadyExists(publicFolder.Name)); } } throw folderSaveResult.ToException(ServerStrings.ErrorFolderSave(instance.Identity.ToString(), folderSaveResult.ToString())); } }