Пример #1
0
        public async Task InsertKPIsAsync(List <AggregationItem> items, long searchIndexId, DateTime logDate)
        {
            List <KPIMetric> metrics = new List <KPIMetric>();

            using (var context = new SmartKPIDbContext(this._connectionString))
            {
                foreach (var item in items)
                {
                    KPIMetric metric = this.GetKPI(item, searchIndexId, logDate);

                    if (metric != null)
                    {
                        metrics.Add(metric);
                    }
                }
                context.KPIMetrics.AddRange(metrics);
                int result = await context.SaveChangesAsync();

                if (result > 0)
                {
                    this.InsertOrUpdateMetricTimer(indexId: searchIndexId, logDate: logDate);
                }
                await Task.WhenAll();
            }
        }
Пример #2
0
 public async Task InserKPIAsync(AggregationItem item, long searchIndexId, DateTime logDate)
 {
     using (var context = new SmartKPIDbContext(this._connectionString))
     {
         KPIMetric metric = this.GetKPI(item, searchIndexId, logDate);
         if (metric != null)
         {
             context.KPIMetrics.Add(metric);
             await context.SaveChangesAsync();
         }
     }
 }