Ejemplo n.º 1
0
        public object[][] GetCalendarView(ExDateTime startTime, ExDateTime endTime, params PropertyDefinition[] dataColumns)
        {
            base.CheckDisposed("GetCalendarView");
            if (startTime > endTime)
            {
                throw new ArgumentException(ServerStrings.ExInvalidDateTimeRange((DateTime)startTime, (DateTime)endTime));
            }
            ExDateTime calendarViewFromDateTime = this.GetCalendarViewFromDateTime(startTime);
            ExDateTime calendarViewToDateTime   = this.GetCalendarViewToDateTime(endTime);

            if (calendarViewFromDateTime > calendarViewToDateTime)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, ExDateTime, ExDateTime>((long)this.GetHashCode(), "{0}: GetCalendarView: the request window is out of range of published window. CalendarViewFromDateTime = {1}; CalendarViewToDateTime = {2}.", base.OwnerDisplayName, calendarViewFromDateTime, calendarViewToDateTime);
                return(Array <object[]> .Empty);
            }
            ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "{0}: GetCalendarView: FolderId = {1}; DetailLevel = {2}; CalendarViewFromDateTime = {3}; CalendarViewToDateTime = {4}.", new object[]
            {
                base.OwnerDisplayName,
                base.FolderId,
                this.DetailLevel,
                calendarViewFromDateTime,
                calendarViewToDateTime
            });
            object[][] result;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(base.MailboxSession, base.FolderId))
            {
                result = calendarFolder.InternalGetCalendarView(calendarViewFromDateTime, calendarViewToDateTime, this.DetailLevel == DetailLevelEnumType.AvailabilityOnly, true, true, RecurrenceExpansionOption.IncludeRegularOccurrences, dataColumns);
            }
            return(result);
        }
        public virtual IEnumerable <BirthdayEvent> GetBirthdayCalendarView(ExDateTime startTime, ExDateTime endTime)
        {
            IEnumerable <BirthdayEvent> result;

            using (CalendarFolder calendarFolder = (CalendarFolder)base.XsoFactory.BindToCalendarFolder(base.Session, base.ContainerFolderId))
            {
                object[][] rows = calendarFolder.InternalGetCalendarView(startTime, endTime, false, false, true, RecurrenceExpansionOption.IncludeRegularOccurrences, BirthdayEventDataProvider.BirthdayEventPropertyDefinitions);
                Dictionary <PropertyDefinition, int> propertyIndices = this.GetPropertyIndices(BirthdayEventDataProvider.BirthdayEventPropertyDefinitions);
                IEnumerable <BirthdayEvent>          enumerable      = from birthdayEvent in this.ReadQueryResults(rows, propertyIndices)
                                                                       where ((IBirthdayEventInternal)birthdayEvent).ContactId != null
                                                                       select birthdayEvent;
                result = enumerable;
            }
            return(result);
        }
Ejemplo n.º 3
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();
                        }
                    }
                }
            }
        }