コード例 #1
0
        public static PropertyDefinition[] FromDetailLevel(DetailLevelEnumType detailLevel)
        {
            switch (detailLevel)
            {
            case DetailLevelEnumType.AvailabilityOnly:
                return(InternetCalendarSchema.ExportFreeBusy);

            case DetailLevelEnumType.LimitedDetails:
                return(InternetCalendarSchema.ExportLimitedDetails);

            case DetailLevelEnumType.FullDetails:
                return(InternetCalendarSchema.ExportFullDetails);

            default:
                throw new ArgumentOutOfRangeException("detailLevel");
            }
        }
コード例 #2
0
        public static void ExportCalendar(Stream outputStream, string charset, OutboundConversionOptions options, MailboxSession session, StoreObjectId folderId, ExDateTime windowStart, ExDateTime windowEnd, DetailLevelEnumType detailType)
        {
            EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(detailType, "detailType");
            PropertyDefinition[] array = InternetCalendarSchema.FromDetailLevel(detailType);
            Array.IndexOf <PropertyDefinition>(array, CalendarItemBaseSchema.FreeBusyStatus);
            int num = Array.IndexOf <PropertyDefinition>(array, InternalSchema.ItemId);

            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId))
            {
                object[][] array2 = calendarFolder.InternalGetCalendarView(windowStart, windowEnd, detailType == DetailLevelEnumType.AvailabilityOnly, true, true, RecurrenceExpansionOption.IncludeMaster | RecurrenceExpansionOption.TruncateMaster, array);
                Item[]     items  = new Item[array2.Length];
                try
                {
                    for (int i = 0; i < array2.Length; i++)
                    {
                        items[i] = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties);
                        for (int j = 0; j < array.Length; j++)
                        {
                            StorePropertyDefinition storePropertyDefinition = array[j] as StorePropertyDefinition;
                            if (storePropertyDefinition != null && (storePropertyDefinition.PropertyFlags & PropertyFlags.ReadOnly) != PropertyFlags.ReadOnly)
                            {
                                object obj = array2[i][j];
                                if (!PropertyError.IsPropertyError(obj))
                                {
                                    items[i][storePropertyDefinition] = obj;
                                }
                            }
                        }
                        if (detailType == DetailLevelEnumType.FullDetails && array2[i][num] is VersionedId)
                        {
                            using (CoreItem coreItem = CoreItem.Bind(session, (VersionedId)array2[i][num], new PropertyDefinition[]
                            {
                                ItemSchema.TextBody,
                                ItemSchema.HtmlBody,
                                ItemSchema.RtfBody
                            }))
                            {
                                using (TextReader textReader = coreItem.Body.OpenTextReader(BodyFormat.TextPlain))
                                {
                                    items[i][ItemSchema.TextBody] = textReader.ReadToEnd();
                                }
                            }
                        }
                    }
                    OutboundAddressCache   addressCache = new OutboundAddressCache(options, new ConversionLimitsTracker(options.Limits));
                    List <LocalizedString> errorStream  = new List <LocalizedString>();
                    ConvertUtils.CallCts(ExTraceGlobals.ICalTracer, "ICalSharingHelper::ExportCalendar", ServerStrings.ConversionCorruptContent, delegate
                    {
                        CalendarDocument.InternalItemsToICal(calendarFolder.DisplayName, items, null, addressCache, true, outputStream, errorStream, charset, options);
                    });
                    if (errorStream.Count > 0)
                    {
                        ExTraceGlobals.ICalTracer.TraceError <int>(0L, "{0} errors found during outbound iCal content conversion.", errorStream.Count);
                        AnonymousSharingLog.LogEntries(session, errorStream);
                    }
                }
                finally
                {
                    foreach (Item item in items)
                    {
                        if (item != null)
                        {
                            item.Dispose();
                        }
                    }
                }
            }
        }
コード例 #3
0
 public NotAllowedPublishingByPolicyException(DetailLevelEnumType detailLevel, DetailLevelEnumType maxAllowedDetailLevel) : base(ServerStrings.DetailLevelNotAllowedByPolicy(LocalizedDescriptionAttribute.FromEnum(typeof(DetailLevelEnumType), detailLevel)))
 {
     EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(detailLevel, "detailLevel");
     EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(maxAllowedDetailLevel, "maxAllowedDetailLevel");
     this.MaxAllowedDetailLevel = (int)maxAllowedDetailLevel;
 }
コード例 #4
0
        public bool TryGetProvider(SmtpAddress recipientAddress, ADRecipient adRecipient, IFrontEndLocator frontEndLocator, out SharingProvider provider, out DetailLevelEnumType detailLevel)
        {
            provider    = null;
            detailLevel = DetailLevelEnumType.AvailabilityOnly;
            bool result;

            try
            {
                if (this.mailboxOwner.GetConfiguration().DataStorage.XOWAConsumerSharing.Enabled)
                {
                    provider    = SharingProvider.SharingProviderConsumer;
                    detailLevel = DetailLevelEnumType.Editor;
                    result      = true;
                }
                else
                {
                    if (adRecipient != null)
                    {
                        if (adRecipient.IsValidSecurityPrincipal)
                        {
                            provider    = SharingProvider.SharingProviderInternal;
                            detailLevel = DetailLevelEnumType.Editor;
                            return(true);
                        }
                        if (DelegateUserCollection.IsCrossPremiseDelegateEnabled(this.mailboxOwner) && (adRecipient.RecipientType == RecipientType.User || adRecipient.RecipientType == RecipientType.UserMailbox || adRecipient.RecipientType == RecipientType.MailUser))
                        {
                            provider    = SharingProvider.SharingProviderInternal;
                            detailLevel = DetailLevelEnumType.Editor;
                            return(true);
                        }
                        if (adRecipient.RecipientType != RecipientType.User && adRecipient.RecipientType != RecipientType.UserMailbox && adRecipient.RecipientType != RecipientType.MailUser && adRecipient.RecipientType != RecipientType.Contact && adRecipient.RecipientType != RecipientType.MailContact)
                        {
                            return(false);
                        }
                    }
                    SharingPolicyDomain effectiveCalendarSharingPolicy = this.GetEffectiveCalendarSharingPolicy(recipientAddress.Domain, frontEndLocator);
                    this.TraceDebug("Policy found:{0}", new object[]
                    {
                        (effectiveCalendarSharingPolicy == null) ? "none" : effectiveCalendarSharingPolicy.Domain
                    });
                    int maxAllowed;
                    if (effectiveCalendarSharingPolicy != null && (maxAllowed = PolicyAllowedDetailLevel.GetMaxAllowed(effectiveCalendarSharingPolicy.Actions)) > 0)
                    {
                        detailLevel = (DetailLevelEnumType)maxAllowed;
                        if (effectiveCalendarSharingPolicy.Domain == "Anonymous")
                        {
                            provider = SharingProvider.SharingProviderPublishReach;
                        }
                        else
                        {
                            provider = SharingProvider.SharingProviderExternal;
                        }
                    }
                    result = (provider != null);
                }
            }
            finally
            {
                this.TraceDebug("MailboxOwner:{0},Recipient:{1},RecipientType:{2},Handler={2},DetailLevel={3}", new object[]
                {
                    this.mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    recipientAddress,
                    (adRecipient == null) ? "none" : adRecipient.RecipientType.ToString(),
                    (provider == null) ? "none" : provider.Name,
                    detailLevel
                });
            }
            return(result);
        }
コード例 #5
0
 private PolicyAllowedDetailLevel(SharingPolicyAction action, DetailLevelEnumType maxAllowedDetailLevel)
 {
     this.action = action;
     this.maxAllowedDetailLevel = maxAllowedDetailLevel;
 }