Esempio n. 1
0
        public override void Execute(Task task, Guid?serviceInstanceId)
        {
            if (!Enum.IsDefined(typeof(OperationTaskType), task.Name))
            {
                var message = string.Format(TaskResources.OperationsTaskRequest_InvalidRequestInvalidTaskName, task.Name);
                _taskService.CompleteUnrecoverableTaskException(task, message);
                throw new UnRecoverableErrorException(message);
            }

            // Acquire the lock
            _timerLockService.AcquireLock(serviceInstanceId.Value, task.Pin ?? 0, task.Id);

            if (task.Name.SafeEquals(TaskNames.MergePin))
            {
                _timerLockService.AcquireLock(serviceInstanceId.Value, task.FromPin ?? 0, task.Id);
                _timerLockService.AcquireLock(serviceInstanceId.Value, task.ToPin ?? 0, task.Id);
            }

            // Execute the operation task
            var operationsTask = _objectBuilder.Resolve <IOperationsTaskProcessor>(task.Name);

            operationsTask.Execute(task);

            // Complete the task
            _taskService.CompleteTask(task, true);
        }
Esempio n. 2
0
 /// <summary>
 /// This will build a proxy for the interface representing the gateway and register the 
 /// proxy instance in the container based on the definition.
 /// </summary>
 /// <param name="container"><seealso cref="IContainer"/></param>
 /// <param name="gatewayDefinition">Definition of the gateway</param>
 public void BuildProxy(IObjectBuilder container, IGatewayDefinition gatewayDefinition)
 {
     var methodInterceptor = new GatewayMethodInterceptor(container, gatewayDefinition);
     var gatewayInstance = container.Resolve<IReflection>().GetTypeForNamedInstance(gatewayDefinition.Contract);
     var proxy = BuildFor(gatewayInstance, methodInterceptor);
     container.Register(gatewayDefinition.Id, gatewayInstance, proxy);
 }
Esempio n. 3
0
        public void Process(Task task)
        {
            if (!Enum.IsDefined(typeof(OperationType), task.Name))
            {
                throw new ArgumentException("OperationProcessorInvalidOperationType");
            }

            var operation = _objectBuilder.Resolve <IOperationProcessor>(task.Name);

            operation.Execute(task);
        }
Esempio n. 4
0
        public void The_object_should_be_loaded_without_issues()
        {
            using (MemberRepository repository = _container.Resolve <MemberRepository>())
            {
                var query = from m in repository where m.Id == _memberId select m;

                Member member = query.FirstOrDefault();

                Assert.IsNotNull(member);
                //Assert.That(member, Is.Not.Null);

                Assert.AreEqual(_memberId, member.Id);
                //Assert.That(member.Id, Is.EqualTo(_memberId));
            }
        }
Esempio n. 5
0
        public ActionResult ReadServiceDeskStructureChart(int id,
                                                          bool svcDomains,
                                                          string[] domainsSelected,
                                                          bool svcFunctions,
                                                          bool svcComponents,
                                                          bool resolverGroups,
                                                          bool svcActivities,
                                                          bool opProcs)
        {
            var generator = _objectBuilder.Resolve <IDiagramGenerator>(Diagram.ServiceDeskStructure);
            var chartData = generator.Generate(id, svcDomains, svcFunctions, svcComponents, resolverGroups,
                                               svcActivities, opProcs, domainsSelected);
            var chart = Mapper.Map <List <ChartDataViewModel> >(chartData);

            return(Json(chart, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        private void Execute(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            _timer.Stop();

            try
            {
                var taskHandler = _objectBuilder.Resolve <ITaskHandlerManager>(TaskHandlerNames.OperationsHandler);
                if (taskHandler.CanExecute(DateTime.Now.Hour))
                {
                    taskHandler.Execute();
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(ex.Flatten(), EventLogEntryType.Error);
            }

            _timer.Start();
        }
Esempio n. 7
0
 private static void ExecuteCommand(string command, IObjectBuilder objectBuilder)
 {
     try
     {
         var prfMon = new PrfMon();
         System.Console.WriteLine($"Fujitsu.AFC.TaskProcessor.Console -> {command}.");
         var taskHandler = objectBuilder.Resolve <ITaskHandlerManager>(command);
         if (taskHandler.CanExecute(DateTime.Now.Hour))
         {
             taskHandler.Execute();
         }
         System.Console.WriteLine("Fujitsu.AFC.TaskProcessor.Console -> {0} Completed Processing. Duration: {1:0.000}s", command, prfMon.Stop());
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("An exception has occurred. See below for further details.");
         System.Console.WriteLine("    Message: {0}", ex.Message);
         System.Console.WriteLine("    Stack Trace: {0}", ex.StackTrace);
     }
 }
Esempio n. 8
0
        public override void Execute(Task task, Guid?serviceInstanceId)
        {
            try
            {
                if (!Enum.IsDefined(typeof(ProvisionTaskType), task.Name))
                {
                    var message = string.Format(TaskResources.ProvisioningTaskRequest_InvalidRequestInvalidTaskName, task.Name);
                    throw new UnRecoverableErrorException(string.Format(message, task.Name));
                }

                // We do not want the task to retry if we have a problem
                var provisioningTask = _objectBuilder.Resolve <IProvisioningTaskProcessor>(task.Name);
                provisioningTask.Execute(task);

                // Complete the task
                _taskService.CompleteTask(task, true);
            }
            catch (UnRecoverableErrorException ex)
            {
                // Catch and log the exception
                _loggingManager.Write(LoggingEventSource.ProvisioningService, LoggingEventType.Error, ex.Message);

                // Complete UnRecoverable Exception
                _taskService.CompleteUnrecoverableTaskException(task, ex.Message);
            }
            catch (Exception ex)
            {
                // Catch and log the exception
                _loggingManager.Write(LoggingEventSource.ProvisioningService, LoggingEventType.Error, ex.Message);

                // Create a History Log
                var historyLog = task.CreateHistoryLog(_userIdentity.Name);
                historyLog.EventType   = LoggingEventTypeNames.Error;
                historyLog.EventDetail = string.Format(TaskResources.UnexpectedApplicationError, "Provisioning");
                historyLog.Escalated   = false;
                _historyLogService.Create(historyLog);

                // Complete the task
                _taskService.CompleteTask(task, false);
            }
        }
        public override void Execute()
        {
            try
            {
                // Get all outstanding provisioning tasks
                var tasks = _taskService.AllProvisioningHandlerTasks().ToList();

                if (tasks.Any())
                {
                    foreach (var task in tasks)
                    {
                        try
                        {
                            // Create a new DI container to keep all work with the handler discrete
                            _objectBuilder.AddChildContainer();

                            // Instantiate the task handler
                            using (var taskHandler = _objectBuilder.Resolve <ITaskHandler>(task.Handler))
                            {
                                // Check that the task is scheduled to be executed
                                if (!taskHandler.CanExecute(task, null))
                                {
                                    return;
                                }

                                taskHandler.Execute(task, null);
                            }
                        }
                        finally
                        {
                            _objectBuilder.RemoveAllChildContainers();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _loggingManager.Write(LoggingEventSource.ProvisioningService, LoggingEventType.Error, ex.Message);
            }
        }
Esempio n. 10
0
        public override void Execute()
        {
            try
            {
                var serviceInstanceId = Settings.Default.ServiceInstanceId;

                // Check that the Service Instance Id is not empty
                if (serviceInstanceId == Guid.Empty)
                {
                    throw new ArgumentNullException(string.Format(TaskResources.ConfigurationFile_SettingMissing, nameof(serviceInstanceId)));
                }

                // Get all outstanding operations tasks
                var tasks = _taskService.AllOperationsHandlerTasks().ToList();

                if (tasks.Any())
                {
                    foreach (var task in tasks)
                    {
                        try
                        {
                            RetryableOperation.Invoke(
                                ExceptionPolicies.General,
                                () =>
                            {
                                // Create a new DI container to keep all work with the handler discrete
                                _objectBuilder.AddChildContainer();

                                // Instantiate the task handler
                                using (var taskHandler = _objectBuilder.Resolve <ITaskHandler>(task.Handler))
                                {
                                    // Check that the task is scheduled to be executed
                                    if (!taskHandler.CanExecute(task, serviceInstanceId))
                                    {
                                        return;
                                    }

                                    taskHandler.Execute(task, serviceInstanceId);
                                }
                            });
                        }
                        catch (UnRecoverableErrorException)
                        {
                            // Already handled
                        }
                        catch (Exception ex)
                        {
                            // Create a History Log
                            var historyLog = task.CreateHistoryLog(_userIdentity.Name);
                            historyLog.EventType   = LoggingEventTypeNames.Error;
                            historyLog.EventDetail = string.Format(TaskResources.UnexpectedApplicationErrorInstanceHandlingId, ex.Message);
                            historyLog.Escalated   = false;
                            _historyLogService.Create(historyLog);

                            // Update Task NextScheduledDate
                            task.NextScheduledDate = DateTime.Now.AddMinutes(_parameterService.GetParameterByNameAndCache <int>(ParameterNames.RecoverableExceptionRetryDelayIntervalInMinutes));
                            _taskService.Update(task);
                        }
                        finally
                        {
                            _objectBuilder.RemoveAllChildContainers();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _loggingManager.Write(LoggingEventSource.OperationsService, LoggingEventType.Error, ex.Message);
            }
        }