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

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

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

                await _tradeViewNseFoRepository.LoadTradeviewFromSource(dateTimeVal : dateVal);

                _log.Info($"SyncNseFoTrades Finished");
                return(Ok(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                _log.Error("Error in SyncBseCmTrades ", ex);
                return(StatusCode(500));
            }
        }
Exemple #2
0
        //public Task LoadNseFoDataFromSourceDb()
        //{
        //    try
        //    {
        //        _logger.Info($"Inside LoadNseFoDataFromSourceDb");
        //        var cts = new CancellationTokenSource();
        //        if (!LoadTradeviewDataNseFo.isSyncDataStarted)
        //        {
        //            _logger.Info($"Intializing AutoSync");
        //            LoadTradeviewDataNseFo.isSyncDataStarted = true;
        //            Task t = Task.Factory.StartNew(
        //            async () =>
        //            {
        //                while (LoadTradeviewDataNseFo.isSyncDataStarted)
        //                {
        //                    cts.Token.ThrowIfCancellationRequested();
        //                    try
        //                    {
        //                        await _tradeViewNseFoRepository.LoadTradeviewFromSource(isDeltaLoadRequested: true);
        //                        await Task.Delay(60000, cts.Token);
        //                    }
        //                    catch (TaskCanceledException ex)
        //                    {
        //                        _logger.Error($"Exception in LoadNseCmDataFromSourceDb ", ex);
        //                    }
        //                }
        //                _logger.Info($"LoadNseFoDataFromSourceDb: 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 LoadNseFoDataFromSourceDb()
        {
            try
            {
                _logger.Info($"Inside LoadNseFoDataFromSourceDb");
                await _tradeViewNseFoRepository.LoadTradeviewFromSource(isDeltaLoadRequested : true);
            }
            catch (Exception ex)
            {
                _logger.Error($"Exception in LoadNseCmDataFromSourceDb", ex);
            }
        }