void dump(FreeBusyCollection fbc)
        {
            Console.WriteLine("Begin FreeBusyCollection");

            foreach (KeyValuePair <DateTime, FreeBusyTimeBlock> pair in fbc)
            {
                DateTime          dt = pair.Key;
                FreeBusyTimeBlock b  = pair.Value;
                Console.WriteLine("{0}: {1} -> {2} [{3}]",
                                  dt, b.StartDate, b.EndDate, b.Appointments.Count);
            }
            Console.WriteLine("End FreeBusyCollection");
        }
Esempio n. 2
0
        private void GenerateResponseForTimeBlock(
            ExchangeUser user,
            FreeBusyTimeBlock timeBlock,
            BusyStatus busyStatus,
            bool firstAppointment,
            StringBuilder result)
        {
            if (timeBlock.Appointments == null || timeBlock.Appointments.Count == 0)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                AppendPrivateFreeBusyEntry(timeBlock.StartDate,
                                           timeBlock.EndDate,
                                           user.CommonName,
                                           busyStatus,
                                           result);
                return;
            }

            foreach (Appointment appt in timeBlock.Appointments)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                if (!appt.IsPrivate)
                {
                    AppendFreeBusyEntry(appt.StartDate,
                                        appt.EndDate,
                                        appt.Subject,
                                        appt.Location,
                                        appt.Organizer,
                                        appt.BusyStatus,
                                        result);
                }
                else
                {
                    AppendPrivateFreeBusyEntry(appt.StartDate,
                                               appt.EndDate,
                                               user.CommonName,
                                               appt.BusyStatus,
                                               result);
                }

                firstAppointment = false;
            }
        }
Esempio n. 3
0
        private void AddFreeBusyBlock(
            FreeBusyCollection result,
            DateTimeRange eventRange,
            bool existingEvent)
        {
            FreeBusyTimeBlock block = new FreeBusyTimeBlock(eventRange);
            Appointment       appt  = new Appointment();

            appt.StartDate  = eventRange.Start;
            appt.EndDate    = eventRange.End;
            appt.BusyStatus = BusyStatus.Busy;

            if (existingEvent)
            {
                AssignOwnership(appt);
            }

            block.Appointments.Add(appt);
            result.Appointments.Add(appt);
            result[eventRange.Start] = block;
        }
        private static void ConvertFreeBusyToBlocks(
            DateTimeRange window,
            List <DateTimeRange> ranges,
            FreeBusyCollection times,
            IntervalTree <FreeBusyTimeBlock> intervals)
        {
            foreach (DateTimeRange range in ranges)
            {
                /* If the free busy date is between the start and end dates request */
                if (DateUtil.IsWithinRange(range.Start, window.Start, window.End) ||
                    DateUtil.IsWithinRange(range.End, window.Start, window.End))
                {
                    /* Add the a new FreeBusyTimeBlock to the collection,
                     * Set the key to the start date of the block */
                    FreeBusyTimeBlock block = new FreeBusyTimeBlock(range);

                    if (!times.ContainsKey(range.Start))
                    {
                        times.Add(range.Start, block);
                        intervals.Insert(range, block);
                    }
                }
            }
        }
        private void GenerateResponseForTimeBlock(
            ExchangeUser user,
            FreeBusyTimeBlock timeBlock,
            BusyStatus busyStatus,
            bool firstAppointment,
            StringBuilder result)
        {
            if (timeBlock.Appointments == null || timeBlock.Appointments.Count == 0)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                AppendPrivateFreeBusyEntry(timeBlock.StartDate,
                                           timeBlock.EndDate,
                                           user.CommonName,
                                           busyStatus,
                                           result);
                return;
            }

            foreach (Appointment appt in timeBlock.Appointments)
            {
                if (!firstAppointment)
                {
                    result.Append(",");
                }

                if (!appt.IsPrivate)
                {
                    AppendFreeBusyEntry(appt.StartDate,
                                        appt.EndDate,
                                        appt.Subject,
                                        appt.Location,
                                        appt.Organizer,
                                        appt.BusyStatus,
                                        result);
                }
                else
                {
                    AppendPrivateFreeBusyEntry(appt.StartDate,
                                               appt.EndDate,
                                               user.CommonName,
                                               appt.BusyStatus,
                                               result);
                }

                firstAppointment = false;
            }
        }
        private void AddFreeBusyBlock(
            FreeBusyCollection result,
            DateTimeRange eventRange,
            bool existingEvent)
        {
            FreeBusyTimeBlock block = new FreeBusyTimeBlock(eventRange);
            Appointment appt = new Appointment();
            appt.StartDate = eventRange.Start;
            appt.EndDate = eventRange.End;
            appt.BusyStatus = BusyStatus.Busy;

            if (existingEvent)
            {
                AssignOwnership(appt);
            }

            block.Appointments.Add(appt);
            result.Appointments.Add(appt);
            result[eventRange.Start] = block;
        }
Esempio n. 7
0
        /// <summary>
        /// Compare two free busy time blocks
        /// </summary>
        /// <param name="obj">The free busy time block to compare to</param>
        /// <returns>Comparison value</returns>
        public int CompareTo(object obj)
        {
            FreeBusyTimeBlock block = (FreeBusyTimeBlock)obj;

            return(StartDate.CompareTo(block.StartDate));
        }
        private static void ConvertFreeBusyToBlocks(
            DateTimeRange window,
            List<DateTimeRange> ranges,
            FreeBusyCollection times,
            IntervalTree<FreeBusyTimeBlock> intervals)
        {
            foreach (DateTimeRange range in ranges)
            {
                /* If the free busy date is between the start and end dates request */
                if (DateUtil.IsWithinRange(range.Start, window.Start, window.End) ||
                    DateUtil.IsWithinRange(range.End, window.Start, window.End))
                {
                    /* Add the a new FreeBusyTimeBlock to the collection,
                     * Set the key to the start date of the block */
                    FreeBusyTimeBlock block = new FreeBusyTimeBlock(range);

                    if (!times.ContainsKey(range.Start))
                    {
                        times.Add(range.Start, block);
                        intervals.Insert(range, block);
                    }
                }
            }
        }