// GET: StockMarketXML
        public ActionResult LoadList()
        {
            StockRequestInfos stockInfosFromFile = SerializationHelper.LoadXML <StockRequestInfos>(requestFilePath);

            if (stockInfosFromFile != null && stockInfosFromFile.ListOfStockRequests != null && stockInfosFromFile.ListOfStockRequests.Count > 0)
            {
                ViewBag.ListOfStocksRequested = stockInfosFromFile.ListOfStockRequests;
            }
            else
            {
                ApplicationLog.Instance.WriteWarning("Something wrong with reading request xml file");
            }
            return(View());
        }
        private static bool CreateRequestFile()
        {
            bool bFileCreated = false;

            try
            {
                String            strRawRequest        = File.ReadAllText(rowRequestFilePath);
                String[]          strStockRequestInfos = strRawRequest.Split(';');
                StockRequestInfos o_StockRequestInfos  = new StockRequestInfos();
                o_StockRequestInfos.ListOfStockRequests = new List <StockRequestInfo>();
                foreach (String strTempRequest in strStockRequestInfos)
                {
                    if (!String.IsNullOrEmpty(strTempRequest))
                    {
                        String[] t = strTempRequest.Split(' ');
                        if (!o_StockRequestInfos.ListOfStockRequests.Any(x => x.Ticker.Equals(t[0].Trim(), StringComparison.OrdinalIgnoreCase)))
                        {
                            StockRequestInfo obj = new StockRequestInfo();
                            obj.Ticker = t[0].Trim();
                            obj.URL    = t[1].Trim();
                            o_StockRequestInfos.ListOfStockRequests.Add(obj);
                        }
                    }
                }
                if (o_StockRequestInfos.ListOfStockRequests != null && o_StockRequestInfos.ListOfStockRequests.Count > 0)
                {
                    o_StockRequestInfos.ListOfStockRequests = o_StockRequestInfos.ListOfStockRequests.OrderBy(x => x.Ticker).ToList();
                    SerializationHelper.WriteXML <StockRequestInfos>(o_StockRequestInfos, requestFilePath);
                    bFileCreated = true;
                }
                else
                {
                    ApplicationLog.Instance.WriteError("List of request is not created. please check raw file");
                }
            }
            catch (Exception ex)
            {
                bFileCreated = false;
                ApplicationLog.Instance.WriteException(ex);
            }
            return(bFileCreated);
        }
        public bool RunApplication()
        {
            bool bRtnVal = false;

            try
            {
                if (!File.Exists(requestFilePath) || StockMarketRunnerStatus.CreateRequestFileBasedOnStatus())
                {
                    CreateRequestFile();
                }

                StockRequestInfos stockInfosFromFile = SerializationHelper.LoadXML <StockRequestInfos>(requestFilePath);
                if (stockInfosFromFile != null)
                {
                    List <StockRequestInfo> listOfStockInfos = stockInfosFromFile.ListOfStockRequests;
                    List <MarketValueInfo>  lstMarketValues  = new List <MarketValueInfo>();
                    foreach (StockRequestInfo stockRequestInfo in listOfStockInfos)
                    {
                        MarketValueInfo marketValue = GetTickerInfo(stockRequestInfo);
                        if (marketValue != null)
                        {
                            lstMarketValues.Add(marketValue);
                        }
                    }
                    if (lstMarketValues != null && lstMarketValues.Count > 0)
                    {
                        CreateExcel(new MarketValueInfo());
                        UpdateExcel(lstMarketValues);
                        List <EmailUtil> lst = new List <EmailUtil>()
                        {
                            new EmailUtil()
                            {
                                ToEmail = "*****@*****.**", ToName = "Sunita Gaikwad"
                            },
                            new EmailUtil()
                            {
                                ToEmail = "*****@*****.**", ToName = "Pratik outlook"
                            },
                            //new EmailUtil() { ToEmail = "*****@*****.**", ToName = "Mayur Gaikwad" }
                        };
                        foreach (EmailUtil u in lst)
                        {
                            u.Subject = String.Format("Portfolio Excel for - '{0}'", DateTime.Today.Date.ToString("MM-dd-yyyy"));
                            u.Body    = "Please find attached portfolio excel sheet for today.";
                            bool bSendEMail = EmailUtil.Instance.SendEmail(u, strAttchmentFileName: String.Format("{0}{1}.xlsx", PortfoliExcelPath, excelFileName));
                            if (bSendEMail)
                            {
                                ApplicationLog.Instance.WriteInfo(String.Format("Email sent to '{0}' at '{1}'", u.ToEmail, DateTime.Now));
                            }
                            else
                            {
                                ApplicationLog.Instance.WriteWarning(String.Format("Email NOT sent to '{0}'", u.ToEmail));
                            }
                        }
                    }
                    bRtnVal = true;
                }
                else
                {
                    ApplicationLog.Instance.WriteError("Request file not in correct format.");
                }
            }
            catch (Exception ex)
            {
                bRtnVal = false;
                ApplicationLog.Instance.WriteException(ex);
            }
            return(bRtnVal);
        }