Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);

            Console.WriteLine("CTRL+C,CTRL+BREAK to exit");



            MarketingEntities          entity = new MarketingEntities();
            MarketingCalcServiceCaller mcsc   = new MarketingCalcServiceCaller();

            DateTime dt;
            String   portfolioId = null;

            if (args != null && args.Length > 0)
            {
                if (DateTime.TryParse(args[0], out dt))
                {
                    //do nothing
                }
                else
                {
                    Console.WriteLine("Bad date format");
                    //return ;
                }
                if (args.Length > 1 && args[1] != null)
                {
                    portfolioId = args[1];
                }
            }
            else
            {
                dt = getPreviousMonthEndDate();
            }

            int holdingCount = entity.GF_PORTFOLIO_LTHOLDINGS_HISTORY.Where(g => g.PORTFOLIO_DATE == dt).Count();

            if (holdingCount == 0)
            {
                Console.WriteLine(DateTime.Now + " There are  no holdings in  GF_PORTFOLIO_LTHOLDINGS_HISTORY table for the date  " + dt.ToString());
                // return;
                Environment.Exit(-1);
            }

            int securityCount = entity.GF_SECURITY_BASEVIEW_HISTORY.Where(g => g.EFFECTIVE_DATE == dt).Count();

            if (securityCount == 0)
            {
                Console.WriteLine(DateTime.Now + " There are  no securities in  GF_SECURITY_BASEVIEW_HISTORY table for the date  " + dt.ToString());
                //return ;
                Environment.Exit(-1);
            }

            int pfCount = entity.PERIOD_FINANCIALS_HISTORY.Where(g => g.EFFECTIVE_DATE == dt).Count();

            if (pfCount == 0)
            {
                Console.WriteLine(DateTime.Now + " There are  no data in  PERIOD_FINANCIALS_HISTORY table for the date  " + dt.ToString());
                //return ;
                Environment.Exit(-1);
            }


            if (portfolioId == null)
            {
                List <GetPortfolioList_Result> pf = entity.GetPortfolioList().ToList();

                foreach (var portfolio in pf)
                {
                    mcsc.CallService(portfolio.portfolio_id, dt);
                    if (isclosing)
                    {
                        Console.WriteLine("External intervention stopped gracefull ");
                        //break;
                        Environment.Exit(-2);
                    }
                }
            }
            else
            {
                if (portfolioId.Equals("ALL"))
                {
                    List <GetPortfolioList_Result> pf = entity.GetPortfolioList().ToList();
                    foreach (var portfolio in pf)
                    {
                        mcsc.CallService(portfolio.portfolio_id, dt);
                        if (isclosing)
                        {
                            Console.WriteLine("External intervention stopped gracefully ");
                            //break;
                            Environment.Exit(-2);
                        }
                    }
                }
                else
                {
                    mcsc.CallService(portfolioId, dt);
                }
            }
        }