Exemplo n.º 1
0
 internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
 {
     if (ObjectClass.IsCalendarItem((validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string) ?? string.Empty))
     {
         PersistablePropertyBag persistablePropertyBag = validatablePropertyBag as PersistablePropertyBag;
         if (persistablePropertyBag != null)
         {
             byte[] largeBinaryProperty = persistablePropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
             if (largeBinaryProperty != null)
             {
                 ExTimeZone createTimeZone = TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(persistablePropertyBag) ?? ExTimeZone.CurrentTimeZone;
                 try
                 {
                     InternalRecurrence.InternalParse(largeBinaryProperty, persistablePropertyBag.TryGetProperty(InternalSchema.ItemId) as VersionedId, createTimeZone, persistablePropertyBag.ExTimeZone, CalendarItem.DefaultCodePage);
                 }
                 catch (RecurrenceCalendarTypeNotSupportedException ex)
                 {
                     ExTraceGlobals.RecurrenceTracer.TraceDebug <CalendarType>((long)this.GetHashCode(), "RecurrenceBlobConstraint::Validate. Not supported calendar type found. CalendarType:{0}", ex.CalendarType);
                 }
                 catch (RecurrenceFormatException)
                 {
                     return(new StoreObjectValidationError(context, InternalSchema.AppointmentRecurrenceBlob, largeBinaryProperty, this));
                 }
             }
         }
     }
     return(null);
 }
        private void WriteProperty(NativeStorePropertyDefinition property, PersistablePropertyBag propertyBag)
        {
            object        obj           = propertyBag.TryGetProperty(property);
            PropertyError propertyError = obj as PropertyError;

            if (propertyError == null)
            {
                this.WriteProperty(property, obj);
                return;
            }
            if (PropertyError.IsPropertyValueTooBig(propertyError))
            {
                this.StreamProperty(property, propertyBag);
            }
        }
        internal static void CopyProperty(PersistablePropertyBag source, PropertyDefinition property, PersistablePropertyBag destination)
        {
            object        obj           = source.TryGetProperty(property);
            PropertyError propertyError = obj as PropertyError;

            if (propertyError == null)
            {
                destination[property] = obj;
                return;
            }
            if (PropertyError.IsPropertyValueTooBig(propertyError))
            {
                Stream stream;
                Stream readStream = stream = source.OpenPropertyStream(property, PropertyOpenMode.ReadOnly);
                try
                {
                    Stream stream2;
                    Stream writeStream = stream2 = destination.OpenPropertyStream(property, PropertyOpenMode.Create);
                    try
                    {
                        Util.StreamHandler.CopyStreamData(readStream, writeStream);
                    }
                    finally
                    {
                        if (stream2 != null)
                        {
                            ((IDisposable)stream2).Dispose();
                        }
                    }
                }
                finally
                {
                    if (stream != null)
                    {
                        ((IDisposable)stream).Dispose();
                    }
                }
            }
        }
Exemplo n.º 4
0
        internal static CoreItem CreateNewCoreItem(StoreSession session, ItemCreateInfo itemCreateInfo, VersionedId itemId, bool useAcr, ItemBuilder.MapiMessageCreator mapiMessageCreator)
        {
            PersistablePropertyBag persistablePropertyBag = null;
            CoreItem      coreItem      = null;
            bool          flag          = false;
            StoreObjectId storeObjectId = null;

            byte[]   changeKey = null;
            Origin   origin    = Origin.New;
            CoreItem result;

            try
            {
                persistablePropertyBag = ItemBuilder.ConstructItemPersistablePropertyBag(session, itemCreateInfo.Schema.AutoloadProperties, useAcr, itemCreateInfo.AcrProfile, mapiMessageCreator);
                if (itemId != null)
                {
                    object obj = persistablePropertyBag.TryGetProperty(CoreItemSchema.ReadCnNew);
                    if (obj is byte[] && ((byte[])obj).Length > 0)
                    {
                        changeKey     = itemId.ChangeKeyAsByteArray();
                        storeObjectId = itemId.ObjectId;
                        origin        = Origin.Existing;
                    }
                }
                coreItem = new CoreItem(session, persistablePropertyBag, storeObjectId, changeKey, origin, ItemLevel.TopLevel, itemCreateInfo.Schema.AutoloadProperties, ItemBindOption.None);
                flag     = true;
                result   = coreItem;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(coreItem);
                    Util.DisposeIfPresent(persistablePropertyBag);
                }
            }
            return(result);
        }