// Token: 0x06000038 RID: 56 RVA: 0x00002D10 File Offset: 0x00000F10
        protected RetrievedPayload RetrieveJobDistributionPayload(OrganizationId organizationId, Guid jobRunId, int taskId)
        {
            RetrievedPayload      retrievedPayload      = new RetrievedPayload();
            ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(organizationId);
            Guid tenantGuid = organizationId.GetTenantGuid();

            retrievedPayload.IsComplete = this.HasMoreTasks(organizationId, jobRunId);
            IEnumerable <CompositeTask> enumerable = from x in complianceJobProvider.FindCompositeTasks(tenantGuid, jobRunId, null, null)
                                                     where x.TaskId > taskId
                                                     select x;

            if (enumerable != null)
            {
                foreach (CompositeTask compositeTask in enumerable)
                {
                    JobPayload jobPayload = new JobPayload();
                    jobPayload.Target = new Target
                    {
                        TargetType = Target.Type.MailboxSmtpAddress,
                        Identifier = compositeTask.UserMaster
                    };
                    PayloadReference payloadReference = PayloadHelper.GetPayloadReference(jobRunId, compositeTask.TaskId);
                    jobPayload.Children.Add(ComplianceSerializer.Serialize <PayloadReference>(PayloadReference.Description, payloadReference));
                    retrievedPayload.Children.Add(jobPayload);
                    retrievedPayload.Bookmark = compositeTask.TaskId.ToString();
                }
                return(retrievedPayload);
            }
            throw new ArgumentException(string.Format("Not Task Data Found. TenantId-{0} JobId-{1} and TaskId-{2}", tenantGuid, jobRunId, taskId));
        }
        // Token: 0x0600003A RID: 58 RVA: 0x00002F48 File Offset: 0x00001148
        private ComplianceJob GetComplianceJob(OrganizationId organizationId, Guid jobRunId)
        {
            ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(organizationId);
            Guid          tenantGuid    = organizationId.GetTenantGuid();
            ComplianceJob complianceJob = complianceJobProvider.FindComplianceJob(tenantGuid, jobRunId).Single <ComplianceJob>();

            if (complianceJob != null)
            {
                return(complianceJob);
            }
            throw new ArgumentException(string.Format("No job data found. TenantId-{0} and JobRunId-{1}", tenantGuid, jobRunId));
        }
Example #3
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (!base.HasErrors)
     {
         TDataObject dataObject = this.DataObject;
         if (dataObject.IsChanged(ComplianceJobSchema.DisplayName))
         {
             ComplianceJobProvider complianceJobProvider = (ComplianceJobProvider)base.DataSession;
             TDataObject           dataObject2           = this.DataObject;
             if (complianceJobProvider.FindJobsByName <ComplianceSearch>(dataObject2.Name) != null)
             {
                 TDataObject dataObject3 = this.DataObject;
                 base.WriteError(new ComplianceSearchNameIsNotUniqueException(dataObject3.Name), ErrorCategory.InvalidArgument, this.DataObject);
             }
         }
     }
     TaskLogger.LogExit();
 }
Example #4
0
        // Token: 0x0600003D RID: 61 RVA: 0x00002FCC File Offset: 0x000011CC
        public override ComplianceMessage Process(ComplianceMessage input)
        {
            StatusPayload statusPayload = new StatusPayload();

            if (input == null)
            {
                return(new ComplianceMessage
                {
                    Payload = ComplianceSerializer.Serialize <StatusPayload>(StatusPayload.Description, statusPayload)
                });
            }
            statusPayload.QueuedMessages.Add(input.MessageId);
            WorkPayload     workPayload;
            FaultDefinition faultDefinition;
            OrganizationId  orgId;

            if (ComplianceSerializer.TryDeserialize <WorkPayload>(WorkPayload.Description, input.Payload, out workPayload, out faultDefinition, "Process", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\TaskDistributionFabric\\Blocks\\StoreResultsBlock.cs", 47) && OrganizationId.TryCreateFromBytes(input.TenantId, Encoding.UTF8, out orgId))
            {
                Guid correlationId = input.CorrelationId;
                ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(orgId);
                ComplianceJobStatus   status = ComplianceJobStatus.StatusUnknown;
                switch (workPayload.WorkDefinitionType)
                {
                case WorkDefinitionType.EDiscovery:
                    status = ComplianceJobStatus.Succeeded;
                    break;

                case WorkDefinitionType.Fault:
                    status = ComplianceJobStatus.Failed;
                    break;
                }
                complianceJobProvider.UpdateWorkloadResults(correlationId, input.Payload, ComplianceBindingType.ExchangeBinding, status);
            }
            return(new ComplianceMessage
            {
                Payload = ComplianceSerializer.Serialize <StatusPayload>(StatusPayload.Description, statusPayload)
            });
        }
        // Token: 0x06000039 RID: 57 RVA: 0x00002E68 File Offset: 0x00001068
        protected RetrievedPayload RetrieveTaskDistributionPayload(OrganizationId organizationId, Guid jobRunId, int taskId)
        {
            RetrievedPayload      retrievedPayload      = new RetrievedPayload();
            ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(organizationId);
            Guid          tenantGuid    = organizationId.GetTenantGuid();
            CompositeTask compositeTask = complianceJobProvider.FindCompositeTasks(tenantGuid, jobRunId, null, new int?(taskId)).SingleOrDefault <CompositeTask>();

            if (compositeTask != null)
            {
                foreach (string identifier in compositeTask.Users)
                {
                    JobPayload jobPayload = new JobPayload();
                    jobPayload.Target = new Target
                    {
                        TargetType = Target.Type.MailboxSmtpAddress,
                        Identifier = identifier
                    };
                    retrievedPayload.Children.Add(jobPayload);
                }
                return(retrievedPayload);
            }
            throw new ArgumentException(string.Format("No Task data found. TenantId-{0} JobId-{1} and TaskId-{2}", tenantGuid, jobRunId, taskId));
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.DataObject == null)
            {
                return;
            }
            if (base.ExchangeRunspaceConfig == null)
            {
                base.WriteError(new ComplianceJobTaskException(Strings.UnableToDetermineExecutingUser), ErrorCategory.InvalidOperation, null);
            }
            TDataObject dataObject = this.DataObject;

            switch (dataObject.JobStatus)
            {
            case ComplianceJobStatus.Starting:
            case ComplianceJobStatus.InProgress:
            {
                TDataObject dataObject2 = this.DataObject;
                base.WriteError(new ComplianceJobTaskException(Strings.CannotStartRunningJob(dataObject2.Name)), ErrorCategory.InvalidOperation, this.DataObject);
                break;
            }
            }
            TDataObject dataObject3 = this.DataObject;

            dataObject3.Resume = this.Resume;
            TDataObject dataObject4 = this.DataObject;

            dataObject4.RunBy = ((ADObjectId)base.ExchangeRunspaceConfig.ExecutingUserIdentity).Name;
            TDataObject dataObject5 = this.DataObject;

            dataObject5.JobStartTime = DateTime.UtcNow;
            TDataObject dataObject6 = this.DataObject;

            dataObject6.JobRunId = CombGuidGenerator.NewGuid();
            TDataObject dataObject7 = this.DataObject;

            dataObject7.JobStatus = ComplianceJobStatus.Starting;
            base.DataSession.Save(this.DataObject);
            TDataObject dataObject8 = this.DataObject;
            MultiValuedProperty <string> exchangeBindings = dataObject8.ExchangeBindings;

            if (exchangeBindings != null && exchangeBindings.Count > 0)
            {
                try
                {
                    Dictionary <string, ComplianceBindingErrorType> invalidBindings = new Dictionary <string, ComplianceBindingErrorType>();
                    TDataObject dataObject9 = this.DataObject;
                    dataObject9.Bindings[ComplianceBindingType.ExchangeBinding].JobMaster = base.ExchangeRunspaceConfig.IdentityName;
                    TDataObject dataObject10 = this.DataObject;
                    dataObject10.Bindings[ComplianceBindingType.ExchangeBinding].JobStartTime = DateTime.UtcNow;
                    base.DataSession.Save(this.DataObject);
                    ComplianceMessage           item = this.CreateStartJobMessage();
                    InterExchangeWorkloadClient interExchangeWorkloadClient = new InterExchangeWorkloadClient();
                    Task <bool[]> task = interExchangeWorkloadClient.SendMessageAsync(new List <ComplianceMessage>
                    {
                        item
                    });
                    IComplianceTaskCreator instance        = ComplianceTaskCreatorFactory.GetInstance(ComplianceBindingType.ExchangeBinding);
                    IEnumerable <CompositeTask> enumerable = instance.CreateTasks(base.DataSession, this.DataObject, CreateTaskOptions.None, delegate(string invalidBinding, ComplianceBindingErrorType errorType)
                    {
                        invalidBindings.Add(invalidBinding, errorType);
                    });
                    int num = 0;
                    foreach (CompositeTask compositeTask in enumerable)
                    {
                        num++;
                        int percentCompleted = (num > 99) ? 99 : num;
                        base.WriteProgress(Strings.ComplianceSearchCreateTaskActivity, Strings.ComplianceSearchTasksCreated(num), percentCompleted);
                    }
                    TimeSpan timeout = TimeSpan.FromSeconds(5.0);
                    bool     flag    = true;
                    for (int i = 0; i < 6; i++)
                    {
                        if (System.Threading.Tasks.Task.WaitAll(new System.Threading.Tasks.Task[]
                        {
                            task
                        }, timeout))
                        {
                            flag = false;
                            break;
                        }
                        base.WriteVerbose(Strings.ComplianceSearchInitializingMessage);
                    }
                    if (flag)
                    {
                        TDataObject dataObject11 = this.DataObject;
                        dataObject11.JobStatus = ComplianceJobStatus.Failed;
                        base.ThrowTerminatingError(new ComplianceJobTaskException(Strings.ComplianceSearchTimeoutError), ErrorCategory.ConnectionError, this.DataObject);
                    }
                    else if (!task.Result[0])
                    {
                        TDataObject dataObject12 = this.DataObject;
                        dataObject12.JobStatus = ComplianceJobStatus.Failed;
                        base.ThrowTerminatingError(new ComplianceJobTaskException(Strings.ComplianceSearchSendStartMessageError("Exchange")), ErrorCategory.ConnectionError, this.DataObject);
                    }
                    this.CreateWarningMessageForInvalidBindings(invalidBindings);
                    TDataObject dataObject13 = this.DataObject;
                    dataObject13.Bindings[ComplianceBindingType.ExchangeBinding].JobStatus = ComplianceJobStatus.InProgress;
                    ComplianceJobProvider complianceJobProvider = (ComplianceJobProvider)base.DataSession;
                    TDataObject           dataObject14          = this.DataObject;
                    complianceJobProvider.UpdateWorkloadResults(dataObject14.JobRunId, null, ComplianceBindingType.ExchangeBinding, ComplianceJobStatus.InProgress);
                }
                catch (Exception ex)
                {
                    TDataObject dataObject15 = this.DataObject;
                    dataObject15.JobStatus = ComplianceJobStatus.Failed;
                    base.DataSession.Save(this.DataObject);
                    throw ex;
                }
            }
            TDataObject dataObject16 = this.DataObject;

            dataObject16.Bindings[ComplianceBindingType.PublicFolderBinding].JobStatus = ComplianceJobStatus.Succeeded;
            ComplianceJobProvider complianceJobProvider2 = (ComplianceJobProvider)base.DataSession;
            TDataObject           dataObject17           = this.DataObject;

            complianceJobProvider2.UpdateWorkloadResults(dataObject17.JobRunId, null, ComplianceBindingType.PublicFolderBinding, ComplianceJobStatus.Succeeded);
            TDataObject dataObject18 = this.DataObject;

            dataObject18.Bindings[ComplianceBindingType.SharePointBinding].JobStatus = ComplianceJobStatus.Succeeded;
            ComplianceJobProvider complianceJobProvider3 = (ComplianceJobProvider)base.DataSession;
            TDataObject           dataObject19           = this.DataObject;

            complianceJobProvider3.UpdateWorkloadResults(dataObject19.JobRunId, null, ComplianceBindingType.SharePointBinding, ComplianceJobStatus.Succeeded);
            TaskLogger.LogExit();
        }