コード例 #1
0
        protected sealed override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            ConversationId conversationId = value as ConversationId;

            if (conversationId == null)
            {
                throw new ArgumentException("value", "Must be a non-null ConversationId instance");
            }
            ConversationIndex conversationIndex;

            if (!ConversationIndex.TryCreate(propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex), out conversationIndex))
            {
                conversationIndex = ConversationIndex.Create(conversationId);
            }
            else
            {
                conversationIndex = conversationIndex.UpdateGuid(new Guid(conversationId.GetBytes()));
            }
            byte[] array          = conversationIndex.ToByteArray();
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);

            if (valueOrDefault != null && ObjectClass.IsOfClass(valueOrDefault, "IPM.ConversationAction"))
            {
                array[0] = 1;
                array[1] = (array[2] = (array[3] = (array[4] = (array[5] = 0))));
            }
            propertyBag.SetValueWithFixup(InternalSchema.ConversationIndex, array);
        }
コード例 #2
0
        private static ConversationIndex GetConversationIndex(ConversationId conversationId)
        {
            ConversationIndex conversationIndex = ConversationIndex.Create(conversationId);

            byte[] header = new byte[5];
            return(conversationIndex.UpdateHeader(header));
        }
コード例 #3
0
 public void LogAggregationResultData(ConversationAggregationResult aggregationResult)
 {
     this.LogEvent(new SchemaBasedLogEvent <ConversationAggregationLogSchema.AggregationResult>
     {
         {
             ConversationAggregationLogSchema.AggregationResult.ConversationFamilyId,
             aggregationResult.ConversationFamilyId
         },
         {
             ConversationAggregationLogSchema.AggregationResult.ConversationId,
             ConversationId.Create(aggregationResult.ConversationIndex)
         },
         {
             ConversationAggregationLogSchema.AggregationResult.IsOutOfOrderDelivery,
             ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(aggregationResult.Stage)
         },
         {
             ConversationAggregationLogSchema.AggregationResult.NewConversationCreated,
             ConversationIndex.IsFixUpCreatingNewConversation(aggregationResult.Stage)
         },
         {
             ConversationAggregationLogSchema.AggregationResult.SupportsSideConversation,
             aggregationResult.SupportsSideConversation
         },
         {
             ConversationAggregationLogSchema.AggregationResult.FixupStage,
             aggregationResult.Stage
         }
     });
 }
コード例 #4
0
        public void Trace(ConversationIndex index)
        {
            Util.ThrowOnNullArgument(index, "index");
            StringBuilder stringBuilder = new StringBuilder(0);

            stringBuilder.Append("[");
            stringBuilder.Append(string.Format("{0}={1}", "CID", index.Guid));
            stringBuilder.Append(";");
            stringBuilder.Append(string.Format("{0}={1}", "IDXHEAD", GlobalObjectId.ByteArrayToHexString(index.Header)));
            stringBuilder.Append(";");
            stringBuilder.Append(string.Format("{0}={1}", "IDXCOUNT", index.Components.Count));
            stringBuilder.Append("]");
            this.Trace("II", stringBuilder.ToString());
        }
コード例 #5
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            string text  = (string)value;
            string text2 = propertyBag.GetValue(InternalSchema.SubjectPrefixInternal) as string;
            string text3 = propertyBag.GetValue(InternalSchema.NormalizedSubjectInternal) as string;

            if (text2 != null && text3 != null && text == text2 + text3)
            {
                return;
            }
            string propertyValue;
            string text4;

            SubjectProperty.ComputeSubjectPrefix(text, out propertyValue, out text4);
            propertyBag.SetValueWithFixup(InternalSchema.SubjectPrefixInternal, propertyValue);
            propertyBag.SetValueWithFixup(InternalSchema.NormalizedSubjectInternal, text4);
            propertyBag.SetValueWithFixup(InternalSchema.MapiSubject, text);
            if (text4 != text3)
            {
                MessageItem messageItem = propertyBag.Context.StoreObject as MessageItem;
                if (messageItem != null)
                {
                    string itemClass = propertyBag.GetValue(InternalSchema.ItemClass) as string;
                    if (!ObjectClass.IsPost(itemClass))
                    {
                        messageItem.ConversationTopic = text4;
                        if (!string.IsNullOrEmpty(text3))
                        {
                            messageItem.ConversationIndex = ConversationIndex.CreateNew().ToByteArray();
                            if (messageItem.MessageResponseType == MessageResponseType.None)
                            {
                                SubjectProperty.ClearReplyForwardProperties(messageItem);
                                return;
                            }
                        }
                        else if (messageItem.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex) == null)
                        {
                            messageItem.ConversationIndex = ConversationIndex.CreateNew().ToByteArray();
                        }
                    }
                }
            }
        }
コード例 #6
0
 public void UpdateManifestFromPropertyBag(IReadOnlyPropertyBag propertyBag)
 {
     this.messageClass = (propertyBag[InternalSchema.ItemClass] as string);
     try
     {
         object obj = propertyBag[ItemSchema.ReceivedTime];
         if (obj is ExDateTime)
         {
             this.filterDate = new ExDateTime?((ExDateTime)obj);
         }
     }
     catch (PropertyErrorException)
     {
         this.filterDate = null;
     }
     try
     {
         object obj = propertyBag[ItemSchema.ConversationId];
         if (obj is ConversationId)
         {
             this.conversationId = (ConversationId)obj;
         }
         obj = propertyBag[ItemSchema.ConversationIndex];
         ConversationIndex index;
         if (obj is byte[] && ConversationIndex.TryCreate((byte[])obj, out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
         {
             this.firstMessageInConversation = true;
         }
     }
     catch (PropertyErrorException)
     {
         this.conversationId             = null;
         this.firstMessageInConversation = false;
     }
     try
     {
         object obj = propertyBag[MessageItemSchema.IsRead];
         if (obj is bool)
         {
             this.itemRead = (((bool)obj) ? ServerManifestEntry.ReadFlagState.Read : ServerManifestEntry.ReadFlagState.UnRead);
         }
     }
     catch (PropertyErrorException)
     {
         this.itemRead = ServerManifestEntry.ReadFlagState.Unknown;
     }
 }
コード例 #7
0
        public static MessageItem CreateNotReadNotification(MessageItem originalItem)
        {
            ExDateTime  utcNow      = ExDateTime.UtcNow;
            MessageItem messageItem = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties);

            messageItem.ClassName = ObjectClass.MakeReportClassName(originalItem.ClassName, "IPNNRN");
            messageItem.SafeSetProperty(InternalSchema.ReportTime, utcNow);
            Participant participant = originalItem.ReadReceiptAddressee;

            if (null == participant)
            {
                if (null != originalItem.Sender)
                {
                    participant = originalItem.Sender;
                }
                else
                {
                    participant = originalItem.From;
                }
            }
            messageItem.Recipients.Add(participant, RecipientItemType.To);
            foreach (KeyValuePair <PropertyDefinition, PropertyDefinition> keyValuePair in RuleMessageUtils.NrnPropertyMap)
            {
                messageItem.SafeSetProperty(keyValuePair.Key, originalItem.TryGetProperty(keyValuePair.Value));
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, originalItem.Body.RawCharset.Name);
            CultureInfo            formatProvider;

            using (Stream stream = messageItem.Body.OpenWriteStream(configuration))
            {
                Charset charset;
                ReportMessage.GenerateReportBody(messageItem, stream, out formatProvider, out charset);
            }
            messageItem.SafeSetProperty(InternalSchema.Subject, ServerStrings.NotRead.ToString(formatProvider) + originalItem.TryGetProperty(InternalSchema.Subject));
            byte[] parentBytes = originalItem.TryGetProperty(InternalSchema.ConversationIndex) as byte[];
            messageItem.SafeSetProperty(InternalSchema.ConversationIndex, ConversationIndex.CreateFromParent(parentBytes).ToByteArray());
            messageItem.SafeSetProperty(InternalSchema.ConversationTopic, StoreObject.SafePropertyValue(originalItem.TryGetProperty(InternalSchema.ConversationTopic), typeof(string), StoreObject.SafePropertyValue(originalItem.TryGetProperty(InternalSchema.NormalizedSubjectInternal), typeof(string), null)));
            messageItem.SafeSetProperty(InternalSchema.IsReadReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.IsDeliveryReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.IsNonDeliveryReceiptRequested, false);
            messageItem.SafeSetProperty(InternalSchema.NonReceiptReason, 0);
            messageItem.SafeSetProperty(InternalSchema.DiscardReason, 1);
            messageItem.SafeSetProperty(InternalSchema.OriginalDeliveryTime, utcNow);
            return(messageItem);
        }
コード例 #8
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            byte[] valueOrDefault  = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.MapiConversationFamilyId, null);
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex);
            if (valueOrDefault2 == null || valueOrDefault == null)
            {
                return(null);
            }
            ConversationIndex conversationIndex;
            bool           flag           = ConversationIndex.TryCreate(valueOrDefault2, out conversationIndex);
            ConversationId conversationId = ConversationId.Create(valueOrDefault);

            if (!flag)
            {
                return(null);
            }
            return(conversationIndex.UpdateGuid(conversationId).ToByteArray());
        }
コード例 #9
0
        public bool Aggregate(ICorePropertyBag propertyBag, out ConversationIndex newIndex, out ConversationIndex.FixupStage stage)
        {
            newIndex = ConversationIndex.Empty;
            Participant valueOrDefault = propertyBag.GetValueOrDefault <Participant>(InternalSchema.From);

            if (valueOrDefault != null && string.Equals("MOBILE", valueOrDefault.RoutingType, StringComparison.OrdinalIgnoreCase))
            {
                newIndex = ConversationIndex.GenerateFromPhoneNumber(valueOrDefault.EmailAddress);
            }
            if (newIndex != ConversationIndex.Empty)
            {
                stage = ConversationIndex.FixupStage.S1;
                AggregationBySmsItemClassProcessor.ChunkSmsConversation(this.xsoFactory, this.session, newIndex, this.indexTrackingEx);
            }
            else
            {
                newIndex = ConversationIndex.CreateNew();
                stage    = ConversationIndex.FixupStage.S2;
            }
            return(false);
        }
コード例 #10
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);
            byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.ConversationIndex);
            if (valueOrDefault == null)
            {
                return(null);
            }
            ConversationIndex conversationIndex;

            if (!ConversationIndex.TryCreate(valueOrDefault, out conversationIndex))
            {
                return(null);
            }
            bool?valueAsNullable = propertyBag.GetValueAsNullable <bool>(InternalSchema.ConversationIndexTracking);

            if (valueAsNullable == null || !valueAsNullable.Value)
            {
                string topic = propertyBag.GetValueOrDefault <string>(InternalSchema.ConversationTopic) ?? string.Empty;
                byte[] bytes = this.ComputeHashTopic(topic);
                return(ConversationId.Create(bytes));
            }
            return(ConversationId.Create(conversationIndex.Guid));
        }
コード例 #11
0
        public static void ChunkSmsConversation(IXSOFactory xsoFactory, IMailboxSession session, ConversationIndex conversationIndex, ConversationIndexTrackingEx conversationIndexTrackingEx)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(conversationIndex, "conversationIndex");
            byte[]    conversationIdBytes = ConversationId.Create(conversationIndex.Guid).GetBytes();
            int       conversationIdHash  = (int)AllItemsFolderHelper.GetHashValue(conversationIdBytes);
            Stopwatch stopwatch           = Stopwatch.StartNew();
            List <IStorePropertyBag> list = xsoFactory.RunQueryOnAllItemsFolder <List <IStorePropertyBag> >(session, AllItemsFolderHelper.SupportedSortBy.ConversationIdHash, conversationIdHash, null, delegate(QueryResult queryResult)
            {
                List <IStorePropertyBag> list2 = null;
                bool flag = false;
                while (!flag)
                {
                    IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10);
                    if (propertyBags == null || propertyBags.Length <= 0)
                    {
                        break;
                    }
                    for (int i = 0; i < propertyBags.Length; i++)
                    {
                        int?num2 = propertyBags[i].TryGetProperty(ItemSchema.ConversationIdHash) as int?;
                        if (num2 == null)
                        {
                            break;
                        }
                        if (num2.Value != conversationIdHash)
                        {
                            flag = true;
                            break;
                        }
                        byte[] array = propertyBags[i].TryGetProperty(InternalSchema.MapiConversationId) as byte[];
                        if (array != null && Util.CompareByteArray(conversationIdBytes, array))
                        {
                            if (list2 == null)
                            {
                                list2 = new List <IStorePropertyBag>(10);
                            }
                            list2.Add(propertyBags[i]);
                        }
                    }
                }
                return(list2);
            }, new StorePropertyDefinition[]
            {
                ItemSchema.Id,
                ItemSchema.ConversationIdHash,
                ItemSchema.ReceivedTime,
                InternalSchema.MapiConversationId
            });

            stopwatch.Stop();
            if (conversationIndexTrackingEx != null)
            {
                conversationIndexTrackingEx.Trace("SBSMSCID", stopwatch.ElapsedMilliseconds.ToString());
            }
            if (list == null || list.Count < 79)
            {
                return;
            }
            list.Sort(delegate(IStorePropertyBag x, IStorePropertyBag y)
            {
                ExDateTime?exDateTime  = x.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?;
                ExDateTime?exDateTime2 = y.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?;
                if (exDateTime == null && exDateTime2 == null)
                {
                    return(0);
                }
                if (exDateTime == null)
                {
                    return(1);
                }
                if (exDateTime2 == null)
                {
                    return(-1);
                }
                return(exDateTime.Value.CompareTo(exDateTime2.Value));
            });
            string str = conversationIndex.Guid.ToString("D").Substring("472e2878-19b1-4ac1-a21a-".Length);
            string text;

            do
            {
                text = Guid.NewGuid().ToString("D").Substring(0, "472e2878-19b1-4ac1-a21a-".Length);
            }while (string.Equals(text, "472e2878-19b1-4ac1-a21a-"));
            ConversationIndex conversationIndex2 = ConversationIndex.Create(new Guid(text + str));
            int num = 0;

            while (num < list.Count && num < 50)
            {
                VersionedId versionedId = (VersionedId)list[num].TryGetProperty(ItemSchema.Id);
                if (versionedId != null)
                {
                    StoreObjectId objectId = versionedId.ObjectId;
                    if (objectId != null)
                    {
                        using (IMessageItem messageItem = xsoFactory.BindToMessage(session, objectId, null))
                        {
                            messageItem.OpenAsReadWrite();
                            messageItem[ItemSchema.ConversationIndex]         = conversationIndex2.ToByteArray();
                            messageItem[ItemSchema.ConversationIndexTracking] = true;
                            messageItem.Save(SaveMode.ResolveConflicts);
                        }
                    }
                }
                num++;
            }
        }
コード例 #12
0
 public static ConversationId Create(ConversationIndex index)
 {
     return(new ConversationId(index.Guid.ToByteArray()));
 }
コード例 #13
0
        public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties)
        {
            EnumValidator.ThrowIfInvalid <ManifestChangeType>(changeType, "changeType");
            if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                this.TraceChangeChangeCallbackProps(entryId, sourceKey, changeKey, changeList, lastModifiedTime, changeType, associated, properties);
            }
            int?           num                        = null;
            string         text                       = null;
            bool           read                       = false;
            ConversationId conversationId             = null;
            bool           firstMessageInConversation = false;
            ExDateTime?    filterDate                 = null;

            foreach (PropValue propValue in properties)
            {
                if (!propValue.IsError())
                {
                    PropTag propTag = propValue.PropTag;
                    if (propTag <= PropTag.MessageDeliveryTime)
                    {
                        if (propTag != PropTag.MessageClass)
                        {
                            ConversationIndex index;
                            if (propTag != PropTag.ConversationIndex)
                            {
                                if (propTag == PropTag.MessageDeliveryTime)
                                {
                                    if (propValue.PropType == PropType.SysTime)
                                    {
                                        filterDate = new ExDateTime?((ExDateTime)propValue.GetDateTime());
                                    }
                                }
                            }
                            else if (propValue.PropType == PropType.Binary && ConversationIndex.TryCreate(propValue.GetBytes(), out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                firstMessageInConversation = true;
                            }
                        }
                        else if (propValue.PropType == PropType.String)
                        {
                            text = propValue.GetString();
                        }
                    }
                    else if (propTag != PropTag.MessageFlags)
                    {
                        if (propTag != PropTag.InternetArticleNumber)
                        {
                            if (propTag == PropTag.ConversationId)
                            {
                                if (propValue.PropType == PropType.Binary)
                                {
                                    conversationId = ConversationId.Create(propValue.GetBytes());
                                }
                            }
                        }
                        else
                        {
                            if (propValue.PropType != PropType.Int)
                            {
                                return(ManifestCallbackStatus.Continue);
                            }
                            num = new int?(propValue.GetInt());
                        }
                    }
                    else if (propValue.PropType == PropType.Int)
                    {
                        MessageFlags @int = (MessageFlags)propValue.GetInt();
                        read = ((@int & MessageFlags.IsRead) == MessageFlags.IsRead);
                    }
                }
            }
            if (changeType == ManifestChangeType.Add || changeType == ManifestChangeType.Change)
            {
                if (num == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                StoreObjectId        id = StoreObjectId.FromProviderSpecificId(entryId, (text == null) ? StoreObjectType.Unknown : ObjectClass.GetObjectType(text));
                MailboxSyncItemId    mailboxSyncItemId    = MailboxSyncItemId.CreateForNewItem(id);
                MailboxSyncWatermark mailboxSyncWatermark = MailboxSyncWatermark.CreateForSingleItem();
                mailboxSyncWatermark.UpdateWithChangeNumber(num.Value, read);
                ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateItemChangeManifestEntry(mailboxSyncItemId, mailboxSyncWatermark);
                serverManifestEntry.IsNew                      = (changeType == ManifestChangeType.Add);
                serverManifestEntry.MessageClass               = text;
                serverManifestEntry.ConversationId             = conversationId;
                serverManifestEntry.FirstMessageInConversation = firstMessageInConversation;
                serverManifestEntry.FilterDate                 = filterDate;
                mailboxSyncItemId.ChangeKey                    = changeKey;
                this.lastServerManifestEntry                   = serverManifestEntry;
            }
            else
            {
                StoreObjectId     id2 = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
                MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id2);
                if (mailboxSyncItemId2 == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId2);
                this.lastServerManifestEntry.ConversationId = conversationId;
            }
            return(this.CheckYieldOrStop());
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public override bool Equals(object obj)
        {
            UniqueItemHash uniqueItemHash = obj as UniqueItemHash;

            if (uniqueItemHash == null)
            {
                return(false);
            }
            if (!UniqueItemHash.CompareInternetMessageIds(this.internetMessageId, uniqueItemHash.internetMessageId) || !ConversationIndex.CompareTopics(this.conversationTopic, uniqueItemHash.conversationTopic))
            {
                return(false);
            }
            if (this.bodyTagInfo != null && uniqueItemHash.bodyTagInfo != null)
            {
                return(this.bodyTagInfo.Equals(uniqueItemHash.bodyTagInfo));
            }
            return((!(this.bodyTagInfo == null) || !(uniqueItemHash.bodyTagInfo == null)) && ((this.bodyTagInfo == null && this.isSentItems) || (uniqueItemHash.bodyTagInfo == null && uniqueItemHash.isSentItems)));
        }
コード例 #16
0
        public static IList <StoreId> QueryConversationActionsFolder(MailboxSession session, ConversationId conversationId, int maxRowCount, out int totalActionItemCount)
        {
            totalActionItemCount = 0;
            StoreId conversationActionsFolderId = ConversationActionItem.GetConversationActionsFolderId(session, false);

            if (conversationActionsFolderId == null)
            {
                return(null);
            }
            IList <StoreId> result;

            try
            {
                using (Folder folder = Folder.Bind(session, conversationActionsFolderId))
                {
                    int?valueAsNullable = folder.GetValueAsNullable <int>(FolderSchema.AssociatedItemCount);
                    if (valueAsNullable != null && valueAsNullable <= 0)
                    {
                        result = null;
                    }
                    else
                    {
                        totalActionItemCount = ((valueAsNullable != null) ? valueAsNullable.Value : 0);
                        if (conversationId == null)
                        {
                            result = null;
                        }
                        else
                        {
                            SortBy[] sortColumns = new SortBy[]
                            {
                                new SortBy(ItemSchema.ConversationIndex, SortOrder.Ascending),
                                new SortBy(StoreObjectSchema.LastModifiedTime, SortOrder.Descending)
                            };
                            ConversationIndex conversationIndex = ConversationActionItem.GetConversationIndex(conversationId);
                            using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.Associated, null, sortColumns, new PropertyDefinition[]
                            {
                                ItemSchema.ConversationIndex,
                                ItemSchema.Id,
                                ConversationActionItemSchema.ConversationActionVersion
                            }))
                            {
                                if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationIndex, conversationIndex.ToByteArray())))
                                {
                                    IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(maxRowCount);
                                    if (propertyBags.Length >= 1)
                                    {
                                        List <StoreId> list = new List <StoreId>();
                                        for (int i = 0; i < propertyBags.Length; i++)
                                        {
                                            byte[] array = propertyBags[i][ItemSchema.ConversationIndex] as byte[];
                                            if (array != null)
                                            {
                                                ConversationIndex conversationIndex2;
                                                bool flag = ConversationIndex.TryCreate(array, out conversationIndex2);
                                                if (flag)
                                                {
                                                    if (!conversationIndex2.Equals(conversationIndex))
                                                    {
                                                        break;
                                                    }
                                                    if (!(propertyBags[i].TryGetProperty(ConversationActionItemSchema.ConversationActionVersion) is PropertyError))
                                                    {
                                                        int version = (int)propertyBags[i].TryGetProperty(ConversationActionItemSchema.ConversationActionVersion);
                                                        if (ConversationActionItem.GetMajorVersion(version) >= 4)
                                                        {
                                                            list.Add(propertyBags[i][ItemSchema.Id] as VersionedId);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        return((list.Count == 0) ? null : list);
                                    }
                                }
                                result = null;
                            }
                        }
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                result = null;
            }
            return(result);
        }
コード例 #17
0
        private bool GetNewOperationsWithFilter(MailboxSyncWatermark minWatermark, MailboxSyncWatermark maxWatermark, int numOperations, QueryFilter filter, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
        {
            this.SyncLogger.Information(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. numOperations {0}, newServerManifest count {1}, minWatermark is New? {2}. Starting change number {3}", new object[]
            {
                numOperations,
                newServerManifest.Count,
                minWatermark.IsNew,
                minWatermark.ChangeNumber
            });
            bool             result           = false;
            ComparisonFilter comparisonFilter = null;

            if (!minWatermark.IsNew)
            {
                comparisonFilter = new ComparisonFilter(ComparisonOperator.GreaterThan, InternalSchema.ArticleId, minWatermark.RawChangeNumber);
            }
            if (this.syncQueryResult == null)
            {
                this.syncQueryResult = MailboxSyncQueryProcessor.ItemQuery(this.folder, ItemQueryType.None, filter, this.itemQueryOptimizationFilter, MailboxSyncProvider.sortByArticleIdAscending, MailboxSyncProvider.queryColumns, this.allowTableRestrict, this.UseSortOrder);
            }
            else if (comparisonFilter == null)
            {
                this.syncQueryResult.SeekToOffset(SeekReference.OriginBeginning, 0);
            }
            if (comparisonFilter != null)
            {
                this.syncQueryResult.SeekToCondition(SeekReference.OriginBeginning, comparisonFilter);
            }
            bool flag = false;

            while (!flag)
            {
                int num;
                if (numOperations == -1)
                {
                    num = 10000;
                }
                else
                {
                    int num2 = numOperations - newServerManifest.Count;
                    num = num2 + 1;
                }
                if (num < 0)
                {
                    throw new InvalidOperationException(ServerStrings.ExNumberOfRowsToFetchInvalid(num.ToString()));
                }
                object[][] rows = this.syncQueryResult.GetRows(num);
                flag = (this.syncQueryResult.CurrentRow == this.syncQueryResult.EstimatedRowCount);
                this.SyncLogger.Information <int, int, bool>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. Requested {0} rows, Received {1} rows, All fetched? {2}", num, rows.Length, flag);
                for (int i = 0; i < rows.Length; i++)
                {
                    try
                    {
                        StoreObjectId        objectId             = ((VersionedId)rows[i][1]).ObjectId;
                        int                  changeNumber         = (int)rows[i][0];
                        MailboxSyncWatermark mailboxSyncWatermark = (MailboxSyncWatermark)this.CreateNewWatermark();
                        mailboxSyncWatermark.UpdateWithChangeNumber(changeNumber, (bool)rows[i][2]);
                        if (maxWatermark == null || maxWatermark.CompareTo(mailboxSyncWatermark) >= 0)
                        {
                            ISyncItemId         syncItemId          = this.CreateISyncItemIdForNewItem(objectId);
                            ServerManifestEntry serverManifestEntry = this.CreateItemChangeManifestEntry(syncItemId, mailboxSyncWatermark);
                            serverManifestEntry.ConversationId = (rows[i][3] as ConversationId);
                            byte[]            bytes = rows[i][4] as byte[];
                            ConversationIndex index;
                            if (ConversationIndex.TryCreate(bytes, out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                serverManifestEntry.FirstMessageInConversation = true;
                            }
                            if (rows[i][5] is ExDateTime)
                            {
                                serverManifestEntry.FilterDate = new ExDateTime?((ExDateTime)rows[i][5]);
                            }
                            serverManifestEntry.MessageClass = (rows[i][6] as string);
                            if (numOperations != -1 && newServerManifest.Count >= numOperations)
                            {
                                result = true;
                                goto IL_2B9;
                            }
                            newServerManifest[serverManifestEntry.Id] = serverManifestEntry;
                            minWatermark.ChangeNumber = changeNumber;
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
IL_2B9:
            this.SyncLogger.Information <int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.GetNewOperationsWithFilter. Ending change number {0}", minWatermark.ChangeNumber);
            return(result);
        }