Exemplo n.º 1
0
        private void StartCollect(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, ExecutionLogBuilder executionLog)
        {
            int attemptsOfEvaluateVariables = 1;
            bool anErrorOccured = false;
            bool allObjectWasCollect = false;

            IEnumerable<ObjectType> objectTypes = collectRequest.GetObjectTypesWasNotCollected(session);
            session.SaveChanges();

            while (!collectTimeOut.IsExceededTheMaxAttemptsOfEvaluateVariables(attemptsOfEvaluateVariables) &&
                   !allObjectWasCollect &&
                   !anErrorOccured &&
                   !Interrupted)
            {
                IEnumerable<StateType> states = collectRequest.GetStates(session);
                IEnumerable<SelectedProbe> selectedProbes = ProbeManager.GetProbesFor(objectTypes, plataform);
                VariablesEvaluated variables = variableEvaluatorService.Evaluate(collectRequest, session);

                session.SaveChanges();

                try
                {
                    this.UpdateSystemInformationOfTarget(session, collectRequest, plataform, executionLog);
                    this.ExecuteCollectWithProbes(session, selectedProbes, collectRequest, variables, states, collectExecution, executionLog);

                    session.SaveChanges();
                }
                catch (SystemInformationException ex)
                {
                    string logMessage;
                    if (ex.InnerException == null)
                    {
                        logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace);
                    }
                    else
                    {
                        logMessage = String.Format(EXECUTION_ERROR_MESSAGE_WITH_INNER_EXCEPTION, ex.Message, ex.InnerException.StackTrace, ex.StackTrace);
                    }
                    Logger.Error(logMessage);
                    collectRequest.SetResultError();
                    collectRequest.Close();
                    anErrorOccured = true;

                    session.SaveChanges();

                    break;
                }
                catch
                {
                    // only ends the loop. The error already was treated
                    anErrorOccured = true;
                }

                objectTypes = collectRequest.GetObjectTypesWasNotCollected(session);
                allObjectWasCollect = objectTypes.Count() == 0;

                attemptsOfEvaluateVariables++;
            }

            if (Interrupted)
            {
                collectRequest.Status = CollectRequestStatus.Canceled;
            }
            else
            {
                if ((!allObjectWasCollect) && (!anErrorOccured))
                {
                    CloseExecutionIfIncomplete(session, collectRequest, collectExecution, plataform, objectTypes);
                }
            }

            session.SaveChanges();
        }
Exemplo n.º 2
0
 private void EndCollect(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution)
 {
     if (collectTimeOut.IsExceededTheMaxOfExecutionsDefined(collectRequest.GetNumberOfExecutions(session)))
     {
         collectRequest.Close();
     }
     else
     {
         if (!collectRequest.isClosed())
         {
             if (!collectExecution.ExistsExecutionsWithError())
             {
                 collectRequest.TryClose(session);
             }
             else
             {
                 collectRequest.Reopen();
             }
         }
     }
     collectExecution.SetDateEndCollect();
     session.SaveChanges();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Ends the request collect because this error is unrecoverable.
 /// This request was not execute because exists some error that is not possible perform the collect.
 /// Ex.: Invalid credentials, bad format of oval xmls, etc.
 /// </summary>
 /// <param name="collectRequest">The request collect.</param>
 /// <param name="probe">The probe.</param>
 /// <param name="collectExecution">the Collect execution object.</param>
 /// <param name="error">the exception that represents an error.</param>
 private void EndsACollectRequestBecauseThisErrorIsUnrecoverable(CollectRequest collectRequest, string probeCapability, CollectExecution collectExecution, Exception error, ExecutionLogBuilder executionLog)
 {
     ConfigureTheCollectRequestWithAnErrorProbeExecute(collectRequest, probeCapability, collectExecution, error, executionLog);
     collectRequest.Close();
 }
Exemplo n.º 4
0
 private void CloseExecutionIfIncomplete(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, IEnumerable<ObjectType> objectTypes)
 {
     IEnumerable<SelectedProbe> objectsNotSupported = ProbeManager.GetNotSupportedObjects(objectTypes, plataform);
     var objectNotSupported = this.GetObjectTypesFromSelectedProbes(objectsNotSupported);
     var objectSupportedNotCollect = objectTypes.Except(objectNotSupported);
     this.CreateCollectedObjectsForNotSupportedObjects(session, objectsNotSupported, collectRequest, collectExecution);
     if (objectSupportedNotCollect.Count() > 0)
     {
         IEnumerable<SelectedProbe> objectsSupportedNotCollected = ProbeManager.GetProbesFor(objectSupportedNotCollect, plataform);
         this.CreateCollectedObjectsForNotSupportedObjects(session, objectsSupportedNotCollected, collectRequest, collectExecution);
     }
     collectRequest.SetResultComplete(session);
     collectRequest.Close();
     session.SaveChanges();
 }