Ejemplo n.º 1
0
        private static void ParseFreeBusyRaster(
            ExchangeUserDict users,
            DateTime baseTime,
            string emailAddress,
            string freeBusyRaster,
            Dictionary <ExchangeUser, FreeBusy> result)
        {
            ExchangeUser user = null;

            if (emailAddress == null || !users.TryGetValue(emailAddress, out user))
            {
                return;
            }

            FreeBusy freeBusy = new FreeBusy();

            freeBusy.User = user;

            FreeBusyConverter.ParseRasterFreeBusy(baseTime,
                                                  kFreeBusyInterval,
                                                  freeBusyRaster,
                                                  freeBusy);

            FreeBusyConverter.CondenseFreeBusyTimes(freeBusy.All);

            result[user] = freeBusy;
        }
Ejemplo n.º 2
0
        private static List <ITranslationRule <ICalendarItemBase, Event> > CreateTranslationRules()
        {
            ITranslationRule <ICalendarItemBase, IActionPropagationState>  lastExecutedInteropActionRule = CalendarItemAccessors.LastExecutedInteropAction.MapTo(Event.Accessors.LastExecutedInteropAction);
            TranslationStrategy <ICalendarItem, PropertyDefinition, Event> internalRule = new TranslationStrategy <ICalendarItem, PropertyDefinition, Event>(new ITranslationRule <ICalendarItem, Event>[]
            {
                new PatternedRecurrenceRule(),
                CalendarItemAccessors.SeriesMasterDataPropagationOperation.MapTo(Event.Accessors.InternalSeriesToInstancePropagation),
                CalendarItemAccessors.MarkAllPropagatedPropertiesAsException.MapTo(Event.Accessors.InternalMarkAllPropagatedPropertiesAsException)
            });
            TranslationStrategy <ICalendarItemSeries, PropertyDefinition, Event> internalRule2 = new TranslationStrategy <ICalendarItemSeries, PropertyDefinition, Event>(new ITranslationRule <ICalendarItemSeries, Event>[]
            {
                CalendarItemAccessors.SeriesCreationHash.MapTo(Event.Accessors.InternalSeriesCreationHash),
                CalendarItemAccessors.SeriesSequenceNumber.MapTo(Event.Accessors.InternalSeriesSequenceNumber),
                new ActionQueueRules()
            });
            DateTimeHelper    dateTimeHelper = new DateTimeHelper();
            FreeBusyConverter converter      = default(FreeBusyConverter);

            return(new List <ITranslationRule <ICalendarItemBase, Event> >
            {
                new DraftStateRules(),
                CalendarItemAccessors.Attendees.MapTo(Event.Accessors.Attendees),
                CalendarItemAccessors.DisallowNewTimeProposal.MapTo(Event.Accessors.DisallowNewTimeProposal),
                CalendarItemAccessors.EndTime.MapTo(CalendarItemAccessors.EndTimeZone, Event.Accessors.End, Event.Accessors.IntendedEndTimeZoneId, dateTimeHelper),
                CalendarItemAccessors.GlobalObjectId.MapTo(Event.Accessors.InternalGlobalObjectId, default(GlobalObjectIdConverter)),
                CalendarItemAccessors.HasAttendees.MapTo(Event.Accessors.HasAttendees),
                CalendarItemAccessors.IntendedFreeBusyStatus.MapTo(Event.Accessors.IntendedStatus, converter),
                CalendarItemAccessors.IsAllDay.MapTo(Event.Accessors.IsAllDay),
                CalendarItemAccessors.IsCancelled.MapTo(Event.Accessors.IsCancelled),
                CalendarItemAccessors.IsOnlineMeeting.MapTo(Event.Accessors.IsOnlineMeeting),
                CalendarItemAccessors.IsOrganizer.MapTo(Event.Accessors.IsOrganizer),
                CalendarItemAccessors.Location.MapTo(Event.Accessors.Location),
                CalendarItemAccessors.OnlineMeetingConfLink.MapTo(Event.Accessors.OnlineMeetingConfLink),
                CalendarItemAccessors.OnlineMeetingExternalLink.MapTo(Event.Accessors.OnlineMeetingExternalLink),
                CalendarItemAccessors.Organizer.MapTo(Event.Accessors.Organizer),
                CalendarItemAccessors.ResponseRequested.MapTo(Event.Accessors.ResponseRequested),
                new ResponseStatusRule(),
                EventTranslator.SeriesIdRule,
                CalendarItemAccessors.FreeBusyStatus.MapTo(Event.Accessors.ShowAs, converter),
                CalendarItemAccessors.StartTime.MapTo(CalendarItemAccessors.StartTimeZone, Event.Accessors.Start, Event.Accessors.IntendedStartTimeZoneId, dateTimeHelper),
                EventTranslator.EventTypeTranslationRule,
                CalendarItemAccessors.IsReceivedAccessor.MapTo(Event.Accessors.InternalIsReceived),
                new DelegatedTranslationRule <ICalendarItemBase, Event>(delegate(ICalendarItemBase calendarItemBase, Event theEvent)
                {
                    if (!(calendarItemBase is ICalendarItemOccurrence))
                    {
                        lastExecutedInteropActionRule.FromLeftToRightType(calendarItemBase, theEvent);
                    }
                }, new Action <ICalendarItemBase, Event>(lastExecutedInteropActionRule.FromRightToLeftType)),
                internalRule.OfType <ICalendarItemBase, Event, ICalendarItem, Event>(),
                internalRule2.OfType <ICalendarItemBase, Event, ICalendarItemSeries, Event>(),
                new EventPopupReminderSettingsRules(),
                EventTranslator.SeriesMasterIdRule
            });
        }
Ejemplo n.º 3
0
        public static void WriteFreeBusyMessage(string commonName)
        {
            ExchangeService gw = new ExchangeService(
                ConfigCache.ExchangeFreeBusyServerUrl,
                ConfigCache.ExchangeUserLogin,
                ConfigCache.ExchangeUserPassword);

            SchedulePlusFreeBusyWriter writer =
                new SchedulePlusFreeBusyWriter();

            ExchangeUserDict users = QueryFreeBusy(commonName);

            if (users.Count < 1)
            {
                string msg = string.Format("User {0} not found", commonName);
                throw new Exception(msg);
            }

            if (users.Count > 1)
            {
                string msg = string.Format("More than one user matches {0}", commonName);
                throw new Exception(msg);
            }

            string userFreeBusyUrl = FreeBusyUrl.GenerateUrlFromDN(
                ConfigCache.ExchangeFreeBusyServerUrl,
                users[commonName].LegacyExchangeDN);

            List <string> emtpyList      = new List <string>();
            string        nowMinus30Days =
                FreeBusyConverter.ConvertToSysTime(DateUtil.NowUtc.AddDays(-30)).ToString();
            string nowPlus60Days =
                FreeBusyConverter.ConvertToSysTime(DateUtil.NowUtc.AddDays(60)).ToString();

            gw.FreeBusy.CreateFreeBusyMessage(userFreeBusyUrl,
                                              commonName,
                                              emtpyList,
                                              emtpyList,
                                              emtpyList,
                                              emtpyList,
                                              nowMinus30Days,
                                              nowPlus60Days);
        }