Ejemplo n.º 1
0
 private static void CreateRequestFile()
 {
     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(' ');
                 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);
         }
         else
         {
             ApplicationLog.Instance.WriteError("List of request is not created. please check raw file");
         }
     }
     catch (Exception ex)
     {
         ApplicationLog.Instance.WriteException(ex);
     }
 }
Ejemplo n.º 2
0
        void Main()
        {
            if (!File.Exists(requestFilePath))
            {
                CreateRequestFile();
            }

            StockRequestInfos stockInfosFromFile = SerializationHelper.LoadXML <StockRequestInfos>(requestFilePath);

            if (stockInfosFromFile != null)
            {
                List <StockRequestInfo> listOfStockInfos = stockInfosFromFile.ListOfStockRequests;
                foreach (StockRequestInfo stockRequestInfo in listOfStockInfos)
                {
                    MarketValueInfo marketValue = GetTickerInfo(stockRequestInfo);
                    if (marketValue != null)
                    {
                        CreateExcel(marketValue);
                        if (!UpdateExcel(marketValue))
                        {
                            ApplicationLog.Instance.WriteError(String.Format("Excel update failed for {0}", stockRequestInfo.Ticker));
                        }
                        Console.WriteLine(String.Format("Symbole done {0}", marketValue.SYMBOL));
                    }
                }
            }
            else
            {
                ApplicationLog.Instance.WriteError("Request file not in correct format.");
            }
        }