Ejemplo n.º 1
0
        public void IntradayManager()
        {
            var    config    = new Utils().ReadTokensAppsettings();
            string outputMsg = "Running Intraday Service...";
            string status    = "R";
            string asset     = string.Empty;

            List <AssetItem> listAssets = new ProcessingAssetRepository().ProcessingAssetList();

            for (int y = 0; y < listAssets.Count; y++)
            {
                //RequestApi
                Intraday intraday = new IntradayController().GetIntraday(listAssets[y].idt);

                if (intraday.data != null)
                {
                    for (int x = 0; x < intraday.data.Count; x++)
                    {
                        bool dataVerification = new IntradayRepository().IntradayVerification(intraday.data[x].date, listAssets[y].idt);
                        if (!dataVerification)
                        {
                            new IntradayRepository().Save(listAssets[y].idt, intraday.data[x]);
                        }
                    }
                }
                new StockQuoteMenu().RunningIntradayScreen(outputMsg, status, $"PROCESS: {listAssets[y].asset}");
            }

            // Minutos para proxima rodada
            string WaitMinutesSetting = config.GetSection("Settings:IntradayWaitMinutes").Value;
            int    waitMinutes        = new Utils().ConvertStringToInt(WaitMinutesSetting);

            new StockQuoteMenu().RunningIntradayScreen("Waiting...", "W", $"Next Process: {DateTime.Now.AddMinutes(waitMinutes)}");
            Thread.Sleep(new Utils().ConvertMinutesToMillis(waitMinutes));
        }
Ejemplo n.º 2
0
        public void InterdayManager(DateTime begintDate, DateTime endDate, bool loadListAsset = default(bool))
        {
            new StockQuoteMenu().RunInterday($"Start Date: {string.Format("{0:d}", begintDate)} ~ End Data: {string.Format("{0:d}", endDate)}\n\n");

            List <AssetItem> listAssets;

            if (loadListAsset)
            {
                listAssets = new ProcessingAssetRepository().ProcessingAssetList();
            }
            else
            {
                listAssets = new AssetRepository().GetAllAssets();
            }

            for (int y = 0; y < listAssets.Count; y++)
            {
                Interday interday = new Interday();
                try
                {
                    //RequestApi
                    interday = new InterdayController().GetInterday(listAssets[y].idt, begintDate, endDate);
                }
                catch (Exception exReq)
                {
                    new LineColorLine().PrintResult($"{listAssets[y].asset} - {listAssets[y].companyAbvName}", StatusScreen.Error);
                    new ExceptionRepository().Save($"{listAssets[y].asset} || Interday Request Error --> {exReq.Message}");
                }

                try
                {
                    if (interday.data != null)
                    {
                        for (int x = 0; x < interday.data.Count; x++)
                        {
                            bool dataVerification = new InterdayRepository().InterdayVerification(interday.data[x].date, listAssets[y].idt);
                            if (!dataVerification)
                            {
                                new InterdayRepository().Save(listAssets[y].idt, interday.data[x]);
                            }
                        }
                    }
                    new LineColorLine().PrintResult($"{listAssets[y].asset} - {listAssets[y].companyAbvName}", StatusScreen.Success);
                }
                catch (Exception exReqBD)
                {
                    new LineColorLine().PrintResult($"{listAssets[y].asset} - {listAssets[y].companyAbvName}", StatusScreen.Warning);
                    new ExceptionRepository().Save($"{listAssets[y].asset} || Interday Repository Error --> {exReqBD.Message}");
                }
            }

            new MainMenu().GoBackMainMenu();
        }
Ejemplo n.º 3
0
        private void RenderAssetList(string outputMsg = null, string status = null)
        {
            Console.Clear();
            new LineColorLine().Bold("\n\nLoading Assets...");
            List <string> assetList = new ProcessingAssetRepository().AssetList();

            Console.Clear();
            new LineColorAlert().Render(outputMsg, status);
            Console.WriteLine("\n");
            Console.WriteLine("╔═══════════════════════════════════════════════╗");
            Console.WriteLine("║                                               ║");

            foreach (string asset in assetList)
            {
                new LineColorLine().White("\t" + asset + "\n");
            }
        }
Ejemplo n.º 4
0
        public Tuple <string, string> RemoveAssetOnProcessingList(string inputAssetCode)
        {
            string outputMsg = string.Empty;
            string status    = string.Empty;

            //Verifica se o ativo já esta cadastrado
            bool vefAsset = new ProcessingAssetRepository().AssetVerification(inputAssetCode);

            if (vefAsset)
            {
                new ProcessingAssetRepository().Delete(inputAssetCode);
                outputMsg = $"Ativo {inputAssetCode} removido com sucesso!";
                status    = "S";
            }
            else
            {
                outputMsg = $"Ativo {inputAssetCode} não encontrado";
                status    = "W";
            }

            return(Tuple.Create(outputMsg, status));
        }