public static void addWazeData(wazeXML x) { wazeXML found = wazes.Find(delegate(wazeXML find) { return(find.uuid == x.uuid); }); if (found == null) //only add if we don't already have one with the same uuid { x.dispatched = false; x.acked = false; x.accepted = false; wazes.Add(x); SQL.SQLCode sql = new SQL.SQLCode(); sql.logIncomingWaze(x); } else { found.city = x.city; found.confidence = x.confidence; found.country = x.country; found.lat = x.lat; found.lon = x.lon; found.nThumbsUp = x.nThumbsUp; found.pubDate = x.pubDate; found.reliability = x.reliability; found.reportRating = x.reportRating; found.roadType = x.roadType; found.segment = x.segment; found.street = x.street; found.subtype = x.subtype; found.title = x.title; found.type = x.type; found.uuid = x.uuid; } }
public static void readWazes() { XDocument doc = XDocument.Load(URIXML); var matches = doc.Descendants("item"); List <wazeXML> xList = new List <wazeXML>(); foreach (var x in matches) { wazeXML w = new wazeXML(); //int orderID = Convert.ToInt32(orderXML.Element("ID").Value); foreach (XElement xl in x.Elements()) { string name = xl.Name.ToString(); if (name.Contains("title")) { w.title = xl.Value; } if (name.Contains("type")) { w.type = xl.Value; } if (name.Contains("subtype")) { w.subtype = xl.Value; } if (name.Contains("pubDate")) { w.pubDate = makeDT(xl.Value); } if (name.Contains("uuid")) { w.uuid = xl.Value; } if (name.Contains("confidence")) { w.confidence = Convert.ToInt32(xl.Value); } if (name.Contains("point")) { w.lat = getLat(xl.Value); w.lon = getLon(xl.Value); string segment = BeatData.BeatSegments.findBeatSeg(w.lat, w.lon); if (segment != "NOT FOUND") { w.segment = segment; } } if (name.Contains("nThumbsUp")) { w.nThumbsUp = Convert.ToInt32(xl.Value); } if (name.Contains("reliability")) { w.reliability = Convert.ToInt32(xl.Value); } if (name.Contains("street")) { w.street = xl.Value; } if (name.Contains("city")) { w.city = xl.Value; } if (name.Contains("country")) { w.country = xl.Value; } if (name.Contains("roadType")) { w.roadType = Convert.ToInt32(xl.Value); } if (name.Contains("reportRating")) { w.reportRating = Convert.ToInt32(xl.Value); } } if (valids.Contains(w.type) && DateTime.Now.AddMinutes(-90) < w.pubDate && validRoads.Contains(w.roadType) && w.confidence >= minConfidence && w.reliability >= minReliability && !String.IsNullOrEmpty(w.segment)) { addWazeData(w); } } //checkSegs(); clearBadWazes(); checkForDispatches(); }