Пример #1
0
        public async Task <BuildCacheInfo> BuildCache()
        {
            var buildInfo = await _redisCacheProvider.GetBuildCacheInfoAsync();

            if (buildInfo?.Status == BuildCacheStatusType.Queued)
            {
                try
                {
                    _redisCacheProvider.FlushCache();
                    buildInfo.Status    = BuildCacheStatusType.InProgress;
                    buildInfo.StartTime = DateTime.Now.ToString();
                    buildInfo.Heartbeat = Constants.Cache.HeartbeatMessage.StartsmartFunds;
                    buildInfo.Error     = "";
                    buildInfo.EndTime   = null;
                    await _redisCacheProvider.SetBuildCacheInfoAsync(buildInfo);

                    //await _unitOfWork.BuildCacheAsync();
                    buildInfo.Heartbeat = Constants.Cache.HeartbeatMessage.FinishsmartFunds;
                    await _redisCacheProvider.SetBuildCacheInfoAsync(buildInfo);

                    buildInfo.Heartbeat = Constants.Cache.HeartbeatMessage.StartContactBase;
                    await _redisCacheProvider.SetBuildCacheInfoAsync(buildInfo);

                    await _cacheBuilder.BuildCacheAsync(_serviceProvider);

                    buildInfo.Heartbeat = Constants.Cache.HeartbeatMessage.FinishContactBase;
                    buildInfo.EndTime   = DateTime.Now.ToString();
                    buildInfo.Status    = BuildCacheStatusType.Finished;
                    await _redisCacheProvider.SetBuildCacheInfoAsync(buildInfo);
                }
                catch (Exception ex)
                {
                    buildInfo.Error  = ex.ToString();
                    buildInfo.Status = BuildCacheStatusType.Error;
                    await _redisCacheProvider.SetBuildCacheInfoAsync(buildInfo);
                }
            }

            return(buildInfo);
        }