示例#1
0
        internal void UpdateWorkloadResults(Guid runId, byte[] jobResults, ComplianceBindingType bindingType, ComplianceJobStatus status)
        {
            IEnumerable <ComplianceBinding> enumerable = TempDatabase.Instance.FindComplianceJobBindings(this.organizationId.OrganizationalUnit.ObjectGuid, runId, new ComplianceBindingType?(bindingType));

            if (enumerable != null)
            {
                ComplianceBinding complianceBinding = enumerable.First <ComplianceBinding>();
                if (jobResults != null)
                {
                    complianceBinding.JobResults = jobResults;
                }
                if (complianceBinding.JobStatus != ComplianceJobStatus.StatusUnknown)
                {
                    complianceBinding.JobStatus = status;
                }
                switch (status)
                {
                case ComplianceJobStatus.Succeeded:
                case ComplianceJobStatus.Failed:
                case ComplianceJobStatus.PartiallySucceeded:
                    this.DeleteTasks(this.organizationId.OrganizationalUnit.ObjectGuid, runId, new ComplianceBindingType?(bindingType));
                    break;
                }
                TempDatabase.Instance.UpdateBindingTable(complianceBinding);
            }
        }
示例#2
0
 internal void UpdateBindingTable(ComplianceBinding newBinding)
 {
     try
     {
         using (SqlConnection sqlConnection = new SqlConnection(this.GetConnectionString()))
         {
             using (DataContext dataContext = new DataContext(sqlConnection))
             {
                 Table <TempDatabase.ComplianceJobBindingTable>      table     = dataContext.GetTable <TempDatabase.ComplianceJobBindingTable>();
                 IQueryable <TempDatabase.ComplianceJobBindingTable> queryable = from binding in table
                                                                                 where binding.JobRunId == newBinding.JobRunId && (int)binding.BindingType == (int)newBinding.BindingType
                                                                                 select binding;
                 foreach (TempDatabase.ComplianceJobBindingTable complianceJobBindingTable in queryable)
                 {
                     complianceJobBindingTable.SetRowData(newBinding);
                 }
                 dataContext.SubmitChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
 public void Delete(ComplianceBinding binding)
 {
     using (SqlConnection sqlConnection = new SqlConnection(this.GetConnectionString()))
     {
         using (DataContext dataContext = new DataContext(sqlConnection))
         {
             Table <TempDatabase.ComplianceJobBindingTable>      table     = dataContext.GetTable <TempDatabase.ComplianceJobBindingTable>();
             IQueryable <TempDatabase.ComplianceJobBindingTable> queryable = from bindingRow in table
                                                                             where bindingRow.JobRunId == binding.JobRunId && (int)bindingRow.BindingType == (int)binding.BindingType
                                                                             select bindingRow;
             if (queryable != null && queryable.Count <TempDatabase.ComplianceJobBindingTable>() > 0)
             {
                 TempDatabase.ComplianceJobBindingTable entity = queryable.First <TempDatabase.ComplianceJobBindingTable>();
                 table.DeleteOnSubmit(entity);
                 dataContext.SubmitChanges();
             }
         }
     }
 }
示例#4
0
 internal IEnumerable <ComplianceBinding> FindComplianceJobBindings(Guid tenantId, Guid runId, ComplianceBindingType?bindingType = null)
 {
     using (SqlConnection dbConn = new SqlConnection(this.GetConnectionString()))
     {
         using (DataContext dbContext = new DataContext(dbConn))
         {
             Table <TempDatabase.ComplianceJobBindingTable>      bindings     = dbContext.GetTable <TempDatabase.ComplianceJobBindingTable>();
             IQueryable <TempDatabase.ComplianceJobBindingTable> bindingQuery = from binding in bindings
                                                                                where binding.JobRunId == runId && binding.TenantId == tenantId && ((int?)bindingType == (int?)null || (int)binding.BindingType == (int)bindingType.Value)
                                                                                select binding;
             foreach (TempDatabase.ComplianceJobBindingTable bindingRow in bindingQuery)
             {
                 ComplianceBinding bindingObj = new ComplianceBinding();
                 bindingObj.CopyFromRow(bindingRow);
                 yield return(bindingObj);
             }
         }
     }
     yield break;
 }