Пример #1
0
        protected override async Task <MinionRunResultsModel> Execute()
        {
            var runResults = new MinionRunResultsModel();

            var listCount = await GetListCount(Policy.ListToWatch);

            Logger.LogInformation($"{Name}-Review List {Policy.ListToWatch}: Count:{listCount}");

            if (listCount > 0)
            {
                var sendOrdertoServiceBus = await GetListIds <Order>(Policy.ListToWatch, System.Convert.ToInt32(listCount));

                foreach (var id in sendOrdertoServiceBus.IdList)
                {
                    Logger.LogDebug($"{Name}-Sending Order to ServiceBus: {id}");
                    await Pipeline.Run(id, new CommercePipelineExecutionContextOptions(new CommerceContext(Logger, MinionContext.TelemetryClient)
                    {
                        Environment = Environment
                    }));
                }

                listCount = await GetListCount(Policy.ListToWatch);
            }

            Logger.LogInformation($"{Name}-Send to ServiceBus complete for : {listCount}");
            return(runResults);
        }
        protected override async Task <MinionRunResultsModel> Execute()
        {
            MinionRunResultsModel runResults = new MinionRunResultsModel();

            /* STUDENT: Complete the body of this method. You need to pull from an appropriate list
             * and then execute an appropriate pipeline. */
            long listCount = await GetListCount(Policy.ListToWatch).ConfigureAwait(false);

            this.Logger.LogInformation(string.Format("{0}-Review List {1}: Count:{2}", (object)this.Name, (object)this.Policy.ListToWatch, (object)listCount));
            // var  entitleMentList = await this.GetListIds<XC.Order>(this.Policy.ListToWatch, Convert.ToInt32(listCount)).ConfigureAwait(false);

            foreach (var commerceEnty in (await this.GetListItems <XC.Order>(Policy.ListToWatch, Convert.ToInt32(listCount)).ConfigureAwait(false)))
            {
                this.Logger.LogDebug(string.Format("{0}-Reviewing Pending Order: {1}", commerceEnty.Name, commerceEnty.Id), Array.Empty <object>());

                var minionPipeline       = ExportOrderPipeline;
                var ordersMinionArgument = new ExportOrderArgument(commerceEnty.Id);
                using (var commerceContext = new CommerceContext(this.Logger, this.MinionContext.TelemetryClient, (IGetLocalizableMessagePipeline)null))
                {
                    commerceContext.Environment = this.Environment;
                    CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);
                    var order = await minionPipeline.Run(ordersMinionArgument, executionContextOptions).ConfigureAwait(false);
                }
            }

            return(runResults);
        }
Пример #3
0
        protected override async Task <MinionRunResultsModel> Execute()
        {
            MinionRunResultsModel runResults = new MinionRunResultsModel();
            /* Pull from an appropriate list and execute an appropriate pipeline. */

            /*Gets list of Items from ReleasedOrders and executes export order to file block*/
            long listCount = await this.GetListCount(this.Policy.ListToWatch).ConfigureAwait(false);

            this.Logger.LogInformation(string.Format("{0}-Review List {1}: Count:{2}", Name, Policy.ListToWatch, listCount));
            foreach (var commerceEnty in (await this.GetListItems <XC.Order>(Policy.ListToWatch, Convert.ToInt32(listCount)).ConfigureAwait(false)))
            {
                this.Logger.LogDebug(string.Format("{0}-Reviewing Pending Order: {1}", commerceEnty.Name, commerceEnty.Id), Array.Empty <object>());

                var minionPipeline       = ExportOrderPipeline;
                var ordersMinionArgument = new ExportOrderArgument(commerceEnty.Id);
                using (var commerceContext = new CommerceContext(this.Logger, this.MinionContext.TelemetryClient, null))
                {
                    commerceContext.Environment = this.Environment;
                    CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);
                    var order = await minionPipeline.Run(ordersMinionArgument, executionContextOptions).ConfigureAwait(false);
                }
            }

            return(runResults);
        }
Пример #4
0
        public override async Task <MinionRunResultsModel> Run()
        {
            MinionRunResultsModel result = new MinionRunResultsModel();

            Logger.LogTrace($"{this.Name}: Invoked.");
            string      listName  = Policy.ListToWatch;
            Task <long> itemCount = GetListCount(listName);

            //TODO correct handling of <cref='MinionResultArgument.HasMoreItems'>HasMoreItems</cref>

            IEnumerable <CommerceEntity> entities = await GetListItems <CommerceEntity>(listName, Policy.ItemsPerBatch);

            foreach (Customer customer in entities.OfType <Customer>())
            {
                var executionContext = new CommercePipelineExecutionContextOptions(
                    new CommerceContext(MinionContext.Logger, MinionContext.TelemetryClient)
                {
                    Environment = this.Environment
                });
                var issueCouponArgument = new IssueCouponArgument {
                    Customer = customer
                };
                var pipelineResult = await this.MinionPipeline.Run(issueCouponArgument, executionContext);

                // TODO Appropriate handling of pipeline status. Look at other minions.
                result.ItemsProcessed++;
            }

            return(result);
        }
        protected override async Task <MinionRunResultsModel> Execute()
        {
            MinionRunResultsModel runResults = new MinionRunResultsModel();
            /*Gets all the ReleasedOrders and executes export order*/
            long listCount = await GetListCount(Policy.ListToWatch).ConfigureAwait(false);

            this.Logger.LogInformation(string.Format(CultureInfo.InvariantCulture, "{0}-Review List {1}: Count:{2}", Name, Policy.ListsToWatch, listCount));
            foreach (var listItems in (await GetListItems <XC.Order>(Policy.ListToWatch, Convert.ToInt32(listCount)).ConfigureAwait(false)))
            {
                this.Logger.LogDebug(string.Format(CultureInfo.InvariantCulture, "{0}-Reviewing Pending Order: {1}", listItems.Name, listItems.Id), Array.Empty <object>());

                var minionPipeline       = ExportOrderPipeline;
                var ordersMinionArgument = new ExportOrderArgument(listItems.Id);
                using (var commerceContext = new CommerceContext(Logger, MinionContext.TelemetryClient, null))
                {
                    commerceContext.Environment = this.Environment;

                    CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);

                    var order = await minionPipeline.Run(ordersMinionArgument, executionContextOptions).ConfigureAwait(false);
                }
            }

            return(runResults);
        }
Пример #6
0
        public async Task <string> Process(CommerceContext commerceContext)
        {
            using (var activity = CommandActivity.Start(commerceContext, this))
            {
                commerceContext.Logger.LogInformation($"ProductImport Minion Started: Start Time: {DateTime.Now}");
                var context = commerceContext.PipelineContextOptions;
                MinionRunResultsModel pArg = new MinionRunResultsModel();
                var result = await this._pipeline.Run(pArg, context);

                return("Success");
            }
        }
Пример #7
0
        protected override async Task <MinionRunResultsModel> Execute()
        {
            var arg = new SynchronizeCatalogArgument();

            var policy = MinionContext.GetPolicy <SynchronizeCatalogPolicy>();

            arg.Options.ExcludeLogInResults = policy.ExcludeLogInResults;
            arg.Options.SkipRelationships   = policy.SkipRelationships;

            var result = await Pipeline.Run(arg, new CommercePipelineExecutionContextOptions(MinionContext)).ConfigureAwait(false);

            var runResults = new MinionRunResultsModel {
                ItemsProcessed = result.TotalNumberOfEntitiesEffected, DidRun = true
            };

            return(runResults);
        }
Пример #8
0
        public override async Task <MinionRunResultsModel> Run()
        {
            MinionRunResultsModel result = new MinionRunResultsModel();

            Logger.LogTrace($"{this.Name}: Invoked.");


            var executionContext = new CommercePipelineExecutionContextOptions(
                new CommerceContext(
                    MinionContext.Logger,
                    MinionContext.TelemetryClient,
                    (IGetLocalizableMessagePipeline)null)
            {
                Environment = this.Environment
            });
            var pipelineResult = await this.MinionPipeline.Run(new CreateCouponsArgument(), executionContext);

            return(result);
        }
        public override async Task <MinionRunResultsModel> Run()
        {
            MinionRunResultsModel runResults = new MinionRunResultsModel();
            long listCount = await this.GetListCount(this.Policy.ListToWatch);

            this.Logger.LogInformation(string.Format("{0}-Review List {1}: Count:{2}", (object)this.Name, (object)this.Policy.ListToWatch, (object)listCount));
            foreach (string id in (await this.GetListIds <Order>(this.Policy.ListToWatch, Convert.ToInt32(listCount))).IdList)
            {
                this.Logger.LogDebug(string.Format("{0}-Reviewing Pending Order: {1}", (object)this.Name, (object)id), Array.Empty <object>());

                var minionPipeline       = MinionPipeline;
                var ordersMinionArgument = new ExportOrdersMinionArgument(id);
                var commerceContext      = new CommerceContext(this.Logger, this.MinionContext.TelemetryClient, (IGetLocalizableMessagePipeline)null);
                commerceContext.Environment = this.Environment;

                CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);

                var order = await minionPipeline.Run(ordersMinionArgument, executionContextOptions);
            }

            return(runResults);
        }
Пример #10
0
        protected override async Task <MinionRunResultsModel> Execute()
        {
            this.Logger.LogInformation("ImportProduct minion started");
            MinionRunResultsModel runResults = new MinionRunResultsModel();

            var commerceContext = new CommerceContext(this.Logger, this.MinionContext.TelemetryClient, (IGetLocalizableMessagePipeline)null);

            commerceContext.Environment = this.Environment;
            CommercePipelineExecutionContextOptions executionContextOptions = new CommercePipelineExecutionContextOptions(commerceContext, null, null, null, null, null);

            try
            {
                runResults = await _iImportProuctsMinionPipeline.Run(runResults, executionContextOptions);
            }
            finally
            {
                runResults.HasMoreItems = false;
                runResults.DidRun       = true;
            }

            this.Logger.LogInformation("ImportProduct minion completed");
            return(runResults);
        }