Beispiel #1
0
        internal void Validate(Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent, List <GlobalObjectId> inquiredMasterGoids, Action <long> onItemRepaired)
        {
            MeetingComparisonResult resultPerAttendee = CalendarInstanceContext.GetResultPerAttendee(this.ValidationResult, this.ValidationContext.Attendee);
            MeetingComparer         meetingComparer   = new MeetingComparer(this.ValidationContext);

            meetingComparer.Run(resultPerAttendee, ref organizerRumsSent);
            if (resultPerAttendee.InquiredMeeting && this.ValidationContext.BaseItem.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                inquiredMasterGoids.Add(this.ValidationContext.BaseItem.GlobalObjectId);
            }
            if (onItemRepaired != null)
            {
                onItemRepaired(meetingComparer.NumberOfSuccessfulRepairAttempts);
            }
            foreach (ConsistencyCheckResult consistencyCheckResult in resultPerAttendee)
            {
                if (consistencyCheckResult.Status != CheckStatusType.Passed)
                {
                    this.ValidationResult.IsConsistent = false;
                    break;
                }
            }
            this.IsValidationDone = true;
            this.ValidationResult.WasValidationSuccessful = true;
        }
        private bool IsOrganizerValid(MailboxSession organizerSession, CalendarInstanceContext instanceContext)
        {
            bool isOrganizer = false;
            CalendarVersionStoreGateway cvsGateway = instanceContext.ValidationContext.CvsGateway;

            cvsGateway.QueryByGlobalObjectId(organizerSession, instanceContext.ValidationContext.BaseItem.GlobalObjectId, string.Empty, new StorePropertyDefinition[]
            {
                StoreObjectSchema.ItemClass,
                CalendarItemBaseSchema.AppointmentState
            }, delegate(PropertyBag propertyBag)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass);
                if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault))
                {
                    AppointmentStateFlags valueOrDefault2 = propertyBag.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
                    isOrganizer = ((valueOrDefault2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None);
                    if (!isOrganizer)
                    {
                        return(false);
                    }
                }
                return(true);
            }, false, null, null, null);
            return(isOrganizer);
        }
Beispiel #3
0
        internal void ValidateInstance(CalendarInstanceContext instanceContext, Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent, Action <long> onItemRepaired)
        {
            GlobalObjectId item = new GlobalObjectId(instanceContext.ValidationContext.BaseItem.CleanGlobalObjectId);

            if (!this.inquiredMasterGoids.Contains(item))
            {
                try
                {
                    instanceContext.Validate(organizerRumsSent, this.inquiredMasterGoids, onItemRepaired);
                    return;
                }
                catch (AttachmentExceededException arg)
                {
                    Globals.ConsistencyChecksTracer.TraceError <AttachmentExceededException>((long)this.GetHashCode(), "{0}: Unable to save RUM", arg);
                    return;
                }
            }
            Globals.ConsistencyChecksTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "Skipping meeting validation because its master instance already sent an inquiry message. Meeting GOID: {0}", instanceContext.ValidationContext.BaseItem.GlobalObjectId);
        }
        internal override void ValidateMeetings(ref Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent, Action <long> onItemRepaired)
        {
            bool shouldProcessMailbox = CalendarParticipant.InternalShouldProcessMailbox(this.ExchangePrincipal);

            try
            {
                List <SearchExpressionType> list = new List <SearchExpressionType>();
                foreach (CalendarInstanceContext calendarInstanceContext in base.ItemList.Values)
                {
                    calendarInstanceContext.ValidationContext.CalendarInstance = new CalendarRemoteItem(this.ExchangePrincipal, this.binding);
                    calendarInstanceContext.ValidationContext.CalendarInstance.ShouldProcessMailbox = shouldProcessMailbox;
                    GlobalObjectId       globalObjectId = calendarInstanceContext.ValidationContext.BaseItem.GlobalObjectId;
                    string               value          = Convert.ToBase64String(globalObjectId.CleanGlobalObjectIdBytes);
                    SearchExpressionType item           = new IsEqualToType
                    {
                        Item = CalendarItemFields.CleanGlobalObjectIdProp,
                        FieldURIOrConstant = new FieldURIOrConstantType
                        {
                            Item = new ConstantValueType
                            {
                                Value = value
                            }
                        }
                    };
                    list.Add(item);
                }
                ItemType[] remoteCalendarItems = this.GetRemoteCalendarItems(list);
                if (remoteCalendarItems != null)
                {
                    Dictionary <GlobalObjectId, CalendarItemType> dictionary = new Dictionary <GlobalObjectId, CalendarItemType>();
                    foreach (ItemType itemType in remoteCalendarItems)
                    {
                        CalendarItemType calendarItemType = itemType as CalendarItemType;
                        GlobalObjectId   globalObjectId2  = CalendarItemFields.GetGlobalObjectId(calendarItemType);
                        dictionary.Add(globalObjectId2, calendarItemType);
                    }
                    foreach (KeyValuePair <GlobalObjectId, CalendarInstanceContext> keyValuePair in base.ItemList)
                    {
                        if (dictionary.ContainsKey(keyValuePair.Key))
                        {
                            CalendarItemType        remoteItem = dictionary[keyValuePair.Key];
                            CalendarInstanceContext value2     = keyValuePair.Value;
                            try
                            {
                                try
                                {
                                    CalendarItemBase calendarItemBase = CalendarItem.Create(this.localSession, this.localSession.GetDefaultFolderId(DefaultFolderType.Calendar));
                                    Globals.ConsistencyChecksTracer.TraceDebug((long)this.GetHashCode(), "Converting the EWS item to XSO.");
                                    this.calendarConverter.ConvertItem(calendarItemBase, remoteItem);
                                    value2.ValidationContext.OppositeItem = calendarItemBase;
                                }
                                catch (FormatException ex)
                                {
                                    string text = string.Format("Could not convert the remote item, exception = {0}", ex.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                catch (CorruptDataException ex2)
                                {
                                    string text2 = string.Format("Could not convert the remote item, exception = {0}", ex2.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text2);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text2, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                catch (StorageTransientException ex3)
                                {
                                    string text3 = string.Format("Could not convert the remote item, exception = {0}", ex3.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text3);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text3, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                continue;
                            }
                            finally
                            {
                                base.ValidateInstance(value2, organizerRumsSent, onItemRepaired);
                                if (value2.ValidationContext.OppositeItem != null)
                                {
                                    value2.ValidationContext.OppositeItem.Dispose();
                                    value2.ValidationContext.OppositeItem = null;
                                }
                            }
                        }
                        Globals.ConsistencyChecksTracer.TraceDebug((long)this.GetHashCode(), "GetItem didn't return an expected GlobalObjectId.");
                    }
                }
                foreach (CalendarInstanceContext calendarInstanceContext2 in base.ItemList.Values)
                {
                    if (!calendarInstanceContext2.IsValidationDone)
                    {
                        if (calendarInstanceContext2.ValidationContext.OppositeRole == RoleType.Organizer && calendarInstanceContext2.ValidationContext.OppositeItem == null)
                        {
                            calendarInstanceContext2.ValidationContext.OppositeRoleOrganizerIsValid = true;
                        }
                        base.ValidateInstance(calendarInstanceContext2, organizerRumsSent, onItemRepaired);
                    }
                }
            }
            catch (ProtocolViolationException exception)
            {
                this.HandleRemoteException(exception);
            }
            catch (SecurityException exception2)
            {
                this.HandleRemoteException(exception2);
            }
            catch (ArgumentException exception3)
            {
                this.HandleRemoteException(exception3);
            }
            catch (InvalidOperationException exception4)
            {
                this.HandleRemoteException(exception4);
            }
            catch (NotSupportedException exception5)
            {
                this.HandleRemoteException(exception5);
            }
            catch (XmlException exception6)
            {
                this.HandleRemoteException(exception6);
            }
            catch (XPathException exception7)
            {
                this.HandleRemoteException(exception7);
            }
            catch (SoapException exception8)
            {
                this.HandleRemoteException(exception8);
            }
            catch (IOException exception9)
            {
                this.HandleRemoteException(exception9);
            }
        }