public ACTFBWatchNotification(ACTFBIncidentItem IncidentItem, IWatchList Parent, ACTFBIncidentSourceOptions Options, ACTFBIncidentSource ParentSource) { InitializeComponent(); mIncidentItem = IncidentItem; mParent = Parent; mOptions = Options; mParentSource = ParentSource; mfFadeOut = true; UpdateDialog(); //Check if a stream exists for this region if (String.IsNullOrEmpty(mOptions.StreamURL) == false && String.IsNullOrEmpty(mParentSource.GetIncidentWatcher().GetStreamListenerPath()) == false) { //If we have it set to open the stream if (mParentSource.GetIncidentWatcher().GetAutoOpenStreamOnWatch() == true) { OpenStream(); } } }
private bool UpdateIncidentList() { bool fNewIncident = false; //Create a request for the xml file HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(mParentSource.GetOptions().IncidentSourceURL); //Set the proxy if there is one if (mParentSource.GetIncidentWatcher().UsesProxy() == true) { webRequest.Proxy = mParentSource.GetIncidentWatcher().GetProxy(); } //Get the response as an xml file HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.ContentLength == 0) return false; //Get the xml document XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(webResponse.GetResponseStream()); //Get the first node "<rss><channel>" XmlNode markerNode = xmlDoc.SelectSingleNode("rss").ChildNodes[0]; Dictionary<string, ACTFBIncidentItem> latestIncidentsList = new Dictionary<string,ACTFBIncidentItem>(); //Loop through the chillen foreach (XmlNode incidentEntry in markerNode.SelectNodes("item")) { //Process the node into an incident item ACTFBIncidentItem newIncident = new ACTFBIncidentItem(mParentSource, incidentEntry); //Add the new incident to the existing incident list for checking latestIncidentsList.Add(newIncident.ID, newIncident); //Add the incident or update it if (mIncidents.ContainsKey(newIncident.ID) == true) { //This incident already exists, update the entry values ACTFBIncidentItem oldIncident = mIncidents[newIncident.ID]; //Is it already being watched? if (mParentSource.GetWatchList().IsKeyBeingWatched(oldIncident.ID_GENERIC) == false) { //Should we auto watch if (mParentSource.GetOptions().ShouldWeAutowatch(false, oldIncident, newIncident) == true) { //Make autowatch noise mParentSource.GetIncidentWatcher().PlayNoise(NoiseType.NewAutowatch); mParentSource.GetWatchList().Add(new ACTFBWatchNotification(oldIncident, mParentSource.GetWatchList(), mParentSource.GetOptions(), mParentSource), oldIncident); } } oldIncident.Location = newIncident.Location; oldIncident.Latitude = newIncident.Latitude; oldIncident.Longitude = newIncident.Longitude; oldIncident.Status = newIncident.Status; oldIncident.Suburb = newIncident.Suburb; oldIncident.Type = newIncident.Type; oldIncident.LastUpdate = newIncident.LastUpdate; //Reseat the old incident mIncidents[newIncident.ID] = oldIncident; } else { //Set flag to Make a noise fNewIncident = true; //Check for autowatch if( mParentSource.GetOptions().ShouldWeAutowatch( true, newIncident) == true) { //Make a noise mParentSource.GetIncidentWatcher().PlayNoise(NoiseType.NewAutowatch); //Add watch mParentSource.GetWatchList().Add(new ACTFBWatchNotification(newIncident, mParentSource.GetWatchList(), mParentSource.GetOptions(), mParentSource), newIncident); } //Its a new Incident, add it to list and tooltip mIncidents.Add(newIncident.ID, newIncident); mToolTipText += "ACTFB: "+ACTFBIncidentItem.IncidentTypeToString(newIncident.Type) + "." + newIncident.Location + "," + newIncident.Suburb + "\n"; } } //No Problems encountered if( fNewIncident == true && mFirstUpdate == false ) mParentSource.GetIncidentWatcher().PlayNoise(NoiseType.NewIncident); mFirstUpdate = false; return true; }
private bool CheckType(ACTFBIncidentItem Incident) { //Get Values from the list foreach (string s in mSourceSettings.AutoWatchTypes) { //Get the type ACTFBIncidentItem.ACTFBTypes watchType = (ACTFBIncidentItem.ACTFBTypes)Enum.Parse(typeof(ACTFBIncidentItem.ACTFBTypes), s); //Does it match if (Incident.Type == watchType) return true; } //No Matches return false; }
private bool CheckSuburb(ACTFBIncidentItem Incident) { //Get Values from the list foreach (string s in mSourceSettings.AutoWatchSuburbs) { //Does it match if (s == "*")//Match all return true; if (Regex.IsMatch(Incident.Suburb, s, RegexOptions.IgnoreCase)) return true; } //No matches return false; }
private bool CheckStatus(ACTFBIncidentItem Incident) { //Get Values from the list foreach (string s in mSourceSettings.AutoWatchStatuses) { //Get the type ACTFBIncidentItem.ACTFBStatus watchStatus = (ACTFBIncidentItem.ACTFBStatus)Enum.Parse(typeof(ACTFBIncidentItem.ACTFBStatus), s); //Does it match if (Incident.Status == watchStatus) return true; } //No matches return false; }
internal string ReplaceInciWatchVarsInString(string oldString, ACTFBIncidentItem IncidentItem) { String returnString; returnString = oldString; //Do Replaces //ID returnString = returnString.Replace("%ID%", IncidentItem.ID); //SUBURB returnString = returnString.Replace("%SUBURB%", IncidentItem.Suburb); //REGION returnString = returnString.Replace("%REGION%", IncidentItem.Region_GENERIC); //ADDR returnString = returnString.Replace("%ADDR%", IncidentItem.Location); //TYPE returnString = returnString.Replace("%TYPE%", IncidentItem.Type.ToString()); //STREAM returnString = returnString.Replace("%STREAM%", this.StreamURL); //STATUS returnString = returnString.Replace("%STATUS%", IncidentItem.Status.ToString()); //SIZE returnString = returnString.Replace("%SIZE%", IncidentItem.Size_GENERIC); //LAST Updated returnString = returnString.Replace("%LASTUP%", IncidentItem.LastUpdate.ToString("yyyy-MM-dd_HH-mm-ss")); //APPLIANCE returnString = returnString.Replace("%APPLIANCES%", IncidentItem.ApplianceCount_GENERIC.ToString()); //CURTIME returnString = returnString.Replace("%CURTIME%", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")); //Return adjusted string return returnString; }
public bool ShouldWeAutowatch(bool NewIncident, ACTFBIncidentItem OldIncident,ACTFBIncidentItem NewUpdate) { //Check if autowatch is enabled? if (mSourceSettings.AutoWatchEnabled == false) return false; //Suburb //Was there a change? if (OldIncident.Suburb != NewUpdate.Suburb) { if (CheckSuburb(NewUpdate) == true) return true; } //Location if (OldIncident.Location != NewUpdate.Location) { if (CheckLocation(NewUpdate) == true) return true; } //Status if (OldIncident.Status != NewUpdate.Status) { if (CheckStatus(NewUpdate) == true) return true; } //Incident if (OldIncident.Type != NewUpdate.Type) { if (CheckType(NewUpdate) == true) return true; } return false; }
public bool ShouldWeAutowatch(bool NewIncident, ACTFBIncidentItem Incident) { //Check if autowatch is enabled? if (mSourceSettings.AutoWatchEnabled == false) return false; //Suburb if (CheckSuburb(Incident) == true) return true; //Location if (CheckLocation(Incident) == true) return true; //Status if (CheckStatus(Incident) == true) return true; //Incident if (CheckType(Incident) == true) return true; return false; }