Пример #1
0
 public FreeBusyEntry(IPeriod period, FreeBusyStatus status)
 {
     //Sets the status associated with a given period, which requires copying the period values
     //Probably the Period object should just have a FreeBusyStatus directly?
     CopyFrom(period);
     Status = status;
 }
Пример #2
0
        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);

            var fb = obj as IFreeBusyEntry;

            if (fb != null)
            {
                Status = fb.Status;
            }
        }
Пример #3
0
        virtual public FreeBusyStatus GetFreeBusyStatus(IDateTime dt)
        {
            FreeBusyStatus status = FreeBusyStatus.Free;

            if (dt != null)
            {
                foreach (IFreeBusyEntry fbe in Entries)
                {
                    if (fbe.Contains(dt) && status < fbe.Status)
                    {
                        status = fbe.Status;
                    }
                }
            }
            return(status);
        }
Пример #4
0
        virtual public FreeBusyStatus GetFreeBusyStatus(IPeriod period)
        {
            FreeBusyStatus status = FreeBusyStatus.Free;

            if (period != null)
            {
                foreach (IFreeBusyEntry fbe in Entries)
                {
                    if (fbe.CollidesWith(period) && status < fbe.Status)
                    {
                        status = fbe.Status;
                    }
                }
            }
            return(status);
        }
Пример #5
0
        private static EasBusyStatus?GetBusyStatus(FreeBusyStatus showAs)
        {
            switch (showAs)
            {
            case FreeBusyStatus.Unknown:
            case FreeBusyStatus.WorkingElsewhere:
                return(null);

            case FreeBusyStatus.Free:
                return(new EasBusyStatus?(EasBusyStatus.Free));

            case FreeBusyStatus.Tentative:
                return(new EasBusyStatus?(EasBusyStatus.Tentative));

            case FreeBusyStatus.Busy:
                return(new EasBusyStatus?(EasBusyStatus.Busy));

            case FreeBusyStatus.Oof:
                return(new EasBusyStatus?(EasBusyStatus.OutOfOffice));

            default:
                throw new EasSyncFailedPermanentException("Invalid showAs status : " + showAs);
            }
        }
Пример #6
0
 public FreeBusyEntry(IPeriod period, FreeBusyStatus status) : base()
 {
     Initialize();
     CopyFrom(period);
     Status = status;
 }
Пример #7
0
 public FreeBusyEntry()
 {
     Status = FreeBusyStatus.Busy;
 }
Пример #8
0
 public FreeBusyEntry(IPeriod period, FreeBusyStatus status) : base()
 {
     Initialize();
     CopyFrom(period);
     Status = status;
 }
Пример #9
0
        static public IFreeBusy Create(ICalendarObject obj, IFreeBusy freeBusyRequest)
        {
            if (obj is IGetOccurrencesTyped)
            {
                IGetOccurrencesTyped getOccurrences = (IGetOccurrencesTyped)obj;
                IList <Occurrence>   occurrences    = getOccurrences.GetOccurrences <IEvent>(freeBusyRequest.Start, freeBusyRequest.End);
                List <string>        contacts       = new List <string>();
                bool isFilteredByAttendees          = false;

                if (freeBusyRequest.Attendees != null &&
                    freeBusyRequest.Attendees.Count > 0)
                {
                    isFilteredByAttendees = true;
                    foreach (IAttendee attendee in freeBusyRequest.Attendees)
                    {
                        if (attendee.Value != null)
                        {
                            contacts.Add(attendee.Value.OriginalString.Trim());
                        }
                    }
                }

                IFreeBusy fb = freeBusyRequest.Copy <IFreeBusy>();
                fb.UID = new UIDFactory().Build();
                fb.Entries.Clear();
                fb.DTStamp = iCalDateTime.Now;

                foreach (Occurrence o in occurrences)
                {
                    IUniqueComponent uc = o.Source as IUniqueComponent;

                    if (uc != null)
                    {
                        IEvent         evt      = uc as IEvent;
                        bool           accepted = false;
                        FreeBusyStatus type     = FreeBusyStatus.Busy;

                        // We only accept events, and only "opaque" events.
                        if (evt != null && evt.Transparency != TransparencyType.Transparent)
                        {
                            accepted = true;
                        }

                        // If the result is filtered by attendees, then
                        // we won't accept it until we find an event
                        // that is being attended by this person.
                        if (accepted && isFilteredByAttendees)
                        {
                            accepted = false;
                            foreach (IAttendee a in uc.Attendees)
                            {
                                if (a.Value != null && contacts.Contains(a.Value.OriginalString.Trim()))
                                {
                                    if (a.ParticipationStatus != null)
                                    {
                                        switch (a.ParticipationStatus.ToUpperInvariant())
                                        {
                                        case ParticipationStatus.Tentative:
                                            accepted = true;
                                            type     = FreeBusyStatus.BusyTentative;
                                            break;

                                        case ParticipationStatus.Accepted:
                                            accepted = true;
                                            type     = FreeBusyStatus.Busy;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        if (accepted)
                        {
                            // If the entry was accepted, add it to our list!
                            fb.Entries.Add(new FreeBusyEntry(o.Period, type));
                        }
                    }
                }

                return(fb);
            }
            return(null);
        }
Пример #10
0
 /// <summary>
 ///     Initializes this instance.
 /// </summary>
 private void Initialize( )
 {
     Status = FreeBusyStatus.Busy;
 }