Exemple #1
0
 protected override GetModernAttachmentsResponse InternalExecute()
 {
     if (this.request != null)
     {
         this.response = new GetModernAttachmentsResponse();
         if (this.request.FolderId != null && this.request.FolderId.Length > 0)
         {
             foreach (BaseFolderId baseFolderId in this.request.FolderId)
             {
                 if (this.IsAttachmentCountExceeded())
                 {
                     return(this.response);
                 }
                 ModernAttachmentGroup modernAttachmentGroup = new ModernAttachmentGroup();
                 this.GetAttachmentsFromEwsFolder(baseFolderId, modernAttachmentGroup);
                 this.response.AddGroup(modernAttachmentGroup);
             }
         }
         if (this.request.ItemId != null)
         {
             for (int j = 0; j < this.request.ItemId.Length; j++)
             {
                 if (this.IsAttachmentCountExceeded())
                 {
                     return(this.response);
                 }
                 ModernAttachmentGroup modernAttachmentGroup2 = new ModernAttachmentGroup();
                 this.GetAttachmentsFromEwsItem(this.request.ItemId[j], modernAttachmentGroup2);
                 this.response.AddGroup(modernAttachmentGroup2);
             }
         }
     }
     return(this.response);
 }
Exemple #2
0
        private void GetAttachmentsFromEwsItem(BaseItemId baseItemId, ModernAttachmentGroup outGroup)
        {
            if (baseItemId == null || outGroup == null)
            {
                return;
            }
            string itemIdDisplayName = GetModernAttachmentsCommand.Utilities.GetItemIdDisplayName(baseItemId);

            try
            {
                IdAndSession idAndSession = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(baseItemId);
                using (Item item = Item.Bind(idAndSession.Session, idAndSession.Id))
                {
                    List <ModernAttachment> list = new List <ModernAttachment>(0);
                    this.GetAttachmentsFromItemByStoreId(item.Session, item.Id, list);
                    outGroup.AttachmentGroup = list.ToArray();
                    outGroup.Path            = new string[]
                    {
                        GetModernAttachmentsCommand.Utilities.FormatParam("itemId.DisplayName", itemIdDisplayName),
                        GetModernAttachmentsCommand.Utilities.FormatParam("itemId.Id", baseItemId.GetId()),
                        GetModernAttachmentsCommand.Utilities.FormatParam("itemId.ChangeKey", baseItemId.GetChangeKey())
                    };
                }
            }
            catch (Exception exception)
            {
                StructuredErrors structuredErrors = this.ConvertToNestedErrors(exception);
                structuredErrors.Path = new string[]
                {
                    "GetAttachmentsFromEwsItem",
                    GetModernAttachmentsCommand.Utilities.FormatParam("itemId.DisplayName", itemIdDisplayName),
                    GetModernAttachmentsCommand.Utilities.FormatParam("itemId.Id", baseItemId.GetId()),
                    GetModernAttachmentsCommand.Utilities.FormatParam("itemId.ChangeKey", baseItemId.GetChangeKey())
                };
                this.response.AddError(structuredErrors);
            }
        }
Exemple #3
0
        private void GetAttachmentsFromEwsFolder(BaseFolderId baseFolderId, ModernAttachmentGroup outGroup)
        {
            if (baseFolderId == null || outGroup == null)
            {
                return;
            }
            string folderIdDisplayName = GetModernAttachmentsCommand.Utilities.GetFolderIdDisplayName(baseFolderId);

            try
            {
                IdAndSession idAndSession = base.IdConverter.ConvertFolderIdToIdAndSessionReadOnly(baseFolderId);
                ExDateTime   now          = ExDateTime.Now;
                using (Folder folder = Folder.Bind(idAndSession.Session, idAndSession.Id))
                {
                    List <ModernAttachment> list = new List <ModernAttachment>(0);
                    SortBy[]    sortColumns      = this.BuildSortBy();
                    QueryFilter queryFilter      = this.BuildQueryFilter();
                    using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, queryFilter, sortColumns, GetModernAttachmentsCommand.findItemsQueryPropDefs))
                    {
                        int        itemsOffset = this.request.ItemsOffset;
                        int        num         = this.request.ItemsToProcessMax;
                        int        num2        = itemsOffset + num + 1;
                        object[][] rows        = queryResult.GetRows(num2 - 1);
                        this.perfFindItemsDuration = ExDateTime.Now - now;
                        now = ExDateTime.Now;
                        outGroup.ItemsTotal = rows.Length;
                        if (itemsOffset >= rows.Length)
                        {
                            return;
                        }
                        if (num2 > rows.Length)
                        {
                            num2 = rows.Length;
                        }
                        outGroup.ItemsOffsetNext   = num2;
                        outGroup.RetrievedLastItem = (num2 == rows.Length);
                        if (rows != null && rows.Length > 0)
                        {
                            this.perfItemsFoundCount += rows.Length;
                            for (int i = itemsOffset; i < num2; i++)
                            {
                                object[] array   = rows[i];
                                StoreId  storeId = (StoreId)array[0];
                                this.GetAttachmentsFromItemByStoreId(idAndSession.Session, storeId, list);
                                outGroup.ItemsProcessed++;
                            }
                        }
                        outGroup.AttachmentsReturned = this.perfAttachmentCount;
                        this.perfBindItemsDuration   = ExDateTime.Now - now;
                        outGroup.AttachmentGroup     = list.ToArray();
                    }
                    outGroup.Path = new string[]
                    {
                        GetModernAttachmentsCommand.Utilities.FormatParam("folderId.DisplayName", folderIdDisplayName),
                        GetModernAttachmentsCommand.Utilities.FormatParam("folder.ClassName", folder.ClassName),
                        GetModernAttachmentsCommand.Utilities.FormatParam("folder.DisplayName", folder.DisplayName),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfItemsFoundCount", this.perfItemsFoundCount),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfItemsBoundCount", this.perfItemsBoundCount),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfAttachmentsEnumeratedCount", this.perfAttachmentsEnumeratedCount),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfAttachmentCount", this.perfAttachmentCount),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfFindItemsDuration", this.perfFindItemsDuration),
                        GetModernAttachmentsCommand.Utilities.FormatParam("perfBindItemsDuration", this.perfBindItemsDuration)
                    };
                }
            }
            catch (Exception exception)
            {
                StructuredErrors structuredErrors = this.ConvertToNestedErrors(exception);
                structuredErrors.Path = new string[]
                {
                    "GetAttachmentsFromEwsFolder",
                    GetModernAttachmentsCommand.Utilities.FormatParam("folderId.DisplayName", folderIdDisplayName),
                    GetModernAttachmentsCommand.Utilities.FormatParam("folderId.DisplayName", folderIdDisplayName),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfItemsFoundCount", this.perfItemsFoundCount),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfItemsBoundCount", this.perfItemsBoundCount),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfAttachmentsEnumeratedCount", this.perfAttachmentsEnumeratedCount),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfAttachmentCount", this.perfAttachmentCount),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfFindItemsDuration", this.perfFindItemsDuration),
                    GetModernAttachmentsCommand.Utilities.FormatParam("perfBindItemsDuration", this.perfBindItemsDuration)
                };
                this.response.AddError(structuredErrors);
            }
        }