public Task Execute(IJobExecutionContext context)
        {
            if (context.Trigger.JobDataMap.TryGetValue("AgregationType", out var agrrBy))
            {
                if (agrrBy is null)
                {
                    throw new InvalidOperationException("Job trigger agregation type cannot be null");
                }


                AgregationBy agregation = (AgregationBy)agrrBy;

                switch (agregation)
                {
                case AgregationBy.Customer:
                    var culastdate = this.getDateVal(_paramKeyCustomer);
                    _agregationManager.AgregateCustomers(PeriodType.Daily, culastdate);
                    this.setValue(_paramKeyCustomer, _timeManager.Now);
                    break;

                case AgregationBy.Catering:
                    var calastdate = this.getDateVal(_paramKeyCatering);
                    _agregationManager.AgregateCaterings(PeriodType.Daily, calastdate);
                    this.setValue(_paramKeyCatering, _timeManager.Now);
                    break;

                case AgregationBy.CateringCategory:
                    break;

                case AgregationBy.CustomerCatering:
                    var cclastdate = this.getDateVal(_paramKeyCustomerCatering);
                    _agregationManager.AgregateCateringCustomers(PeriodType.Daily, cclastdate);
                    this.setValue(_paramKeyCustomerCatering, _timeManager.Now);
                    break;
                }

                return(Task.CompletedTask);
            }

            throw new InvalidOperationException("Job trigger must have a agregation type");
        }
示例#2
0
        public List <Agregation> GetAgregations(PeriodType periodType, DateTime from, AgregationBy agregationBy)
        {
            var data = _db.SimpleGet("Agregations", _reflectionHelper.GetPropNames(typeof(Agregation)), new Dictionary <string, object>
            {
                { nameof(Agregation.PeriodType), periodType },
                { nameof(Agregation.AgregationBy), agregationBy },
                { nameof(Agregation.PeriodStart), from }
            }, new Filter {
                Comparison = Comparison.Equal, Name = nameof(Agregation.PeriodType)
            },
                                     new Filter {
                Comparison = Comparison.Equal, Name = nameof(Agregation.AgregationBy)
            },
                                     new Filter {
                Comparison = Comparison.GreaterThan, Name = nameof(Agregation.PeriodStart)
            });

            var agregations = new List <Agregation>();

            foreach (var item in data.Rows.OfType <DataRow>())
            {
                var agrr = this.getFromDbRow(item);

                agrr.PeriodStart  = item.Field <DateTime>("PeriodStart");
                agrr.PeriodType   = item.Field <PeriodType>("PeriodType");
                agrr.Tag          = item.Field <string>("Tag");
                agrr.AgregationBy = item.Field <AgregationBy>("AgregationBy");
                agrr.Id           = item.Field <int>("Id");

                agregations.Add(agrr);
            }

            return(agregations);
        }