// Token: 0x06001095 RID: 4245 RVA: 0x00061458 File Offset: 0x0005F658
        protected override DirectoryProcessorBaseTaskContext DoChunkWork(DirectoryProcessorBaseTaskContext context, RecipientType recipientType)
        {
            base.Logger.TraceDebug(this, "Entering GroupMetricsGenerator.DoChunkWork recipientType='{0}' at {1}", new object[]
            {
                recipientType.ToString(),
                DateTime.UtcNow.ToString("o")
            });
            if ((context.TaskStatus & TaskStatus.DLADCrawlerFailed) != TaskStatus.NoError)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupMetricsGenerationSkippedNoADFile, null, new object[]
                {
                    base.RunData.TenantId,
                    base.RunData.RunId,
                    recipientType
                });
                return(null);
            }
            GroupMetricsGeneratorTaskContext groupMetricsGeneratorTaskContext = context as GroupMetricsGeneratorTaskContext;

            if (groupMetricsGeneratorTaskContext == null)
            {
                groupMetricsGeneratorTaskContext = new GroupMetricsGeneratorTaskContext(context.MailboxData, context.Job, context.TaskQueue, context.Step, context.TaskStatus, context.RunData, context.DeferredFinalizeTasks);
                this.Initialize(recipientType);
                base.Logger.TraceDebug(this, "First time GroupMetricsGenerator.DoChunkWork is called.", new object[0]);
            }
            this.syncType = this.UpdateGroupMetrics(groupMetricsGeneratorTaskContext);
            if (GroupMetricsSyncType.Failed == this.syncType || groupMetricsGeneratorTaskContext.AllChunksFinished)
            {
                return(null);
            }
            return(groupMetricsGeneratorTaskContext);
        }
 // Token: 0x06001083 RID: 4227 RVA: 0x000601E4 File Offset: 0x0005E3E4
 public GroupMetricsSyncType UpdateGroupMetrics(GroupMetricsGeneratorTaskContext context)
 {
     try
     {
         if (context.LastProcessedGroupDistinguishedName == null)
         {
             CachedOrganizationConfiguration instance = CachedOrganizationConfiguration.GetInstance(base.OrgId, CachedOrganizationConfiguration.ConfigurationTypes.Domains);
             this.domains        = instance.Domains;
             this.updatedCookies = new List <GroupMetricsCookie>();
             bool flag;
             if (!this.TryDeltaSync(out flag, this.updatedCookies))
             {
                 this.updatedCookies.Clear();
                 if (!flag || !this.TryFullSync(this.updatedCookies))
                 {
                     this.lastSyncType = GroupMetricsSyncType.Failed;
                 }
             }
         }
         if (!this.GetMetricsForChangedGroups(context))
         {
             this.lastSyncType = GroupMetricsSyncType.Failed;
         }
     }
     catch (Exception ex)
     {
         this.exception    = ex;
         this.lastSyncType = GroupMetricsSyncType.Failed;
         return(this.lastSyncType);
     }
     return(this.lastSyncType);
 }
        // Token: 0x06001094 RID: 4244 RVA: 0x000611B4 File Offset: 0x0005F3B4
        private bool GetMetricsForChangedGroups(GroupMetricsGeneratorTaskContext context)
        {
            string       text             = this.changedGroupListPath;
            TypedHashSet calculatedGroups = new TypedHashSet(20000);

            try
            {
                if (GroupMetricsUtility.Fault == GroupMetricsFault.UnreadableChangedGroupFile)
                {
                    text = this.tenantDirectory;
                }
                List <string> list = new List <string>();
                Dictionary <string, object> parentGroupDictionary           = new Dictionary <string, object>();
                IRecipientSession           tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(base.OrgId), 1316, "GetMetricsForChangedGroups", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\DirectoryProcessor\\GroupMetricsGenerator\\GroupMetricsGenerator.cs");
                using (StreamReader streamReader = new StreamReader(text))
                {
                    string text2;
                    if (context.LastProcessedGroupDistinguishedName != null)
                    {
                        while ((text2 = streamReader.ReadLine()) != null && text2 != context.LastProcessedGroupDistinguishedName)
                        {
                        }
                    }
                    DateTime utcNow = DateTime.UtcNow;
                    while ((text2 = streamReader.ReadLine()) != null)
                    {
                        this.GetMetricsForSingleGroup(tenantOrRootOrgRecipientSession, text2, calculatedGroups, parentGroupDictionary, list);
                        context.LastProcessedGroupDistinguishedName = text2;
                        if ((Utilities.TestForceYieldChunk && this.groupsExpanded > 2) || DateTime.UtcNow - utcNow > this.OneChunkTimeLimit)
                        {
                            break;
                        }
                        base.RunData.ThrowIfShuttingDown();
                    }
                    if (text2 == null)
                    {
                        context.AllChunksFinished = true;
                    }
                }
                for (int i = 0; i < list.Count; i++)
                {
                    string text2 = list[i];
                    this.GetMetricsForSingleGroup(tenantOrRootOrgRecipientSession, text2, calculatedGroups, parentGroupDictionary, list);
                }
                return(true);
            }
            catch (FileNotFoundException)
            {
                context.AllChunksFinished = true;
                return(true);
            }
            catch (IOException ex)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex.GetType().FullName,
                    ex.Message
                });
            }
            catch (UnauthorizedAccessException ex2)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex2.GetType().FullName,
                    ex2.Message
                });
            }
            catch (SecurityException ex3)
            {
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToReadChangedGroupList, null, new object[]
                {
                    this.GetOrganizationIdString(),
                    text,
                    ex3.GetType().FullName,
                    ex3.Message
                });
            }
            return(false);
        }