protected void PromoteLargeProperty(StorePropertyDefinition property)
        {
            NativeStorePropertyDefinition nativeStorePropertyDefinition = property as NativeStorePropertyDefinition;

            if (nativeStorePropertyDefinition == null)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "AbstractInboundConverter::ReadSmallPropertyValue: non-native property");
                throw new ConversionFailedException(ConversionFailureReason.CorruptContent);
            }
            if (nativeStorePropertyDefinition.MapiPropertyType != PropType.String && nativeStorePropertyDefinition.MapiPropertyType != PropType.Binary)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "AbstractInboundConverter::ReadSmallPropertyValue: non-streamable property");
                throw new ConversionFailedException(ConversionFailureReason.CorruptContent);
            }
            int trailingNulls = 0;

            using (Stream stream = this.OpenValueReadStream(out trailingNulls))
            {
                using (Stream stream2 = this.OpenPropertyStream(property))
                {
                    Util.StreamHandler.CopyStreamData(stream, stream2, null, trailingNulls);
                }
            }
        }
 static PropertyChangeMetadata()
 {
     PropertyChangeMetadata.PropertyNameToPropertyAndIndex = new Dictionary <string, PropertyChangeMetadata.PropertyAndIndex>();
     for (int i = 0; i < PropertyChangeMetadata.ListOfTrackedPropertyGroups.Length; i++)
     {
         PropertyChangeMetadata.PropertyGroup propertyGroup = PropertyChangeMetadata.ListOfTrackedPropertyGroups[i];
         if (propertyGroup != null)
         {
             StorePropertyDefinition storeProperty = propertyGroup.StoreProperty;
             if (storeProperty != null && !(storeProperty is NativeStorePropertyDefinition))
             {
                 PropertyChangeMetadata.CheckAndAddProperty(storeProperty.Name, storeProperty, propertyGroup, i);
             }
             else if (propertyGroup.IsBitField)
             {
                 PropertyChangeMetadata.CheckAndAddProperty(propertyGroup.Name, null, propertyGroup, i);
             }
             foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in PropertyChangeMetadata.ListOfTrackedPropertyGroups[i])
             {
                 PropertyChangeMetadata.CheckAndAddProperty(nativeStorePropertyDefinition.Name, nativeStorePropertyDefinition, propertyGroup, i);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public override void DeleteValue(StorePropertyDefinition propertyDefinition)
 {
     this.storePropertyBag.Delete(propertyDefinition);
 }
Ejemplo n.º 4
0
 protected abstract T GetValueOrDefaultInternal <T>(StorePropertyDefinition propertyDefinition, T defaultValue);
Ejemplo n.º 5
0
 public abstract void SetValue(StorePropertyDefinition propertyDefinition, object value);
Ejemplo n.º 6
0
        internal PropertyError[] DeleteProperties(ICollection <PropertyDefinition> propertyDefinitions)
        {
            this.CheckDisposed("DeleteProperties");
            if (propertyDefinitions == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1));
            }
            if (propertyDefinitions.Count == 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. {0} contain zero elements.", "propertyDefinitions");
                throw new ArgumentException(ServerStrings.ExEmptyCollection("propertyDefinitions"), "propertyDefinitions");
            }
            IList <PropertyDefinition> list  = new List <PropertyDefinition>();
            IList <PropertyDefinition> list2 = new List <PropertyDefinition>();

            foreach (PropertyDefinition propertyDefinition in propertyDefinitions)
            {
                StorePropertyDefinition       storePropertyDefinition       = InternalSchema.ToStorePropertyDefinition(propertyDefinition);
                NativeStorePropertyDefinition nativeStorePropertyDefinition = storePropertyDefinition as NativeStorePropertyDefinition;
                if (nativeStorePropertyDefinition != null)
                {
                    list.Add(storePropertyDefinition);
                }
                else
                {
                    list2.Add(storePropertyDefinition);
                }
            }
            ICollection <PropTag> tags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, false, list);

            PropProblem[] array        = null;
            StoreSession  storeSession = this.StoreSession;
            bool          flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                array = this.MapiProp.DeleteProps(tags, (this.SaveFlags & PropertyBagSaveFlags.NoChangeTracking) != PropertyBagSaveFlags.NoChangeTracking);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            PropertyError[] array2;
            if (array != null || list2.Count > 0)
            {
                int num = list2.Count;
                if (array != null)
                {
                    num += array.Length;
                }
                array2 = new PropertyError[num];
                int num2 = 0;
                if (array != null)
                {
                    int i = 0;
                    while (i < array.Length)
                    {
                        int               scode = array[i].Scode;
                        string            errorDescription;
                        PropertyErrorCode error         = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription);
                        PropertyError     propertyError = new PropertyError(list[array[i].Index], error, errorDescription);
                        array2[num2] = propertyError;
                        ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list[array[i].Index].Name, propertyError);
                        i++;
                        num2++;
                    }
                }
                int count = list2.Count;
                int j     = 0;
                while (j < count)
                {
                    PropertyError propertyError2 = new PropertyError(list2[j], PropertyErrorCode.SetCalculatedPropertyError, ServerStrings.ExSetNotSupportedForCalculatedProperty(list2[j].Name));
                    array2[num2] = propertyError2;
                    ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list2[j].Name, propertyError2);
                    j++;
                    num2++;
                }
            }
            else
            {
                array2 = MapiPropertyBag.EmptyPropertyErrorArray;
            }
            return(array2);
        }
Ejemplo n.º 7
0
        public static void ExportCalendar(Stream outputStream, string charset, OutboundConversionOptions options, MailboxSession session, StoreObjectId folderId, ExDateTime windowStart, ExDateTime windowEnd, DetailLevelEnumType detailType)
        {
            EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(detailType, "detailType");
            PropertyDefinition[] array = InternetCalendarSchema.FromDetailLevel(detailType);
            Array.IndexOf <PropertyDefinition>(array, CalendarItemBaseSchema.FreeBusyStatus);
            int num = Array.IndexOf <PropertyDefinition>(array, InternalSchema.ItemId);

            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId))
            {
                object[][] array2 = calendarFolder.InternalGetCalendarView(windowStart, windowEnd, detailType == DetailLevelEnumType.AvailabilityOnly, true, true, RecurrenceExpansionOption.IncludeMaster | RecurrenceExpansionOption.TruncateMaster, array);
                Item[]     items  = new Item[array2.Length];
                try
                {
                    for (int i = 0; i < array2.Length; i++)
                    {
                        items[i] = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties);
                        for (int j = 0; j < array.Length; j++)
                        {
                            StorePropertyDefinition storePropertyDefinition = array[j] as StorePropertyDefinition;
                            if (storePropertyDefinition != null && (storePropertyDefinition.PropertyFlags & PropertyFlags.ReadOnly) != PropertyFlags.ReadOnly)
                            {
                                object obj = array2[i][j];
                                if (!PropertyError.IsPropertyError(obj))
                                {
                                    items[i][storePropertyDefinition] = obj;
                                }
                            }
                        }
                        if (detailType == DetailLevelEnumType.FullDetails && array2[i][num] is VersionedId)
                        {
                            using (CoreItem coreItem = CoreItem.Bind(session, (VersionedId)array2[i][num], new PropertyDefinition[]
                            {
                                ItemSchema.TextBody,
                                ItemSchema.HtmlBody,
                                ItemSchema.RtfBody
                            }))
                            {
                                using (TextReader textReader = coreItem.Body.OpenTextReader(BodyFormat.TextPlain))
                                {
                                    items[i][ItemSchema.TextBody] = textReader.ReadToEnd();
                                }
                            }
                        }
                    }
                    OutboundAddressCache   addressCache = new OutboundAddressCache(options, new ConversionLimitsTracker(options.Limits));
                    List <LocalizedString> errorStream  = new List <LocalizedString>();
                    ConvertUtils.CallCts(ExTraceGlobals.ICalTracer, "ICalSharingHelper::ExportCalendar", ServerStrings.ConversionCorruptContent, delegate
                    {
                        CalendarDocument.InternalItemsToICal(calendarFolder.DisplayName, items, null, addressCache, true, outputStream, errorStream, charset, options);
                    });
                    if (errorStream.Count > 0)
                    {
                        ExTraceGlobals.ICalTracer.TraceError <int>(0L, "{0} errors found during outbound iCal content conversion.", errorStream.Count);
                        AnonymousSharingLog.LogEntries(session, errorStream);
                    }
                }
                finally
                {
                    foreach (Item item in items)
                    {
                        if (item != null)
                        {
                            item.Dispose();
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
 internal object TryGetProperty(StorePropertyDefinition property)
 {
     return(this.propertyValues.TryGetProperty(property));
 }
Ejemplo n.º 9
0
        public void SetOrDeleteProperty(PropertyDefinition propertyDefinition, object propertyValue)
        {
            StorePropertyDefinition propertyDefinition2 = InternalSchema.ToStorePropertyDefinition(propertyDefinition);

            this.SetOrDeleteProperty(propertyDefinition2, propertyValue);
        }
Ejemplo n.º 10
0
 protected abstract void DeleteStoreProperty(StorePropertyDefinition propertyDefinition);
Ejemplo n.º 11
0
 protected abstract object TryGetStoreProperty(StorePropertyDefinition propertyDefinition);
Ejemplo n.º 12
0
 protected abstract void SetValidatedStoreProperty(StorePropertyDefinition propertyDefinition, object propertyValue);
Ejemplo n.º 13
0
 void IDirectPropertyBag.Delete(StorePropertyDefinition propertyDefinition)
 {
     this.DeleteStoreProperty(propertyDefinition);
 }
Ejemplo n.º 14
0
 object IDirectPropertyBag.GetValue(StorePropertyDefinition propertyDefinition)
 {
     return(this.TryGetStoreProperty(propertyDefinition));
 }
Ejemplo n.º 15
0
 void IDirectPropertyBag.SetValue(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     this.SetValidatedStoreProperty(propertyDefinition, propertyValue);
 }
Ejemplo n.º 16
0
 internal override StoreObjectConstraint GetConstraint(StorePropertyDefinition propertyDefinition)
 {
     return(new StoreObjectAdditionalPropertyConstraint(propertyDefinition, new StringLengthConstraint(this.minLength, this.maxLength)));
 }
Ejemplo n.º 17
0
 protected override void DeleteStoreProperty(StorePropertyDefinition propertyDefinition)
 {
     ((IDirectPropertyBag)this.MemoryPropertyBag).Delete(propertyDefinition);
     this.TrackProperty(propertyDefinition, false);
 }
Ejemplo n.º 18
0
 public static T CheckPropertyValue <T>(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     PropertyBag.EnsurePropertyIsNotStreamable(propertyDefinition);
     PropertyBag.ThrowIfPropertyError(propertyDefinition, propertyValue);
     return((T)((object)propertyValue));
 }
 internal Ex12MultivalueEntryIdStrategyForSyncIssue(StorePropertyDefinition property, LocationEntryIdStrategy.GetLocationPropertyBagDelegate getLocationPropertyBag) : base(property, getLocationPropertyBag, 1)
 {
 }
Ejemplo n.º 20
0
 protected override void SetValidatedStoreProperty(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     ((IDirectPropertyBag)this.propertyBag).SetValue(propertyDefinition, propertyValue);
 }
Ejemplo n.º 21
0
        public ConversationBodyScanner GetConversationBodyScanner(HtmlCallbackBase callback, long maxBytes, long bytesLoaded, bool fixCharset, bool filterHtml, out long bytesRead)
        {
            ConversationBodyScanner conversationBodyScanner = null;
            StorePropertyDefinition bodyProperty            = null;
            BodyFormat bodyFormat;

            if (fixCharset)
            {
                bodyFormat = this.RawFormat;
            }
            else
            {
                bodyFormat = this.Format;
            }
            switch (bodyFormat)
            {
            case BodyFormat.TextPlain:
            {
                TextConversationBodyScanner textConversationBodyScanner = new TextConversationBodyScanner();
                conversationBodyScanner = textConversationBodyScanner;
                if (fixCharset)
                {
                    textConversationBodyScanner.InputEncoding = ConvertUtils.UnicodeEncoding;
                }
                else
                {
                    textConversationBodyScanner.InputEncoding = this.GetBodyEncoding();
                }
                if (this.IsRtfEmbeddedBody)
                {
                    bodyProperty = ItemSchema.RtfBody;
                }
                else
                {
                    bodyProperty = ItemSchema.TextBody;
                }
                break;
            }

            case BodyFormat.TextHtml:
            {
                HtmlConversationBodyScanner htmlConversationBodyScanner = new HtmlConversationBodyScanner();
                conversationBodyScanner = htmlConversationBodyScanner;
                htmlConversationBodyScanner.InputEncoding             = this.GetBodyEncoding();
                htmlConversationBodyScanner.DetectEncodingFromMetaTag = false;
                bodyProperty = ItemSchema.HtmlBody;
                break;
            }

            case BodyFormat.ApplicationRtf:
                conversationBodyScanner = new RtfConversationBodyScanner();
                bodyProperty            = ItemSchema.RtfBody;
                break;
            }
            conversationBodyScanner.FilterHtml = filterHtml;
            if (callback != null)
            {
                conversationBodyScanner.HtmlCallback = new HtmlTagCallback(callback.ProcessTag);
            }
            if (this.IsBodyDefined)
            {
                using (Stream stream = this.InternalOpenBodyStream(bodyProperty, PropertyOpenMode.ReadOnly))
                {
                    bytesRead = stream.Length;
                    if (maxBytes > -1L && bytesRead + bytesLoaded > maxBytes)
                    {
                        throw new MessageLoadFailedInConversationException(new LocalizedString("Message body size exceeded the conversation threshold for loading"));
                    }
                    if (this.RawFormat == BodyFormat.ApplicationRtf)
                    {
                        using (Stream stream2 = new ConverterStream(stream, new RtfCompressedToRtf(), ConverterStreamAccess.Read))
                        {
                            conversationBodyScanner.Load(stream2);
                            goto IL_12F;
                        }
                    }
                    conversationBodyScanner.Load(stream);
IL_12F:
                    return(conversationBodyScanner);
                }
            }
            bytesRead = 0L;
            MemoryStream sourceStream = new MemoryStream(0);

            conversationBodyScanner.Load(sourceStream);
            return(conversationBodyScanner);
        }
Ejemplo n.º 22
0
 protected override object TryGetStoreProperty(StorePropertyDefinition propertyDefinition)
 {
     return(((IDirectPropertyBag)this.propertyBag).GetValue(propertyDefinition));
 }
Ejemplo n.º 23
0
        internal static object GetValueFromPropValue(StoreSession storeSession, ExTimeZone exTimeZone, StorePropertyDefinition propertyDefinition, PropValue propertyValue)
        {
            if (propertyValue.IsError())
            {
                int num = propertyValue.GetErrorValue();
                if (num == -2147220732 && (propertyDefinition.SpecifiedWith == PropertyTypeSpecifier.GuidId || propertyDefinition.SpecifiedWith == PropertyTypeSpecifier.GuidString))
                {
                    num = -2147221233;
                }
                return(MapiPropertyBag.CreatePropertyError(num, propertyDefinition));
            }
            PropType propType = propertyValue.PropTag.ValueType();

            if (propType == PropType.Restriction)
            {
                if (storeSession == null)
                {
                    throw new NotSupportedException("PT_RESTRICTION is not supported when we do not have a session. This very likely is an attachment.");
                }
                return(FilterRestrictionConverter.CreateFilter(storeSession, storeSession.Mailbox.MapiStore, (Restriction)propertyValue.Value, false));
            }
            else
            {
                if (propertyValue.Value == null)
                {
                    return(MapiPropertyBag.CreatePropertyError(-2147221233, propertyDefinition));
                }
                if (propType == PropType.Actions)
                {
                    if (storeSession == null)
                    {
                        throw new NotSupportedException("RuleAction type not supported without a session.");
                    }
                    RuleAction[] array  = (RuleAction[])propertyValue.Value;
                    RuleAction[] array2 = new RuleAction[array.Length];
                    for (int i = 0; i < array2.Length; i++)
                    {
                        array2[i] = RuleActionConverter.ConvertRuleAction(storeSession, exTimeZone, array[i]);
                    }
                    return(array2);
                }
                else if (propType == PropType.SysTime)
                {
                    DateTime dateTime = (DateTime)propertyValue.Value;
                    if (ExDateTime.IsValidDateTime(dateTime))
                    {
                        return(new ExDateTime(exTimeZone, dateTime));
                    }
                    return(MapiPropertyBag.CreatePropertyError(-2147221221, propertyDefinition));
                }
                else
                {
                    if (propType == PropType.SysTimeArray)
                    {
                        DateTime[] array3 = (DateTime[])propertyValue.Value;
                        foreach (DateTime dateTime2 in array3)
                        {
                            if (!ExDateTime.IsValidDateTime(dateTime2))
                            {
                                return(MapiPropertyBag.CreatePropertyError(-2147221221, propertyDefinition));
                            }
                        }
                        return(ExTimeZoneHelperForMigrationOnly.ToExDateTimeArray(exTimeZone, array3));
                    }
                    return(propertyValue.Value);
                }
            }
        }
Ejemplo n.º 24
0
 protected override void DeleteStoreProperty(StorePropertyDefinition propertyDefinition)
 {
     ((IDirectPropertyBag)this.propertyBag).Delete(propertyDefinition);
 }
Ejemplo n.º 25
0
 public abstract void DeleteValue(StorePropertyDefinition propertyDefinition);
Ejemplo n.º 26
0
 protected override void SetValidatedStoreProperty(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     throw new NotSupportedException(ServerStrings.MapiCannotSetProps);
 }
Ejemplo n.º 27
0
 public override void SetValue(StorePropertyDefinition propertyDefinition, object value)
 {
     this.storePropertyBag[propertyDefinition] = value;
 }
Ejemplo n.º 28
0
 protected override void DeleteStoreProperty(StorePropertyDefinition propertyDefinition)
 {
     throw new NotSupportedException(ServerStrings.MapiCannotDeleteProperties);
 }
Ejemplo n.º 29
0
 protected override T GetValueOrDefaultInternal <T>(StorePropertyDefinition propertyDefinition, T defaultValue)
 {
     return(this.storePropertyBag.GetValueOrDefault <T>(propertyDefinition, defaultValue));
 }
Ejemplo n.º 30
0
 internal override StoreObjectConstraint GetConstraint(StorePropertyDefinition propertyDefinition)
 {
     return(ConditionallyRequiredAttribute.GetConstraint(propertyDefinition, this.isPropertyRequired));
 }