Ejemplo n.º 1
0
        internal static IEnumerable <StoreObjectId> GetSubfolders(IDiagnosticsSession tracer, Folder parentFolder, QueryFilter filter)
        {
            XsoUtil.< > c__DisplayClass6 CS$ < > 8__locals1 = new XsoUtil.< > c__DisplayClass6();
            CS$ < > 8__locals1.parentFolder = parentFolder;
            CS$ < > 8__locals1.filter       = filter;
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.parentFolder, "parentFolder");
            Guid mailboxGuid = CS$ < > 8__locals1.parentFolder.Session.MailboxGuid;

            using (QueryResult queryResult = XsoUtil.TranslateXsoExceptionsWithReturnValue <QueryResult>(tracer, Strings.ConnectionToMailboxFailed(mailboxGuid), () => CS$ < > 8__locals1.parentFolder.FolderQuery(FolderQueryFlags.DeepTraversal, CS$ < > 8__locals1.filter, null, new PropertyDefinition[]
            {
                FolderSchema.Id
            })))
            {
                for (;;)
                {
                    object[][] folders = XsoUtil.TranslateXsoExceptionsWithReturnValue <object[][]>(tracer, Strings.ConnectionToMailboxFailed(mailboxGuid), () => queryResult.GetRows(10000));
                    if (folders == null || folders.Length == 0)
                    {
                        break;
                    }
                    foreach (object[] folderProps in folders)
                    {
                        if (folderProps[0] != null && !PropertyError.IsPropertyError(folderProps[0]))
                        {
                            yield return(StoreId.GetStoreObjectId((StoreId)folderProps[0]));
                        }
                    }
                }
            }
            yield break;
        }
        private bool HandlePropertySetException(SettingsBase settings, SettingsStorageModel property, Exception ex, bool?throwSetException = null)
        {
            throwSetException = throwSetException ?? ThrowPropertySetException;

            if (!throwSetException.Value)
            {
                string caughtExceptionDetails = string.Format("{0}-{1}", ex.GetType().Name, property.Name);

                _periodicReaderErrors.Add(caughtExceptionDetails);

                if (PropertyError != null) //only raise event when not throttling
                {
                    var propertyException = new SettingsPropertyException(
                        String.Format("Error setting property {0}.{1}", settings.Category, property.Name),
                        property.Name,
                        settings.Category,
                        ex);

                    var repeatingErrorEventArgs = new RepeatingErrorEventArgs()
                    {
                        Exception   = propertyException,
                        IsRepeating = _periodicReaderErrors.Contains(caughtExceptionDetails)
                    };

                    PropertyError.Invoke(settings, repeatingErrorEventArgs);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 private void ProcessFolderNameChange(FolderCommand.FolderRequest folderRequest, Folder folder)
 {
     if (folder.DisplayName != folderRequest.DisplayName)
     {
         folder.DisplayName = folderRequest.DisplayName;
         FolderSaveResult folderSaveResult = folder.Save();
         if (folderSaveResult.Exception != null)
         {
             throw folderSaveResult.Exception;
         }
         if (folderSaveResult.OperationResult == OperationResult.PartiallySucceeded)
         {
             if (folderSaveResult.PropertyErrors.Length > 0)
             {
                 PropertyError propertyError = folderSaveResult.PropertyErrors[0];
                 if (propertyError.PropertyErrorCode == PropertyErrorCode.FolderNameConflict)
                 {
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderNameConflict");
                     throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                 }
                 this.ThrowUnknownFolderError(propertyError.PropertyErrorCode.ToString());
             }
             this.ThrowUnknownFolderError("PartialSuccessNoPropertyErrors");
         }
         folder.Load();
     }
 }
Ejemplo n.º 4
0
        private static bool HasTimerFired(ReliableTimer.Feature feature, IItem item)
        {
            StorePropertyDefinition storePropertyDefinition = ReliableTimer.featureToStorePropertyMapping[feature];

            item.Load(new List <PropertyDefinition>
            {
                storePropertyDefinition
            });
            object obj = item.TryGetProperty(storePropertyDefinition);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                ExTraceGlobals.ReliableTimerTracer.TraceDebug <ReliableTimer.Feature>(0L, "Timer not set for feature={0}", feature);
                return(false);
            }
            if (PropertyError.IsPropertyError(obj))
            {
                PropertyError propertyError = (PropertyError)obj;
                ExTraceGlobals.ReliableTimerTracer.TraceError <ReliableTimer.Feature, PropertyErrorCode>(0L, "Property error for feature={0}, propertyErrorCode={1}", feature, propertyError.PropertyErrorCode);
                throw PropertyError.ToException(new PropertyError[]
                {
                    propertyError
                });
            }
            ExDateTime exDateTime = (ExDateTime)obj;

            ExTraceGlobals.ReliableTimerTracer.TraceDebug <ReliableTimer.Feature, ExDateTime>(0L, "Timer value for feature={0}, timerValue={1}", feature, exDateTime);
            return(exDateTime == ReliableTimer.FiredTimerPropertyValue);
        }
 // Token: 0x06000604 RID: 1540 RVA: 0x0002E2C8 File Offset: 0x0002C4C8
 private bool AreItemsLegallyEqual(ICollection <PropertyDefinition> legalTrackingProperties, Item originalItem, Item currentItem)
 {
     using (IEnumerator <PropertyDefinition> enumerator = legalTrackingProperties.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             PropertyDefinition legalTrackingProperty = enumerator.Current;
             object             value  = originalItem.GetValue(legalTrackingProperty);
             object             value2 = currentItem.GetValue(legalTrackingProperty);
             if (value != null && value2 != null)
             {
                 if (!PropertyError.IsPropertyNotFound(value) || !PropertyError.IsPropertyNotFound(value2))
                 {
                     if (PropertyError.IsPropertyValueTooBig(value) && PropertyError.IsPropertyValueTooBig(value2))
                     {
                         if (!this.CompareStreams(() => originalItem.GetStream(legalTrackingProperty), () => currentItem.GetStream(legalTrackingProperty)))
                         {
                             this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, legalTrackingProperty);
                             return(false);
                         }
                     }
                     else if (!PropertyError.IsPropertyError(value) && !PropertyError.IsPropertyError(value2))
                     {
                         if (legalTrackingProperty.Type.IsArray)
                         {
                             if (!((Array)value).Compare((Array)value2))
                             {
                                 this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, legalTrackingProperty);
                                 return(false);
                             }
                         }
                         else if (!value.Equals(value2))
                         {
                             this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, legalTrackingProperty);
                             return(false);
                         }
                     }
                 }
             }
             else if (value != null || value2 != null)
             {
                 this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, legalTrackingProperty);
                 return(false);
             }
         }
     }
     if (originalItem is MessageItem && !this.CompareRecipients(((MessageItem)originalItem).Recipients, ((MessageItem)currentItem).Recipients))
     {
         this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, "Recipients");
         return(false);
     }
     if (!this.CompareAttachments(originalItem.AttachmentCollection, currentItem.AttachmentCollection))
     {
         this.LogDirtyProperty(currentItem.Id, originalItem.Id, originalItem.ClassName, "Attachments");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 6
0
        private static void LogPropError(object value)
        {
            PropertyError propertyError = value as PropertyError;

            if (propertyError != null && propertyError.PropertyErrorCode != PropertyErrorCode.NotFound)
            {
                TraceHelper.StoreDriverTracer.TracePass <PropertyError>(TraceHelper.MessageProbeActivityId, 0L, "Error when trying to access prop : {0}", propertyError);
            }
        }
        public AnnotatedPropertyValue GetAnnotatedProperty(PropertyTag propertyTag)
        {
            if (propertyTag == PropertyTag.Mid)
            {
                return(new AnnotatedPropertyValue(propertyTag, new PropertyValue(propertyTag, 0L), null));
            }
            object        obj           = this.propertyBag.TryGetProperty(ActivityPropertyBagAdapter.PropDefFromPropTag(propertyTag));
            PropertyValue propertyValue = PropertyError.IsPropertyError(obj) ? PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U) : new PropertyValue(propertyTag, obj);

            return(new AnnotatedPropertyValue(propertyTag, propertyValue, null));
        }
Ejemplo n.º 8
0
 public bool Equals(PropertyError other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Code, Code) && Equals(other.Attribute, Attribute));
 }
Ejemplo n.º 9
0
        private bool CheckAllPropertiesWereRetrieved(IStorePropertyBag propertyBag, ICollection <NativeStorePropertyDefinition> nativeRequiredPropertiesDefinition)
        {
            bool result = true;

            foreach (PropertyDefinition propertyDefinition in nativeRequiredPropertiesDefinition)
            {
                PropertyError propertyError = propertyBag.TryGetProperty(propertyDefinition) as PropertyError;
                if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.PropertyNotPromoted)
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
        protected override void StartListeningCore(WeakReference <object> reference)
        {
            reference.TryGetTarget(out object target);

            IPropertyAccessorPlugin plugin = null;

            foreach (IPropertyAccessorPlugin x in ExpressionObserver.PropertyAccessors)
            {
                if (x.Match(target, PropertyName))
                {
                    plugin = x;
                    break;
                }
            }

            var accessor = plugin?.Start(reference, PropertyName);

            // We need to handle accessor fallback before handling validation. Validators do not support null accessors.
            if (accessor == null)
            {
                reference.TryGetTarget(out object instance);

                var message = $"Could not find a matching property accessor for '{PropertyName}' on '{instance}'";

                var exception = new MissingMemberException(message);

                accessor = new PropertyError(new BindingNotification(exception, BindingErrorType.Error));
            }

            if (_enableValidation && Next == null)
            {
                foreach (var validator in ExpressionObserver.DataValidators)
                {
                    if (validator.Match(reference, PropertyName))
                    {
                        accessor = validator.Start(reference, PropertyName, accessor);
                    }
                }
            }

            if (accessor is null)
            {
                throw new AvaloniaInternalException("Data validators must return non-null accessor.");
            }

            _accessor = accessor;
            accessor.Subscribe(ValueChanged);
        }
Ejemplo n.º 11
0
 public static object BuildErrorDictionary(PropertyError root)
 {
     if(root.Indexes.Count > 0)
     {
         var ary = new object[root.Indexes.Keys.Max() + 1];
         foreach(var kvp in root.Indexes)
         {
             ary[kvp.Key] = BuildErrorDictionary(kvp.Value);
         }
         return ary;
     }
     if(root.Properties.Count > 0)
     {
         return root.Properties.ToDictionary(kvp => kvp.Key, kvp => BuildErrorDictionary(kvp.Value));
     }
     return root.BuildMessage();
 }
Ejemplo n.º 12
0
        private bool ValidateItem(string context, IStorePropertyBag item)
        {
            object obj = item[MailboxAssociationBaseSchema.LegacyDN];

            if (obj == null || PropertyError.IsPropertyError(obj) || string.IsNullOrEmpty(obj as string))
            {
                this.performanceTracker.IncrementMissingLegacyDns();
                string        arg            = item[ItemSchema.Id].ToString();
                string        valueOrDefault = item.GetValueOrDefault <string>(MailboxAssociationBaseSchema.ExternalId, "empty");
                PropertyError propertyError  = obj as PropertyError;
                string        arg2           = (propertyError == null) ? "null" : propertyError.ToString();
                string        errorMessage   = string.Format("LocalAssociationStore.QueryAssociationFolder: Missing LegacyDn for property bag with Id {0}, ExternalId {1}, PropertyError {2}", arg, valueOrDefault, arg2);
                this.LogError(context, errorMessage);
                return(false);
            }
            return(true);
        }
 public IEnumerable <AnnotatedPropertyValue> GetAnnotatedProperties()
 {
     foreach (KeyValuePair <PropertyDefinition, object> prop in ((IEnumerable <KeyValuePair <PropertyDefinition, object> >) this.propertyBag))
     {
         KeyValuePair <PropertyDefinition, object> keyValuePair = prop;
         if (!PropertyError.IsPropertyError(keyValuePair.Value))
         {
             KeyValuePair <PropertyDefinition, object> keyValuePair2 = prop;
             PropertyTag propertyTag  = new PropertyTag(((PropertyTagPropertyDefinition)keyValuePair2.Key).PropertyTag);
             PropertyTag propertyTag2 = propertyTag;
             PropertyTag propertyTag3 = propertyTag;
             KeyValuePair <PropertyDefinition, object> keyValuePair3 = prop;
             yield return(new AnnotatedPropertyValue(propertyTag2, new PropertyValue(propertyTag3, keyValuePair3.Value), null));
         }
     }
     yield break;
 }
Ejemplo n.º 14
0
        private bool TryGetPropertyFromBag <T>(IStorePropertyBag propertyBag, PropertyDefinition propDef, out T value)
        {
            object obj = null;

            try
            {
                obj = propertyBag.TryGetProperty(propDef);
            }
            catch (NotInBagPropertyErrorException)
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.TryGetPropertyFromBag] Caught NotInBag exception for property {0}.  Returning default for type.", propDef.Name);
                value = default(T);
                return(false);
            }
            if (obj is T)
            {
                value = (T)((object)obj);
                return(true);
            }
            PropertyError propertyError = obj as PropertyError;

            if (propertyError != null)
            {
                AirSyncDiagnostics.TraceDebug <Type, string, PropertyErrorCode>(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.TryGetPropertyFromBag] Expected property of type {0} in bag for propDef {1}, but encountered error {2}.", typeof(T), propDef.Name, propertyError.PropertyErrorCode);
            }
            else
            {
                try
                {
                    value = (T)((object)obj);
                    return(true);
                }
                catch (InvalidCastException ex)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.SyncProcessTracer, this, "[FirstTimeSyncProvider.TryGetPropertyFromBag] Tried to cast property '{0}' with value '{1}' to type '{2}', but the cast failed with error '{3}'.", new object[]
                    {
                        propDef.Name,
                        (obj == null) ? "<NULL>" : obj,
                        typeof(T).FullName,
                        ex
                    });
                }
            }
            value = default(T);
            return(false);
        }
Ejemplo n.º 15
0
        internal static object CheckPropertyValue(object propertyValue)
        {
            PropertyError propertyError = propertyValue as PropertyError;

            if (propertyError == null)
            {
                return(propertyValue);
            }
            if (propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                return(null);
            }
            throw PropertyError.ToException(new PropertyError[]
            {
                propertyError
            });
        }
Ejemplo n.º 16
0
        private object TryGetProperty(PropertyDefinition propertyDefinition)
        {
            object obj = this.StoreObject.TryGetProperty(propertyDefinition);

            if (propertyDefinition.Type == typeof(string) && PropertyError.IsPropertyValueTooBig(obj))
            {
                this.AnchorContext.Logger.Log(MigrationEventType.Verbose, "AnchorStoreObject.TryGetProperty: reading {0} as a stream", new object[]
                {
                    propertyDefinition
                });
                using (Stream stream = this.StoreObject.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
                {
                    if (stream.Length > 131072L)
                    {
                        throw new MigrationDataCorruptionException(string.Format("size of property {0} too large {1}", propertyDefinition, stream.Length));
                    }
                    int    num   = (int)stream.Length;
                    byte[] array = new byte[num];
                    int    i     = 0;
                    while (i < num)
                    {
                        int num2 = stream.Read(array, i, num - i);
                        i += num2;
                        if (num2 <= 0)
                        {
                            break;
                        }
                    }
                    if (i != num)
                    {
                        throw new MigrationDataCorruptionException(string.Format("size of property {0} inconsistent, expected {1}, found {2}", propertyDefinition, num, i));
                    }
                    UnicodeEncoding unicodeEncoding = new UnicodeEncoding(false, true, true);
                    try
                    {
                        obj = unicodeEncoding.GetString(array);
                    }
                    catch (ArgumentException innerException)
                    {
                        throw new MigrationDataCorruptionException(string.Format("couldn't decode bytes to utf16 for property {0}", propertyDefinition), innerException);
                    }
                }
            }
            return(obj);
        }
Ejemplo n.º 17
0
 public static PropertyError MakeHierarchical(ModelStateDictionary modelStateDictionary)
 {
     var root = new PropertyError();
     foreach(var kvp in modelStateDictionary.Where(kvp => kvp.Value.Errors.Count > 0))
     {
         PropertyError current = root;
         foreach(string property in kvp.Key.Split('.', '[', ']').Where(k => k != ""))
         {
             int index;
             current = int.TryParse(property, out index) ? current[index] : current[property];
         }
         foreach(ModelError modelError in kvp.Value.Errors)
         {
             current.Errors.Add(modelError);
         }
     }
     return root;
 }
Ejemplo n.º 18
0
        public object Convert(object value, object parameter)
        {
            ValidationErrorEventArgs e   = (ValidationErrorEventArgs)value;
            PropertyError            err = new PropertyError();

            err.PropertyName = ((System.Windows.Data.BindingExpression)(e.Error.BindingInError)).ResolvedSourcePropertyName;
            err.Error        = e.Error.ErrorContent.ToString();
            // Validation.ErrorEvent fires for addition and removal
            if (e.Action.ToString() == "Added")
            {
                err.Added = true;
            }
            else
            {
                err.Added = false;
            }
            return(err);
        }
Ejemplo n.º 19
0
        public T GetValueOrDefault <T>(PropertyDefinition propertyDefinition, T defaultValue)
        {
            object        obj           = this.TryGetProperty(propertyDefinition);
            PropertyError propertyError = obj as PropertyError;

            if (obj == null || (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound))
            {
                return(defaultValue);
            }
            if (propertyError != null)
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    (PropertyError)obj
                });
            }
            return((T)((object)obj));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Sets the property value to the new value</summary>
        /// <param name="owner">Object whose property is set</param>
        /// <param name="descriptor">Property descriptor</param>
        /// <param name="value">New property value</param>
        public static void SetProperty(object owner, PropertyDescriptor descriptor, object value)
        {
            try
            {
                TypeConverter converter = descriptor.Converter;
                if (converter != null &&
                    value != null &&
                    converter.CanConvertFrom(value.GetType()))
                {
                    value = converter.ConvertFrom(value);
                }

                bool   notifyChange = false;
                object oldValue     = null;
                EventHandler <PropertyEditedEventArgs> handler = PropertyEdited;
                if (handler != null)
                {
                    oldValue     = descriptor.GetValue(owner);
                    notifyChange = !PropertyUtils.AreEqual(oldValue, value);
                }
                descriptor.SetValue(owner, value);
                if (notifyChange)
                {
                    PropertyEditedEventArgs eventArgs = new PropertyEditedEventArgs(owner, descriptor, oldValue, value);
                    handler(null, eventArgs);
                }
            }
            catch (InvalidTransactionException)
            {
                // The transaction needs to be cancelled.
                throw;
            }
            catch (Exception ex)
            {
                PropertyErrorEventArgs eventArgs = new PropertyErrorEventArgs(owner, descriptor, ex);

                PropertyError.Raise(null, eventArgs);

                if (!eventArgs.Cancel)
                {
                    Outputs.WriteLine(OutputMessageType.Error, ex.Message);
                }
            }
        }
Ejemplo n.º 21
0
        protected override void StartListeningCore(WeakReference <object> reference)
        {
            reference.TryGetTarget(out object target);

            IPropertyAccessorPlugin plugin = null;

            foreach (IPropertyAccessorPlugin x in ExpressionObserver.PropertyAccessors)
            {
                if (x.Match(target, PropertyName))
                {
                    plugin = x;
                    break;
                }
            }

            var accessor = plugin?.Start(reference, PropertyName);

            if (_enableValidation && Next == null)
            {
                foreach (var validator in ExpressionObserver.DataValidators)
                {
                    if (validator.Match(reference, PropertyName))
                    {
                        accessor = validator.Start(reference, PropertyName, accessor);
                    }
                }
            }

            if (accessor == null)
            {
                reference.TryGetTarget(out object instance);

                var message = $"Could not find a matching property accessor for '{PropertyName}' on '{instance}'";

                var exception = new MissingMemberException(message);

                accessor = new PropertyError(new BindingNotification(exception, BindingErrorType.Error));
            }

            _accessor = accessor;
            accessor.Subscribe(ValueChanged);
        }
Ejemplo n.º 22
0
        private object GetProperty(PropertyDefinition propertyDefinition)
        {
            object obj = this.TryGetProperty(propertyDefinition);

            if (obj == null)
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    new PropertyError(propertyDefinition, PropertyErrorCode.NullValue)
                });
            }
            if (PropertyError.IsPropertyError(obj))
            {
                throw PropertyError.ToException(new PropertyError[]
                {
                    (PropertyError)obj
                });
            }
            return(obj);
        }
        private void AddBodySummaryError(IConversationTree conversationTree, ref IStorePropertyBag propertyBag)
        {
            StoreObjectId objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            if (!this.bodySummaryLoadedNodes.Contains(objectId) && this.loadedItemParts.ContainsKey(objectId))
            {
                if (!this.loadedItemParts[objectId].DidLoadSucceed)
                {
                    this.bodySummaryLoadedNodes.Add(objectId);
                    PropertyError summary = new PropertyError(InternalSchema.TextBody, PropertyErrorCode.NotEnoughMemory);
                    this.SetBodySummary(conversationTree, ref propertyBag, summary, objectId);
                    return;
                }
                if (this.InternalHasIrmFailed(objectId))
                {
                    this.bodySummaryLoadedNodes.Add(objectId);
                    PropertyError summary2 = new PropertyError(InternalSchema.TextBody, PropertyErrorCode.AccessDenied);
                    this.SetBodySummary(conversationTree, ref propertyBag, summary2, objectId);
                }
            }
        }
        protected object GetPropertyValue(PropTag tag)
        {
            StorePropertyDefinition propertyDefinitionForTag = this.GetPropertyDefinitionForTag(tag);
            IStorePropertyBag       propertyBag = this.PropertyBag;
            object obj = propertyBag.TryGetProperty(propertyDefinitionForTag);

            if (obj is PropertyError)
            {
                if (!PropertyError.IsPropertyValueTooBig(obj))
                {
                    this.TraceError <object, StorePropertyDefinition>("Encountered error {0} while reading value of property {1}", obj, propertyDefinitionForTag);
                    return(null);
                }
                obj = RuleUtil.ReadStreamedProperty(propertyBag, propertyDefinitionForTag);
            }
            if (obj.GetType().GetTypeInfo().IsEnum)
            {
                obj = RuleUtil.ConvertEnumValue(tag, obj);
            }
            return(obj);
        }
Ejemplo n.º 25
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            byte[] largeBinaryProperty = propertyBag.Context.StoreObject.PropertyBag.GetLargeBinaryProperty(this.rawQueueProperty);
            if (largeBinaryProperty.IsNullOrEmpty <byte>())
            {
                return(ActionQueueProperty.EmptyQueue);
            }
            object result;

            try
            {
                using (MemoryStream memoryStream = new MemoryStream(largeBinaryProperty))
                {
                    result = JsonConverter.Deserialize <ActionInfo[]>(memoryStream, null);
                }
            }
            catch (SerializationException ex)
            {
                result = new PropertyError(this, PropertyErrorCode.CorruptedData, ex.ToString());
            }
            return(result);
        }
        private bool TryGetParticipantsFromReplyAllParticipantsProperty(IStorePropertyBag propertyBag, SmartPropertyDefinition propertyDefinition, out ParticipantTable participantTable)
        {
            participantTable = new ParticipantTable();
            object obj = propertyBag.TryGetProperty(propertyDefinition);

            if (PropertyError.IsPropertyError(obj))
            {
                return(false);
            }
            IDictionary <RecipientItemType, HashSet <string> > dictionary = (IDictionary <RecipientItemType, HashSet <string> >)obj;

            foreach (KeyValuePair <RecipientItemType, HashSet <string> > keyValuePair in dictionary)
            {
                IList <Participant> participants = new List <Participant>();
                if (!this.TryResolveParticipants(keyValuePair.Value, participants))
                {
                    return(false);
                }
                participantTable.Add(keyValuePair.Key, participants);
            }
            return(true);
        }
Ejemplo n.º 27
0
 public object this[PropertyDefinition propertyDefinition]
 {
     get
     {
         object obj = null;
         StorePropertyDefinition storePropertyDefinition = propertyDefinition as StorePropertyDefinition;
         if (storePropertyDefinition != null)
         {
             if (ItemSchema.TextBody.CompareTo(storePropertyDefinition) == 0)
             {
                 if (this.ewsItem.ExtendedProperty != null && this.ewsItem.ExtendedProperty.Length > 0)
                 {
                     foreach (ExtendedPropertyType extendedPropertyType in this.ewsItem.ExtendedProperty)
                     {
                         if (string.Equals("0x1000", extendedPropertyType.ExtendedFieldURI.PropertyTag))
                         {
                             obj = (extendedPropertyType.Item as string);
                         }
                     }
                 }
             }
             else if (ItemSchema.Id.CompareTo(storePropertyDefinition) == 0)
             {
                 obj = new ConfigObjectId(this.ewsItem.ItemId.Id);
             }
             else if (StoreObjectSchema.CreationTime.CompareTo(storePropertyDefinition) == 0 && this.ewsItem.DateTimeCreatedSpecified)
             {
                 obj = new ExDateTime(ExTimeZone.UtcTimeZone, this.ewsItem.DateTimeCreated);
             }
         }
         if (obj == null)
         {
             obj = new PropertyError(propertyDefinition, PropertyErrorCode.NotFound);
         }
         return(obj);
     }
 }
Ejemplo n.º 28
0
        protected virtual bool TryCastValue(object givenValue, out TValue value)
        {
            if (givenValue == null)
            {
                value = default(TValue);
                return(false);
            }
            PropertyError propertyError = givenValue as PropertyError;

            if (propertyError != null)
            {
                value = default(TValue);
                return(false);
            }
            bool result;

            try
            {
                value  = (TValue)((object)givenValue);
                result = true;
            }
            catch (InvalidCastException)
            {
                this.Trace.TraceError((long)this.GetHashCode(), "[{0}::TryCastValue] InvalidCastException - Property: {1}; Type: {2}; Value Type: {3}; Value: {4}", new object[]
                {
                    base.GetType().Name,
                    this.Property.Name,
                    this.Property.Type.FullName,
                    givenValue.GetType().FullName,
                    givenValue
                });
                value  = default(TValue);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 29
0
 // Token: 0x0600012E RID: 302 RVA: 0x000076F8 File Offset: 0x000058F8
 private static bool ShouldLicenseMessage(MessageItem item)
 {
     return(item.IsRestricted && (PropertyError.IsPropertyNotFound(item.TryGetProperty(MessageItemSchema.DRMRights)) || PropertyError.IsPropertyNotFound(item.TryGetProperty(MessageItemSchema.DRMExpiryTime))));
 }
Ejemplo n.º 30
0
 // Token: 0x060013CC RID: 5068 RVA: 0x00071D20 File Offset: 0x0006FF20
 public void ComputePropertyState()
 {
     if (this.supportedItemClasses != null)
     {
         bool flag = false;
         foreach (string value in this.supportedItemClasses)
         {
             if (this.item.ClassName.StartsWith(value, StringComparison.OrdinalIgnoreCase))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             base.State = PropertyState.NotSupported;
             return;
         }
     }
     base.State = PropertyState.Modified;
     if (this.PropertyDef != null)
     {
         PropertyError          propertyError = this.XsoItem.TryGetProperty(this.PropertyDef) as PropertyError;
         CalendarItemOccurrence calendarItemOccurrence;
         if (propertyError != null)
         {
             if (propertyError.PropertyErrorCode == PropertyErrorCode.NotFound || propertyError.PropertyErrorCode == PropertyErrorCode.GetCalculatedPropertyError)
             {
                 base.State = PropertyState.SetToDefault;
                 return;
             }
             if (propertyError.PropertyErrorCode != PropertyErrorCode.NotEnoughMemory)
             {
                 throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "Property = {0} could not be fetched, Property Error code = {1}, Description = {2}", new object[]
                 {
                     this.PropertyDef,
                     propertyError.PropertyErrorCode,
                     propertyError.PropertyErrorDescription
                 }));
             }
             if (this is XsoStringProperty)
             {
                 base.State = PropertyState.Stream;
                 return;
             }
             base.State = PropertyState.SetToDefault;
             return;
         }
         else if ((calendarItemOccurrence = (this.XsoItem as CalendarItemOccurrence)) != null)
         {
             if (calendarItemOccurrence.IsModifiedProperty(this.PropertyDef))
             {
                 return;
             }
             foreach (PropertyDefinition propertyDefinition in this.prefetchPropertyDef)
             {
                 if (calendarItemOccurrence.IsModifiedProperty(propertyDefinition))
                 {
                     return;
                 }
             }
             base.State = PropertyState.Unmodified;
         }
     }
 }
        public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
        {
            ConversationsProcessingAgent.tracer.TraceDebug(0L, "Called ConversationsProcessingAgent.OnPromotedMessageHandler");
            if (args == null)
            {
                return;
            }
            StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args;

            if (ConversationsProcessingAgent.ShouldSkipMessageProcessing(storeDriverDeliveryEventArgsImpl))
            {
                return;
            }
            if (storeDriverDeliveryEventArgsImpl.MailboxOwner == null)
            {
                return;
            }
            MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession;

            if (mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion <= 1937801369)
            {
                if (ConversationsProcessingAgent.tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    ConversationsProcessingAgent.tracer.TraceDebug <string, string>((long)this.GetHashCode(), "Backend server version (0x{0}) is less than minimum required (0x{1})", mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion.ToString("X"), 1937801369.ToString("X"));
                }
                return;
            }
            ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing incoming message");
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                if (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies == null)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = new Dictionary <PropertyDefinition, object>();
                }
                ConversationIndexTrackingEx conversationIndexTrackingEx = ConversationIndexTrackingEx.Create();
                this.performanceContext = ConversationsProcessingAgent.conversationLatencyDetectionContextFactory.CreateContext("15.00.1497.012", "FIXUP", new IPerformanceDataProvider[0]);
                if (!this.isBodyTagCalculated)
                {
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Calculating body tag");
                    Stopwatch stopwatch2 = Stopwatch.StartNew();
                    if (storeDriverDeliveryEventArgsImpl.ReplayItem.IsRestricted)
                    {
                        if (!this.TryCalculateIrmBodyTag(storeDriverDeliveryEventArgsImpl))
                        {
                            this.bodyTag = null;
                        }
                    }
                    else if (PropertyError.IsPropertyNotFound(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.BodyTag)))
                    {
                        this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.Body.CalculateBodyTag(out this.latestMessageWordCount);
                    }
                    else
                    {
                        this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <byte[]>(ItemSchema.BodyTag);
                        this.latestMessageWordCount = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <int>(MessageItemSchema.LatestMessageWordCount, int.MinValue);
                    }
                    stopwatch2.Stop();
                    conversationIndexTrackingEx.Trace("BT", stopwatch2.ElapsedMilliseconds.ToString());
                    this.isBodyTagCalculated = true;
                }
                if (this.bodyTag != null)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.BodyTag] = this.bodyTag;
                    if (this.latestMessageWordCount >= 0)
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.LatestMessageWordCount] = this.latestMessageWordCount;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(MessageItemSchema.LatestMessageWordCount, this.latestMessageWordCount);
                    }
                }
                if (this.forceAllAttachmentsHidden)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.AllAttachmentsHidden] = true;
                }
                if (!ConversationIndex.CompareTopics(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.ConversationTopic) as string, storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string))
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationTopic] = ((storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string) ?? string.Empty);
                }
                if (!storeDriverDeliveryEventArgsImpl.MessageClass.Equals("IPM.WorkingSet.Signal", StringComparison.InvariantCulture))
                {
                    ConversationAggregationResult conversationAggregationResult = new ConversationAggregationResult();
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Fixing up the conversation id");
                    try
                    {
                        IConversationAggregator conversationAggregator;
                        if (ConversationAggregatorFactory.TryInstantiateAggregatorForDelivery(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationIndexTrackingEx, out conversationAggregator))
                        {
                            conversationAggregationResult = conversationAggregator.Aggregate(storeDriverDeliveryEventArgsImpl.ReplayItem.CoreItem);
                        }
                        else
                        {
                            ConversationsProcessingAgent.tracer.TraceError((long)this.GetHashCode(), "Not able to identify a valid conversationAggregator");
                            conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew();
                            conversationAggregationResult.Stage             = ConversationIndex.FixupStage.Error;
                        }
                    }
                    catch (ObjectNotFoundException arg)
                    {
                        ConversationsProcessingAgent.tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "Exception - {0}", arg);
                        conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew();
                        conversationAggregationResult.Stage             = ConversationIndex.FixupStage.Error;
                    }
                    this.performanceContext.StopAndFinalizeCollection();
                    conversationIndexTrackingEx.Trace("FIXUP", this.performanceContext.Elapsed.TotalMilliseconds.ToString());
                    ConversationsProcessingAgent.tracer.TraceDebug <int>((long)this.GetHashCode(), "FixupStage = {0}", (int)conversationAggregationResult.Stage);
                    ConversationId conversationId = ConversationId.Create(conversationAggregationResult.ConversationIndex);
                    ConversationsProcessingAgent.tracer.TraceDebug <ConversationId>((long)this.GetHashCode(), "ConversationId (CID) for item: {0}", conversationId);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex] = conversationAggregationResult.ConversationIndex.ToByteArray();
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndex, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex]);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId] = conversationAggregationResult.ConversationFamilyId;
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationFamilyId, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId]);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation] = conversationAggregationResult.SupportsSideConversation;
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.SupportsSideConversation, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation]);
                    byte[] value;
                    if (this.TryCalculateConversationCreatorSid(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationAggregationResult, storeDriverDeliveryEventArgsImpl.ReplayItem.PropertyBag, out value))
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID] = value;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID]);
                    }
                    conversationIndexTrackingEx.TraceVersionAndHeuristics(conversationAggregationResult.Stage.ToString());
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTrackingEx] = conversationIndexTrackingEx.ToString();
                    if (conversationAggregationResult.Stage != ConversationIndex.FixupStage.L1)
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking] = true;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndexTracking, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking]);
                    }
                    ConversationsProcessingAgent.tracer.TraceDebug <ConversationIndexTrackingEx>((long)this.GetHashCode(), "Time Spent in different stages - {0}", conversationIndexTrackingEx);
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing conversation actions");
                    if (!ConversationIndex.IsFixUpCreatingNewConversation(conversationAggregationResult.Stage))
                    {
                        this.ProcessConversationActions(conversationId, storeDriverDeliveryEventArgsImpl);
                    }
                    if (ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(conversationAggregationResult.Stage))
                    {
                        if (storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents == null)
                        {
                            storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents = new Dictionary <PropertyDefinition, object>();
                        }
                        storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents[ItemSchema.ConversationLoadRequiredByInference] = true;
                    }
                }
            }
            finally
            {
                stopwatch.Stop();
                MSExchangeConversationsProcessing.LastMessageProcessingTime.RawValue = stopwatch.ElapsedMilliseconds;
                ConversationsProcessingAgent.averageMessageProcessingTime.Update(stopwatch.ElapsedMilliseconds);
                ConversationsProcessingAgent.tracer.TraceDebug <long>((long)this.GetHashCode(), "Exiting ConversationsProcessing.ProcessMessage.  Total execution time = {0} ms.", stopwatch.ElapsedMilliseconds);
            }
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Raises the PropertyError event and performs custom processing</summary>
 /// <param name="e">PropertyErrorEventArgs containing event data</param>
 protected virtual void OnPropertyError(PropertyErrorEventArgs e)
 {
     PropertyError.Raise <PropertyErrorEventArgs>(this, e);
 }
Ejemplo n.º 33
0
 public bool Equals(PropertyError other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Code, Code) && Equals(other.Attribute, Attribute);
 }