Exemplo n.º 1
0
        internal override ClientIntentFlags?GetLocationIntent(CalendarValidationContext context, GlobalObjectId globalObjectId, string organizerLocation, string attendeeLocation)
        {
            ICalendarItemStateDefinition initialState      = new LocationBasedCalendarItemStateDefinition(organizerLocation);
            ICalendarItemStateDefinition targetState       = new LocationBasedCalendarItemStateDefinition(attendeeLocation);
            ClientIntentQuery            clientIntentQuery = new TransitionalClientIntentQuery(globalObjectId, initialState, targetState);

            return(clientIntentQuery.Execute(this.session, context.CvsGateway).Intent);
        }
        protected override ConsistencyCheckResult DetectInconsistencies()
        {
            ConsistencyCheckResult result    = ConsistencyCheckResult.CreateInstance(base.Type, base.Description);
            ExDateTime             startTime = base.Context.OrganizerItem.StartTime;
            ExDateTime             endTime   = base.Context.OrganizerItem.EndTime;
            string     location   = base.Context.OrganizerItem.Location;
            ExDateTime startTime2 = base.Context.AttendeeItem.StartTime;
            ExDateTime endTime2   = base.Context.AttendeeItem.EndTime;
            string     location2  = base.Context.AttendeeItem.Location;
            int        appointmentSequenceNumber     = base.Context.OrganizerItem.AppointmentSequenceNumber;
            int        appointmentLastSequenceNumber = base.Context.OrganizerItem.AppointmentLastSequenceNumber;
            ExDateTime ownerCriticalChangeTime       = base.Context.OrganizerItem.OwnerCriticalChangeTime;
            ExDateTime attendeeCriticalChangeTime    = base.Context.OrganizerItem.AttendeeCriticalChangeTime;
            int        appointmentSequenceNumber2    = base.Context.AttendeeItem.AppointmentSequenceNumber;
            ExDateTime ownerCriticalChangeTime2      = base.Context.AttendeeItem.OwnerCriticalChangeTime;
            ExDateTime attendeeCriticalChangeTime2   = base.Context.AttendeeItem.AttendeeCriticalChangeTime;
            bool       flag = false;

            if (appointmentSequenceNumber == appointmentSequenceNumber2 || (appointmentSequenceNumber != appointmentLastSequenceNumber && appointmentLastSequenceNumber >= appointmentSequenceNumber2))
            {
                flag = true;
            }
            else if (ExDateTime.Compare(ownerCriticalChangeTime, ownerCriticalChangeTime2, MeetingPropertiesMatchCheck.DateTimeComparisonTreshold) == 0)
            {
                flag = true;
            }
            else if (ExDateTime.Compare(attendeeCriticalChangeTime, attendeeCriticalChangeTime2, MeetingPropertiesMatchCheck.DateTimeComparisonTreshold) == 0)
            {
                flag = true;
            }
            else
            {
                this.FailCheck(result, CalendarInconsistencyFlag.VersionInfo, "SequenceNumber", appointmentSequenceNumber, appointmentSequenceNumber2);
                this.FailCheck(result, CalendarInconsistencyFlag.VersionInfo, "OwnerCriticalChangeTime", ownerCriticalChangeTime, ownerCriticalChangeTime2);
                this.FailCheck(result, CalendarInconsistencyFlag.VersionInfo, "AttendeeCriticalChangeTime", attendeeCriticalChangeTime, attendeeCriticalChangeTime2);
            }
            if (!flag)
            {
                ExDateTime utcNow = ExDateTime.UtcNow;
                if (ExDateTime.Compare(ownerCriticalChangeTime, utcNow, TimeSpan.FromMinutes(120.0)) != 0)
                {
                    this.FailCheck(result, CalendarInconsistencyFlag.VersionInfo, "DelayedUpdates", ownerCriticalChangeTime.ToUtc().ToString(), utcNow.ToUtc().ToString());
                }
            }
            bool flag2 = MeetingPropertiesMatchCheck.CheckForMeetingOverlapInconsistency(startTime, endTime, startTime2, endTime2);

            if (flag2)
            {
                this.FailCheck(result, CalendarInconsistencyFlag.TimeOverlap, "MeetingOverlap", (startTime - endTime).TotalMinutes, 0);
            }
            bool flag3 = false;

            this.CheckTimeConsistency(result, MeetingPropertiesMatchCheck.TimeProperty.StartTime, ref flag3);
            this.CheckTimeConsistency(result, MeetingPropertiesMatchCheck.TimeProperty.EndTime, ref flag3);
            if (location != null && location2 != null && !location2.Contains(location))
            {
                try
                {
                    ClientIntentFlags?clientIntentFlags;
                    if (base.Context.BaseRole == RoleType.Attendee)
                    {
                        ICalendarItemStateDefinition initialState      = new LocationBasedCalendarItemStateDefinition(location);
                        ICalendarItemStateDefinition targetState       = new LocationBasedCalendarItemStateDefinition(location2);
                        ClientIntentQuery            clientIntentQuery = new TransitionalClientIntentQuery(base.Context.AttendeeItem.GlobalObjectId, initialState, targetState);
                        clientIntentFlags = clientIntentQuery.Execute((MailboxSession)base.Context.AttendeeItem.Session, base.Context.CvsGateway).Intent;
                    }
                    else
                    {
                        clientIntentFlags = base.Context.CalendarInstance.GetLocationIntent(base.Context, base.Context.AttendeeItem.GlobalObjectId, location, location2);
                    }
                    if (!ClientIntentQuery.CheckDesiredClientIntent(clientIntentFlags, new ClientIntentFlags[]
                    {
                        ClientIntentFlags.ModifiedLocation
                    }))
                    {
                        this.FailCheck(result, CalendarInconsistencyFlag.Location, "Location", location, location2, clientIntentFlags);
                    }
                }
                catch (CalendarVersionStoreNotPopulatedException exc)
                {
                    this.FailCheck(result, Inconsistency.CreateMissingCvsInconsistency(RoleType.Attendee, exc, base.Context));
                }
            }
            return(result);
        }