示例#1
0
 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));
 }
示例#2
0
 private void WorkWithPermissions(MailboxSession itemStore)
 {
     if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0 || this.policyMembersToAddPermission.Count > 0 || this.policyMembersToRemovePermission.Count > 0 || this.oldAllPolicy != this.newAllPolicy)
     {
         using (CalendarFolder calendarFolder = CalendarFolder.Bind(itemStore, DefaultFolderType.Calendar))
         {
             using (Folder folder = Folder.Create(itemStore, itemStore.GetDefaultFolderId(DefaultFolderType.Configuration), StoreObjectType.Folder, "Freebusy Data", CreateMode.OpenIfExists))
             {
                 CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet();
                 PermissionSet permissionSet2 = folder.GetPermissionSet();
                 permissionSet.DefaultPermission.FreeBusyAccess = (this.newAllPolicy ? FreeBusyAccess.Details : FreeBusyAccess.Basic);
                 this.AddPermissions(permissionSet, permissionSet2);
                 this.RemovePermissions(permissionSet, permissionSet2);
                 FolderSaveResult folderSaveResult = folder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
                 folderSaveResult = calendarFolder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0)
         {
             this.DataObject.GrantSendOnBehalfTo = this.Instance.ResourceDelegates;
             base.DataSession.Save(this.DataObject);
         }
     }
 }
示例#3
0
        // If not there - then it will create it. Otherwise finds it.
        public static void GetRestoreFld()
        {
            CalendarFolder fld = new CalendarFolder(exService);

            fld.DisplayName = "CalRestore";

            bool bEmpty = false;

            try
            {
                Console.WriteLine("Accessing/Creating the CalRestore folder.");
                fld.Save(WellKnownFolderName.Calendar);
            }
            catch (ServiceResponseException ex)
            {
                if (!(ex.ErrorCode.ToString().ToUpper() == "ERRORFOLDEREXISTS"))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("");
                    Console.WriteLine(ex.Message);
                    Console.ResetColor();
                    return;
                }
                else
                {
                    fld = FindCalFolder("CalRestore");
                    Console.WriteLine("Removing previously restored items from the CalRestore folder.");
                    bEmpty = EmptyFolder(fld);
                    Console.WriteLine("\r\nFinished removing items from the CalRestore folder.");
                }
            }
            fldCalRestore = fld;
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            MailboxCalendarFolder mailboxCalendarFolder = instance as MailboxCalendarFolder;

            if (mailboxCalendarFolder == null)
            {
                throw new NotSupportedException("Save: " + instance.GetType().FullName);
            }
            if (mailboxCalendarFolder.PublishEnabled)
            {
                SharingPolicy sharingPolicy = DirectoryHelper.ReadSharingPolicy(base.MailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive, base.MailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));
                if (sharingPolicy == null || !sharingPolicy.Enabled || !sharingPolicy.IsAllowedForAnonymousCalendarSharing())
                {
                    throw new NotAllowedPublishingByPolicyException();
                }
                SharingPolicyAction allowedForAnonymousCalendarSharing = sharingPolicy.GetAllowedForAnonymousCalendarSharing();
                int maxAllowed = PolicyAllowedDetailLevel.GetMaxAllowed(allowedForAnonymousCalendarSharing);
                if (mailboxCalendarFolder.DetailLevel > (DetailLevelEnumType)maxAllowed)
                {
                    throw new NotAllowedPublishingByPolicyException(mailboxCalendarFolder.DetailLevel, (DetailLevelEnumType)maxAllowed);
                }
            }
            MailboxFolderId mailboxFolderId = mailboxCalendarFolder.MailboxFolderId;
            StoreObjectId   folderId        = mailboxFolderId.StoreObjectIdValue ?? base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath);

            if (folderId == null || folderId.ObjectType != StoreObjectType.CalendarFolder)
            {
                throw new CantFindCalendarFolderException(mailboxFolderId);
            }
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(base.MailboxSession, folderId))
            {
                ExtendedFolderFlags?valueAsNullable = calendarFolder.GetValueAsNullable <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags);
                if (valueAsNullable != null && (valueAsNullable.Value & ExtendedFolderFlags.PersonalShare) != (ExtendedFolderFlags)0)
                {
                    throw new CannotShareFolderException(ServerStrings.CannotShareOtherPersonalFolder);
                }
                this.SaveSharingAnonymous(mailboxCalendarFolder, folderId);
                if (!mailboxCalendarFolder.PublishEnabled)
                {
                    mailboxCalendarFolder.PublishedCalendarUrl = null;
                    mailboxCalendarFolder.PublishedICalUrl     = null;
                }
                UserConfigurationDictionaryHelper.Save(mailboxCalendarFolder, MailboxCalendarFolder.CalendarFolderConfigurationProperties, (bool createIfNonexisting) => UserConfigurationHelper.GetPublishingConfiguration(this.MailboxSession, folderId, createIfNonexisting));
                if (MailboxCalendarFolderDataProvider.UpdateExtendedFolderFlags(mailboxCalendarFolder, calendarFolder))
                {
                    calendarFolder.Save();
                }
            }
        }
        private static void SetBirthdayCalendarHiddenValue(CalendarFolder birthdayCalendar, bool isHidden)
        {
            StoreSession session = birthdayCalendar.Session;

            ExTraceGlobals.BirthdayCalendarTracer.TraceDebug <bool, Guid>(0L, "BirthdayCalendar::SetBirthdayCalendarHiddenValue. IsHidden:{0}. MailboxGuid:{1}", isHidden, session.MailboxGuid);
            if (birthdayCalendar.IsHidden == isHidden)
            {
                return;
            }
            birthdayCalendar.IsHidden = isHidden;
            birthdayCalendar.Save(SaveMode.NoConflictResolution);
        }
示例#6
0
        private void btnCreateCalendar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtCalendarName.Text))
            {
                MessageBox.Show("Input calendar name firstly.");
                return;
            }

            CalendarFolder folder = new CalendarFolder(service);

            folder.DisplayName = this.txtCalendarName.Text;
            folder.Save(WellKnownFolderName.Calendar);
            this.btnGetCalendarList_Click(sender, e);
        }
        private void CreateCalendarFolder(ExchangeService svc, string folderName, FolderId folderId)
        {
            CalendarFolder folder = new CalendarFolder(svc);

            folder.DisplayName = folderName;

            try
            {
                folder.Save(folderId);
            }
            catch (Exception erro)
            {
                ValidationCreationFolderException(erro);
            }
        }