public void StatisticTest() { var cacheManager = new CacheManager(new InMemoryCachingProvider(), null); var statisticJob = new CollectOrderStatisticJob(GetOrderRepositoryFactory(), cacheManager); statisticJob.CollectStatistics(DateTime.UtcNow.AddYears(-1), DateTime.UtcNow); }
public IHttpActionResult GetDashboardStatistics([FromUri] DateTime?start = null, [FromUri] DateTime?end = null) { start = start ?? DateTime.UtcNow.AddYears(-1); end = end ?? DateTime.UtcNow; var cacheKey = CacheKey.Create("Statistic", start.Value.ToString("yyyy-MM-dd"), end.Value.ToString("yyyy-MM-dd")); var retVal = _cacheManager.Get(cacheKey, () => { var collectStaticJob = new CollectOrderStatisticJob(_repositoryFactory, _cacheManager); return(collectStaticJob.CollectStatistics(start.Value, end.Value)); }); return(Ok(retVal)); }
public async Task <ActionResult <DashboardStatisticsResult> > GetDashboardStatisticsAsync([FromQuery] DateTime?start = null, [FromQuery] DateTime?end = null) { start ??= DateTime.UtcNow.AddYears(-1); end ??= DateTime.UtcNow; // Hack: to compinsate for incorrect Local dates to UTC end = end.Value.AddDays(2); var cacheKey = CacheKey.With(GetType(), string.Join(":", "Statistic", start.Value.ToString("yyyy-MM-dd"), end.Value.ToString("yyyy-MM-dd"))); var retVal = await _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) => { cacheEntry.AddExpirationToken(OrderSearchCacheRegion.CreateChangeToken()); var collectStaticJob = new CollectOrderStatisticJob(_repositoryFactory); var result = await collectStaticJob.CollectStatisticsAsync(start.Value, end.Value); return(result); }); return(Ok(retVal)); }
public IHttpActionResult GetDashboardStatistics([FromUri] DateTime?start = null, [FromUri] DateTime?end = null) { webModel.DashboardStatisticsResult retVal = null; start = start ?? DateTime.UtcNow.AddYears(-1); end = end ?? DateTime.UtcNow; // Hack: to compinsate for incorrect Local dates to UTC end = end.Value.AddDays(2); var cacheKey = CacheKey.Create("Statistic", start.Value.ToString("yyyy-MM-dd"), end.Value.ToString("yyyy-MM-dd")); lock (_lockObject) { retVal = _cacheManager.Get(cacheKey, () => { var collectStaticJob = new CollectOrderStatisticJob(_repositoryFactory, _cacheManager); return(collectStaticJob.CollectStatistics(start.Value, end.Value)); }); } return(Ok(retVal)); }