private static void Parse(List <EquityRes> equity, XDocument doc) { XElement results = doc.Root.Element("results"); string exception = ""; foreach (EquityRes item in equity) { try { XElement q = results.Elements("quote").First(data => data.Attribute("symbol").Value == item.Symbol); BackgroundJob _BackgroundJob = GetBackgroundJob(item.EntityId, item.Symbol); _BackgroundJob.EntityID = item.EntityId; _BackgroundJob.Symbol = item.Symbol; _BackgroundJob.Ask = GetDecimal(q.Element("Ask").Value); _BackgroundJob.Bid = GetDecimal(q.Element("Bid").Value); _BackgroundJob.AverageDailyVolume = GetDecimal(q.Element("AverageDailyVolume").Value); _BackgroundJob.BookValue = GetDecimal(q.Element("BookValue").Value); _BackgroundJob.Change = GetDecimal(q.Element("Change").Value); _BackgroundJob.DividendShare = GetDecimal(q.Element("DividendShare").Value); _BackgroundJob.LastTradeDate = GetDateTime(q.Element("LastTradeDate") + " " + q.Element("LastTradeTime").Value); _BackgroundJob.EarningsShare = GetDecimal(q.Element("EarningsShare").Value); _BackgroundJob.EpsEstimateCurrentYear = GetDecimal(q.Element("EPSEstimateCurrentYear").Value); _BackgroundJob.EpsEstimateNextYear = GetDecimal(q.Element("EPSEstimateNextYear").Value); _BackgroundJob.EpsEstimateNextQuarter = GetDecimal(q.Element("EPSEstimateNextQuarter").Value); _BackgroundJob.DailyLow = GetDecimal(q.Element("DaysLow").Value); _BackgroundJob.DailyHigh = GetDecimal(q.Element("DaysHigh").Value); _BackgroundJob.YearlyLow = GetDecimal(q.Element("YearLow").Value); _BackgroundJob.YearlyHigh = GetDecimal(q.Element("YearHigh").Value); _BackgroundJob.MarketCapitalization = GetDecimal(q.Element("MarketCapitalization").Value); _BackgroundJob.Ebitda = GetDecimal(q.Element("EBITDA").Value); _BackgroundJob.ChangeFromYearLow = GetDecimal(q.Element("ChangeFromYearLow").Value); _BackgroundJob.PercentChangeFromYearLow = GetDecimal(q.Element("PercentChangeFromYearLow").Value); _BackgroundJob.ChangeFromYearHigh = GetDecimal(q.Element("ChangeFromYearHigh").Value); _BackgroundJob.LastTradePrice = GetDecimal(q.Element("LastTradePriceOnly").Value); _BackgroundJob.PercentChangeFromYearHigh = GetDecimal(q.Element("PercebtChangeFromYearHigh").Value); //missspelling in yahoo for field name _BackgroundJob.FiftyDayMovingAverage = GetDecimal(q.Element("FiftydayMovingAverage").Value); _BackgroundJob.TwoHunderedDayMovingAverage = GetDecimal(q.Element("TwoHundreddayMovingAverage").Value); _BackgroundJob.ChangeFrom200DayMovingAverage = GetDecimal(q.Element("ChangeFromTwoHundreddayMovingAverage").Value); _BackgroundJob.PercentChangeFrom200DayMovingAverage = GetDecimal(q.Element("PercentChangeFromTwoHundreddayMovingAverage").Value); _BackgroundJob.PercentChangeFrom50DayMovingAverage = GetDecimal(q.Element("PercentChangeFromFiftydayMovingAverage").Value); _BackgroundJob.Name = q.Element("Name").Value; _BackgroundJob.Open = GetDecimal(q.Element("Open").Value); _BackgroundJob.PreviousClose = GetDecimal(q.Element("PreviousClose").Value); _BackgroundJob.ChangeInPercent = GetDecimal(q.Element("ChangeinPercent").Value); _BackgroundJob.PriceSales = GetDecimal(q.Element("PriceSales").Value); _BackgroundJob.PriceBook = GetDecimal(q.Element("PriceBook").Value); _BackgroundJob.ExDividendDate = GetDateTime(q.Element("ExDividendDate").Value); _BackgroundJob.PeRatio = GetDecimal(q.Element("PERatio").Value); _BackgroundJob.DividendPayDate = GetDateTime(q.Element("DividendPayDate").Value); _BackgroundJob.PegRatio = GetDecimal(q.Element("PEGRatio").Value); _BackgroundJob.PriceEpsEstimateCurrentYear = GetDecimal(q.Element("PriceEPSEstimateCurrentYear").Value); _BackgroundJob.PriceEpsEstimateNextYear = GetDecimal(q.Element("PriceEPSEstimateNextYear").Value); _BackgroundJob.ShortRatio = GetDecimal(q.Element("ShortRatio").Value); _BackgroundJob.OneYearPriceTarget = GetDecimal(q.Element("OneyrTargetPrice").Value); _BackgroundJob.Volume = GetDecimal(q.Element("Volume").Value); _BackgroundJob.StockExchange = q.Element("StockExchange").Value; _BackgroundJob.LastUpdatedDate = DateTime.Now; _BackgroundJob.LastUpdatedBy = null; IEnumerable <ErrorInfo> errorInfo = _BackgroundJob.Save(); } catch (Exception e) { exception += e.Message; } } #region comments //foreach (Quote quote in quotes) //{ // XElement q = results.Elements("quote").First(w => w.Attribute("symbol").Value == quote.Symbol); // quote.Ask = GetDecimal(q.Element("Ask").Value); // quote.Bid = GetDecimal(q.Element("Bid").Value); // quote.AverageDailyVolume = GetDecimal(q.Element("AverageDailyVolume").Value); // quote.BookValue = GetDecimal(q.Element("BookValue").Value); // quote.Change = GetDecimal(q.Element("Change").Value); // quote.DividendShare = GetDecimal(q.Element("DividendShare").Value); // quote.LastTradeDate = GetDateTime(q.Element("LastTradeDate") + " " + q.Element("LastTradeTime").Value); // quote.EarningsShare = GetDecimal(q.Element("EarningsShare").Value); // quote.EpsEstimateCurrentYear = GetDecimal(q.Element("EPSEstimateCurrentYear").Value); // quote.EpsEstimateNextYear = GetDecimal(q.Element("EPSEstimateNextYear").Value); // quote.EpsEstimateNextQuarter = GetDecimal(q.Element("EPSEstimateNextQuarter").Value); // quote.DailyLow = GetDecimal(q.Element("DaysLow").Value); // quote.DailyHigh = GetDecimal(q.Element("DaysHigh").Value); // quote.YearlyLow = GetDecimal(q.Element("YearLow").Value); // quote.YearlyHigh = GetDecimal(q.Element("YearHigh").Value); // quote.MarketCapitalization = GetDecimal(q.Element("MarketCapitalization").Value); // quote.Ebitda = GetDecimal(q.Element("EBITDA").Value); // quote.ChangeFromYearLow = GetDecimal(q.Element("ChangeFromYearLow").Value); // quote.PercentChangeFromYearLow = GetDecimal(q.Element("PercentChangeFromYearLow").Value); // quote.ChangeFromYearHigh = GetDecimal(q.Element("ChangeFromYearHigh").Value); // quote.LastTradePrice = GetDecimal(q.Element("LastTradePriceOnly").Value); // quote.PercentChangeFromYearHigh = GetDecimal(q.Element("PercebtChangeFromYearHigh").Value); //missspelling in yahoo for field name // quote.FiftyDayMovingAverage = GetDecimal(q.Element("FiftydayMovingAverage").Value); // quote.TwoHunderedDayMovingAverage = GetDecimal(q.Element("TwoHundreddayMovingAverage").Value); // quote.ChangeFromTwoHundredDayMovingAverage = GetDecimal(q.Element("ChangeFromTwoHundreddayMovingAverage").Value); // quote.PercentChangeFromTwoHundredDayMovingAverage = GetDecimal(q.Element("PercentChangeFromTwoHundreddayMovingAverage").Value); // quote.PercentChangeFromFiftyDayMovingAverage = GetDecimal(q.Element("PercentChangeFromFiftydayMovingAverage").Value); // quote.Name = q.Element("Name").Value; // quote.Open = GetDecimal(q.Element("Open").Value); // quote.PreviousClose = GetDecimal(q.Element("PreviousClose").Value); // quote.ChangeInPercent = GetDecimal(q.Element("ChangeinPercent").Value); // quote.PriceSales = GetDecimal(q.Element("PriceSales").Value); // quote.PriceBook = GetDecimal(q.Element("PriceBook").Value); // quote.ExDividendDate = GetDateTime(q.Element("ExDividendDate").Value); // quote.PeRatio = GetDecimal(q.Element("PERatio").Value); // quote.DividendPayDate = GetDateTime(q.Element("DividendPayDate").Value); // quote.PegRatio = GetDecimal(q.Element("PEGRatio").Value); // quote.PriceEpsEstimateCurrentYear = GetDecimal(q.Element("PriceEPSEstimateCurrentYear").Value); // quote.PriceEpsEstimateNextYear = GetDecimal(q.Element("PriceEPSEstimateNextYear").Value); // quote.ShortRatio = GetDecimal(q.Element("ShortRatio").Value); // quote.OneYearPriceTarget = GetDecimal(q.Element("OneyrTargetPrice").Value); // quote.Volume = GetDecimal(q.Element("Volume").Value); // quote.StockExchange = q.Element("StockExchange").Value; // quote.LastUpdate = DateTime.Now; //} #endregion comments }