Пример #1
0
        private void FilterSuggestions(List <Suggestion> suggestionList, ConfigOptions options, ExDateTime currentMeetingTime)
        {
            suggestionList.RemoveAll((Suggestion suggestion) => !(suggestion.MeetingTime == (DateTime)currentMeetingTime) && (suggestion.TimeSlotRating == -1L || suggestion.SuggestionQuality > options.MinimumSuggestionQuality) && options.MinimumSuggestionQuality != SuggestionQuality.Poor);
            SuggestionDayResult.Tracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: {1} suggestions passing minimum quality.", TraceContext.Get(), suggestionList.Count);
            suggestionList.Sort(delegate(Suggestion x, Suggestion y)
            {
                if (x == y)
                {
                    return(0);
                }
                if (x.MeetingTime == (DateTime)currentMeetingTime)
                {
                    return(-1);
                }
                if (y.MeetingTime == (DateTime)currentMeetingTime)
                {
                    return(1);
                }
                if (x.TimeSlotRating == y.TimeSlotRating)
                {
                    if (x.MeetingTime < y.MeetingTime)
                    {
                        return(-1);
                    }
                    if (x.MeetingTime > y.MeetingTime)
                    {
                        return(1);
                    }
                    return(0);
                }
                else
                {
                    if (x.TimeSlotRating > y.TimeSlotRating)
                    {
                        return(1);
                    }
                    return(-1);
                }
            });
            int num = 0;

            for (int i = 0; i < suggestionList.Count; i++)
            {
                if (!suggestionList[i].IsWorkTime)
                {
                    if (num >= options.MaximumNonWorkHourResultsPerDay)
                    {
                        suggestionList.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        num++;
                    }
                }
            }
            SuggestionDayResult.Tracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: {1} suggestions after non-working hour restrictions.", TraceContext.Get(), suggestionList.Count);
            if (suggestionList.Count > options.MaximumResultsPerDay)
            {
                suggestionList.RemoveRange(options.MaximumResultsPerDay, suggestionList.Count - options.MaximumResultsPerDay);
                SuggestionDayResult.Tracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: suggestions array length shortened to MaximumResultsPerDay ({1}).", TraceContext.Get(), options.MaximumResultsPerDay);
            }
        }
Пример #2
0
        internal Suggestion(ExDateTime meetingStartTime, int inputMeetingDuration, int inputRequiredAttendeeCount, int inputOptionalAttendeeCount, AttendeeData[] inputAttendees, ConfigOptions inputOptions)
        {
            this.options = inputOptions;
            Suggestion.Tracer.TraceDebug <object, ExDateTime>((long)this.GetHashCode(), "{0}: Suggestion.Suggestion() entered, inputStartDateTime: {1}", TraceContext.Get(), meetingStartTime);
            this.meetingStartTime      = meetingStartTime;
            this.startDateTime         = meetingStartTime.LocalTime;
            this.meetingDuration       = inputMeetingDuration;
            this.requiredAttendeeCount = inputRequiredAttendeeCount;
            this.optionalAttendeeCount = inputOptionalAttendeeCount;
            ExDateTime endUtc = meetingStartTime.AddMinutes((double)inputMeetingDuration);
            bool       flag   = true;
            int        num    = 0;

            this.attendeeConflictDataArray = new AttendeeConflictData[inputAttendees.Length];
            foreach (AttendeeData attendeeData in inputAttendees)
            {
                BusyType busyType = attendeeData.GetBusyType(this.meetingStartTime, this.meetingDuration);
                IndividualAttendeeConflictData individualAttendeeConflictData = IndividualAttendeeConflictData.Create(attendeeData, busyType);
                if (attendeeData.AttendeeType == MeetingAttendeeType.Required || attendeeData.AttendeeType == MeetingAttendeeType.Organizer)
                {
                    this.SetRequiredAttendeeAvailability(attendeeData, individualAttendeeConflictData);
                    if (individualAttendeeConflictData.BusyType != BusyType.NoData)
                    {
                        this.excludeConflict |= attendeeData.ExcludeConflict;
                    }
                }
                else if (attendeeData.AttendeeType == MeetingAttendeeType.Optional)
                {
                    this.SetOptionalAttendeeAvailability(attendeeData, individualAttendeeConflictData);
                }
                else if (attendeeData.AttendeeType == MeetingAttendeeType.Room)
                {
                    this.SetRoomAttendeeAvailability(attendeeData, individualAttendeeConflictData);
                    if (individualAttendeeConflictData.BusyType != BusyType.NoData)
                    {
                        flag &= attendeeData.ExcludeConflict;
                    }
                }
                else if (attendeeData.AttendeeType == MeetingAttendeeType.Resource)
                {
                    this.SetResourceAttendeeAvailability(attendeeData, individualAttendeeConflictData);
                }
                else
                {
                    Suggestion.Tracer.TraceError <object, MeetingAttendeeType>((long)this.GetHashCode(), "{0}: unknown attendee type: {1}", TraceContext.Get(), attendeeData.AttendeeType);
                }
                if (attendeeData.AttendeeType == MeetingAttendeeType.Organizer)
                {
                    this.isWorkTime = attendeeData.WorkingHours.IsWorkTime(this.meetingStartTime, endUtc);
                }
                this.attendeeConflictDataArray[num] = individualAttendeeConflictData;
                num++;
            }
            if (this.roomsRequested)
            {
                this.excludeConflict = (this.excludeConflict || flag);
            }
            Suggestion.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: required: {1}, optional: {2}, worktime?: {3}", new object[]
            {
                TraceContext.Get(),
                this.requiredAttendeeCount,
                this.optionalAttendeeCount,
                this.isWorkTime
            });
            if (this.requiredAttendeeCount != 0)
            {
                this.sumPctReqFrontTime      = this.sumReqFrontTime / (double)this.requiredAttendeeCount;
                this.weightedPctReqConflicts = this.weightedReqConflicts / (double)this.requiredAttendeeCount;
            }
            else
            {
                this.weightedPctReqConflicts = 1.0;
            }
            if (this.optionalAttendeeCount != 0)
            {
                this.pctOptConflicts = (double)this.optionalAttendeeConflictCount / (double)this.optionalAttendeeCount;
                this.pctOptOverlap   = this.optOverlap / (double)this.optionalAttendeeCount;
            }
            this.timeSlotRating = this.GetRating();
            if (this.weightedPctReqConflicts == 0.0)
            {
                this.bucket = SuggestionQuality.Excellent;
            }
            else if (this.weightedPctReqConflicts * 100.0 >= 50.0)
            {
                this.bucket = SuggestionQuality.Poor;
            }
            else if (this.weightedPctReqConflicts * 100.0 <= (double)this.options.GoodThreshold)
            {
                this.bucket = SuggestionQuality.Good;
            }
            else
            {
                this.bucket = SuggestionQuality.Fair;
            }
            Suggestion.Tracer.TraceDebug <object, long, SuggestionQuality>((long)this.GetHashCode(), "{0}: final suggestion results, timeSlotRating: {1}, bucket: {2}", TraceContext.Get(), this.timeSlotRating, this.bucket);
        }
Пример #3
0
        internal SuggestionDayResult(ExDateTime currentDate, int inputMeetingDuration, int requiredAttendeeCount, int optionalAttendeeCount, AttendeeData[] attendees, ConfigOptions options, ExDateTime currentMeetingTime)
        {
            this.date = currentDate.LocalTime;
            ExDateTime        t          = ExDateTime.Now.ToUtc();
            List <Suggestion> list       = new List <Suggestion>();
            ExDateTime        t2         = currentDate.AddDays(1.0);
            ExDateTime        exDateTime = currentDate.ToUtc();

            while (exDateTime < t2)
            {
                if (exDateTime >= t || exDateTime == currentMeetingTime)
                {
                    list.Add(new Suggestion(currentDate.TimeZone.ConvertDateTime(exDateTime), inputMeetingDuration, requiredAttendeeCount, optionalAttendeeCount, attendees, options));
                }
                exDateTime = exDateTime.AddMinutes((double)options.SuggestionInterval);
            }
            this.rawSuggestionsList = list.ToArray();
            this.FilterSuggestions(list, options, currentMeetingTime);
            foreach (Suggestion suggestion in list)
            {
                if (suggestion.SuggestionQuality < this.quality)
                {
                    this.quality = suggestion.SuggestionQuality;
                }
            }
            this.meetingSuggestions = list.ToArray();
        }