Exemplo n.º 1
0
 protected async Task RunStep(IActionContext actionContext, int value, IIdGenService idGenService, IActionExecuterService actionExecuterService)
 {
     _ = actionExecuterService ?? throw new ArgumentNullException(nameof(actionExecuterService));
     _ = actionContext ?? throw new ArgumentNullException(nameof(actionContext));
     _ = idGenService ?? throw new ArgumentNullException(nameof(idGenService));
     IExecuteContext executeContext = this.OnCreateExecuteContext(actionContext, idGenService, value);
     var             result         = await actionExecuterService.Execute(executeContext);
 }
Exemplo n.º 2
0
        protected virtual void RunConcurrent(IActionContext context, IEnumerable <int> values)
        {
            IIdGenService          idGenService          = context.GetRequiredService <IIdGenService>();
            IActionExecuterService actionExecuterService = context.GetRequiredService <IActionExecuterService>();
            var allTasks = values.Select(p => RunStep(context, p, idGenService, actionExecuterService)).ToArray();

            Task.WaitAll(allTasks);
        }
 public DefaultGroupRunnerService(IActionExecuterService actionExecuterService, IPublishValueService publishValueService, IIdGenService idGenService, IDynamicValueService dynamicValueService, IConvertService convertService, WorkflowOption workflowOption)
 {
     this.actionExecuterService = actionExecuterService;
     this.publishValueService   = publishValueService;
     this.idGenService          = idGenService;
     this.dynamicValueService   = dynamicValueService;
     this.convertService        = convertService;
     this.workflowOption        = workflowOption;
 }
Exemplo n.º 4
0
        protected virtual void RunOneByOne(IActionContext context, IEnumerable <int> values)
        {
            IIdGenService          idGenService          = context.GetRequiredService <IIdGenService>();
            IActionExecuterService actionExecuterService = context.GetRequiredService <IActionExecuterService>();

            foreach (var val in values ?? Enumerable.Empty <int>())
            {
                RunStep(context, val, idGenService, actionExecuterService).Wait();
            }
        }
Exemplo n.º 5
0
        protected void RunOneByOne(IActionContext context, ICollection source)
        {
            IIdGenService          idGenService          = context.GetRequiredService <IIdGenService>();
            IActionExecuterService actionExecuterService = context.GetRequiredService <IActionExecuterService>();
            int index = this.StartIndex;

            foreach (var item in source ?? Array.Empty <object>())
            {
                RunStep(context, index++, item, idGenService, actionExecuterService).Wait();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateCommandHandler"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="idGenService">The service to generate unique identifiers.</param>
 /// <param name="serializer">The JSON serializer.</param>
 /// <param name="queue">The task queue.</param>
 public CreateCommandHandler(
     IAmiUnitOfWork context,
     IIdGenService idGenService,
     IDefaultJsonSerializer serializer,
     ITaskQueue queue)
     : base()
 {
     this.context      = context ?? throw new ArgumentNullException(nameof(context));
     this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService));
     this.serializer   = serializer ?? throw new ArgumentNullException(nameof(serializer));
     this.queue        = queue ?? throw new ArgumentNullException(nameof(queue));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessCommandHandler"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="idGenService">The service to generate unique identifiers.</param>
 /// <param name="serializer">The JSON serializer.</param>
 /// <param name="imageService">The image service.</param>
 public ProcessCommandHandler(
     IAmiUnitOfWork context,
     IIdGenService idGenService,
     IDefaultJsonSerializer serializer,
     IImageService imageService)
     : base()
 {
     this.context      = context ?? throw new ArgumentNullException(nameof(context));
     this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService));
     this.serializer   = serializer ?? throw new ArgumentNullException(nameof(serializer));
     this.imageService = imageService ?? throw new ArgumentNullException(nameof(imageService));
 }
Exemplo n.º 8
0
        private IExecuteContext OnCreateExecuteContext(IActionContext actionContext, IIdGenService idGenService, int index, object _)
        {
            string newid = idGenService.NewId();

            return(new ExecuteContext()
            {
                ActionFullName = "core.group",
                ActionRetryCount = 1,
                ExecuteName = $"{actionContext.ExecuteName}_{index}",
                ExecutePath = actionContext.ExecutePath.NewSubPath(newid),
                Token = actionContext.Token,
            });
        }
Exemplo n.º 9
0
        protected void RunConcurrent(IActionContext context, ICollection source)
        {
            IIdGenService          idGenService          = context.GetRequiredService <IIdGenService>();
            IActionExecuterService actionExecuterService = context.GetRequiredService <IActionExecuterService>();
            int index    = this.StartIndex;
            var allTasks = new List <Task>();

            foreach (var item in source ?? Array.Empty <object>())
            {
                var task = RunStep(context, index++, item, idGenService, actionExecuterService);
                allTasks.Add(task);
            }
            Task.WaitAll(allTasks.ToArray());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateCommandHandler"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="idGenService">The service to generate unique identifiers.</param>
        /// <param name="constants">The application constants.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="fileSystemStrategy">The file system strategy.</param>
        public CreateCommandHandler(
            IAmiUnitOfWork context,
            IIdGenService idGenService,
            IApplicationConstants constants,
            IAmiConfigurationManager configuration,
            IFileSystemStrategy fileSystemStrategy)
            : base()
        {
            this.context       = context ?? throw new ArgumentNullException(nameof(context));
            this.idGenService  = idGenService ?? throw new ArgumentNullException(nameof(idGenService));
            this.constants     = constants ?? throw new ArgumentNullException(nameof(constants));
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            if (fileSystemStrategy == null)
            {
                throw new ArgumentNullException(nameof(fileSystemStrategy));
            }

            fileSystem = fileSystemStrategy.Create(configuration.WorkingDirectory);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessCommandHandler"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="idGenService">The service to generate unique identifiers.</param>
        /// <param name="serializer">The JSON serializer.</param>
        /// <param name="mediator">The mediator.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="fileSystemStrategy">The file system strategy.</param>
        public ProcessCommandHandler(
            IAmiUnitOfWork context,
            IIdGenService idGenService,
            IDefaultJsonSerializer serializer,
            IMediator mediator,
            IAmiConfigurationManager configuration,
            IFileSystemStrategy fileSystemStrategy)
            : base()
        {
            this.context       = context ?? throw new ArgumentNullException(nameof(context));
            this.idGenService  = idGenService ?? throw new ArgumentNullException(nameof(idGenService));
            this.serializer    = serializer ?? throw new ArgumentNullException(nameof(serializer));
            this.mediator      = mediator ?? throw new ArgumentNullException(nameof(mediator));
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            if (fileSystemStrategy == null)
            {
                throw new ArgumentNullException(nameof(fileSystemStrategy));
            }

            fileSystem = fileSystemStrategy.Create(configuration.WorkingDirectory);
        }
 public DefaultJobEngineService(ILogger <DefaultJobEngineService> logger, IActionExecuterService actionExecuterService, IIdGenService idGenService)
 {
     this.logger                = logger;
     this.idGenService          = idGenService;
     this.actionExecuterService = actionExecuterService;
 }