예제 #1
0
        private static CalendarGroup CreateMyCalendarsGroup(MailboxSession session)
        {
            CalendarGroup calendarGroup = null;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                calendarGroup = CalendarGroup.InternalCreateGroup(session, CalendarGroupType.MyCalendars);
                disposeGuard.Add <CalendarGroup>(calendarGroup);
                using (CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, session.GetDefaultFolderId(DefaultFolderType.Calendar), FolderTreeData.MyFoldersClassId, calendarGroup.GroupName))
                {
                    calendarGroupEntry.CalendarName = ClientStrings.Calendar.ToString(session.InternalCulture);
                    ConflictResolutionResult conflictResolutionResult = calendarGroupEntry.Save(SaveMode.NoConflictResolution);
                    if (conflictResolutionResult.SaveStatus != SaveResult.Success)
                    {
                        ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to associate default calendar with the MyCalendars group for user: {0}. Attempting to delete default calendars group.", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress);
                        AggregateOperationResult aggregateOperationResult = session.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            calendarGroup.Id
                        });
                        if (aggregateOperationResult.OperationResult != OperationResult.Succeeded)
                        {
                            ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to delete default calendar group after failing to add the default calendar to it. User: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress);
                        }
                        throw new DefaultCalendarNodeCreationException();
                    }
                }
                disposeGuard.Success();
            }
            return(calendarGroup);
        }
예제 #2
0
        public static CalendarGroupEntry Create(MailboxSession session, StoreObjectId calendarFolderId, CalendarGroup parentGroup)
        {
            Util.ThrowOnNullArgument(parentGroup, "parentGroup");
            CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, calendarFolderId, parentGroup.GroupClassId, parentGroup.GroupName);

            calendarGroupEntry.parentGroup = parentGroup;
            return(calendarGroupEntry);
        }
예제 #3
0
        public static CalendarGroupEntry Create(MailboxSession session, string legacyDistinguishedName, CalendarGroup parentGroup)
        {
            Util.ThrowOnNullOrEmptyArgument(legacyDistinguishedName, "legacyDistinguishedName");
            CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, parentGroup.GroupClassId, parentGroup.GroupName);

            calendarGroupEntry[FolderTreeDataSchema.Type] = FolderTreeDataType.SharedFolder;
            calendarGroupEntry[FolderTreeDataSchema.FolderTreeDataFlags] = 0;
            calendarGroupEntry.SharerAddressBookEntryId    = AddressBookEntryId.MakeAddressBookEntryID(legacyDistinguishedName, false);
            calendarGroupEntry.UserAddressBookStoreEntryId = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(session.MailboxOwner);
            return(calendarGroupEntry);
        }
예제 #4
0
        internal static CalendarGroupEntry Create(MailboxSession session, StoreObjectId calendarFolderId, Guid parentGroupClassId, string parentGroupName)
        {
            Util.ThrowOnNullArgument(calendarFolderId, "calendarFolderId");
            if (calendarFolderId.ObjectType != StoreObjectType.CalendarFolder)
            {
                throw new NotSupportedException("A calendar group entry can only be associated with a storeobject of type calendar folder.");
            }
            CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, parentGroupClassId, parentGroupName);

            calendarGroupEntry.CalendarId   = calendarFolderId;
            calendarGroupEntry.StoreEntryId = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(session.MailboxOwner);
            return(calendarGroupEntry);
        }
예제 #5
0
        public static CalendarGroupEntry Create(MailboxSession session, CalendarFolder calendarFolder, CalendarGroup parentGroup)
        {
            Util.ThrowOnNullArgument(parentGroup, "parentGroup");
            Util.ThrowOnNullArgument(calendarFolder, "calendarFolder");
            CalendarGroupEntry  calendarGroupEntry  = CalendarGroupEntry.Create(session, calendarFolder.Id.ObjectId, parentGroup.GroupClassId, parentGroup.GroupName);
            FolderTreeDataFlags folderTreeDataFlags = CalendarGroupEntry.ReadSharingFlags(calendarFolder);
            bool flag = !session.MailboxGuid.Equals(((MailboxSession)calendarFolder.Session).MailboxGuid);

            if (flag)
            {
                calendarGroupEntry[FolderTreeDataSchema.Type] = FolderTreeDataType.SharedFolder;
                calendarGroupEntry.StoreEntryId      = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(((MailboxSession)calendarFolder.Session).MailboxOwner);
                calendarGroupEntry.CalendarRecordKey = (byte[])calendarFolder.TryGetProperty(StoreObjectSchema.RecordKey);
            }
            else
            {
                folderTreeDataFlags |= FolderTreeDataFlags.IsDefaultStore;
            }
            calendarGroupEntry[FolderTreeDataSchema.FolderTreeDataFlags] = folderTreeDataFlags;
            return(calendarGroupEntry);
        }
예제 #6
0
 public ICalendarGroupEntry CreateCalendarGroupEntry(IMailboxSession session, StoreObjectId calendarFolderId, ICalendarGroup parentGroup)
 {
     return(CalendarGroupEntry.Create((MailboxSession)session, calendarFolderId, (CalendarGroup)parentGroup));
 }
예제 #7
0
 public ICalendarGroupEntry CreateCalendarGroupEntry(IMailboxSession session, string legacyDistinguishedName, ICalendarGroup parentGroup)
 {
     return(CalendarGroupEntry.Create((MailboxSession)session, legacyDistinguishedName, (CalendarGroup)parentGroup));
 }