Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dbOps = (DBOperations)Application["dbOps"];
        rssReader = (RssReader)Application["rssReader"];
        gui = (GUIVariables)Application["gui"];
        links = (Links)Application["links"];
        engine = (ProcessingEngine)Application["engine"];

        //  username = Convert.ToString(Session["username"]);

        if (Request.Cookies["stoockerCookie"] != null)
        {
            HttpCookie stoockerCookie = Request.Cookies["stoockerCookie"];
            username = dbOps.Decrypt(stoockerCookie["username"].ToString().Trim());
        }

        if (string.IsNullOrEmpty(username))
        {
            Response.Redirect(links.SessionExpiredPageLink);
        }
        else
        {
            upPredict = (int)ProcessingEngine.Movement.Up;
            downPredict = (int)ProcessingEngine.Movement.Down;

            yesterday = DateTime.Now.AddDays(-1).ToString(dateFormatString);
            today = DateTime.Now.ToString(dateFormatString);
            tomorrow = DateTime.Now.AddDays(+1).ToString(dateFormatString);

            //  If Today=Friday Then Tomorrow=Monday. Why? Because Stock Markets are closed on Weekends.
            if (DateTime.Now.DayOfWeek == DayOfWeek.Friday || DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                if (DateTime.Now.DayOfWeek == DayOfWeek.Friday)
                    tomorrow = DateTime.Now.AddDays(+3).ToString(dateFormatString);
                if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
                    tomorrow = DateTime.Now.AddDays(+2).ToString(dateFormatString);
                if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                    tomorrow = DateTime.Now.AddDays(+1).ToString(dateFormatString);
            }

            symbol = Convert.ToString(Request.QueryString["stock"]);
            if (string.IsNullOrEmpty(symbol))
            {
                Response.Redirect(links.HomePageLink);
            }
            else
            {
                StockDetailsLabel.Text = LoadStockDetails(symbol);
                LoadYahooFinanceBadgeIFrame(symbol);

                string newsFeeds = rssReader.LoadPerStockNews(symbol);
                if (!string.IsNullOrEmpty(newsFeeds))
                {
                    NewsMessageLabel.Text = gui.BoldFontStart + "Latest News & Recommended Readings from " + gui.StoocksFont + gui.BoldFontEnd;
                    NewsLabel.Text = newsFeeds;
                }
            }
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dbOps = (DBOperations)Application["dbOps"];
        rssReader = (RssReader)Application["rssReader"];
        gui = (GUIVariables)Application["gui"];
        stockService = (StockService)Application["stockService"];
        links = (Links)Application["links"];
        general = (General)Application["general"];
        engine = (ProcessingEngine)Application["engine"];

        //  username = Convert.ToString(Session["username"]);
        //  username = "******";

        if (Request.Cookies["stoockerCookie"] != null)
        {
            HttpCookie stoockerCookie = Request.Cookies["stoockerCookie"];
            username = dbOps.Decrypt(stoockerCookie["username"].ToString().Trim());
        }

        if (string.IsNullOrEmpty(username))
        {
            Response.Redirect(links.SessionExpiredPageLink);
        }
        else
        {
            upPredict = (int)ProcessingEngine.Movement.Up;
            downPredict = (int)ProcessingEngine.Movement.Down;

            yesterday = DateTime.Now.AddDays(-1).ToString(dateFormatString);
            today = DateTime.Now.ToString(dateFormatString);
            tomorrow = DateTime.Now.AddDays(+1).ToString(dateFormatString);

            //  If Today=Friday Then Tomorrow=Monday. Why? Because Stock Markets are closed on Weekends.
            if (DateTime.Now.DayOfWeek == DayOfWeek.Friday || DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                if (DateTime.Now.DayOfWeek == DayOfWeek.Friday)
                    tomorrow = DateTime.Now.AddDays(+3).ToString(dateFormatString);
                if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
                    tomorrow = DateTime.Now.AddDays(+2).ToString(dateFormatString);
                if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                    tomorrow = DateTime.Now.AddDays(+1).ToString(dateFormatString);
            }

            string welcomeMessage = gui.BoldFontStart + "Welcome to" + gui.StoocksFont + gui.BoldFontEnd;
            WelcomeLabel.Text = welcomeMessage;

            //  Trace.Write("Enter LoadCommonIndicesData");
            LoadCommonIndicesData();
            //  Trace.Write("Exit LoadCommonIndicesData");

            Trace.Write("Enter ShowAlreadySelectedStocks");
            interestedStocks = ShowAlreadySelectedStocks(username);
            Trace.Write("Exit ShowAlreadySelectedStocks");

            if (!string.IsNullOrEmpty(alreadySelectedStocks))
            {
                Trace.Write("Enter LoadYahooFinanceBadgeIFrame");
                LoadYahooFinanceBadgeIFrame(alreadySelectedStocks);
                Trace.Write("Exit LoadYahooFinanceBadgeIFrame");
            }

            //  if (!Page.IsPostBack)
            {
                Trace.Write("Enter LoadUserData");
                UserDetailsLabel.Text = LoadUserData(username);
                Trace.Write("Exit LoadUserData");

                if (isShowUserStockData)
                {
                    Trace.Write("Enter LoadCurrentData");
                    LoadCurrentData();
                    Trace.Write("Exit LoadCurrentData");
                }

                MessageLabel.Text = "";

                Trace.Write("Enter LoadNews");
                string newsFeeds = "";
                if (isGenericNews)      //  Show the same News for all Users, Do Cache, Update every 30 minutes.
                {
                    newsFeeds = rssReader.LoadPerStockNews(alreadySelectedStocks);
                }
                else
                {
                    newsFeeds = rssReader.LoadGenericNews("", false);
                }
                Trace.Write("Exit LoadNews");

                if (!string.IsNullOrEmpty(newsFeeds))
                {
                    NewsMessageLabel.Text = gui.BoldFontStart + "Latest News & Recommended Readings from " + gui.StoocksFont + gui.BoldFontEnd;
                    NewsLabel.Text = newsFeeds;
                }
            }
        }
    }