Пример #1
0
 protected override void CopySingleMessage(MessageRec curMsg, IFolderProxy folderProxy, PropTag[] propsToCopyExplicitly, PropTag[] excludeProps)
 {
     ExecutionContext.Create(new DataContext[]
     {
         new OperationDataContext("MapiSourceMailbox.CopySingleMessage", OperationType.None),
         new EntryIDsDataContext(curMsg.EntryId)
     }).Execute(delegate
     {
         using (this.RHTracker.Start())
         {
             using (MapiMessage mapiMessage = (MapiMessage)this.OpenMapiEntry(curMsg.FolderId, curMsg.EntryId, OpenEntryFlags.DontThrowIfEntryIsMissing))
             {
                 if (mapiMessage == null)
                 {
                     MrsTracer.Provider.Debug("Message {0} is missing in source, ignoring", new object[]
                     {
                         TraceUtils.DumpEntryId(curMsg.EntryId)
                     });
                 }
                 else
                 {
                     using (IMessageProxy messageProxy = folderProxy.OpenMessage(curMsg.EntryId))
                     {
                         using (FxProxyBudgetWrapper fxProxyBudgetWrapper = new FxProxyBudgetWrapper(messageProxy, false, new Func <IDisposable>(this.RHTracker.StartExclusive), new Action <uint>(this.RHTracker.Charge)))
                         {
                             mapiMessage.ExportObject(fxProxyBudgetWrapper, CopyPropertiesFlags.None, excludeProps);
                         }
                         if (propsToCopyExplicitly != null && propsToCopyExplicitly.Length > 0)
                         {
                             PropValue[] props = mapiMessage.GetProps(propsToCopyExplicitly);
                             using (this.RHTracker.StartExclusive())
                             {
                                 List <PropValueData> list = new List <PropValueData>();
                                 foreach (PropValue propValue in props)
                                 {
                                     if (!propValue.IsNull() && !propValue.IsError())
                                     {
                                         list.Add(new PropValueData(propValue.PropTag, propValue.Value));
                                     }
                                 }
                                 if (list.Count > 0)
                                 {
                                     messageProxy.SetProps(list.ToArray());
                                 }
                             }
                         }
                         using (this.RHTracker.StartExclusive())
                         {
                             messageProxy.SaveChanges();
                         }
                     }
                 }
             }
         }
     });
 }
Пример #2
0
 public static void CopyMimeStream(ISupportMime mimeSource, MessageRec message, IFolderProxy folderProxy)
 {
     ArgumentValidator.ThrowIfNull("mimeSource", mimeSource);
     ArgumentValidator.ThrowIfNull("message", message);
     ArgumentValidator.ThrowIfNull("folderProxy", folderProxy);
     using (mimeSource.RHTracker.Start())
     {
         PropValueData[] array;
         using (Stream mimeStream = mimeSource.GetMimeStream(message, out array))
         {
             using (IMessageProxy messageProxy = folderProxy.OpenMessage(message.EntryId))
             {
                 BufferPool bufferPool = BufferPoolCollection.AutoCleanupCollection.Acquire(BufferPoolCollection.BufferSize.Size128K);
                 byte[]     array2     = bufferPool.Acquire();
                 try
                 {
                     for (;;)
                     {
                         int num = mimeStream.Read(array2, 0, array2.Length);
                         if (num == 0)
                         {
                             break;
                         }
                         if (num == array2.Length)
                         {
                             messageProxy.WriteToMime(array2);
                         }
                         else
                         {
                             byte[] array3 = new byte[num];
                             Array.Copy(array2, 0, array3, 0, num);
                             messageProxy.WriteToMime(array3);
                         }
                     }
                 }
                 finally
                 {
                     bufferPool.Release(array2);
                 }
                 List <PropValueData> list = new List <PropValueData>(SyncEmailUtils.SyncEmailPropTags.Length);
                 list.AddRange(Array.FindAll <PropValueData>(message.AdditionalProps, (PropValueData propValue) => Array.IndexOf <PropTag>(SyncEmailUtils.SyncEmailPropTags, (PropTag)propValue.PropTag) >= 0));
                 if (array != null)
                 {
                     list.AddRange(array);
                 }
                 using (mimeSource.RHTracker.StartExclusive())
                 {
                     messageProxy.SetProps(list.ToArray());
                     messageProxy.SaveChanges();
                 }
             }
         }
     }
 }
Пример #3
0
 public static void CopyItem(MessageRec messageRec, IMessage message, IFolderProxy folderProxy, PropTag[] propsToExclude)
 {
     using (IMessageProxy messageProxy = folderProxy.OpenMessage(messageRec.EntryId))
     {
         FxCollectorSerializer fxCollectorSerializer = new FxCollectorSerializer(messageProxy);
         fxCollectorSerializer.Config(0, 1);
         using (FastTransferDownloadContext fastTransferDownloadContext = FastTransferDownloadContext.CreateForDownload(FastTransferSendOption.Unicode | FastTransferSendOption.UseCpId | FastTransferSendOption.ForceUnicode, 1U, Encoding.Default, NullResourceTracker.Instance, new PropertyFilterFactory(false, false, (from ptag in propsToExclude
                                                                                                                                                                                                                                                                                                                            select new PropertyTag((uint)ptag)).ToArray <PropertyTag>()), false))
         {
             FastTransferMessageCopyTo fastTransferObject = new FastTransferMessageCopyTo(false, message, true);
             fastTransferDownloadContext.PushInitial(fastTransferObject);
             FxUtils.TransferFxBuffers(fastTransferDownloadContext, fxCollectorSerializer);
             messageProxy.SaveChanges();
         }
     }
 }
Пример #4
0
 protected override void CopySingleMessage(MessageRec message, IFolderProxy targetFolderProxy, PropTag[] propsToCopyExplicitly, PropTag[] propTagsToExclude)
 {
     ExecutionContext.Create(new DataContext[]
     {
         new OperationDataContext("PstSourceMailbox.CopySingleMessage", OperationType.None),
         new EntryIDsDataContext(message.EntryId)
     }).Execute(delegate
     {
         try
         {
             uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(this.IPst.MessageStore.Guid, message.EntryId);
             IMessage message2      = this.IPst.ReadMessage(nodeIdFromEntryId);
             if (message2 == null)
             {
                 throw new UnableToReadPSTMessagePermanentException(this.IPst.FileName, nodeIdFromEntryId);
             }
             PSTMessage pstmessage = new PSTMessage(this, message2);
             using (IMessageProxy messageProxy = targetFolderProxy.OpenMessage(message.EntryId))
             {
                 FxCollectorSerializer fxCollectorSerializer = new FxCollectorSerializer(messageProxy);
                 fxCollectorSerializer.Config(0, 1);
                 using (FastTransferDownloadContext fastTransferDownloadContext = FastTransferDownloadContext.CreateForDownload(FastTransferSendOption.Unicode | FastTransferSendOption.UseCpId | FastTransferSendOption.ForceUnicode, 1U, pstmessage.RawPropertyBag.CachedEncoding, NullResourceTracker.Instance, this.GetPropertyFilterFactory(PstMailbox.MoMTPtaFromPta(propTagsToExclude)), false))
                 {
                     FastTransferMessageCopyTo fastTransferObject = new FastTransferMessageCopyTo(false, pstmessage, true);
                     fastTransferDownloadContext.PushInitial(fastTransferObject);
                     FxUtils.TransferFxBuffers(fastTransferDownloadContext, fxCollectorSerializer);
                     messageProxy.SaveChanges();
                 }
             }
         }
         catch (PSTExceptionBase innerException)
         {
             throw new UnableToReadPSTMessagePermanentException(this.IPst.FileName, PstMailbox.GetNodeIdFromEntryId(this.IPst.MessageStore.Guid, message.EntryId), innerException);
         }
     });
 }