Пример #1
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();
        }
Пример #2
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();
        }