Esempio n. 1
0
 internal void UpdateMeetingRequest(CalendarItemBase calendarItem)
 {
     ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.UpdateMeetingRequest: GOID={0}", this.GlobalObjectId);
     this.SetDefaultMeetingRequestTypeIfNeeded(calendarItem);
     this.UpdateIconIndex();
     base.AdjustAppointmentState();
     if (!calendarItem.IsNew)
     {
         if (calendarItem.CalendarItemType != CalendarItemType.RecurringMaster)
         {
             base.LocationIdentifierHelperInstance.SetLocationIdentifier(64629U);
             this[InternalSchema.OldStartWhole] = calendarItem.StartTime;
             this[InternalSchema.OldEndWhole]   = calendarItem.EndTime;
             this.SetCalendarProcessingSteps(CalendarProcessingSteps.CopiedOldProps);
         }
         string valueOrDefault = base.GetValueOrDefault <string>(InternalSchema.OldLocation, string.Empty);
         if (string.IsNullOrEmpty(valueOrDefault))
         {
             string location = calendarItem.Location;
             if (!string.IsNullOrEmpty(location))
             {
                 this.OldLocation = location;
                 this.SetCalendarProcessingSteps(CalendarProcessingSteps.CopiedOldProps);
             }
         }
         if (!PropertyError.IsPropertyError(calendarItem.TryGetProperty(CalendarItemBaseSchema.ResponseType)))
         {
             base.LocationIdentifierHelperInstance.SetLocationIdentifier(56437U);
             this[InternalSchema.ResponseState] = (int)calendarItem.ResponseType;
         }
     }
 }
Esempio n. 2
0
        private void CopyNlgPropertiesTo(CalendarItemBase calendarItem)
        {
            bool flag = false;

            foreach (PropertyExistenceTracker propertyDefinition in MeetingRequest.NlgExtractedExistenceProperties)
            {
                if (base.GetValueOrDefault <bool>(propertyDefinition, false))
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                base.Load(MeetingRequest.NlgExtractedProperties);
            }
            foreach (StorePropertyDefinition storePropertyDefinition in MeetingRequest.NlgExtractedProperties)
            {
                object obj = flag ? base.TryGetProperty(storePropertyDefinition) : null;
                if (obj != null && !PropertyError.IsPropertyError(obj))
                {
                    calendarItem[storePropertyDefinition] = obj;
                }
                else
                {
                    calendarItem.DeleteProperties(new PropertyDefinition[]
                    {
                        storePropertyDefinition
                    });
                }
            }
        }
        private bool GetStoredFolderId(out StoreObjectId folderId)
        {
            folderId = null;
            byte[] valueOrDefault = base.CoreItem.PropertyBag.GetValueOrDefault <byte[]>(ConversationActionItemSchema.ConversationActionMoveStoreId);
            if (valueOrDefault != null && valueOrDefault.Length > 0)
            {
                return(false);
            }
            object obj = base.CoreItem.PropertyBag.TryGetProperty(ConversationActionItemSchema.ConversationActionMoveFolderId);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                return(false);
            }
            byte[] array = (byte[])obj;
            if (array != null && array.Length != 0)
            {
                try
                {
                    folderId = StoreObjectId.FromProviderSpecificId(array, StoreObjectType.Unknown);
                }
                catch (CorruptDataException)
                {
                    return(false);
                }
                return(true);
            }
            folderId = null;
            return(true);
        }
Esempio n. 4
0
        private long WriteAttachment(Item item, Attachment attachment)
        {
            this.limitsTracker.CountMessageAttachment();
            this.WriteAttachmentAttributes(attachment);
            long             result           = 0L;
            StreamAttachment streamAttachment = attachment as StreamAttachment;

            if (streamAttachment != null)
            {
                using (Stream stream = this.tnefWriter.OpenAttributeStream(TnefAttributeTag.AttachData, TnefAttributeLevel.Attachment))
                {
                    object        obj           = attachment.TryGetProperty(InternalSchema.AttachDataBin);
                    PropertyError propertyError = obj as PropertyError;
                    if (propertyError != null)
                    {
                        using (Stream stream2 = streamAttachment.TryGetRawContentStream(PropertyOpenMode.ReadOnly))
                        {
                            if (stream2 != null)
                            {
                                result = Util.StreamHandler.CopyStreamData(stream2, stream);
                            }
                            goto IL_88;
                        }
                    }
                    byte[] array = (byte[])obj;
                    result = (long)array.Length;
                    stream.Write(array, 0, array.Length);
                    IL_88 :;
                }
            }
            this.WriteAttachmentProperties(attachment);
            return(result);
        }
        private static UserConfiguration BuildConfigurationFromQueryItem(Folder folder, IStorePropertyBag row, bool hasLoadedUserConfigurationData)
        {
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemClass)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemId)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.UserConfigurationType)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType"));
            }
            string name = (string)row[InternalSchema.ItemClass];

            if (!UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass))
            {
                return(null);
            }
            UserConfigurationName configurationName = new UserConfigurationName(name, ConfigurationNameKind.ItemClass);

            if (hasLoadedUserConfigurationData)
            {
                object dictionaryObject = UserConfiguration.CheckDictionaryData(row.TryGetProperty(InternalSchema.UserConfigurationDictionary));
                return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], dictionaryObject, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
            }
            return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], null, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
        }
Esempio n. 6
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object value = propertyBag.GetValue(this.conversationIdPropertyDefinition);

            byte[] array = value as byte[];
            if (array != null)
            {
                object result;
                try
                {
                    result = ConversationId.Create(array);
                }
                catch (CorruptDataException)
                {
                    result = new PropertyError(this, PropertyErrorCode.CorruptedData);
                }
                return(result);
            }
            PropertyError propertyError = (PropertyError)value;

            if (propertyError.PropertyErrorCode == PropertyErrorCode.NotEnoughMemory)
            {
                return(new PropertyError(this, PropertyErrorCode.CorruptedData));
            }
            return(new PropertyError(this, propertyError.PropertyErrorCode));
        }
Esempio n. 7
0
        internal static bool MatchPropertyValues(object propValue1, object propValue2)
        {
            PropertyError propertyError  = propValue1 as PropertyError;
            PropertyError propertyError2 = propValue2 as PropertyError;

            return((propertyError == null && Util.ValueEquals(propValue1, propValue2)) || (propertyError != null && propertyError2 != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound && propertyError2.PropertyErrorCode == PropertyErrorCode.NotFound));
        }
        internal override void Normalize(PropertyBag participantPropertyBag)
        {
            string valueOrDefault  = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.DisplayName);
            string valueOrDefault2 = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.EmailAddress);
            string valueOrDefault3 = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.SmtpAddress);

            if (valueOrDefault == null)
            {
                if (valueOrDefault3 != null)
                {
                    participantPropertyBag[ParticipantSchema.DisplayName] = valueOrDefault3;
                }
                else if (valueOrDefault2 != null && ExRoutingTypeDriver.IsValidExAddress(valueOrDefault2))
                {
                    participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.DisplayName, Util.SubstringBetween(valueOrDefault2, "=", null, SubstringOptions.Backward));
                }
            }
            if (PropertyError.IsPropertyNotFound(participantPropertyBag.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.EmailAddressForDisplay, valueOrDefault3);
            }
            participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.LegacyExchangeDN, valueOrDefault2);
            participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.SendRichInfo, true);
            base.Normalize(participantPropertyBag);
        }
Esempio n. 9
0
        private static bool EvaluateExistsFilter(ExistsFilter existsFilter, IReadOnlyPropertyBag propertyBag)
        {
            object        obj           = propertyBag[existsFilter.Property];
            PropertyError propertyError = obj as PropertyError;

            if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                return(false);
            }
            if (propertyBag is ADPropertyBag || propertyBag is ADRawEntry)
            {
                if (obj == null)
                {
                    return(false);
                }
                if (obj is string && string.IsNullOrEmpty((string)obj))
                {
                    return(false);
                }
                if (obj is SmtpAddress && !((SmtpAddress)obj).IsValidAddress)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 10
0
        private static bool IsPropertyError(IReadOnlyPropertyBag propertyBag, PropertyDefinition property, bool shouldThrow)
        {
            object obj = propertyBag[property];

            if (obj != null)
            {
                PropertyError propertyError = obj as PropertyError;
                if (propertyError != null)
                {
                    if (shouldThrow)
                    {
                        throw PropertyErrorException.FromPropertyErrorsInternal(new PropertyError[]
                        {
                            obj as PropertyError
                        });
                    }
                    return(true);
                }
            }
            else if (propertyBag is ADPropertyBag || propertyBag is ADRawEntry)
            {
                if (shouldThrow)
                {
                    throw PropertyErrorException.FromPropertyErrorsInternal(new PropertyError[]
                    {
                        new PropertyError(property, PropertyErrorCode.NotFound)
                    });
                }
                return(true);
            }
            return(false);
        }
 protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
 {
     byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.PropertyChangeMetadataRaw);
     if (valueOrDefault == null)
     {
         CalendarItemOccurrence calendarItemOccurrence = propertyBag.Context.StoreObject as CalendarItemOccurrence;
         if (calendarItemOccurrence == null)
         {
             return(null);
         }
         return(calendarItemOccurrence.OccurrencePropertyBag.ComputeChangeMetadataBasedOnLoadedProperties());
     }
     else
     {
         if (valueOrDefault.Length == 0)
         {
             return(null);
         }
         object result;
         try
         {
             result = PropertyChangeMetadata.Parse(valueOrDefault);
         }
         catch (PropertyChangeMetadataFormatException ex)
         {
             result = new PropertyError(this, PropertyErrorCode.CorruptedData, ex.Message);
         }
         return(result);
     }
 }
Esempio n. 12
0
        private void UpdateAttachmentTableCache()
        {
            if (this.attachmentTablePropertyBag != null)
            {
                bool flag = false;
                foreach (NativeStorePropertyDefinition propertyDefinition in this.attachmentTablePropertySet)
                {
                    PropertyError propertyError = ((IDirectPropertyBag)this.attachmentTablePropertyBag).GetValue(propertyDefinition) as PropertyError;
                    if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.PropertyValueTruncated)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    return;
                }
            }
            MemoryPropertyBag  memoryPropertyBag = new MemoryPropertyBag();
            IDirectPropertyBag directPropertyBag = memoryPropertyBag;

            foreach (NativeStorePropertyDefinition propertyDefinition2 in this.attachmentTablePropertySet)
            {
                object value = ((IDirectPropertyBag)this.persistablePropertyBag).GetValue(propertyDefinition2);
                directPropertyBag.SetValue(propertyDefinition2, value);
            }
            memoryPropertyBag.ClearChangeInfo();
            memoryPropertyBag.Context.Session   = this.attachmentTablePropertyBag.Context.Session;
            memoryPropertyBag.Context.CoreState = this.attachmentTablePropertyBag.Context.CoreState;
            this.attachmentTablePropertyBag     = memoryPropertyBag;
        }
Esempio n. 13
0
        internal static StoreObjectType ReadStoreObjectTypeFromPropertyBag(ICorePropertyBag propertyBag)
        {
            object propertyValue = propertyBag.TryGetProperty(CoreItemSchema.ItemClass);
            string text;

            if (PropertyError.IsPropertyValueTooBig(propertyValue) || PropertyError.IsPropertyNotFound(propertyValue))
            {
                text = string.Empty;
            }
            else
            {
                text = PropertyBag.CheckPropertyValue <string>(CoreItemSchema.ItemClass, propertyValue);
            }
            StoreObjectType objectType = ObjectClass.GetObjectType(text);

            for (int i = 0; i < ItemBuilder.storeObjectTypeDetectionChain.Length; i++)
            {
                StoreObjectType?storeObjectType = ItemBuilder.storeObjectTypeDetectionChain[i](propertyBag, text, objectType);
                if (storeObjectType != null)
                {
                    return(storeObjectType.Value);
                }
            }
            return(objectType);
        }
        public override Stream OpenPropertyStream(PropertyDefinition propertyDefinition, PropertyOpenMode openMode)
        {
            Stream stream = null;
            StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition);

            if (openMode != PropertyOpenMode.Create)
            {
                object        value         = ((IDirectPropertyBag)this.memoryPropertyBag).GetValue(storePropertyDefinition);
                PropertyError propertyError = value as PropertyError;
                if (propertyError == null)
                {
                    stream = this.WrapValueInStream(value);
                }
                else if (propertyError.PropertyErrorCode == PropertyErrorCode.RequireStreamed)
                {
                    stream = this.streamList[storePropertyDefinition];
                }
                else if (openMode == PropertyOpenMode.ReadOnly)
                {
                    throw new ObjectNotFoundException(ServerStrings.StreamPropertyNotFound(storePropertyDefinition.ToString()));
                }
            }
            if (stream == null)
            {
                stream = new MemoryStream();
                ((IDirectPropertyBag)this.memoryPropertyBag).SetValue(storePropertyDefinition, new PropertyError(storePropertyDefinition, PropertyErrorCode.RequireStreamed));
                this.streamList[storePropertyDefinition] = stream;
            }
            if (openMode != PropertyOpenMode.ReadOnly)
            {
                this.isDirty = true;
            }
            stream.Seek(0L, SeekOrigin.Begin);
            return(new StreamWrapper(stream, false));
        }
Esempio n. 15
0
        private PropertyError MarkAsNotFound(StorePropertyDefinition propertyDefinition)
        {
            PropertyError propertyError = new PropertyError(propertyDefinition, PropertyErrorCode.NotFound);

            this.PropertyValues[propertyDefinition] = propertyError;
            return(propertyError);
        }
Esempio n. 16
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            IDictionary <RecipientItemType, HashSet <string> > recipients = null;

            foreach (ComplexParticipantExtractorBase <string> complexParticipantExtractorBase in ReplyAllDisplayNamesProperty.Extractors)
            {
                if (complexParticipantExtractorBase.ShouldExtract(propertyBag))
                {
                    IList <string> replyTo;
                    object         result;
                    if (complexParticipantExtractorBase.Extract(propertyBag, (Participant participant) => participant.DisplayName, this.ParticipantRepresentationComparer, out recipients, out replyTo))
                    {
                        IParticipant simpleParticipant  = base.GetSimpleParticipant(InternalSchema.Sender, propertyBag);
                        IParticipant simpleParticipant2 = base.GetSimpleParticipant(InternalSchema.From, propertyBag);
                        result = ReplyAllParticipantsRepresentationProperty <string> .BuildReplyAllRecipients <string>((simpleParticipant == null)?null : simpleParticipant.DisplayName, (simpleParticipant2 == null)?null : simpleParticipant2.DisplayName, replyTo, recipients, this.ParticipantRepresentationComparer);
                    }
                    else
                    {
                        result = new PropertyError(this, PropertyErrorCode.GetCalculatedPropertyError);
                    }
                    return(result);
                }
            }
            return(new PropertyError(this, PropertyErrorCode.GetCalculatedPropertyError));
        }
        internal static object CalculateIsAllDayEvent(PropertyBag.BasicPropertyStore propertyBag)
        {
            object value = propertyBag.GetValue(InternalSchema.MapiIsAllDayEvent);

            if (propertyBag.TimeZone == null)
            {
                return(value);
            }
            object        value2        = propertyBag.GetValue(InternalSchema.MapiStartTime);
            object        value3        = propertyBag.GetValue(InternalSchema.MapiEndTime);
            PropertyError propertyError = value2 as PropertyError;

            if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                value2 = propertyBag.GetValue(InternalSchema.MapiPRStartDate);
            }
            propertyError = (value3 as PropertyError);
            if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                value3 = propertyBag.GetValue(InternalSchema.MapiPREndDate);
            }
            if (!(value is bool) || !(value2 is ExDateTime) || !(value3 is ExDateTime))
            {
                return(value);
            }
            ExDateTime exDateTime  = (ExDateTime)value2;
            ExDateTime exDateTime2 = (ExDateTime)value3;

            if ((bool)value && exDateTime == exDateTime.Date && exDateTime2 == exDateTime2.Date && exDateTime2 > exDateTime)
            {
                return(true);
            }
            return(false);
        }
        internal byte[] GetLargeBinaryProperty(PropertyDefinition propertyDefinition)
        {
            object obj = base.TryGetProperty(propertyDefinition);

            byte[] array = obj as byte[];
            if (array != null)
            {
                return(array);
            }
            if (PropertyError.IsPropertyValueTooBig(obj))
            {
                ExTraceGlobals.StorageTracer.Information <PropertyDefinition>((long)this.GetHashCode(), "PersitablePropertyBag::GetLargeBinaryProperty, {0} too big to fit in GetProp, streaming it", propertyDefinition);
                using (Stream stream = this.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
                {
                    return(Util.ReadByteArray(stream));
                }
            }
            PropertyError propertyError = obj as PropertyError;

            if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                ExTraceGlobals.StorageTracer.Information <PropertyDefinition>((long)this.GetHashCode(), "PersitablePropertyBag::GetLargeBinaryProperty, {0} not found", propertyDefinition);
                return(null);
            }
            ExTraceGlobals.StorageTracer.TraceError <PropertyDefinition>((long)this.GetHashCode(), "PersitablePropertyBag::GetLargeBinaryProperty, Error when accessing {0}", propertyDefinition);
            throw new CorruptDataException(ServerStrings.ErrorAccessingLargeProperty);
        }
Esempio n. 19
0
 public Stream GetReadOnlyApplefileStream()
 {
     base.CheckDisposed("GetReadOnlyApplefileStream");
     if (this.IsFlaggedAsMacAttachment)
     {
         object obj = base.TryGetProperty(InternalSchema.AttachmentMacInfo);
         if (obj is byte[])
         {
             return(new MemoryStream(obj as byte[], false));
         }
         if (PropertyError.IsPropertyValueTooBig(obj))
         {
             return(this.OpenPropertyStream(InternalSchema.AttachmentMacInfo, PropertyOpenMode.ReadOnly));
         }
         using (Stream rawContentStream = this.GetRawContentStream(PropertyOpenMode.ReadOnly))
         {
             if (this.IsMacAttachmentInternal(rawContentStream))
             {
                 using (DisposeGuard disposeGuard = default(DisposeGuard))
                 {
                     Stream stream = disposeGuard.Add <MemoryStream>(new MemoryStream());
                     string text   = null;
                     byte[] array  = null;
                     MimeAppleTranscoder.MacBinToApplefile(rawContentStream, stream, out text, out array);
                     disposeGuard.Success();
                     return(stream);
                 }
             }
             throw new CorruptDataException(ServerStrings.ConversionFailedInvalidMacBin);
         }
     }
     throw new InvalidOperationException();
 }
Esempio n. 20
0
            public override void Export(ContactWriter writer, Contact contact, OutboundVCardConverter.PropertyExporter.Context context)
            {
                object obj = contact.TryGetProperty(this.prop);

                if (obj is string)
                {
                    writer.WriteProperty(this.propName, obj as string);
                    return;
                }
                if (PropertyError.IsPropertyValueTooBig(obj))
                {
                    writer.StartProperty(this.propName);
                    using (Stream stream = contact.OpenPropertyStream(this.prop, PropertyOpenMode.ReadOnly))
                    {
                        using (Stream stream2 = new ConverterStream(stream, new TextToText
                        {
                            InputEncoding = Encoding.Unicode,
                            OutputEncoding = context.Encoding
                        }, ConverterStreamAccess.Read))
                        {
                            writer.WritePropertyValue(stream2);
                        }
                    }
                }
            }
Esempio n. 21
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object value = propertyBag.GetValue(InternalSchema.ConversationIndex);

            byte[] array = value as byte[];
            if (array == null)
            {
                PropertyError propertyError = (PropertyError)value;
                if (propertyError.PropertyErrorCode == PropertyErrorCode.NotEnoughMemory)
                {
                    return(new PropertyError(this, PropertyErrorCode.CorruptedData));
                }
                return(new PropertyError(this, propertyError.PropertyErrorCode));
            }
            else
            {
                if (array.Length < 22)
                {
                    return(new PropertyError(this, PropertyErrorCode.CorruptedData));
                }
                byte[] array2 = new byte[16];
                Array.Copy(array, 6, array2, 0, 16);
                object result;
                try
                {
                    result = PersonId.Create(array2);
                }
                catch (CorruptDataException)
                {
                    result = new PropertyError(this, PropertyErrorCode.CorruptedData);
                }
                return(result);
            }
        }
Esempio n. 22
0
        protected override bool WriteEnforceRule(ICorePropertyBag propertyBag)
        {
            bool   flag = false;
            object obj  = null;

            foreach (PropertyDefinition propertyDefinition in base.ReadProperties)
            {
                if (propertyBag.IsPropertyDirty(propertyDefinition))
                {
                    flag = true;
                    obj  = propertyBag.TryGetProperty(propertyDefinition);
                    if (!PropertyError.IsPropertyNotFound(obj))
                    {
                        break;
                    }
                }
            }
            if (flag)
            {
                foreach (PropertyDefinition property in base.WriteProperties)
                {
                    propertyBag.SetOrDeleteProperty(property, obj);
                }
            }
            return(flag);
        }
Esempio n. 23
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            if (!(value is bool))
            {
                string message = ServerStrings.ExInvalidValueForFlagsCalculatedProperty(this.flag);
                ExTraceGlobals.StorageTracer.TraceError((long)this.GetHashCode(), message);
                throw new ArgumentException(message);
            }
            object        value2        = propertyBag.GetValue(this.nativeProperty);
            PropertyError propertyError = value2 as PropertyError;
            int           num;

            if (propertyError == null)
            {
                num = (int)value2;
            }
            else
            {
                if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound)
                {
                    throw PropertyError.ToException(new PropertyError[]
                    {
                        propertyError
                    });
                }
                num = 0;
            }
            if ((bool)value)
            {
                propertyBag.SetValueWithFixup(this.nativeProperty, num | this.flag);
                return;
            }
            propertyBag.SetValueWithFixup(this.nativeProperty, num & ~this.flag);
        }
Esempio n. 24
0
        private long WriteAttachmentProperties(Attachment attachment)
        {
            long result = 0L;

            this.tnefWriter.StartAttribute(TnefAttributeTag.Attachment, TnefAttributeLevel.Attachment);
            foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in attachment.AllNativeProperties)
            {
                if (nativeStorePropertyDefinition.Equals(InternalSchema.AttachDataObj))
                {
                    result = this.WriteAttachDataObj(attachment);
                }
                else if (!nativeStorePropertyDefinition.Equals(InternalSchema.AttachDataBin) && this.propertyChecker.IsAttachmentPropertyWritable(nativeStorePropertyDefinition))
                {
                    object        obj           = attachment.TryGetProperty(nativeStorePropertyDefinition);
                    PropertyError propertyError = obj as PropertyError;
                    if (propertyError != null && PropertyError.IsPropertyValueTooBig(propertyError))
                    {
                        this.WritePropertyStreamData(attachment.PropertyBag, nativeStorePropertyDefinition);
                    }
                    else if (propertyError == null)
                    {
                        obj = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(obj);
                        this.tnefWriter.WriteProperty(nativeStorePropertyDefinition, obj);
                    }
                }
            }
            ItemAttachment itemAttachment = attachment as ItemAttachment;

            if (itemAttachment != null)
            {
                result = this.WriteAttachedItem(itemAttachment);
            }
            return(result);
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            bool flag = base.Get(propertyBag, builder);

            if (this.emailAddressForDisplayPropDef != null)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(this.emailAddressForDisplayPropDef);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    builder[ParticipantSchema.EmailAddressForDisplay] = valueOrDefault;
                    if (Participant.RoutingTypeEquals(builder.RoutingType, "EX") && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.SmtpAddress)) && SmtpAddress.IsValidSmtpAddress(valueOrDefault))
                    {
                        builder[ParticipantSchema.SmtpAddress] = valueOrDefault;
                    }
                }
            }
            if (!flag && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault2 != null)
            {
                builder.Origin = new StoreParticipantOrigin(StoreObjectId.FromProviderSpecificId(valueOrDefault2), this.emailAddressIndex);
            }
            return(builder.ToParticipant());
        }
Esempio n. 26
0
        private static PropertyError CreatePropertyError(int mapiErrorCode, StorePropertyDefinition propertyDefinition)
        {
            string            errorDescription;
            PropertyErrorCode propertyErrorCode = MapiPropertyHelper.MapiErrorToXsoError(mapiErrorCode, out errorDescription);

            if (propertyErrorCode == PropertyErrorCode.NotEnoughMemory && propertyDefinition.Type != typeof(string) && propertyDefinition.Type != typeof(byte[]))
            {
                propertyErrorCode = PropertyErrorCode.CorruptedData;
            }
            PropertyError propertyError;

            if (propertyErrorCode == PropertyErrorCode.NotFound)
            {
                propertyError = propertyDefinition.GetNotFoundError();
            }
            else if (propertyErrorCode == PropertyErrorCode.NotEnoughMemory)
            {
                propertyError = propertyDefinition.GetNotEnoughMemoryError();
            }
            else
            {
                propertyError = new PropertyError(propertyDefinition, propertyErrorCode, errorDescription);
                ExTraceGlobals.StorageTracer.TraceError <PropertyError>(0L, "MapiPropertyBag::GetValueFromPropValue. Error = {0}.", propertyError);
            }
            return(propertyError);
        }
Esempio n. 27
0
 private static void WriteAttributeForProperty(XmlWriter xmlWriter, string localName, object value)
 {
     if (!PropertyError.IsPropertyNotFound(value))
     {
         xmlWriter.WriteAttributeString(localName, MasterCategoryListSerializer.ConvertToXmlString(value));
     }
 }
        internal static PropertyError UpdateElcRootFolderName(DefaultFolderContext context, string newName)
        {
            PropertyError result        = null;
            StoreObjectId storeObjectId = context[DefaultFolderType.ElcRoot];

            if (storeObjectId != null)
            {
                using (MapiPropertyBag mapiPropertyBag = MapiPropertyBag.CreateMapiPropertyBag(context.Session, storeObjectId))
                {
                    PropertyDefinition[] propertyDefinitions = new PropertyDefinition[]
                    {
                        FolderSchema.DisplayName
                    };
                    PropertyError[] array = mapiPropertyBag.SetProperties(propertyDefinitions, new object[]
                    {
                        newName
                    });
                    if (array.Length > 0)
                    {
                        result = array[0];
                    }
                    mapiPropertyBag.SaveChanges(false);
                    return(result);
                }
            }
            throw new ObjectNotFoundException(ServerStrings.ExDefaultFolderNotFound(DefaultFolderType.ElcRoot));
        }
Esempio n. 29
0
 public void Update(AtomicStorePropertyDefinition propertyDefinition, object propertyValue)
 {
     if (propertyValue == null || PropertyError.IsPropertyNotFound(propertyValue))
     {
         this.parent.DeleteStoreProperty(propertyDefinition);
         return;
     }
     this.parent.SetProperty(propertyDefinition, propertyValue);
 }
Esempio n. 30
0
 public void SetOrDeleteProperty(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     if (propertyValue == null || PropertyError.IsPropertyNotFound(propertyValue))
     {
         this.Delete(propertyDefinition);
         return;
     }
     this.SetProperty(propertyDefinition, propertyValue);
 }