// Token: 0x06001BF7 RID: 7159 RVA: 0x0006D004 File Offset: 0x0006B204
 private static void ProcessUpdatePermissionsAsyncResult(UserContext userContext, UpdatePermissionsAsyncResult result, List <string> resourceList, List <string> largeDLsList)
 {
     ExTraceGlobals.AttachmentHandlingTracer.TraceDebug(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Method start");
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             Dictionary <string, IList <IUserSharingResult> > dictionary = new Dictionary <string, IList <IUserSharingResult> >();
             foreach (string text in result.ResultsDictionary.Keys)
             {
                 IEnumerable <IUserSharingResult> enumerable = result.ResultsDictionary[text];
                 foreach (IUserSharingResult userSharingResult in enumerable)
                 {
                     if (!userSharingResult.Status)
                     {
                         if (!dictionary.ContainsKey(text))
                         {
                             dictionary.Add(text, new List <IUserSharingResult>());
                         }
                         dictionary[text].Add(userSharingResult);
                     }
                     if (!string.IsNullOrEmpty(userSharingResult.InvitationLink) && !string.IsNullOrEmpty(userSharingResult.User))
                     {
                         ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Send invitiation for user : {0}", userSharingResult.User);
                         UpdateAttachmentPermissions.SendInvitationMessage(userContext, userContext.ExchangePrincipal, userSharingResult.User, HttpUtility.UrlDecode(text), userSharingResult.InvitationLink);
                     }
                 }
             }
             if (dictionary.Count > 0 || (largeDLsList != null && largeDLsList.Count > 0))
             {
                 ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <int>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] There were {0} number of failures when setting perms", dictionary.Count);
                 UpdateAttachmentPermissions.CreateFailureMessages(userContext, userContext.ExchangePrincipal, dictionary, null, resourceList, largeDLsList);
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Exception happened when processing results : {0}", ex.StackTrace);
     }
 }
 // Token: 0x06001BF5 RID: 7157 RVA: 0x0006CC0C File Offset: 0x0006AE0C
 internal static void UpdateAttachmentPermissionsAsync(AttachmentDataProvider attachmentDataProvider, string[] userIds, AttachmentPermissionAssignment[] permissionAssignments, UserContext userContext, List <string> resourceList, List <string> largeDLsList)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
         {
             UpdatePermissionsAsyncResult updatePermissionsAsyncResult = await attachmentDataProvider.UpdateDocumentPermissionsAsync(userIds, permissionAssignments, default(CancellationToken)).ConfigureAwait(false);
             if (updatePermissionsAsyncResult.ResultCode != AttachmentResultCode.Success)
             {
                 UpdateAttachmentPermissions.CreateFailureMessages(userContext, userContext.ExchangePrincipal, null, null, resourceList, null);
             }
             else
             {
                 UpdateAttachmentPermissions.ProcessUpdatePermissionsAsyncResult(userContext, updatePermissionsAsyncResult, resourceList, largeDLsList);
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "UpdateAttachmentPermissions.UpdateAttachmentPermissionsAsync Exception while trying to update permissions async : {0}", ex.StackTrace);
     }
 }
        // Token: 0x06001BF6 RID: 7158 RVA: 0x0006CC90 File Offset: 0x0006AE90
        private Dictionary <string, List <AttachmentPermissionAssignment> > ProcessUpdateAttachmentPermissionsRequest(UpdateAttachmentPermissionsRequest request, UserContext userContext, CallContext callContext, out List <string> resourceList)
        {
            Dictionary <string, List <AttachmentPermissionAssignment> > dictionary = new Dictionary <string, List <AttachmentPermissionAssignment> >();
            List <string> list = new List <string>();

            resourceList = new List <string>();
            AttachmentDataProvider[] providers = userContext.AttachmentDataProviderManager.GetProviders(callContext, null);
            foreach (AttachmentDataProviderPermissions attachmentDataProviderPermissions2 in request.AttachmentDataProviderPermissions)
            {
                if (attachmentDataProviderPermissions2.PermissionAssignments != null)
                {
                    string attachmentDataProviderId = attachmentDataProviderPermissions2.AttachmentDataProviderId;
                    foreach (AttachmentPermissionAssignment attachmentPermissionAssignment in attachmentDataProviderPermissions2.PermissionAssignments)
                    {
                        resourceList.Add(attachmentPermissionAssignment.ResourceLocation);
                    }
                    if (string.IsNullOrEmpty(attachmentDataProviderId))
                    {
                        if (providers != null)
                        {
                            foreach (AttachmentPermissionAssignment attachmentPermissionAssignment2 in attachmentDataProviderPermissions2.PermissionAssignments)
                            {
                                bool flag = false;
                                AttachmentDataProvider[] array = providers;
                                int l = 0;
                                while (l < array.Length)
                                {
                                    AttachmentDataProvider attachmentDataProvider = array[l];
                                    if (attachmentDataProvider.FileExists(attachmentPermissionAssignment2.ResourceLocation))
                                    {
                                        flag = true;
                                        if (dictionary.ContainsKey(attachmentDataProvider.Id))
                                        {
                                            dictionary[attachmentDataProvider.Id].Add(attachmentPermissionAssignment2);
                                            break;
                                        }
                                        dictionary.Add(attachmentDataProvider.Id, new List <AttachmentPermissionAssignment>());
                                        dictionary[attachmentDataProvider.Id].Add(attachmentPermissionAssignment2);
                                        break;
                                    }
                                    else
                                    {
                                        l++;
                                    }
                                }
                                if (!flag)
                                {
                                    list.Add(attachmentPermissionAssignment2.ResourceLocation);
                                }
                            }
                        }
                    }
                    else if (dictionary.ContainsKey(attachmentDataProviderId))
                    {
                        dictionary[attachmentDataProviderId].AddRange(attachmentDataProviderPermissions2.PermissionAssignments);
                    }
                    else
                    {
                        dictionary.Add(attachmentDataProviderId, new List <AttachmentPermissionAssignment>());
                        dictionary[attachmentDataProviderId].AddRange(attachmentDataProviderPermissions2.PermissionAssignments);
                    }
                }
            }
            if (list.Count > 0)
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <int>(0L, "[UpdateAttachmentPermissions : ProcessUpdateAttachmentPermissionsRequest] There were {0} number of resources not found on the existing data providers", list.Count);
                UpdateAttachmentPermissions.CreateFailureMessages(userContext, userContext.ExchangePrincipal, null, list, resourceList, null);
            }
            return(dictionary);
        }