Example #1
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 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));
        }
Example #3
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;
         }
     }
 }
        private void WriteRecipientProperty(ConversionRecipientEntry recipient, NativeStorePropertyDefinition property)
        {
            object obj = recipient.TryGetProperty(property);

            if (!PropertyError.IsPropertyError(obj))
            {
                this.WriteProperty(property, obj);
            }
        }
        private static void AddToConfigurationCache(Folder folder, IList <IStorePropertyBag> items)
        {
            if (items == null || items.Count == 0)
            {
                return;
            }
            MailboxSession mailboxSession = folder.Session as MailboxSession;

            if (mailboxSession == null)
            {
                throw new NotSupportedException();
            }
            UserConfigurationManager userConfigurationManager = mailboxSession.UserConfigurationManager;
            List <VersionedId>       list = new List <VersionedId>();

            new List <int>();
            string a = null;

            for (int i = 0; i < items.Count; i++)
            {
                IStorePropertyBag storePropertyBag = items[i];
                if (PropertyError.IsPropertyError(storePropertyBag.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(storePropertyBag.TryGetProperty(InternalSchema.ItemId)))
                {
                    ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id.");
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id"));
                }
                string b = storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;
                if (a == b)
                {
                    list.Add((VersionedId)storePropertyBag[InternalSchema.ItemId]);
                    items.RemoveAt(i);
                    i--;
                }
                else
                {
                    string name = (string)storePropertyBag[InternalSchema.ItemClass];
                    if (UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass))
                    {
                        userConfigurationManager.UserConfigurationCache.Add(folder.Id.ObjectId, new UserConfigurationName(name, ConfigurationNameKind.ItemClass), ((VersionedId)storePropertyBag[InternalSchema.ItemId]).ObjectId);
                    }
                }
                a = (storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string);
            }
            if (folder.Session.LogonType == LogonType.Owner)
            {
                userConfigurationManager.UserConfigurationCache.Save();
            }
            AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list.ToArray());

            UserConfiguration.CheckOperationResults(result, "DeleteDuplicates");
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object value = propertyBag.GetValue(InternalSchema.DisplayTypeExInternal);

            if (PropertyError.IsPropertyError(value))
            {
                return(value);
            }
            return((RecipientDisplayType)((int)value));
        }
Example #7
0
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            object obj = validatablePropertyBag.TryGetProperty(this.propertyDefinition);

            if (PropertyError.IsPropertyError(obj) && !PropertyError.IsPropertyValueTooBig(obj))
            {
                return(new StoreObjectValidationError(context, this.propertyDefinition, obj, this));
            }
            return(null);
        }
Example #8
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object obj = base.InternalTryGetValue(propertyBag);

            if (PropertyError.IsPropertyError(obj))
            {
                return(obj);
            }
            return(FileAsStringProperty.TranslateMarkup((string)obj, "{0} ({1})") ?? new PropertyError(this, PropertyErrorCode.NotFound));
        }
Example #9
0
        private bool WriteRecipientProperty(ConversionRecipientEntry recipient, NativeStorePropertyDefinition property)
        {
            object obj = recipient.TryGetProperty(property);

            if (!PropertyError.IsPropertyError(obj))
            {
                obj = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(obj);
                this.tnefWriter.WriteProperty(property, obj);
                return(true);
            }
            return(false);
        }
        public bool TryRetrieveReplyAllDisplayNames(IStorePropertyBag propertyBag, out HashSet <string> displayNames)
        {
            ReplyAllParticipantsRepresentationProperty <string> replyAllDisplayNames = InternalSchema.ReplyAllDisplayNames;
            object obj = propertyBag.TryGetProperty(replyAllDisplayNames);

            displayNames = null;
            if (PropertyError.IsPropertyError(obj))
            {
                return(false);
            }
            displayNames = this.RetrieveReplyAllData((IDictionary <RecipientItemType, HashSet <string> >)obj, replyAllDisplayNames.ParticipantRepresentationComparer);
            return(true);
        }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            object obj  = validatablePropertyBag.TryGetProperty(this.leftPropertyDefinition);
            object obj2 = validatablePropertyBag.TryGetProperty(this.rightPropertyDefinition);

            if (PropertyError.IsPropertyNotFound(obj) && PropertyError.IsPropertyNotFound(obj2) && (this.comparisonOperator == ComparisonOperator.Equal || this.comparisonOperator == ComparisonOperator.LessThanOrEqual || this.comparisonOperator == ComparisonOperator.GreaterThanOrEqual))
            {
                return(null);
            }
            if (PropertyError.IsPropertyError(obj))
            {
                return(new StoreObjectValidationError(context, this.leftPropertyDefinition, obj, this));
            }
            if (PropertyError.IsPropertyError(obj2))
            {
                return(new StoreObjectValidationError(context, this.rightPropertyDefinition, obj2, this));
            }
            bool flag = false;

            switch (this.comparisonOperator)
            {
            case ComparisonOperator.Equal:
                flag = Util.ValueEquals(obj, obj2);
                break;

            case ComparisonOperator.NotEqual:
                flag = !Util.ValueEquals(obj, obj2);
                break;

            case ComparisonOperator.LessThan:
                flag = PropertyComparisonConstraint.LessThan(obj, obj2);
                break;

            case ComparisonOperator.LessThanOrEqual:
                flag = !PropertyComparisonConstraint.LessThan(obj2, obj);
                break;

            case ComparisonOperator.GreaterThan:
                flag = PropertyComparisonConstraint.LessThan(obj2, obj);
                break;

            case ComparisonOperator.GreaterThanOrEqual:
                flag = !PropertyComparisonConstraint.LessThan(obj, obj2);
                break;
            }
            if (flag)
            {
                return(null);
            }
            return(new StoreObjectValidationError(context, this.rightPropertyDefinition, obj2, this));
        }
        private static IEnumerable <PropValue> GetProperties(ADRawEntry adEntry)
        {
            List <PropValue>      list = new List <PropValue>();
            ConversionPropertyBag conversionPropertyBag = new ConversionPropertyBag(adEntry, StoreToDirectorySchemaConverter.Instance);

            foreach (StorePropertyDefinition storePropertyDefinition in DirectoryParticipantOrigin.propertiesToDonate)
            {
                object obj = conversionPropertyBag.TryGetProperty(storePropertyDefinition);
                if (!PropertyError.IsPropertyError(obj))
                {
                    list.Add(new PropValue(storePropertyDefinition, obj));
                }
            }
            return(list.ToArray());
        }
Example #13
0
 private static void ThrowIfPropertyError(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     if (propertyValue == null)
     {
         throw PropertyError.ToException(new PropertyError[]
         {
             new PropertyError(propertyDefinition, PropertyErrorCode.NullValue)
         });
     }
     if (PropertyError.IsPropertyError(propertyValue))
     {
         throw PropertyError.ToException(new PropertyError[]
         {
             (PropertyError)propertyValue
         });
     }
 }
Example #14
0
 private static bool PropertyValuesAreEqual(PropertyDefinition property, object x, object y)
 {
     if (!PropertyError.IsPropertyError(x) && !PropertyError.IsPropertyError(y))
     {
         if (property.Type.IsArray)
         {
             Array array  = x as Array;
             Array array2 = y as Array;
             if (array == null || array2 == null || array.Length != array2.Length)
             {
                 return(false);
             }
             for (int i = 0; i < array2.Length; i++)
             {
                 if (!array.GetValue(i).Equals(array2.GetValue(i)))
                 {
                     return(false);
                 }
             }
         }
         else if (!x.Equals(y))
         {
             return(false);
         }
     }
     else
     {
         if (PropertyError.IsPropertyNotFound(x) && !PropertyError.IsPropertyNotFound(y))
         {
             return(false);
         }
         if (PropertyError.IsPropertyNotFound(y) && !PropertyError.IsPropertyNotFound(x))
         {
             return(false);
         }
         if (PropertyError.IsPropertyValueTooBig(x) || PropertyError.IsPropertyValueTooBig(y))
         {
             return(false);
         }
     }
     return(true);
 }
Example #15
0
 internal override FolderSaveResult SaveFolderPropertyBag(bool needVersionCheck)
 {
     if (this.Context.CoreObject.Origin == Origin.New)
     {
         try
         {
             try
             {
                 using (Folder folder = Folder.Bind(this.context.Session, this.parentFolderId, null))
                 {
                     if (folder is SearchFolder)
                     {
                         throw new InvalidParentFolderException(ServerStrings.ExCannotCreateSubfolderUnderSearchFolder);
                     }
                 }
             }
             catch (ObjectNotFoundException)
             {
             }
             List <PropertyDefinition> list  = new List <PropertyDefinition>(base.MemoryPropertyBag.ChangeList.Count);
             List <object>             list2 = new List <object>(list.Count);
             foreach (PropertyDefinition propertyDefinition in base.MemoryPropertyBag.ChangeList)
             {
                 object obj = base.MemoryPropertyBag.TryGetProperty(propertyDefinition);
                 if (!PropertyError.IsPropertyError(obj))
                 {
                     list.Add(propertyDefinition);
                     list2.Add(obj);
                 }
             }
             this.context.ImportChange(this.ExTimeZone, list, list2);
             this.Context.CoreState.Origin = Origin.Existing;
             return(FolderPropertyBag.SuccessfulSave);
         }
         finally
         {
             this.Clear();
         }
     }
     return(base.SaveFolderPropertyBag(needVersionCheck));
 }
Example #16
0
 internal static GroupExpansionRecipients RetrieveFromStore(MessageItem messageItem, StorePropertyDefinition propertyDefinition)
 {
     if (messageItem == null)
     {
         return(null);
     }
     try
     {
         object propertyValue = messageItem.TryGetProperty(propertyDefinition);
         if (PropertyError.IsPropertyNotFound(propertyValue))
         {
             return(null);
         }
         if (PropertyError.IsPropertyValueTooBig(propertyValue))
         {
             using (Stream stream = messageItem.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
             {
                 Encoding encoding = new UnicodeEncoding(false, false);
                 using (StreamReader streamReader = new StreamReader(stream, encoding))
                 {
                     string data = streamReader.ReadToEnd();
                     return(GroupExpansionRecipients.Parse(data));
                 }
             }
         }
         if (PropertyError.IsPropertyError(propertyValue))
         {
             return(null);
         }
         string text = messageItem[propertyDefinition] as string;
         if (!string.IsNullOrEmpty(text))
         {
             return(GroupExpansionRecipients.Parse(text));
         }
     }
     catch (PropertyErrorException)
     {
         return(null);
     }
     return(null);
 }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            MessageItem      messageItem      = propertyBag.Context.StoreObject as MessageItem;
            CalendarItemBase calendarItemBase = propertyBag.Context.StoreObject as CalendarItemBase;

            if (messageItem != null)
            {
                return(this.BuildAggregatedValue <Recipient>(messageItem.Recipients));
            }
            if (calendarItemBase != null)
            {
                return(this.BuildAggregatedValue <Attendee>(calendarItemBase.AttendeeCollection));
            }
            if (this.storeComputedProperty != null)
            {
                object value = propertyBag.GetValue(this.storeComputedProperty);
                if (!PropertyError.IsPropertyError(value))
                {
                    return(value);
                }
            }
            return(new PropertyError(this, PropertyErrorCode.GetCalculatedPropertyError));
        }
        private static void WriteRecipient(BinaryWriter writer, BlobRecipient recipient)
        {
            List <PropValue> list = new List <PropValue>(recipient.PropertyValues.Count);

            foreach (PropValue item in PropValue.ConvertEnumerator <PropertyDefinition>(recipient.PropertyValues))
            {
                if (!PropertyError.IsPropertyError(item.Value) && !((PropTag)((PropertyTagPropertyDefinition)item.Property).PropertyTag).IsNamedProperty())
                {
                    list.Add(item);
                }
            }
            uint count = (uint)list.Count;
            uint value = 0U;

            writer.Write(count);
            writer.Write(value);
            foreach (PropValue propValue in list)
            {
                PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)propValue.Property;
                object value2 = ExTimeZoneHelperForMigrationOnly.ToUtcIfDateTime(propValue.Value);
                BlobRecipientParser.WritePropValue(writer, (PropTag)propertyTagPropertyDefinition.PropertyTag, value2);
            }
        }
Example #19
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();
                        }
                    }
                }
            }
        }
        protected virtual void UpdateNewItemProperties()
        {
            IExchangePrincipal exchangePrincipal = (this.newItem.Session == null) ? null : this.newItem.Session.MailboxOwner;
            MailboxSession     mailboxSession    = this.newItem.Session as MailboxSession;

            if (mailboxSession != null && exchangePrincipal != null)
            {
                PostItem postItem = this.newItem as PostItem;
                if (postItem != null)
                {
                    postItem.Sender = new Participant(exchangePrincipal);
                }
                else
                {
                    ((MessageItem)this.newItem).Sender = new Participant(exchangePrincipal);
                }
            }
            string text           = null;
            string valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetMessageId);

            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text = valueOrDefault;
            }
            string text2 = null;

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InReplyTo);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text2 = valueOrDefault;
            }
            this.newItem.SafeSetProperty(InternalSchema.InReplyTo, text);
            StringBuilder stringBuilder = new StringBuilder(128);

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetReferences);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                stringBuilder.Append(valueOrDefault);
            }
            else if (text2 != null)
            {
                stringBuilder.Append(text2);
            }
            if (text != null)
            {
                if (stringBuilder.Length + 1 + text.Length > 32768 || stringBuilder.Length == 0)
                {
                    stringBuilder.Clear();
                    stringBuilder.Append(text);
                }
                else
                {
                    stringBuilder.Append(',');
                    stringBuilder.Append(text);
                }
            }
            this.newItem.SafeSetProperty(InternalSchema.InternetReferences, stringBuilder.ToString());
            this.newItem.SafeSetProperty(InternalSchema.Categories, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Categories), typeof(string[]), null));
            byte[]            parentBytes       = this.originalItem.TryGetProperty(InternalSchema.ConversationIndex) as byte[];
            ConversationIndex conversationIndex = ConversationIndex.CreateFromParent(parentBytes);

            this.newItem.SafeSetProperty(InternalSchema.ConversationIndex, conversationIndex.ToByteArray());
            ConversationId valueOrDefault2 = this.originalItem.GetValueOrDefault <ConversationId>(InternalSchema.ConversationFamilyId);

            this.newItem.SafeSetProperty(InternalSchema.ConversationFamilyId, valueOrDefault2);
            object propValue = this.originalItem.TryGetProperty(InternalSchema.SupportsSideConversation);

            this.newItem.SafeSetProperty(InternalSchema.SupportsSideConversation, propValue);
            ConversationCreatorSidCalculatorFactory conversationCreatorSidCalculatorFactory = new ConversationCreatorSidCalculatorFactory(XSOFactory.Default);
            IConversationCreatorSidCalculator       conversationCreatorSidCalculator;

            byte[] propValue2;
            if (conversationCreatorSidCalculatorFactory.TryCreate(mailboxSession, exchangePrincipal, out conversationCreatorSidCalculator) && conversationCreatorSidCalculator.TryCalculateOnReply(conversationIndex, out propValue2))
            {
                this.newItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, propValue2);
            }
            bool?valueAsNullable = this.originalItem.GetValueAsNullable <bool>(InternalSchema.ConversationIndexTracking);

            if (valueAsNullable != null && valueAsNullable.Value)
            {
                this.newItem.SafeSetProperty(InternalSchema.ConversationIndexTracking, true);
            }
            this.newItem.SafeSetProperty(InternalSchema.ConversationTopic, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.ConversationTopic), typeof(string), StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NormalizedSubjectInternal), typeof(string), null)));
            this.newItem.SafeSetProperty(InternalSchema.Sensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Sensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.OriginalSensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.OriginalSensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.IsReadReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsDeliveryReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsReplyRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsReplyRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.IsResponseRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsResponseRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.NativeBlockStatus, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NativeBlockStatus), typeof(int), null));
            object obj = this.originalItem.TryGetProperty(InternalSchema.IconIndex);

            if (!PropertyError.IsPropertyError(obj))
            {
                IconIndex iconIndex = (IconIndex)obj;
                if (iconIndex != IconIndex.Default)
                {
                    iconIndex = ReplyForwardCommon.GetIconIndexForNewItem(iconIndex);
                    this.newItem.SafeSetProperty(InternalSchema.IconIndex, iconIndex);
                }
            }
            ReplyForwardCommon.UpdateXLoop(this.originalItem, this.newItem, this.parameters.XLoop);
        }
Example #21
0
        private ConflictResolutionResult ApplyAcr(PropertyBag acrPropBag, SaveMode saveMode)
        {
            Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> valuesToResolve = this.GetValuesToResolve(acrPropBag);
            string valueOrDefault = this.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                LocationIdentifierHelper           locationIdentifierHelper = new LocationIdentifierHelper();
                AcrPropertyProfile.ValuesToResolve valuesToResolve2;
                object serverValue;
                if (valuesToResolve.TryGetValue(InternalSchema.ChangeList, out valuesToResolve2))
                {
                    locationIdentifierHelper.ChangeBuffer = (byte[])valuesToResolve2.ClientValue;
                    serverValue = valuesToResolve2.ServerValue;
                }
                else
                {
                    serverValue = new PropertyError(InternalSchema.ChangeList, PropertyErrorCode.NotFound);
                }
                locationIdentifierHelper.SetLocationIdentifier(53909U, LastChangeAction.AcrPerformed);
                valuesToResolve2 = new AcrPropertyProfile.ValuesToResolve(locationIdentifierHelper.ChangeBuffer, serverValue, null);
                valuesToResolve[InternalSchema.ChangeList] = valuesToResolve2;
            }
            ConflictResolutionResult conflictResolutionResult = this.profile.ResolveConflicts(valuesToResolve);

            if (this.propertiesWrittenAsStream.Count > 0)
            {
                List <PropertyConflict> list = new List <PropertyConflict>(conflictResolutionResult.PropertyConflicts);
                foreach (PropertyDefinition propertyDefinition in this.propertiesWrittenAsStream.Keys)
                {
                    PropertyConflict item = new PropertyConflict(propertyDefinition, null, null, null, null, false);
                    list.Add(item);
                }
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, list.ToArray());
            }
            if (this.irresolvableChanges || saveMode == SaveMode.FailOnAnyConflict)
            {
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, conflictResolutionResult.PropertyConflicts);
            }
            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict)
            {
                List <PropertyDefinition> list2 = new List <PropertyDefinition>();
                List <PropertyDefinition> list3 = new List <PropertyDefinition>();
                List <object>             list4 = new List <object>();
                if (this.propertyBag == acrPropBag)
                {
                    foreach (PropertyConflict propertyConflict in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict.ResolvedValue) && (!PropertyError.IsPropertyError(propertyConflict.ClientValue) || !PropertyError.IsPropertyNotFound(propertyConflict.ClientValue)))
                            {
                                list2.Add(propertyConflict.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict.ResolvedValue != propertyConflict.ClientValue)
                        {
                            list3.Add(propertyConflict.PropertyDefinition);
                            list4.Add(propertyConflict.ResolvedValue);
                        }
                    }
                }
                else
                {
                    foreach (PropertyConflict propertyConflict2 in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict2.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict2.ResolvedValue))
                            {
                                list2.Add(propertyConflict2.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict2.ServerValue != propertyConflict2.ResolvedValue)
                        {
                            list3.Add(propertyConflict2.PropertyDefinition);
                            list4.Add(propertyConflict2.ResolvedValue);
                        }
                    }
                }
                for (int k = 0; k < list2.Count; k++)
                {
                    acrPropBag.Delete(list2[k]);
                }
                for (int l = 0; l < list3.Count; l++)
                {
                    acrPropBag[list3[l]] = list4[l];
                }
            }
            return(conflictResolutionResult);
        }