Example #1
0
        public static MeetingValidationResult CreateOutputObject(MeetingValidationResult result)
        {
            MeetingValidationResult meetingValidationResult = new MeetingValidationResult();

            meetingValidationResult.PrimarySmtpAddress      = new SmtpAddress(result.MailboxUserPrimarySmtpAddress);
            meetingValidationResult.ValidatingRole          = (result.IsOrganizer ? "Organizer" : "Attendee");
            meetingValidationResult.WasValidationSuccessful = result.WasValidationSuccessful;
            meetingValidationResult.StartTime         = result.StartTime;
            meetingValidationResult.EndTime           = result.EndTime;
            meetingValidationResult.IntervalStartDate = result.IntervalStartDate;
            meetingValidationResult.IntervalEndDate   = result.IntervalEndDate;
            meetingValidationResult.Location          = result.Location;
            meetingValidationResult.Subject           = result.Subject;
            if (result.MeetingId != null)
            {
                meetingValidationResult.MeetingId = result.MeetingId.ToBase64String();
            }
            meetingValidationResult.MeetingType = result.ItemType.ToString();
            if (result.GlobalObjectId != null)
            {
                meetingValidationResult.GlobalObjectId = result.GlobalObjectId.ToString();
            }
            if (result.CleanGlobalObjectId != null)
            {
                meetingValidationResult.CleanGlobalObjectId = result.CleanGlobalObjectId.ToString();
            }
            meetingValidationResult.CreationTime       = result.CreationTime;
            meetingValidationResult.LastModifiedTime   = result.LastModifiedTime;
            meetingValidationResult.DuplicatesDetected = result.DuplicatesDetected;
            meetingValidationResult.IsConsistent       = result.IsConsistent;
            if (!string.IsNullOrEmpty(result.OrganizerPrimarySmtpAddress))
            {
                meetingValidationResult.Organizer = result.OrganizerPrimarySmtpAddress;
            }
            if (result.MeetingData != null)
            {
                meetingValidationResult.InternetMessageId          = result.MeetingData.InternetMessageId;
                meetingValidationResult.ExtractVersion             = result.MeetingData.ExtractVersion;
                meetingValidationResult.ExtractTime                = result.MeetingData.ExtractTime;
                meetingValidationResult.HasConflicts               = result.MeetingData.HasConflicts;
                meetingValidationResult.NumDelegates               = result.NumberOfDelegates;
                meetingValidationResult.SequenceNumber             = result.MeetingData.SequenceNumber;
                meetingValidationResult.OwnerApptId                = (result.MeetingData.OwnerAppointmentId ?? -2);
                meetingValidationResult.OwnerCriticalChangeTime    = result.MeetingData.OwnerCriticalChangeTime;
                meetingValidationResult.AttendeeCriticalChangeTime = result.MeetingData.AttendeeCriticalChangeTime;
            }
            if (!string.IsNullOrEmpty(result.ErrorDescription))
            {
                meetingValidationResult.ErrorDescription = result.ErrorDescription;
            }
            return(meetingValidationResult);
        }
Example #2
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();
        }
        private void DoCalendarValidation(ADUser user)
        {
            List <MeetingValidationResult> list = null;

            base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), 0);
            try
            {
                TopologyProvider.SetProcessTopologyMode(false, false);
                string            mailboxUserAddress = string.Format("SMTP:{0}", user.PrimarySmtpAddress);
                CalendarValidator calendarValidator;
                if (!string.IsNullOrEmpty(this.MeetingID))
                {
                    VersionedId meetingId = new VersionedId(this.MeetingID);
                    calendarValidator = CalendarValidator.CreateMeetingSpecificValidatingInstance(mailboxUserAddress, user.OrganizationId, base.RootOrgContainerId, meetingId);
                }
                else
                {
                    calendarValidator = CalendarValidator.CreateRangeValidatingInstance(mailboxUserAddress, user.OrganizationId, base.RootOrgContainerId, this.IntervalStartDate, this.IntervalEndDate, this.Location, this.Subject);
                }
                list = calendarValidator.Run();
            }
            catch (WrongServerException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidArgument, this);
            }
            catch (MailboxUserNotFoundException exception2)
            {
                base.WriteError(exception2, ErrorCategory.InvalidData, this);
            }
            catch (CorruptDataException exception3)
            {
                base.WriteError(exception3, ErrorCategory.InvalidData, this);
            }
            finally
            {
                TopologyProvider.SetProcessTopologyMode(true, false);
            }
            this.validatorObjectCount = 0;
            int num = (list.Count > 0) ? list.Count : 1;

            foreach (MeetingValidationResult meetingValidationResult in list)
            {
                if (!this.OnlyReportErrors || !meetingValidationResult.IsConsistent || !meetingValidationResult.WasValidationSuccessful || meetingValidationResult.DuplicatesDetected)
                {
                    MeetingValidationResult meetingValidationResult2 = MeetingValidationResult.CreateOutputObject(meetingValidationResult);
                    MeetingValidationResult.FilterResultsLists(meetingValidationResult2, meetingValidationResult, this.FailureCategoryType, this.OnlyReportErrors);
                    this.validatorObjectCount++;
                    bool flag = true;
                    if (meetingValidationResult2.ResultsPerAttendee.Length < 1)
                    {
                        flag = false;
                    }
                    if ((this.FailureCategoryType & FailureCategory.CorruptMeetings) == FailureCategory.CorruptMeetings && !meetingValidationResult2.WasValidationSuccessful)
                    {
                        flag = true;
                    }
                    else if ((this.FailureCategoryType & FailureCategory.DuplicateMeetings) == FailureCategory.DuplicateMeetings && meetingValidationResult2.DuplicatesDetected)
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        meetingValidationResult2.SetIsReadOnly(true);
                        base.WriteResult(meetingValidationResult2);
                    }
                    base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), this.validatorObjectCount / num * 100);
                }
            }
            base.WriteProgress(Strings.CalendarValidationTask, Strings.ValidatingCalendar(this.Identity.ToString()), 100);
        }