示例#1
0
        public async Task <IActionResult> SyncBseCmTrades(bool archiveEnabled = false, DateTime dateVal = default(DateTime))
        {
            try
            {
                _log.Info($"SyncBseCmTrades started");
                if (archiveEnabled)
                {
                    var res = await _tradeViewGenericRepository.ArchiveAndPurgeTradeView(Constants.BseCmExchangeName);

                    _log.Info($"Archiving of TradeView is Complete");
                }

                if (dateVal.Equals(default(DateTime)))
                {
                    dateVal = DateTime.Now;
                }

                await _tradeViewBseCmRepository.LoadTradeviewFromSource(dateVal);

                _log.Info($"SyncBseCmTrades Finished");
                return(Ok(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                _log.Error("Error in SyncBseCmTrades ", ex);
                return(StatusCode(500));
            }
        }
示例#2
0
        //public Task LoadBseCmDataFromSourceDb()
        //{
        //    try
        //    {
        //        _logger.Info($"Inside LoadBseCmDataFromSourceDb");
        //        var cts = new CancellationTokenSource();
        //        if (!LoadTradeViewDataBseCm.isSyncDataStarted)
        //        {
        //            _logger.Info($"Intializing AutoSync");
        //            LoadTradeViewDataBseCm.isSyncDataStarted = true;
        //            Task t = Task.Factory.StartNew(
        //            async () =>
        //            {
        //                while (LoadTradeViewDataBseCm.isSyncDataStarted)
        //                {
        //                    cts.Token.ThrowIfCancellationRequested();
        //                    try
        //                    {
        //                        await _tradeViewBseCmRepository.LoadTradeviewFromSource(isDeltaLoadRequested:true);
        //                        await Task.Delay(60000, cts.Token);
        //                    }
        //                    catch (Exception ex)
        //                    {
        //                        _logger.Error($"Exception in LoadNseCmDataFromSourceDb ", ex);
        //                    }
        //                }
        //                _logger.Info($"LoadBseCmDataFromSourceDb: Auto Sync BSE_CM data Stopped");
        //            }, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default).Unwrap();
        //            return t;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        _logger.Error($"Exception in LoadNseCmDataFromSourceDb", ex);
        //    }
        //    return default(Task);
        //}

        public async Task LoadBseCmDataFromSourceDb()
        {
            try
            {
                _logger.Info($"LoadBseCmDataFromSourceDb Started");
                await _tradeViewBseCmRepository.LoadTradeviewFromSource(isDeltaLoadRequested : true);
            }
            catch (Exception ex)
            {
                _logger.Error($"LoadTradeViewDataBseCm: Exception in LoadBseCmDataFromSourceDb", ex);
            }
        }