Пример #1
0
        private Inconsistency GetAttendeeMissingItemInconsistency(CalendarValidationContext context, string fullDescription, ClientIntentFlags?inconsistencyIntent, ClientIntentFlags declineIntent, ClientIntentFlags deleteIntent)
        {
            Inconsistency inconsistency = null;

            if (ClientIntentQuery.CheckDesiredClientIntent(inconsistencyIntent, new ClientIntentFlags[]
            {
                declineIntent
            }))
            {
                inconsistency        = ResponseInconsistency.CreateInstance(fullDescription, ResponseType.Decline, context.Attendee.ResponseType, ExDateTime.MinValue, context.Attendee.ReplyTime, context);
                inconsistency.Intent = inconsistencyIntent;
            }
            else if (ClientIntentQuery.CheckDesiredClientIntent(inconsistencyIntent, new ClientIntentFlags[]
            {
                deleteIntent
            }))
            {
                inconsistency = null;
            }
            else if (this.calendarIntent != null && this.calendarIntent.ItemVersion > 0)
            {
                inconsistency        = MissingItemInconsistency.CreateAttendeeMissingItemInstance(fullDescription, inconsistencyIntent, new int?(this.calendarIntent.ItemVersion), context);
                inconsistency.Intent = inconsistencyIntent;
            }
            return(inconsistency);
        }
Пример #2
0
        private Inconsistency GetAttendeeMissingItemInconsistency(CalendarValidationContext context, string fullDescription, ClientIntentQuery.QueryResult inconsistencyIntent, ClientIntentFlags declineIntent, ClientIntentFlags deleteIntent)
        {
            Inconsistency inconsistency = null;

            if (ClientIntentQuery.CheckDesiredClientIntent(inconsistencyIntent.Intent, new ClientIntentFlags[]
            {
                declineIntent
            }))
            {
                inconsistency        = ResponseInconsistency.CreateInstance(fullDescription, ResponseType.Decline, context.Attendee.ResponseType, ExDateTime.MinValue, context.Attendee.ReplyTime, context);
                inconsistency.Intent = inconsistencyIntent.Intent;
            }
            else if (ClientIntentQuery.CheckDesiredClientIntent(inconsistencyIntent.Intent, new ClientIntentFlags[]
            {
                deleteIntent
            }))
            {
                inconsistency = null;
            }
            else if (inconsistencyIntent.SourceVersionId != null)
            {
                int?deletedItemVersion = null;
                using (CalendarItemBase calendarItemBase = CalendarItemBase.Bind(this.session, inconsistencyIntent.SourceVersionId))
                {
                    deletedItemVersion = calendarItemBase.GetValueAsNullable <int>(CalendarItemBaseSchema.ItemVersion);
                }
                if (deletedItemVersion != null)
                {
                    inconsistency        = MissingItemInconsistency.CreateAttendeeMissingItemInstance(fullDescription, inconsistencyIntent.Intent, deletedItemVersion, context);
                    inconsistency.Intent = inconsistencyIntent.Intent;
                }
            }
            return(inconsistency);
        }
Пример #3
0
        private static bool TryGetCancelledVersionIdFromCvs(CalendarVersionStoreGateway cvsGateway, GlobalObjectId globalObjectId, MailboxSession session, byte[] calendarFolderId, out VersionedId deletedVersionId)
        {
            ClientIntentFlags clientIntentFlags;
            ClientIntentQuery clientIntentQuery;

            if (globalObjectId.IsCleanGlobalObjectId)
            {
                clientIntentFlags = ClientIntentFlags.MeetingCanceled;
                ICalendarItemStateDefinition deletedFromFolderStateDefinition = CompositeCalendarItemStateDefinition.GetDeletedFromFolderStateDefinition(calendarFolderId);
                clientIntentQuery = new ItemDeletionClientIntentQuery(globalObjectId, deletedFromFolderStateDefinition);
            }
            else
            {
                clientIntentFlags = ClientIntentFlags.MeetingExceptionCanceled;
                ICalendarItemStateDefinition targetState = new DeletedOccurrenceCalendarItemStateDefinition(globalObjectId.Date, false);
                clientIntentQuery = new NonTransitionalClientIntentQuery(globalObjectId, targetState);
            }
            ClientIntentQuery.QueryResult queryResult = clientIntentQuery.Execute(session, cvsGateway);
            deletedVersionId = queryResult.SourceVersionId;
            return(ClientIntentQuery.CheckDesiredClientIntent(queryResult.Intent, new ClientIntentFlags[]
            {
                clientIntentFlags
            }));
        }
Пример #4
0
        public static void FilterResultsLists(MeetingValidationResult cmdLetValidationResult, MeetingValidationResult result, FailureCategory failureCategory, bool onlyReportErrors)
        {
            List <ResultsPerAttendee> list = new List <ResultsPerAttendee>();

            foreach (KeyValuePair <string, MeetingComparisonResult> keyValuePair in result.ResultsPerAttendee)
            {
                ResultsPerAttendee resultsPerAttendee = new ResultsPerAttendee();
                resultsPerAttendee.PrimarySMTPAddress = new SmtpAddress(keyValuePair.Key);
                foreach (ConsistencyCheckResult consistencyCheckResult in keyValuePair.Value)
                {
                    if (!onlyReportErrors || consistencyCheckResult.Status != CheckStatusType.Passed)
                    {
                        foreach (Inconsistency inconsistency in consistencyCheckResult)
                        {
                            switch (consistencyCheckResult.CheckType)
                            {
                            case ConsistencyCheckType.CanValidateOwnerCheck:
                                if (inconsistency.Flag == CalendarInconsistencyFlag.Organizer)
                                {
                                    resultsPerAttendee.CantOpen = "CanValidateCheck failed " + inconsistency.Description;
                                }
                                else
                                {
                                    resultsPerAttendee.MailboxUnavailable = "CanValidateCheck failed " + consistencyCheckResult.ErrorString;
                                }
                                break;

                            case ConsistencyCheckType.MeetingExistenceCheck:
                                if (inconsistency.Flag == CalendarInconsistencyFlag.Response)
                                {
                                    resultsPerAttendee.IntentionalWrongTrackingInfo = string.Format("MeetingExistenceCheck failed (intent: {0}) {1}", inconsistency.Intent, consistencyCheckResult.ErrorString);
                                }
                                else if (inconsistency.Flag == CalendarInconsistencyFlag.OrphanedMeeting && ClientIntentQuery.CheckDesiredClientIntent(inconsistency.Intent, new ClientIntentFlags[]
                                {
                                    ClientIntentFlags.MeetingCanceled,
                                    ClientIntentFlags.MeetingExceptionCanceled
                                }))
                                {
                                    resultsPerAttendee.IntentionalMissingMeetings = string.Format("MeetingExistenceCheck failed (intent: {0}) {1}", inconsistency.Intent, consistencyCheckResult.ErrorString);
                                }
                                else
                                {
                                    resultsPerAttendee.MissingMeetings = string.Format("MeetingExistenceCheck failed (intent: {0}) {1}", inconsistency.Intent, consistencyCheckResult.ErrorString);
                                }
                                break;

                            case ConsistencyCheckType.ValidateStoreObjectCheck:
                                resultsPerAttendee.CantOpen = "ValidateStoreObjectCheck failed " + inconsistency.Description;
                                break;

                            case ConsistencyCheckType.MeetingCancellationCheck:
                                resultsPerAttendee.WrongTrackingInfo = "MeetingCancellationCheck failed " + consistencyCheckResult.ErrorString;
                                break;

                            case ConsistencyCheckType.AttendeeOnListCheck:
                                resultsPerAttendee.WrongTrackingInfo = "AttendeeOnListCheck failed " + consistencyCheckResult.ErrorString;
                                break;

                            case ConsistencyCheckType.CorrectResponseCheck:
                            {
                                ResponseInconsistency responseInconsistency = inconsistency as ResponseInconsistency;
                                if (responseInconsistency != null)
                                {
                                    resultsPerAttendee.WrongTrackingInfo = "CorrectResponseCheck: Attendee has a response that is different from what was sent to the organizer.";
                                    ResultsPerAttendee resultsPerAttendee2 = resultsPerAttendee;
                                    resultsPerAttendee2.WrongTrackingInfo += string.Format("User {0} at {1}, the organizer expected {2} at {3}. ", new object[]
                                        {
                                            responseInconsistency.ExpectedResponse,
                                            responseInconsistency.AttendeeReplyTime,
                                            responseInconsistency.ActualResponse,
                                            responseInconsistency.OrganizerRecordedTime
                                        });
                                    ResultsPerAttendee resultsPerAttendee3 = resultsPerAttendee;
                                    resultsPerAttendee3.WrongTrackingInfo += responseInconsistency.Description;
                                }
                                break;
                            }

                            case ConsistencyCheckType.MeetingPropertiesMatchCheck:
                            {
                                PropertyInconsistency propertyInconsistency = inconsistency as PropertyInconsistency;
                                if (propertyInconsistency != null)
                                {
                                    string text;
                                    if (result.IsOrganizer)
                                    {
                                        text = propertyInconsistency.ActualValue;
                                    }
                                    else
                                    {
                                        text = propertyInconsistency.ExpectedValue;
                                    }
                                    if (propertyInconsistency.PropertyName.Contains("StartTime"))
                                    {
                                        Match match = Regex.Match(text, "Start\\[(?<value>.+)\\]");
                                        resultsPerAttendee.WrongStartTime = (match.Success ? match.Groups["value"].Value : text);
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("EndTime"))
                                    {
                                        Match match2 = Regex.Match(text, "End\\[(?<value>.+)\\]");
                                        resultsPerAttendee.WrongEndTime = (match2.Success ? match2.Groups["value"].Value : text);
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("Location"))
                                    {
                                        resultsPerAttendee.WrongLocation = text;
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("MeetingOverlap"))
                                    {
                                        resultsPerAttendee.WrongOverlap = text;
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("SequenceNumber"))
                                    {
                                        ResultsPerAttendee resultsPerAttendee4 = resultsPerAttendee;
                                        resultsPerAttendee4.DelayedUpdatesWrongVersion = resultsPerAttendee4.DelayedUpdatesWrongVersion + text + ", ";
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("OwnerCriticalChangeTime"))
                                    {
                                        ResultsPerAttendee resultsPerAttendee5 = resultsPerAttendee;
                                        resultsPerAttendee5.DelayedUpdatesWrongVersion = resultsPerAttendee5.DelayedUpdatesWrongVersion + text + ", ";
                                    }
                                    else if (propertyInconsistency.PropertyName.Contains("AttendeeCriticalChangeTime"))
                                    {
                                        ResultsPerAttendee resultsPerAttendee6 = resultsPerAttendee;
                                        resultsPerAttendee6.DelayedUpdatesWrongVersion = resultsPerAttendee6.DelayedUpdatesWrongVersion + text + ", ";
                                    }
                                }
                                break;
                            }

                            case ConsistencyCheckType.RecurrenceBlobsConsistentCheck:
                                resultsPerAttendee.RecurrenceProblems = "RecurrenceBlobsConsistentCheck failed " + consistencyCheckResult.ErrorString;
                                break;

                            case ConsistencyCheckType.RecurrencesMatchCheck:
                                resultsPerAttendee.RecurrenceProblems = "RecurrencesMatchCheck failed " + consistencyCheckResult.ErrorString;
                                break;

                            case ConsistencyCheckType.TimeZoneMatchCheck:
                            {
                                PropertyInconsistency propertyInconsistency2 = inconsistency as PropertyInconsistency;
                                if (propertyInconsistency2 != null)
                                {
                                    resultsPerAttendee.WrongTimeZone = propertyInconsistency2.ActualValue + "(Expected: " + propertyInconsistency2.ExpectedValue + ")";
                                }
                                break;
                            }
                            }
                        }
                    }
                }
                bool flag = false;
                if (failureCategory != FailureCategory.All)
                {
                    if ((failureCategory & FailureCategory.DuplicateMeetings) == FailureCategory.DuplicateMeetings && !string.IsNullOrEmpty(resultsPerAttendee.Duplicates))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.WrongLocation) == FailureCategory.WrongLocation && !string.IsNullOrEmpty(resultsPerAttendee.WrongLocation))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.WrongTime) == FailureCategory.WrongTime && (!string.IsNullOrEmpty(resultsPerAttendee.WrongStartTime) || !string.IsNullOrEmpty(resultsPerAttendee.WrongEndTime)))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.WrongTrackingStatus) == FailureCategory.WrongTrackingStatus && !string.IsNullOrEmpty(resultsPerAttendee.WrongTrackingInfo))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.CorruptMeetings) == FailureCategory.CorruptMeetings && (!string.IsNullOrEmpty(resultsPerAttendee.CantOpen) || !string.IsNullOrEmpty(cmdLetValidationResult.ErrorDescription)))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.MissingMeetings) == FailureCategory.MissingMeetings && !string.IsNullOrEmpty(resultsPerAttendee.MissingMeetings))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.RecurrenceProblems) == FailureCategory.RecurrenceProblems && !string.IsNullOrEmpty(resultsPerAttendee.RecurrenceProblems))
                    {
                        flag = true;
                    }
                    else if ((failureCategory & FailureCategory.MailboxUnavailable) == FailureCategory.MailboxUnavailable && !string.IsNullOrEmpty(resultsPerAttendee.MailboxUnavailable))
                    {
                        flag = true;
                    }
                }
                else if (!onlyReportErrors || resultsPerAttendee.HasErrors())
                {
                    flag = true;
                }
                if (flag)
                {
                    list.Add(resultsPerAttendee);
                }
            }
            cmdLetValidationResult.ResultsPerAttendee = list.ToArray();
        }
        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);
        }