Esempio n. 1
0
        // Token: 0x06000541 RID: 1345 RVA: 0x000281C0 File Offset: 0x000263C0
        private bool ProcessItem(ItemData itemData)
        {
            string     id   = StoreId.StoreIdToEwsId(this.primaryMailboxSession.MailboxGuid, itemData.Id);
            ElcEwsItem item = new ElcEwsItem
            {
                Id              = id,
                Data            = null,
                Error           = null,
                StorageItemData = itemData
            };

            this.currentBatch.Add(item);
            this.currentBatchSize += Convert.ToUInt32(itemData.MessageSize);
            return((ulong)this.currentBatchSize >= (ulong)((long)this.moveToArchiveBatchSizeLimit) || this.currentBatch.Count >= this.moveToArchiveBatchCountLimit);
        }
Esempio n. 2
0
        // Token: 0x06000581 RID: 1409 RVA: 0x0002AA2C File Offset: 0x00028C2C
        public List <ElcEwsItem> UploadItems(FolderIdType parentFolderId, IList <ElcEwsItem> items, bool alwaysCreateNew)
        {
            UploadItemsType uploadItems = new UploadItemsType();

            uploadItems.Items = (from item in items
                                 select new UploadItemType
            {
                CreateAction = (alwaysCreateNew ? CreateActionType.CreateNew : CreateActionType.UpdateOrCreate),
                ItemId = new ItemIdType
                {
                    Id = item.Id
                },
                Data = item.Data,
                ParentFolderId = parentFolderId
            }).ToArray <UploadItemType>();
            List <ElcEwsItem> returnedItems = new List <ElcEwsItem>(uploadItems.Items.Length);
            int startIndex = 0;

            this.CallService(() => this.ServiceBinding.UploadItems(uploadItems), delegate(ResponseMessageType responseMessage, int messageIndex)
            {
                UploadItemsResponseMessageType uploadItemsResponseMessageType = (UploadItemsResponseMessageType)responseMessage;
                ElcEwsItem elcEwsItem = items[startIndex + messageIndex];
                if (uploadItemsResponseMessageType.ResponseClass == ResponseClassType.Error)
                {
                    ElcEwsClient.Tracer.TraceError <ResponseCodeType>(0L, "ElcEwsClient.UploadItems: UploadItems with error response message. ResponseCode : {0}", uploadItemsResponseMessageType.ResponseCode);
                    if (uploadItemsResponseMessageType.ResponseCode == ResponseCodeType.ErrorQuotaExceeded)
                    {
                        throw new ElcEwsException(ElcEwsErrorType.TargetOutOfSpace, uploadItemsResponseMessageType.ResponseCode.ToString());
                    }
                    returnedItems.Add(new ElcEwsItem
                    {
                        Id              = elcEwsItem.Id,
                        Data            = elcEwsItem.Data,
                        Error           = new ElcEwsException(ElcEwsErrorType.FailedToUploadItem, uploadItemsResponseMessageType.ResponseCode.ToString()),
                        StorageItemData = elcEwsItem.StorageItemData
                    });
                }
                else if (uploadItemsResponseMessageType.ResponseClass == ResponseClassType.Warning)
                {
                    ElcEwsClient.Tracer.TraceWarning <ResponseCodeType, string>(0L, "ElcEwsClient.UploadItems: Message response warning. ResponseCode:{0}; MessageText:'{1}'", uploadItemsResponseMessageType.ResponseCode, uploadItemsResponseMessageType.MessageText);
                    if (uploadItemsResponseMessageType.ResponseCode == ResponseCodeType.ErrorBatchProcessingStopped)
                    {
                        ElcEwsClient.Tracer.TraceWarning <int, int>(0L, "ElcEwsClient.UploadItems: Hitting ErrorBatchProcessingStopped, startIndex:{0}; messageIndex={1}", startIndex, messageIndex);
                        if (messageIndex == 0)
                        {
                            throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToUploadItem, "Internal Error: Hitting ErrorBatchProcessingStopped as the first response."), false);
                        }
                        startIndex       += messageIndex;
                        uploadItems.Items = uploadItems.Items.Skip(messageIndex).ToArray <UploadItemType>();
                        throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToUploadItem, "Hitting ErrorBatchProcessingStopped"), true);
                    }
                    else
                    {
                        returnedItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.FailedToUploadItem, uploadItemsResponseMessageType.ResponseCode.ToString()),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                }
                else
                {
                    returnedItems.Add(new ElcEwsItem
                    {
                        Id              = uploadItemsResponseMessageType.ItemId.Id,
                        Data            = elcEwsItem.Data,
                        Error           = null,
                        StorageItemData = elcEwsItem.StorageItemData
                    });
                }
                return(true);
            }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToUploadItem, exception));
            return(returnedItems);
        }
Esempio n. 3
0
        // Token: 0x06000582 RID: 1410 RVA: 0x0002ACDC File Offset: 0x00028EDC
        public List <ElcEwsItem> GetItems(IList <ElcEwsItem> items)
        {
            GetItemType           getItem = new GetItemType();
            ItemResponseShapeType itemResponseShapeType = new ItemResponseShapeType();

            itemResponseShapeType.BaseShape = DefaultShapeNamesType.Default;
            getItem.ItemShape = itemResponseShapeType;
            getItem.ItemIds   = (from elcEwsItem in items
                                 select new ItemIdType
            {
                Id = elcEwsItem.Id
            }).ToArray <ItemIdType>();
            List <ElcEwsItem> getItems = new List <ElcEwsItem>(getItem.ItemIds.Length);

            this.CallService(() => this.ServiceBinding.GetItem(getItem), delegate(ResponseMessageType responseMessage, int messageIndex)
            {
                ItemInfoResponseMessageType itemInfoResponseMessageType = (ItemInfoResponseMessageType)responseMessage;
                ElcEwsItem elcEwsItem = items[messageIndex];
                if (itemInfoResponseMessageType.ResponseClass != ResponseClassType.Success)
                {
                    ElcEwsClient.Tracer.TraceError <ResponseCodeType>(0L, "ElcEwsClient.GetItems: GetItem with error response message. ResponseCode : {0}", itemInfoResponseMessageType.ResponseCode);
                    if (itemInfoResponseMessageType.ResponseCode == ResponseCodeType.ErrorItemNotFound)
                    {
                        getItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.NotFound),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                    else
                    {
                        getItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.FailedToGetItem, itemInfoResponseMessageType.ResponseCode.ToString()),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                }
                else if (itemInfoResponseMessageType.Items != null && itemInfoResponseMessageType.Items.Items != null && itemInfoResponseMessageType.Items.Items.Length > 0)
                {
                    getItems.Add(new ElcEwsItem
                    {
                        Id              = itemInfoResponseMessageType.Items.Items[0].ItemId.Id,
                        Data            = null,
                        Error           = null,
                        StorageItemData = elcEwsItem.StorageItemData
                    });
                }
                else
                {
                    getItems.Add(new ElcEwsItem
                    {
                        Id              = elcEwsItem.Id,
                        Data            = null,
                        Error           = new ElcEwsException(ElcEwsErrorType.NoItemReturned),
                        StorageItemData = elcEwsItem.StorageItemData
                    });
                }
                return(true);
            }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToGetItem, exception));
            return(getItems);
        }
Esempio n. 4
0
        // Token: 0x06000580 RID: 1408 RVA: 0x0002A6E0 File Offset: 0x000288E0
        public List <ElcEwsItem> ExportItems(IList <ElcEwsItem> items)
        {
            ExportItemsType exportItemsType = new ExportItemsType();

            exportItemsType.ItemIds = (from elcEwsItem in items
                                       select new ItemIdType
            {
                Id = elcEwsItem.Id
            }).ToArray <ItemIdType>();
            List <ElcEwsItem> exportedItems = new List <ElcEwsItem>(exportItemsType.ItemIds.Length);
            int startIndex = 0;

            this.CallService(() => this.ServiceBinding.ExportItems(exportItemsType), delegate(ResponseMessageType responseMessage, int messageIndex)
            {
                ExportItemsResponseMessageType exportItemsResponseMessageType = (ExportItemsResponseMessageType)responseMessage;
                ElcEwsItem elcEwsItem = items[startIndex + messageIndex];
                if (exportItemsResponseMessageType.ResponseClass == ResponseClassType.Error)
                {
                    ElcEwsClient.Tracer.TraceError <ResponseCodeType>(0L, "ElcEwsClient.ExportItems: ExportItems with error response message. ResponseCode : {0}", exportItemsResponseMessageType.ResponseCode);
                    if (exportItemsResponseMessageType.ResponseCode == ResponseCodeType.ErrorItemNotFound)
                    {
                        exportedItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.NotFound),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                    else
                    {
                        exportedItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.FailedToExportItem, exportItemsResponseMessageType.ResponseCode.ToString()),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                }
                else if (exportItemsResponseMessageType.ResponseClass == ResponseClassType.Warning)
                {
                    ElcEwsClient.Tracer.TraceWarning <ResponseCodeType, string>(0L, "ElcEwsClient.ExportItems: Message response warning. ResponseCode:{0}; MessageText:'{1}'", exportItemsResponseMessageType.ResponseCode, exportItemsResponseMessageType.MessageText);
                    if (exportItemsResponseMessageType.ResponseCode == ResponseCodeType.ErrorBatchProcessingStopped)
                    {
                        ElcEwsClient.Tracer.TraceWarning <int, int>(0L, "ElcEwsClient.ExportItems: Hitting ErrorBatchProcessingStopped, startIndex:{0}; messageIndex={1}", startIndex, messageIndex);
                        if (messageIndex == 0)
                        {
                            throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToExportItem, "Internal Error: Hitting ErrorBatchProcessingStopped as the first response."), false);
                        }
                        startIndex += messageIndex;
                        exportItemsType.ItemIds = exportItemsType.ItemIds.Skip(messageIndex).ToArray <ItemIdType>();
                        throw new RetryException(new ElcEwsException(ElcEwsErrorType.FailedToExportItem, "Hitting ErrorBatchProcessingStopped"), true);
                    }
                    else
                    {
                        exportedItems.Add(new ElcEwsItem
                        {
                            Id              = elcEwsItem.Id,
                            Data            = null,
                            Error           = new ElcEwsException(ElcEwsErrorType.FailedToExportItem, exportItemsResponseMessageType.ResponseCode.ToString()),
                            StorageItemData = elcEwsItem.StorageItemData
                        });
                    }
                }
                else
                {
                    exportedItems.Add(new ElcEwsItem
                    {
                        Id              = elcEwsItem.Id,
                        Data            = exportItemsResponseMessageType.Data,
                        Error           = null,
                        StorageItemData = elcEwsItem.StorageItemData
                    });
                }
                return(true);
            }, (Exception exception) => ElcEwsClient.WrapElcEwsException(ElcEwsErrorType.FailedToExportItem, exception));
            return(exportedItems);
        }