private void ProcessXmlNode(XmlNode xmlNode) { //Get the values from the xmlNode //Get the Id ID = xmlNode.SelectSingleNode("guid").InnerText; //Process description field string descString = xmlNode.SelectSingleNode("description").InnerText; //Add < and >'s descString = descString.Replace("<", "<").Replace(">", ">").Replace("<br />", "!"); string[] detailFields = descString.Split('!'); //Get the Status string statusString = detailFields[2].Substring(detailFields[2].IndexOf(':') + 2); Status = ACTFBIncidentItem.StringToIncidentStatus(statusString); //TODO: REMOVE if (Status == ACTFBStatus.Unknown) PrintString(statusString,"unkstatuslog.txt"); //Get the type string typeString = detailFields[4].Substring(detailFields[4].IndexOf(':') + 2); Type = ACTFBIncidentItem.StringToIncidentType(typeString); //TODO: REMOVE if( Type == ACTFBTypes.Unknown ) PrintString(typeString, "unktypelog.txt"); //Get the suburb string suburbString = detailFields[3].Substring(detailFields[3].IndexOf(':') + 2); if (String.IsNullOrEmpty(suburbString)) { Suburb = "<Unlocated>"; } else { Suburb = suburbString.Trim(); } //Get the location string locationString = detailFields[1].Substring(detailFields[1].IndexOf(':') + 2); if (String.IsNullOrEmpty(locationString)) { Location = "<Unlocated>"; } else { //Strip suburb Location = locationString.Substring(0, locationString.LastIndexOf(',')).Trim(); } //Get the agency string agencyString = detailFields[5].Substring(detailFields[5].IndexOf(':') + 2); Agency = agencyString.Trim(); //Get the Last update string lastUpdate = detailFields[7].Substring(detailFields[7].IndexOf(':') + 2); //Try DateTime.ParseExact, if it fails try parse try { LastUpdate = DateTime.ParseExact(lastUpdate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); } catch (FormatException) { LastUpdate = DateTime.Parse(lastUpdate); } //Get the location ( if we can ) string[] latlong = xmlNode.LastChild.InnerText.Split(' '); float lat, lon; Latitude = ""; Longitude = ""; if (float.TryParse(latlong[0], out lat) && float.TryParse(latlong[1], out lon)) { //Valid float values, check they are in the australia box if ((lat <= -10.68f && lat >= -43.64) && (lon >= 113.15 && lon <= 153.63)) { Latitude = latlong[0]; Longitude = latlong[1]; } } }
public static string IncidentTypeToString(ACTFBTypes Type) { string returnString = ""; switch (Type) { case ACTFBTypes.CarFire: returnString = "Car Fire"; break; case ACTFBTypes.MVA: returnString = "MVA"; break; case ACTFBTypes.RubbishFire: returnString = "Rubbish Fire"; break; case ACTFBTypes.StructureFire13: returnString = "Structure Fire (1 to 3 Floors)"; break; case ACTFBTypes.StructureFire47: returnString = "Structure Fire (4 to 7 Floors)"; break; case ACTFBTypes.StructureFire8plus: returnString = "Structure Fire (8+ Floors)"; break; case ACTFBTypes.HospitalsAndInstitutionsFire: returnString = "Hospital/Institutional Fire"; break; case ACTFBTypes.GasPiplineNoInj: returnString = "Gas Leak (No Reported Injuries)"; break; case ACTFBTypes.GrassAndBush: returnString = "Grass and Bush Fire"; break; case ACTFBTypes.HouseFireInj: returnString = "House Fire (Reported Injuries)"; break; case ACTFBTypes.PowerlinesDown: returnString = "Powerlines Down/Hazard"; break; case ACTFBTypes.HouseFireNoInj: returnString = "House Fire (No Reported Injuries)"; break; case ACTFBTypes.HazmatNoCBR: returnString = "Hazmat (Non CBR)"; break; case ACTFBTypes.StructureBelowGround: returnString = "Structure Fire (Below Ground)"; break; case ACTFBTypes.TransportFireBusTruck: returnString = "Bus or Truck Fire"; break; case ACTFBTypes.StructuralCollapseMinor: returnString = "Structural Collapse (Minor)"; break; case ACTFBTypes.StructuralCollapseMajor: returnString = "Structural Collapse (Major)"; break; case ACTFBTypes.LPGCylinderNoInj: returnString = "LPG Cylinder Fire (No Injuries)"; break; case ACTFBTypes.LPGCylinderInj: returnString = "LPG Cylinder Fire (Reported Injuries)"; break; default: returnString = "Unknown"; break; } return returnString; }