Exemple #1
0
        // Token: 0x06001AB5 RID: 6837 RVA: 0x00064C58 File Offset: 0x00062E58
        private List <BodyContentAttributedValue> GetNotesFromStore(PersonId personId)
        {
            StoreSession session = base.CallContext.SessionCache.GetMailboxIdentityMailboxSession();
            StoreId      storeId = null;

            if (this.folderId != null && this.folderId.BaseFolderId != null)
            {
                IdAndSession idAndSession = base.GetIdAndSession(this.folderId.BaseFolderId);
                if (idAndSession.Session.IsPublicFolderSession)
                {
                    session = idAndSession.Session;
                    storeId = idAndSession.Id;
                }
            }
            Person person = Person.LoadNotes(session, personId, this.maxBytesToFetch, storeId);
            List <BodyContentAttributedValue> list = new List <BodyContentAttributedValue>();

            if (person != null && person.Bodies != null)
            {
                foreach (AttributedValue <PersonNotes> attributedValue in person.Bodies)
                {
                    if (attributedValue.Value != null)
                    {
                        BodyContentAttributedValue item = new BodyContentAttributedValue(new BodyContentType
                        {
                            BodyType    = BodyType.Text,
                            Value       = attributedValue.Value.NotesBody,
                            IsTruncated = attributedValue.Value.IsTruncated
                        }, attributedValue.Attributions);
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemple #2
0
        // Token: 0x06001C33 RID: 7219 RVA: 0x0006FF24 File Offset: 0x0006E124
        protected override string InternalExecute()
        {
            IdAndSession idAndSession = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(this.itemId);
            MessageItem  messageItem  = Item.BindAsMessage(idAndSession.Session, idAndSession.Id);

            messageItem.Load(StoreObjectSchema.ContentConversionProperties);
            OutboundConversionOptions outboundConversionOptions = new OutboundConversionOptions(base.CallContext.DefaultDomain.DomainName.ToString());
            UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext);

            outboundConversionOptions.UserADSession = UserContextUtilities.CreateADRecipientSession(base.CallContext.ClientCulture.LCID, true, ConsistencyMode.IgnoreInvalid, false, userContext, true, base.CallContext.Budget);
            outboundConversionOptions.LoadPerOrganizationCharsetDetectionOptions(userContext.ExchangePrincipal.MailboxInfo.OrganizationId);
            outboundConversionOptions.AllowPartialStnefConversion = true;
            outboundConversionOptions.DemoteBcc = true;
            string @string;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                ItemConversion.ConvertItemToMime(messageItem, memoryStream, outboundConversionOptions);
                memoryStream.Position = 0L;
                byte[] array = new byte[memoryStream.Length];
                memoryStream.Read(array, 0, array.Length);
                @string = Encoding.ASCII.GetString(array);
            }
            return(@string);
        }
        // Token: 0x060019CD RID: 6605 RVA: 0x0005C2F0 File Offset: 0x0005A4F0
        internal static CreateAttachmentResponse AttachReferenceAttachment(AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, IdConverter idConverter, string dataProviderParentItemId = null, string providerEndpointUrl = null)
        {
            CreateAttachmentResponse result = null;

            if (!userContext.IsDisposed)
            {
                if (string.IsNullOrEmpty(providerEndpointUrl))
                {
                    providerEndpointUrl = attachmentDataProvider.GetEndpointUrlFromItemLocation(location);
                }
                string linkingUrl = attachmentDataProvider.GetLinkingUrl(userContext, location, providerEndpointUrl, dataProviderItemId, dataProviderParentItemId);
                string text       = Path.GetFileName(HttpUtility.UrlDecode(linkingUrl));
                if (OneDriveProUtilities.IsDurableUrlFormat(text))
                {
                    text = text.Substring(0, text.LastIndexOf("?", StringComparison.InvariantCulture));
                }
                try
                {
                    userContext.LockAndReconnectMailboxSession();
                    IdAndSession            idAndSession            = new IdAndSession(StoreId.EwsIdToStoreObjectId(parentItemId), userContext.MailboxSession);
                    ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType
                    {
                        Name = text,
                        AttachLongPathName  = linkingUrl,
                        ProviderEndpointUrl = providerEndpointUrl,
                        ProviderType        = attachmentDataProvider.Type.ToString()
                    };
                    if (!userContext.IsGroupUserContext)
                    {
                        referenceAttachmentType.ContentId   = Guid.NewGuid().ToString();
                        referenceAttachmentType.ContentType = "image/png";
                    }
                    AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true);
                    using (AttachmentBuilder attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[]
                    {
                        referenceAttachmentType
                    }, idConverter, true))
                    {
                        ServiceError serviceError;
                        Attachment   attachment = attachmentBuilder.CreateAttachment(referenceAttachmentType, out serviceError);
                        if (serviceError == null)
                        {
                            attachmentHierarchy.SaveAll();
                        }
                        result = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, referenceAttachmentType, idAndSession, serviceError);
                    }
                }
                finally
                {
                    userContext.UnlockAndDisconnectMailboxSession();
                }
            }
            return(result);
        }
        // Token: 0x06001AD4 RID: 6868 RVA: 0x00065E44 File Offset: 0x00064044
        internal static AttachmentIdType GetEwsAttachmentIdType(CallContext callContext, VersionedId itemId, string ewsAttachmentId)
        {
            IdAndSession idAndSession = GetWacAttachmentInfo.GetIdAndSession(callContext, ewsAttachmentId, true);
            ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(itemId, idAndSession, null);

            return(new AttachmentIdType
            {
                Id = ewsAttachmentId,
                RootItemId = concatenatedId.Id
            });
        }
Exemple #5
0
        // Token: 0x0600199D RID: 6557 RVA: 0x0005A534 File Offset: 0x00058734
        internal static AttachmentIdType CreateAttachmentAndSendPendingGetNotification(UserContext userContext, string itemId, byte[] bytes, string name, CreateAttachmentNotificationPayload result, IdConverter idConverter, string channelId)
        {
            AttachmentIdType result2 = null;

            if (!userContext.IsDisposed)
            {
                AttachmentBuilder attachmentBuilder = null;
                try
                {
                    userContext.LockAndReconnectMailboxSession();
                    if (result.ResultCode == AttachmentResultCode.Success)
                    {
                        IdAndSession       idAndSession       = new IdAndSession(StoreId.EwsIdToStoreObjectId(itemId), userContext.MailboxSession);
                        FileAttachmentType fileAttachmentType = new FileAttachmentType
                        {
                            Content  = bytes,
                            IsInline = false,
                            Name     = name,
                            Size     = bytes.Length
                        };
                        AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true);
                        attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[]
                        {
                            fileAttachmentType
                        }, idConverter, true);
                        ServiceError serviceError;
                        using (Attachment attachment = attachmentBuilder.CreateAttachment(fileAttachmentType, out serviceError))
                        {
                            if (serviceError == null)
                            {
                                attachmentHierarchy.SaveAll();
                            }
                            result.Response = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, fileAttachmentType, idAndSession, serviceError);
                        }
                        if (result.Response.ResponseMessages.Items != null && result.Response.ResponseMessages.Items.Length > 0 && result.Response.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError)
                        {
                            ((AttachmentInfoResponseMessage)result.Response.ResponseMessages.Items[0]).Attachments[0].Size = fileAttachmentType.Size;
                            result2 = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(result.Response);
                        }
                    }
                    CreateAttachmentHelper.SendPendingGetNotification(userContext, result, channelId);
                }
                finally
                {
                    userContext.UnlockAndDisconnectMailboxSession();
                    if (attachmentBuilder != null)
                    {
                        attachmentBuilder.Dispose();
                    }
                }
            }
            return(result2);
        }
Exemple #6
0
 private void GetAttachmentsFromItemByStoreId(StoreSession session, StoreId storeId, List <ModernAttachment> outModernAttachments)
 {
     if (session == null || storeId == null || outModernAttachments == null || this.IsAttachmentCountExceeded())
     {
         return;
     }
     try
     {
         using (Item item = Item.Bind(session, storeId, ItemBindOption.LoadRequiredPropertiesOnly, GetModernAttachmentsCommand.bindItemPropDefs))
         {
             this.perfItemsBoundCount++;
             if (item.AttachmentCollection != null)
             {
                 IdAndSession             idAndSession = new IdAndSession(item.Id, item.Session);
                 IList <AttachmentHandle> handles      = item.AttachmentCollection.GetHandles();
                 for (int i = 0; i < handles.Count; i++)
                 {
                     AttachmentHandle attachmentHandle = handles[i];
                     using (Attachment attachment = item.AttachmentCollection.Open(attachmentHandle))
                     {
                         if (GetModernAttachmentsCommand.Utilities.ShowAttachment(attachment, 100000))
                         {
                             ModernAttachment modernAttachment = new ModernAttachment();
                             GetModernAttachmentsCommand.PopulateAttachmentProperties(idAndSession, item, attachment, modernAttachment);
                             GetModernAttachmentsCommand.PopulateItemProperties(idAndSession, item, modernAttachment);
                             modernAttachment.Info       = new ModernAttachment.AttachmentInfo();
                             modernAttachment.Info.Index = i;
                             modernAttachment.Info.Path  = new string[]
                             {
                                 GetModernAttachmentsCommand.Utilities.FormatParam("ATT.N", attachmentHandle.AttachNumber)
                             };
                             outModernAttachments.Add(modernAttachment);
                             this.perfAttachmentCount++;
                         }
                         this.perfAttachmentsEnumeratedCount++;
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         StructuredErrors structuredErrors = this.ConvertToNestedErrors(exception);
         structuredErrors.Path = new string[]
         {
             "GetAttachmentsFromItemByStoreId",
             GetModernAttachmentsCommand.Utilities.FormatParam("storeId", storeId.ToBase64String())
         };
         this.response.AddError(structuredErrors);
     }
 }
Exemple #7
0
        // Token: 0x0600199B RID: 6555 RVA: 0x0005A370 File Offset: 0x00058570
        internal static CreateAttachmentResponse CreateAttachmentResponse(AttachmentHierarchy attachmentHierarchy, Attachment attachment, AttachmentType attachmentType, IdAndSession parentIdAndSession, ServiceError warning)
        {
            IdAndSession idAndSession = parentIdAndSession.Clone();

            attachment.Load();
            idAndSession.AttachmentIds.Add(attachment.Id);
            AttachmentType attachmentType2;

            if (attachment is StreamAttachment)
            {
                attachmentType2 = new FileAttachmentType();
            }
            else if (attachment is ReferenceAttachment)
            {
                attachmentType2 = new ReferenceAttachmentType();
                ((ReferenceAttachmentType)attachmentType2).AttachLongPathName  = (string)attachment.TryGetProperty(AttachmentSchema.AttachLongPathName);
                ((ReferenceAttachmentType)attachmentType2).ProviderType        = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderType);
                ((ReferenceAttachmentType)attachmentType2).ProviderEndpointUrl = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderEndpointUrl);
                object obj = attachment.TryGetProperty(AttachmentSchema.AttachContentId);
                if (!(obj is PropertyError))
                {
                    ((ReferenceAttachmentType)attachmentType2).ContentId = (string)obj;
                }
                attachmentType2.Name = attachmentType.Name;
            }
            else
            {
                attachmentType2 = new ItemAttachmentType();
            }
            attachmentType2.AttachmentId = new AttachmentIdType(idAndSession.GetConcatenatedId().Id);
            if (attachmentType is ItemIdAttachmentType || attachmentType is ReferenceAttachmentType)
            {
                attachmentType2.Size = ((attachment.Size > 2147483647L) ? int.MaxValue : ((int)attachment.Size));
            }
            CreateAttachmentResponse       createAttachmentResponse = new CreateAttachmentResponse();
            ServiceResult <AttachmentType> serviceResult            = (warning == null) ? new ServiceResult <AttachmentType>(attachmentType2) : new ServiceResult <AttachmentType>(attachmentType2, warning);

            attachmentHierarchy.RootItem.Load();
            if (serviceResult.Value != null)
            {
                ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(attachmentHierarchy.RootItem.Id, parentIdAndSession, null);
                serviceResult.Value.AttachmentId.RootItemId        = concatenatedId.Id;
                serviceResult.Value.AttachmentId.RootItemChangeKey = concatenatedId.ChangeKey;
            }
            createAttachmentResponse.AddResponses(new ServiceResult <AttachmentType>[]
            {
                serviceResult
            });
            return(createAttachmentResponse);
        }
Exemple #8
0
            public static ItemId GetItemId(IdAndSession idAndSession, StoreId storeId)
            {
                ConcatenatedIdAndChangeKey concatenatedIdAndChangeKey;

                if (idAndSession.Session is PublicFolderSession)
                {
                    concatenatedIdAndChangeKey = IdConverter.GetConcatenatedIdForPublicFolderItem(storeId, StoreId.GetStoreObjectId(idAndSession.ParentFolderId), null);
                }
                else
                {
                    concatenatedIdAndChangeKey = IdConverter.GetConcatenatedId(storeId, idAndSession, null);
                }
                return(new ItemId(concatenatedIdAndChangeKey.Id, concatenatedIdAndChangeKey.ChangeKey));
            }
        private ServiceResult <FindItemParentWrapper> CreateServiceResponse(FindItemAnonymous.AnonymousQueryView anonymousView, PublishedCalendar publishedFolder)
        {
            ServiceResult <FindItemParentWrapper> result;

            using (Folder calendarFolder = publishedFolder.GetCalendarFolder())
            {
                PropertyListForViewRowDeterminer classDeterminer = PropertyListForViewRowDeterminer.BuildForItems(base.Request.Body.ItemShape, calendarFolder);
                IdAndSession          idAndSession = new IdAndSession(calendarFolder.Id, calendarFolder.Session);
                ItemType[]            items        = anonymousView.ConvertToItems(FindItemAnonymous.propertiesToFetch, classDeterminer, idAndSession);
                BasePageResult        paging       = new BasePageResult(anonymousView);
                FindItemParentWrapper value        = new FindItemParentWrapper(items, paging);
                result = new ServiceResult <FindItemParentWrapper>(value);
            }
            return(result);
        }
Exemple #10
0
        private static void PopulateItemProperties(IdAndSession idAndSession, Item item, ModernAttachment outAttachment)
        {
            ItemType itemType = ItemType.CreateFromStoreObjectType(item.StoreObjectId.ObjectType);

            itemType.ItemClass        = item.ClassName;
            itemType.Subject          = (item[ItemSchema.Subject] as string);
            itemType.ItemId           = GetModernAttachmentsCommand.Utilities.GetItemId(idAndSession, item.Id);
            itemType.DateTimeCreated  = GetModernAttachmentsCommand.Utilities.FormatExDateTime(item.CreationTime);
            itemType.LastModifiedTime = GetModernAttachmentsCommand.Utilities.FormatExDateTime(item.LastModifiedTime);
            itemType.Size             = new int?((int)item.Size());
            ConversationId conversationId = PropertyCommand.GetPropertyValueFromStoreObject(item, ItemSchema.ConversationId) as ConversationId;
            string         id             = IdConverter.ConversationIdToEwsId(idAndSession.Session.MailboxGuid, conversationId);

            itemType.ConversationId = new ItemId(id, null);
            outAttachment.Data.Item = itemType;
        }
Exemple #11
0
        protected override bool InternalExecute()
        {
            ExchangeVersion.Current = ExchangeVersion.Latest;
            MailboxSession           mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
            IdAndSession             idAndSession             = base.IdConverter.ConvertFolderIdToIdAndSession(this.folderId, IdConverter.ConvertOption.IgnoreChangeKey);
            AggregateOperationResult aggregateOperationResult = mailboxIdentityMailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
            {
                idAndSession.Id
            });

            if (aggregateOperationResult.OperationResult == OperationResult.Succeeded)
            {
                PeopleFilterGroupPriorityManager peopleFilterGroupPriorityManager = new PeopleFilterGroupPriorityManager(mailboxIdentityMailboxSession, new XSOFactory());
                mailboxIdentityMailboxSession.ContactFolders.MyContactFolders.Set(peopleFilterGroupPriorityManager.GetMyContactFolderIds());
                return(true);
            }
            return(false);
        }
Exemple #12
0
        private EwsCalendarItemType CreateServiceObject(CalendarItemBase calendarItem)
        {
            EwsCalendarItemType         ewsCalendarItemType         = (EwsCalendarItemType)ItemType.CreateFromStoreObjectType(calendarItem.StoreObjectId.ObjectType);
            IdAndSession                idAndSession                = new IdAndSession(calendarItem.StoreObjectId, calendarItem.Session);
            ToServiceObjectPropertyList toServiceObjectPropertyList = XsoDataConverter.GetToServiceObjectPropertyList(idAndSession.Id, idAndSession.Session, base.Request.Body.ItemShape, StaticParticipantResolver.DefaultInstance);

            toServiceObjectPropertyList.CharBuffer = new char[32768];
            toServiceObjectPropertyList.ConvertStoreObjectPropertiesToServiceObject(idAndSession, calendarItem, ewsCalendarItemType);
            if (ewsCalendarItemType.Body == null)
            {
                ewsCalendarItemType.Body = new BodyContentType
                {
                    BodyType = ((base.Request.Body.ItemShape.BodyType == BodyResponseType.Text) ? BodyType.Text : BodyType.HTML),
                    Value    = string.Empty
                };
            }
            return(ewsCalendarItemType);
        }
Exemple #13
0
        protected override ContactFolderResponse InternalExecute()
        {
            ExchangeVersion.Current = ExchangeVersion.Latest;
            MailboxSession mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
            IdAndSession   idAndSession = base.IdConverter.ConvertFolderIdToIdAndSession(this.parentFolderId, IdConverter.ConvertOption.IgnoreChangeKey);
            StoreId        id;

            try
            {
                using (Folder folder = ContactsFolder.Create(mailboxIdentityMailboxSession, idAndSession.Id, StoreObjectType.ContactsFolder, this.displayName, CreateMode.CreateNew))
                {
                    PeopleFilterGroupPriorityManager.SetSortGroupPriorityOnFolder(folder, this.priority);
                    folder.Save();
                    folder.Load(new PropertyDefinition[]
                    {
                        FolderSchema.Id
                    });
                    id = folder.Id;
                }
            }
            catch (ObjectExistedException)
            {
                return(new ContactFolderResponse
                {
                    ResponseCode = ResponseCodeType.ErrorFolderExists.ToString()
                });
            }
            PeopleFilterGroupPriorityManager peopleFilterGroupPriorityManager = new PeopleFilterGroupPriorityManager(mailboxIdentityMailboxSession, new XSOFactory());

            mailboxIdentityMailboxSession.ContactFolders.MyContactFolders.Set(peopleFilterGroupPriorityManager.GetMyContactFolderIds());
            ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(id, new MailboxId(mailboxIdentityMailboxSession), null);

            return(new ContactFolderResponse
            {
                ResponseCode = ResponseCodeType.NoError.ToString(),
                FolderId = new FolderId
                {
                    Id = concatenatedId.Id,
                    ChangeKey = concatenatedId.ChangeKey
                }
            });
        }
        // Token: 0x06001A21 RID: 6689 RVA: 0x0005EF2C File Offset: 0x0005D12C
        internal static string GetFromAddress(IdAndSession itemIdAndSession, Item storeItem, PolicyTipRequestLogger policyTipRequestLogger)
        {
            string      text           = ((MailboxSession)itemIdAndSession.Session).MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            Participant valueOrDefault = storeItem.GetValueOrDefault <Participant>(InternalSchema.From);
            string      text2;

            if (valueOrDefault != null)
            {
                text2 = valueOrDefault.GetValueOrDefault <string>(ParticipantSchema.SmtpAddress);
                if (string.IsNullOrEmpty(text2))
                {
                    policyTipRequestLogger.AppendData("FromPropRoutingType", valueOrDefault.RoutingType);
                    policyTipRequestLogger.AppendData("FromPropEmail", PolicyTipRequestLogger.MarkAsPII(valueOrDefault.EmailAddress));
                }
            }
            else
            {
                text2 = text;
            }
            policyTipRequestLogger.AppendData("FromAddress", PolicyTipRequestLogger.MarkAsPII(text2));
            policyTipRequestLogger.AppendData("MailboxOwnerAddress", PolicyTipRequestLogger.MarkAsPII(text));
            return(text2);
        }
Exemple #15
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);
            }
        }
        // Token: 0x06001A1C RID: 6684 RVA: 0x0005E458 File Offset: 0x0005C658
        protected override GetDlpPolicyTipsResponse InternalExecute()
        {
            PolicyTipRequestLogger policyTipRequestLogger = PolicyTipRequestLogger.CreateInstance(this.CorrelationId);

            policyTipRequestLogger.StartStage(LogStage.ReceiveRequest);
            Item item = null;
            GetDlpPolicyTipsResponse result;

            try
            {
                GetDlpPolicyTipsCommand.SetReceiveRequestLogData(policyTipRequestLogger, this.ItemId, this.NeedToReclassify, this.BodyOrSubjectChanged, this.Recipients, this.EventTrigger, this.CustomizedStringsNeeded, this.ClientSupportsScanResultData, this.ScanResultData);
                if (base.CallContext != null && base.CallContext.AccessingADUser != null && base.CallContext.AccessingADUser.OrganizationId != null)
                {
                    this.OrganizationId = base.CallContext.AccessingADUser.OrganizationId;
                    if (this.ItemId == null || string.IsNullOrEmpty(this.ItemId.GetId()))
                    {
                        GetDlpPolicyTipsResponse invalidStoreItemIdResponse = GetDlpPolicyTipsResponse.InvalidStoreItemIdResponse;
                        this.TransitionToSendResponse(false, true, invalidStoreItemIdResponse, policyTipRequestLogger, true);
                        result = invalidStoreItemIdResponse;
                    }
                    else if (this.ItemId.GetId().Equals(GetDlpPolicyTipsCommand.pingRequestItemId, StringComparison.OrdinalIgnoreCase))
                    {
                        policyTipRequestLogger.AppendData("Ping", "1");
                        GetDlpPolicyTipsResponse responseToPingRequest = GetDlpPolicyTipsResponse.GetResponseToPingRequest();
                        this.TransitionToSendResponse(true, false, responseToPingRequest, policyTipRequestLogger, false);
                        result = responseToPingRequest;
                    }
                    else if (!GetDlpPolicyTipsCommand.AddItemToCurrentPending(this.ItemId.GetId()))
                    {
                        policyTipRequestLogger.AppendData("ItemAlreadyBeingProcessed", "1");
                        GetDlpPolicyTipsResponse itemAlreadyBeingProcessedResponse = GetDlpPolicyTipsResponse.ItemAlreadyBeingProcessedResponse;
                        this.TransitionToSendResponse(true, true, itemAlreadyBeingProcessedResponse, policyTipRequestLogger, false);
                        result = itemAlreadyBeingProcessedResponse;
                    }
                    else
                    {
                        ShortList <string> recipients   = GetDlpPolicyTipsCommand.ValidateAndGetEmailAddressStrings(this.Recipients, policyTipRequestLogger);
                        IdAndSession       idAndSession = null;
                        try
                        {
                            idAndSession = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(this.ItemId);
                        }
                        catch (InvalidStoreIdException exception)
                        {
                            policyTipRequestLogger.SetException(exception);
                            GetDlpPolicyTipsResponse invalidStoreItemIdResponse2 = GetDlpPolicyTipsResponse.InvalidStoreItemIdResponse;
                            this.TransitionToSendResponse(false, true, invalidStoreItemIdResponse2, policyTipRequestLogger, true);
                            return(invalidStoreItemIdResponse2);
                        }
                        catch (ObjectNotFoundException exception2)
                        {
                            policyTipRequestLogger.SetException(exception2);
                            GetDlpPolicyTipsResponse invalidStoreItemIdResponse3 = GetDlpPolicyTipsResponse.InvalidStoreItemIdResponse;
                            this.TransitionToSendResponse(false, true, invalidStoreItemIdResponse3, policyTipRequestLogger, true);
                            return(invalidStoreItemIdResponse3);
                        }
                        catch (AccessDeniedException exception3)
                        {
                            policyTipRequestLogger.SetException(exception3);
                            GetDlpPolicyTipsResponse accessDeniedStoreItemIdResponse = GetDlpPolicyTipsResponse.AccessDeniedStoreItemIdResponse;
                            this.TransitionToSendResponse(false, true, accessDeniedStoreItemIdResponse, policyTipRequestLogger, true);
                            return(accessDeniedStoreItemIdResponse);
                        }
                        policyTipRequestLogger.EndStageAndTransitionToStage(LogStage.LoadItem);
                        List <DlpPolicyMatchDetail> list = null;
                        bool   flag   = false;
                        string empty  = string.Empty;
                        string empty2 = string.Empty;
                        item = Item.Bind(idAndSession.Session, idAndSession.Id);
                        ScanResultStorageProvider scanResultStorageProvider = null;
                        if (this.ClientSupportsScanResultData)
                        {
                            try
                            {
                                scanResultStorageProvider = new ClientScanResultStorageProvider(this.ScanResultData, item);
                                goto IL_274;
                            }
                            catch (ClientScanResultParseException exception4)
                            {
                                policyTipRequestLogger.SetException(exception4);
                                GetDlpPolicyTipsResponse invalidClientScanResultResponse = GetDlpPolicyTipsResponse.InvalidClientScanResultResponse;
                                this.TransitionToSendResponse(false, true, invalidClientScanResultResponse, policyTipRequestLogger, true);
                                return(invalidClientScanResultResponse);
                            }
                        }
                        item.OpenAsReadWrite();
                        scanResultStorageProvider = new StoreItemScanResultStorageProvider(item);
IL_274:
                        string empty3 = string.Empty;
                        if (!GetDlpPolicyTipsCommand.IsSupportedStoreItemType(item, policyTipRequestLogger, out empty3))
                        {
                            GetDlpPolicyTipsResponse getDlpPolicyTipsResponse = new GetDlpPolicyTipsResponse(EvaluationResult.PermanentError);
                            getDlpPolicyTipsResponse.DiagnosticData = string.Format("{0}:{1}", "UnSupportedStoreItemType", empty3);
                            this.TransitionToSendResponse(false, true, getDlpPolicyTipsResponse, policyTipRequestLogger, true);
                            result = getDlpPolicyTipsResponse;
                        }
                        else
                        {
                            if (item != null)
                            {
                                policyTipRequestLogger.AppendData("Subject", PolicyTipRequestLogger.MarkAsPII(item.GetValueOrDefault <string>(InternalSchema.Subject, string.Empty)));
                            }
                            string fromAddress = GetDlpPolicyTipsCommand.GetFromAddress(idAndSession, item, policyTipRequestLogger);
                            if (string.IsNullOrEmpty(fromAddress))
                            {
                                policyTipRequestLogger.AppendData("NullFrom", "1");
                                GetDlpPolicyTipsResponse getDlpPolicyTipsResponse2 = new GetDlpPolicyTipsResponse(EvaluationResult.PermanentError);
                                getDlpPolicyTipsResponse2.DiagnosticData = "NullFrom";
                                this.TransitionToSendResponse(false, true, getDlpPolicyTipsResponse2, policyTipRequestLogger, true);
                                result = getDlpPolicyTipsResponse2;
                            }
                            else if (!GetDlpPolicyTipsCommand.HasContent(item, scanResultStorageProvider, policyTipRequestLogger))
                            {
                                policyTipRequestLogger.AppendData("NoContent", "1");
                                GetDlpPolicyTipsResponse noContentResponse = GetDlpPolicyTipsResponse.NoContentResponse;
                                this.TransitionToSendResponse(true, true, noContentResponse, policyTipRequestLogger, true);
                                result = noContentResponse;
                            }
                            else
                            {
                                policyTipRequestLogger.EndStageAndTransitionToStage(LogStage.RefreshClassifications);
                                policyTipRequestLogger.AppendData("BeforeRefreshClassifications", DiscoveredDataClassification.ToString(scanResultStorageProvider.GetDlpDetectedClassificationObjects()));
                                if (this.NeedToReclassify)
                                {
                                    scanResultStorageProvider.ResetAllClassifications();
                                }
                                else
                                {
                                    if (this.BodyOrSubjectChanged)
                                    {
                                        scanResultStorageProvider.RefreshBodyClassifications();
                                    }
                                    scanResultStorageProvider.RefreshAttachmentClassifications();
                                }
                                policyTipRequestLogger.AppendData("AfterRefreshClassifications", DiscoveredDataClassification.ToString(scanResultStorageProvider.GetDlpDetectedClassificationObjects()));
                                policyTipRequestLogger.EndStageAndTransitionToStage(LogStage.LoadRules);
                                policyTipRequestLogger.AppendData("OrganizationId", this.OrganizationId.ToString());
                                RuleCollection ruleCollection = GetDlpPolicyTipsCommand.LoadRules(this.OrganizationId);
                                if (ruleCollection == null || ruleCollection.Count == 0)
                                {
                                    policyTipRequestLogger.AppendData("RuleCount", "0");
                                    GetDlpPolicyTipsResponse noRulesResponse = GetDlpPolicyTipsResponse.NoRulesResponse;
                                    this.TransitionToSendResponse(true, true, noRulesResponse, policyTipRequestLogger, true);
                                    result = noRulesResponse;
                                }
                                else
                                {
                                    policyTipRequestLogger.AppendData("RuleCount", ruleCollection.Count.ToString());
                                    policyTipRequestLogger.AppendData("RuleNames", GetDlpPolicyTipsCommand.GetRuleNamesForTracking(ruleCollection));
                                    policyTipRequestLogger.EndStageAndTransitionToStage(LogStage.EvaluateRules);
                                    ExecutionStatus executionStatus = GetDlpPolicyTipsCommand.RunRules(ruleCollection, scanResultStorageProvider, item, fromAddress, recipients, out list, out flag, out empty, out empty2, policyTipRequestLogger);
                                    policyTipRequestLogger.AppendData("ExecutionStatus", executionStatus.ToString());
                                    policyTipRequestLogger.AppendData("MatchResults", (list == null) ? string.Empty : DlpPolicyMatchDetail.ToString(list));
                                    policyTipRequestLogger.AppendData("RuleEvalLatency", empty);
                                    policyTipRequestLogger.AppendData("RuleEvalResult", empty2);
                                    PolicyTipCustomizedStrings policyTipCustomizedStrings = null;
                                    if (this.CustomizedStringsNeeded)
                                    {
                                        policyTipRequestLogger.EndStageAndTransitionToStage(LogStage.LoadCustomStrings);
                                        UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true);
                                        CultureInfo userCulture = userContext.UserCulture;
                                        policyTipRequestLogger.AppendData("CallersCulture", userCulture.Name);
                                        policyTipCustomizedStrings = ADUtils.GetPolicyTipStrings(this.OrganizationId, userCulture.Name);
                                        policyTipRequestLogger.AppendData("PolicyTipStrings", (policyTipCustomizedStrings == null) ? string.Empty : string.Format("Url:{0}/Notify:{1}/Override:{2}/Block:{3}", new object[]
                                        {
                                            policyTipCustomizedStrings.ComplianceURL ?? string.Empty,
                                            policyTipCustomizedStrings.PolicyTipMessageNotifyString ?? string.Empty,
                                            policyTipCustomizedStrings.PolicyTipMessageOverrideString ?? string.Empty,
                                            policyTipCustomizedStrings.PolicyTipMessageBlockString ?? string.Empty
                                        }));
                                    }
                                    GetDlpPolicyTipsResponse getDlpPolicyTipsResponse3 = new GetDlpPolicyTipsResponse(EvaluationResult.Success);
                                    if (this.ClientSupportsScanResultData)
                                    {
                                        getDlpPolicyTipsResponse3.ScanResultData            = ((ClientScanResultStorageProvider)scanResultStorageProvider).GetScanResultData();
                                        getDlpPolicyTipsResponse3.DetectedClassificationIds = ((ClientScanResultStorageProvider)scanResultStorageProvider).GetDetectedClassificationIds();
                                    }
                                    else
                                    {
                                        item.Save(SaveMode.ResolveConflicts);
                                    }
                                    if (list != null)
                                    {
                                        getDlpPolicyTipsResponse3.Matches = list.ToArray();
                                    }
                                    if (flag)
                                    {
                                        getDlpPolicyTipsResponse3.OptimizationResult = OptimizationResult.NoContentMatch;
                                    }
                                    if (this.CustomizedStringsNeeded)
                                    {
                                        getDlpPolicyTipsResponse3.CustomizedStrings = policyTipCustomizedStrings;
                                    }
                                    this.TransitionToSendResponse(true, false, getDlpPolicyTipsResponse3, policyTipRequestLogger, true);
                                    result = getDlpPolicyTipsResponse3;
                                }
                            }
                        }
                    }
                }
                else
                {
                    GetDlpPolicyTipsResponse nullOrganizationResponse = GetDlpPolicyTipsResponse.NullOrganizationResponse;
                    this.TransitionToSendResponse(false, true, nullOrganizationResponse, policyTipRequestLogger, true);
                    result = nullOrganizationResponse;
                }
            }
            catch (Exception ex)
            {
                policyTipRequestLogger.SetException(ex);
                GetDlpPolicyTipsResponse getDlpPolicyTipsResponse4;
                if (!GetDlpPolicyTipsCommand.CheckIfKnownExceptionAndUpdatePerfCounters(ex))
                {
                    getDlpPolicyTipsResponse4 = new GetDlpPolicyTipsResponse(EvaluationResult.UnexpectedPermanentError);
                    this.TransitionToSendResponse(false, false, getDlpPolicyTipsResponse4, policyTipRequestLogger, true);
                    throw;
                }
                getDlpPolicyTipsResponse4 = new GetDlpPolicyTipsResponse(EvaluationResult.PermanentError);
                this.TransitionToSendResponse(false, false, getDlpPolicyTipsResponse4, policyTipRequestLogger, true);
                List <string> list2 = null;
                List <string> list3 = null;
                string        text  = null;
                PolicyTipProtocolLog.GetExceptionTypeAndDetails(ex, out list2, out list3, out text, false);
                getDlpPolicyTipsResponse4.DiagnosticData = string.Format("OuterExceptionType:{0}/OuterExceptionMessage:{1}/InnerExceptionType:{2}/InnerExceptionMessage:{3}/ExceptionChain:{4}.", new object[]
                {
                    list2[0],
                    list3[0],
                    (list2.Count > 1) ? list2[list2.Count - 1] : string.Empty,
                    (list2.Count > 1) ? list3[list3.Count - 1] : string.Empty,
                    text
                });
                result = getDlpPolicyTipsResponse4;
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
            }
            return(result);
        }
        protected override GetFlowConversationResponse InternalExecute()
        {
            QueryFilter  flowConversationFilter = GetFlowConversation.GetFlowConversationFilter(this.folderId, base.MailboxIdentityMailboxSession);
            IdAndSession folderIdAndSession     = GetFlowConversation.GetFolderIdAndSession(this.folderId, base.MailboxIdentityMailboxSession, base.IdConverter);
            List <FlowConversationItem> list    = new List <FlowConversationItem>();

            new ConversationFactory(base.MailboxIdentityMailboxSession);
            using (Folder folder = Folder.Bind((MailboxSession)folderIdAndSession.Session, folderIdAndSession.Id))
            {
                using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, flowConversationFilter, GetFlowConversation.SortByArray, GetFlowConversation.ItemQueryRequiredProperties))
                {
                    IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10000);
                    foreach (IStorePropertyBag storePropertyBag in propertyBags)
                    {
                        if ((long)list.Count == this.requestedConversationCount)
                        {
                            break;
                        }
                        ParticipantSet participantSet;
                        string         text = this.GenerateParticipantsHash(storePropertyBag, out participantSet);
                        if (!this.allItemsData.ContainsKey(text))
                        {
                            FlowConversationItem flowConversationItem = new FlowConversationItem();
                            ExDateTime           valueOrDefault       = storePropertyBag.GetValueOrDefault <ExDateTime>(ItemSchema.ReceivedTime, ExDateTime.Now);
                            string       valueOrDefault2 = storePropertyBag.GetValueOrDefault <string>(ItemSchema.Preview, null);
                            string       valueOrDefault3 = storePropertyBag.GetValueOrDefault <string>(ItemSchema.Subject, null);
                            bool         valueOrDefault4 = storePropertyBag.GetValueOrDefault <bool>(MessageItemSchema.IsRead, true);
                            IParticipant valueOrDefault5 = storePropertyBag.GetValueOrDefault <IParticipant>(ItemSchema.From, null);
                            VersionedId  valueOrDefault6 = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                            storePropertyBag.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null);
                            List <IParticipant> list2 = new List <IParticipant>(participantSet.Count + 1);
                            participantSet.ExceptWith(new IParticipant[]
                            {
                                valueOrDefault5
                            });
                            list2.Add(valueOrDefault5);
                            list2.AddRange(participantSet);
                            flowConversationItem.FlowConversationId      = text;
                            flowConversationItem.LastItemId              = IdConverter.ConvertStoreItemIdToItemId(valueOrDefault6, folderIdAndSession.Session);
                            flowConversationItem.Participants            = ReplyToProperty.Render(list2).ToArray();
                            flowConversationItem.SenderPhotoEmailAddress = valueOrDefault5.SmtpEmailAddress;
                            flowConversationItem.Preview         = valueOrDefault2;
                            flowConversationItem.Subject         = valueOrDefault3;
                            flowConversationItem.TotalCount      = 1;
                            flowConversationItem.UnReadCount     = (valueOrDefault4 ? 0 : 1);
                            flowConversationItem.ReceivedTimeUtc = ExDateTimeConverter.ToSoapHeaderTimeZoneRelatedXsdDateTime(valueOrDefault);
                            this.allItemsData.Add(text, flowConversationItem);
                            list.Add(flowConversationItem);
                        }
                        else
                        {
                            if (!storePropertyBag.GetValueOrDefault <bool>(MessageItemSchema.IsRead, true))
                            {
                                this.allItemsData[text].UnReadCount++;
                            }
                            this.allItemsData[text].TotalCount++;
                        }
                    }
                }
            }
            return(new GetFlowConversationResponse
            {
                Conversations = list.ToArray()
            });
        }
Exemple #18
0
        private static void PopulateAttachmentProperties(IdAndSession idAndSession, Item item, Attachment attachment, ModernAttachment outAttachment)
        {
            if (outAttachment == null || attachment == null || item == null)
            {
                return;
            }
            outAttachment.Data = new ModernAttachment.AttachmentData();
            outAttachment.Data.AttachmentEx = new AttachmentTypeEx();
            switch (attachment.AttachmentType)
            {
            case AttachmentType.NoAttachment:
                break;

            case AttachmentType.Stream:
            {
                StreamAttachment streamAttachment = attachment as StreamAttachment;
                if (streamAttachment != null)
                {
                    FileAttachmentType fileAttachmentType = new FileAttachmentType();
                    outAttachment.Data.Attachment     = fileAttachmentType;
                    fileAttachmentType.IsContactPhoto = streamAttachment.IsContactPhoto;
                }
                break;
            }

            case AttachmentType.EmbeddedMessage:
            {
                ItemAttachment itemAttachment = attachment as ItemAttachment;
                if (itemAttachment != null)
                {
                    outAttachment.Data.Attachment = new ItemAttachmentType();
                }
                break;
            }

            case AttachmentType.Ole:
            {
                OleAttachment oleAttachment = attachment as OleAttachment;
                if (oleAttachment != null)
                {
                    FileAttachmentType fileAttachmentType2 = new FileAttachmentType();
                    outAttachment.Data.Attachment      = fileAttachmentType2;
                    fileAttachmentType2.IsContactPhoto = oleAttachment.IsContactPhoto;
                }
                break;
            }

            case AttachmentType.Reference:
            {
                ReferenceAttachment referenceAttachment = attachment as ReferenceAttachment;
                if (referenceAttachment != null)
                {
                    UserContext userContext = UserContextManager.GetUserContext(HttpContext.Current);
                    if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ClientServerSettings.AttachmentsFilePicker.Enabled)
                    {
                        ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType();
                        outAttachment.Data.Attachment = referenceAttachmentType;
                        referenceAttachmentType.AttachLongPathName  = referenceAttachment.AttachLongPathName;
                        referenceAttachmentType.ProviderEndpointUrl = referenceAttachment.ProviderEndpointUrl;
                        referenceAttachmentType.ProviderType        = referenceAttachment.ProviderType;
                    }
                    else
                    {
                        outAttachment.Data.Attachment = new FileAttachmentType();
                    }
                }
                break;
            }

            default:
                return;
            }
            if (outAttachment.Data.Attachment == null)
            {
                outAttachment.Data.Attachment = new AttachmentType();
            }
            IdAndSession idAndSession2;

            if (idAndSession == null)
            {
                idAndSession2 = new IdAndSession(item.Id, item.Session);
            }
            else
            {
                idAndSession2 = idAndSession.Clone();
            }
            idAndSession2.AttachmentIds.Add(attachment.Id);
            outAttachment.Data.Attachment.AttachmentId     = new AttachmentIdType(idAndSession2.GetConcatenatedId().Id);
            outAttachment.Data.Attachment.ContentId        = (string.IsNullOrEmpty(attachment.ContentId) ? null : attachment.ContentId);
            outAttachment.Data.Attachment.ContentLocation  = ((attachment.ContentLocation == null) ? null : attachment.ContentLocation.PathAndQuery);
            outAttachment.Data.Attachment.ContentType      = attachment.ContentType;
            outAttachment.Data.Attachment.IsInline         = attachment.IsInline;
            outAttachment.Data.Attachment.LastModifiedTime = GetModernAttachmentsCommand.Utilities.FormatExDateTime(attachment.LastModifiedTime);
            outAttachment.Data.Attachment.Name             = attachment.DisplayName;
            outAttachment.Data.Attachment.Size             = (int)attachment.Size;
        }
Exemple #19
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);
            }
        }
        // Token: 0x060015BF RID: 5567 RVA: 0x0004DD44 File Offset: 0x0004BF44
        protected override FindFlowConversationItemResponse InternalExecute()
        {
            QueryFilter         flowConversationFilter = GetFlowConversation.GetFlowConversationFilter(this.folderId, base.MailboxIdentityMailboxSession);
            IdAndSession        folderIdAndSession     = GetFlowConversation.GetFolderIdAndSession(this.folderId, base.MailboxIdentityMailboxSession, base.IdConverter);
            SortBy              sortBy = new SortBy(ItemSchema.ReceivedTime, SortOrder.Descending);
            List <FlowItem>     list   = new List <FlowItem>();
            ConversationFactory conversationFactory = new ConversationFactory(base.MailboxIdentityMailboxSession);

            using (Folder folder = Folder.Bind((MailboxSession)folderIdAndSession.Session, folderIdAndSession.Id))
            {
                using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, flowConversationFilter, new SortBy[]
                {
                    sortBy
                }, FindFlowConversationItem.requiredProperties))
                {
                    IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10000);
                    foreach (IStorePropertyBag storePropertyBag in propertyBags)
                    {
                        if ((long)list.Count == this.requestedItemCount)
                        {
                            break;
                        }
                        string text = this.GenerateParticipantsHash(storePropertyBag);
                        if (text.Equals(this.flowConversationId))
                        {
                            FlowItem       flowItem        = new FlowItem();
                            ExDateTime     valueOrDefault  = storePropertyBag.GetValueOrDefault <ExDateTime>(ItemSchema.ReceivedTime, ExDateTime.Now);
                            bool           valueOrDefault2 = storePropertyBag.GetValueOrDefault <bool>(MessageItemSchema.IsRead, true);
                            IParticipant   valueOrDefault3 = storePropertyBag.GetValueOrDefault <IParticipant>(ItemSchema.From, null);
                            VersionedId    valueOrDefault4 = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                            ConversationId valueOrDefault5 = storePropertyBag.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null);
                            flowItem.ItemId          = IdConverter.ConvertStoreItemIdToItemId(valueOrDefault4, base.MailboxIdentityMailboxSession);
                            flowItem.Sender          = FindFlowConversationItem.ConvertParticipantToEmailAddressWrapper(valueOrDefault3);
                            flowItem.IsRead          = valueOrDefault2;
                            flowItem.ReceivedTimeUtc = ExDateTimeConverter.ToSoapHeaderTimeZoneRelatedXsdDateTime(valueOrDefault);
                            Conversation key = conversationFactory.CreateConversation(valueOrDefault5, FindFlowConversationItem.ConversationCreatorRelevantProperties);
                            if (!this.conversationMap.ContainsKey(key))
                            {
                                this.conversationMap[key] = new List <StoreObjectId>();
                            }
                            this.conversationMap[key].Add(valueOrDefault4.ObjectId);
                            this.flowItemsMap[valueOrDefault4.ObjectId] = flowItem;
                            list.Add(flowItem);
                        }
                    }
                }
            }
            foreach (KeyValuePair <Conversation, List <StoreObjectId> > keyValuePair in this.conversationMap)
            {
                Conversation         key2  = keyValuePair.Key;
                List <StoreObjectId> value = keyValuePair.Value;
                key2.LoadItemParts(value);
                foreach (StoreObjectId storeObjectId in value)
                {
                    ItemPart itemPart = key2.GetItemPart(storeObjectId);
                    this.flowItemsMap[storeObjectId].ItemBody = itemPart.BodyPart;
                }
            }
            return(new FindFlowConversationItemResponse
            {
                Items = list.ToArray()
            });
        }
        // Token: 0x06001ACF RID: 6863 RVA: 0x0006569C File Offset: 0x0006389C
        public static WacAttachmentType Execute(CallContext callContext, IStoreSession originalAttachmentSession, IItem originalAttachmentItem, IAttachment originalAttachment, string draftId, string ewsAttachmentId, bool isEdit)
        {
            MdbCache.GetInstance().BeginAsyncUpdate();
            UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);

            if (userContext == null)
            {
                throw new OwaInvalidRequestException("Unable to determine user context.");
            }
            if (!userContext.IsWacEditingEnabled)
            {
                isEdit = false;
            }
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            AttachmentPolicy     attachmentPolicy     = configurationContext.AttachmentPolicy;
            bool isPublicLogon = userContext.IsPublicLogon;

            if (!attachmentPolicy.GetWacViewingEnabled(isPublicLogon))
            {
                throw new OwaOperationNotSupportedException("WAC viewing not enabled for the current user");
            }
            MailboxSession mailboxSession = null;
            StoreObjectId  draftObjectId  = null;

            if (draftId != null)
            {
                IdAndSession idAndSession = GetWacAttachmentInfo.GetIdAndSession(callContext, draftId, false);
                mailboxSession = (idAndSession.Session as MailboxSession);
                draftObjectId  = StoreId.EwsIdToStoreObjectId(draftId);
                if (mailboxSession == null)
                {
                    throw new OwaOperationNotSupportedException("We need a MailboxSession to create the draft, but this a " + idAndSession.Session.GetType().Name);
                }
            }
            string text = originalAttachmentSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            string primarySmtpAddress        = callContext.EffectiveCaller.PrimarySmtpAddress;
            RequestDetailsLogger protocolLog = callContext.ProtocolLog;

            protocolLog.Set(GetWacAttachmentInfoMetadata.LogonSmtpAddress, primarySmtpAddress);
            protocolLog.Set(GetWacAttachmentInfoMetadata.MailboxSmtpAddress, text);
            protocolLog.Set(GetWacAttachmentInfoMetadata.Edit, isEdit);
            protocolLog.Set(GetWacAttachmentInfoMetadata.Extension, originalAttachment.FileExtension);
            protocolLog.Set(GetWacAttachmentInfoMetadata.DraftProvided, draftId != null);
            string                 displayName = callContext.AccessingPrincipal.MailboxInfo.DisplayName;
            XSOFactory             factory     = new XSOFactory();
            AttachmentDataProvider defaultUploadDataProvider = new AttachmentDataProviderManager().GetDefaultUploadDataProvider(callContext);
            IReferenceAttachment   referenceAttachment       = originalAttachment as IReferenceAttachment;

            if (referenceAttachment != null)
            {
                GetWacAttachmentInfo.LogReferenceAttachmentProperties(protocolLog, referenceAttachment.ProviderEndpointUrl, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentServiceUrl, referenceAttachment.AttachLongPathName, GetWacAttachmentInfoMetadata.OriginalReferenceAttachmentUrl);
            }
            if (defaultUploadDataProvider != null)
            {
                protocolLog.Set(GetWacAttachmentInfoMetadata.AttachmentDataProvider, defaultUploadDataProvider.ToString());
            }
            WacAttachmentType wacAttachmentType;

            try
            {
                using (GetWacAttachmentInfo.Implementation implementation = new GetWacAttachmentInfo.Implementation(defaultUploadDataProvider, factory, originalAttachmentSession, originalAttachmentSession.MailboxOwner.ModernGroupType, originalAttachmentItem, originalAttachment, ewsAttachmentId, mailboxSession, draftObjectId, isEdit, displayName, (IStoreSession session, StoreId itemId, AttachmentId attachmentId) => new IdAndSession(itemId, (StoreSession)session)
                {
                    AttachmentIds =
                    {
                        attachmentId
                    }
                }.GetConcatenatedId().Id))
                {
                    implementation.Execute();
                    protocolLog.Set(GetWacAttachmentInfoMetadata.OriginalAttachmentType, implementation.OriginalAttachmentType);
                    protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentType, implementation.ResultAttachmentType);
                    protocolLog.Set(GetWacAttachmentInfoMetadata.ResultAttachmentCreation, implementation.ResultAttachmentCreation);
                    if (implementation.ResultAttachmentType == AttachmentType.Reference)
                    {
                        IMailboxInfo mailboxInfo       = originalAttachmentSession.MailboxOwner.MailboxInfo;
                        string       mailboxAddress    = mailboxInfo.PrimarySmtpAddress.ToString();
                        StoreId      id                = originalAttachmentItem.Id;
                        BaseItemId   itemIdFromStoreId = IdConverter.GetItemIdFromStoreId(id, new MailboxId(mailboxInfo.MailboxGuid));
                        string       exchangeSessionId = WacUtilities.GetExchangeSessionId(default(Guid).ToString());
                        protocolLog.Set(GetWacAttachmentInfoMetadata.ExchangeSessionId, exchangeSessionId);
                        wacAttachmentType = GetWacAttachmentInfo.GetResultForReferenceAttachment(callContext, userContext, implementation, defaultUploadDataProvider, mailboxAddress, itemIdFromStoreId, originalAttachment.FileName, isEdit, displayName, exchangeSessionId, protocolLog);
                    }
                    else
                    {
                        if (implementation.ResultAttachmentType != AttachmentType.Stream)
                        {
                            throw new OwaNotSupportedException("Unsupported attachment type " + implementation.ResultAttachmentType);
                        }
                        AttachmentIdType ewsAttachmentIdType = GetWacAttachmentInfo.GetEwsAttachmentIdType(callContext, implementation.ResultItemId, implementation.ResultAttachmentId);
                        wacAttachmentType = GetWacAttachmentInfo.GetResultForStreamAttachment(callContext, userContext, configurationContext, attachmentPolicy, isPublicLogon, Thread.CurrentThread.CurrentCulture.Name, isEdit, (IStreamAttachment)implementation.ResultAttachment, implementation.ResultAttachmentExtension, ewsAttachmentIdType, implementation.ResultIsInDraft, implementation.ResultStoreSession, text, originalAttachmentSession.MailboxOwner.MailboxInfo.IsArchive);
                    }
                }
            }
            catch (ServerException exception)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception, WacAttachmentStatus.UploadFailed);
            }
            catch (GetWacAttachmentInfo.AttachmentUploadException exception2)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception2, WacAttachmentStatus.UploadFailed);
            }
            catch (RightsManagementPermanentException exception3)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception3, WacAttachmentStatus.ProtectedByUnsupportedIrm);
            }
            catch (AttachmentProtectionException exception4)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception4, WacAttachmentStatus.ProtectedByUnsupportedIrm);
            }
            catch (ObjectNotFoundException exception5)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception5, WacAttachmentStatus.NotFound);
            }
            catch (OwaInvalidRequestException exception6)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception6, WacAttachmentStatus.InvalidRequest);
            }
            catch (WacDiscoveryFailureException exception7)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception7, WacAttachmentStatus.WacDiscoveryFailed);
            }
            catch (WebException exception8)
            {
                wacAttachmentType = GetWacAttachmentInfo.HandleException(protocolLog, isEdit, exception8, WacAttachmentStatus.AttachmentDataProviderError);
            }
            if (wacAttachmentType == null)
            {
                throw new OwaInvalidOperationException("There is no reason known for code to reach here without throwing an unhandled exception elsewhere");
            }
            protocolLog.Set(GetWacAttachmentInfoMetadata.Status, wacAttachmentType.Status.ToString());
            return(wacAttachmentType);
        }
        private GetGroupResponse GetPDLData()
        {
            GetGroupResponse getGroupResponse = new GetGroupResponse();
            MailboxSession   mailboxIdentityMailboxSession = base.CallContext.SessionCache.GetMailboxIdentityMailboxSession();
            ItemId           sourceId     = this.itemId;
            IdAndSession     idAndSession = null;

            if (this.parentFolderid != null && this.parentFolderid.BaseFolderId != null)
            {
                IdAndSession idAndSession2 = base.GetIdAndSession(this.parentFolderid.BaseFolderId);
                if (idAndSession2 != null && idAndSession2.Session.IsPublicFolderSession)
                {
                    idAndSession = idAndSession2;
                }
            }
            if (IdConverter.EwsIdIsConversationId(this.itemId.Id))
            {
                try
                {
                    Persona persona;
                    if (idAndSession != null)
                    {
                        persona = Persona.LoadFromPersonaId(idAndSession.Session, null, this.itemId, Persona.FullPersonaShape, null, idAndSession.Id);
                    }
                    else
                    {
                        persona = Persona.LoadFromPersonIdWithGalAggregation(mailboxIdentityMailboxSession, IdConverter.EwsIdToPersonId(this.itemId.Id), Persona.FullPersonaShape, null);
                    }
                    if (persona.Attributions.Length > 0)
                    {
                        sourceId = persona.Attributions[0].SourceId;
                        for (int i = 1; i < persona.Attributions.Length; i++)
                        {
                            StoreId storeId = IdConverter.EwsIdToMessageStoreObjectId(persona.Attributions[i].SourceId.Id);
                            using (Item item = Item.Bind(mailboxIdentityMailboxSession, storeId, new PropertyDefinition[]
                            {
                                ContactSchema.PersonId
                            }))
                            {
                                item.OpenAsReadWrite();
                                item[ContactSchema.PersonId] = PersonId.CreateNew();
                                item.Save(SaveMode.NoConflictResolution);
                            }
                        }
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Success");
                    }
                    else
                    {
                        ExTraceGlobals.GetGroupTracer.TraceError((long)this.hashCode, "ItemId is PersonaId but Persona has no linked contacts (attributions array is empty).");
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Skipped");
                    }
                }
                catch (LocalizedException arg)
                {
                    ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to unlink PDLs: {0}", arg);
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "UnlinkDupedPDLs", "Failed");
                }
            }
            IdAndSession idAndSession3 = base.IdConverter.ConvertItemIdToIdAndSessionReadOnly(sourceId);
            StoreSession storeSession;

            if (idAndSession != null)
            {
                storeSession = idAndSession.Session;
            }
            else
            {
                storeSession = ((idAndSession3.Session as MailboxSession) ?? base.CallContext.SessionCache.GetMailboxIdentityMailboxSession());
            }
            using (DistributionList distributionList = DistributionList.Bind(storeSession, idAndSession3.Id))
            {
                if (distributionList == null)
                {
                    this.WriteDebugTrace("No PDL was found");
                    return(getGroupResponse);
                }
                PersonId personId = (PersonId)distributionList[ContactSchema.PersonId];
                getGroupResponse.PersonaId = IdConverter.PersonaIdFromPersonId(storeSession.MailboxGuid, personId);
                if (!distributionList.GetValueOrDefault <bool>(ItemSchema.ConversationIndexTracking, false))
                {
                    try
                    {
                        distributionList.OpenAsReadWrite();
                        distributionList[ItemSchema.ConversationIndexTracking] = true;
                        distributionList.Save(SaveMode.NoConflictResolution);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Success");
                    }
                    catch (LocalizedException arg2)
                    {
                        ExTraceGlobals.GetGroupTracer.TraceError <LocalizedException>((long)this.hashCode, "Failed to set ConversationIndexTracking on PDL: {0}", arg2);
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLogger.Current, "SetConversationIndexTracking", "Failed");
                    }
                }
                if (!this.IsMembersInResultSet)
                {
                    return(getGroupResponse);
                }
                int count = distributionList.Count;
                getGroupResponse.MembersCount = count;
                this.WriteDebugTrace("Total PDL members count is " + count);
                if (this.paging.Offset < 0 || count <= this.paging.Offset)
                {
                    this.WriteDebugTrace(string.Format("Provided offset is out of range - members count is {0}, offset is {1}.", count, this.paging.Offset));
                    return(getGroupResponse);
                }
                distributionList.Sort(this.PDlMembersComparer);
                List <Persona>           list       = new List <Persona>();
                List <string>            list2      = new List <string>();
                Dictionary <string, int> dictionary = new Dictionary <string, int>();
                int num = Math.Min(count, this.paging.Offset + this.paging.MaxRows);
                for (int j = this.paging.Offset; j < num; j++)
                {
                    DistributionListMember distributionListMember = distributionList[j];
                    if (distributionListMember.Participant == null)
                    {
                        if (num < count)
                        {
                            num++;
                        }
                        getGroupResponse.MembersCount--;
                    }
                    else
                    {
                        bool    flag     = false;
                        Persona persona2 = GetGroupCommand.CreatePersonaFromDistributionListMember(mailboxIdentityMailboxSession, distributionListMember, out flag);
                        if (flag)
                        {
                            list2.Add(persona2.EmailAddress.EmailAddress);
                            dictionary.Add(persona2.EmailAddress.EmailAddress, list.Count);
                        }
                        list.Add(persona2);
                    }
                }
                if (list2.Count > 0)
                {
                    IRecipientSession     galscopedADRecipientSession = base.CallContext.ADRecipientSessionContext.GetGALScopedADRecipientSession(base.CallContext.EffectiveCaller.ClientSecurityContext);
                    Result <ADRawEntry>[] array = galscopedADRecipientSession.FindByLegacyExchangeDNs(list2.ToArray(), new PropertyDefinition[]
                    {
                        ADObjectSchema.Id,
                        ADRecipientSchema.DisplayName,
                        ADRecipientSchema.PrimarySmtpAddress,
                        ADRecipientSchema.RecipientType,
                        ADRecipientSchema.RecipientTypeDetails,
                        ADRecipientSchema.LegacyExchangeDN
                    });
                    foreach (Result <ADRawEntry> result in array)
                    {
                        if (result.Data != null)
                        {
                            Persona personaFromADObject = GetGroupCommand.GetPersonaFromADObject(result.Data);
                            string  key = result.Data[ADRecipientSchema.LegacyExchangeDN] as string;
                            int     num2;
                            if (dictionary.ContainsKey(key) && dictionary.TryGetValue(key, out num2) && num2 >= 0)
                            {
                                list[num2] = personaFromADObject;
                            }
                        }
                    }
                }
                list.Sort(this.PersonaComparer);
                Persona[] array3 = new Persona[list.Count];
                list.CopyTo(0, array3, 0, list.Count);
                getGroupResponse.Members = array3;
                this.WriteDebugTrace("PDL members count loaded in the response is " + getGroupResponse.Members.Length);
            }
            return(getGroupResponse);
        }