public MFBWatchNotification(MFBIncidentItem IncidentItem, IWatchList Parent, MFBIncidentSourceOptions Options, MFBIncidentSource 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; try { //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(); //Get the xml document XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(webResponse.GetResponseStream()); //Get the first node "<markers>" XmlNode markerNode = xmlDoc.FirstChild; Dictionary<string, MFBIncidentItem> latestIncidentsList = new Dictionary<string,MFBIncidentItem>(); //Loop through the chillen foreach (XmlNode incidentEntry in markerNode.ChildNodes) { //Process the node into an incident item MFBIncidentItem newIncident = new MFBIncidentItem(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 MFBIncidentItem 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 MFBWatchNotification(oldIncident, mParentSource.GetWatchList(), mParentSource.GetOptions(), mParentSource), oldIncident); } } oldIncident.ApplicanceString = newIncident.ApplicanceString; oldIncident.Location = newIncident.Location; oldIncident.Latitude = newIncident.Latitude; oldIncident.Longitude = newIncident.Longitude; oldIncident.Status = newIncident.Status; oldIncident.Suburb = newIncident.Suburb; oldIncident.Type = newIncident.Type; //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 MFBWatchNotification(newIncident, mParentSource.GetWatchList(), mParentSource.GetOptions(), mParentSource), newIncident); } //Its a new Incident, add it to list and tooltip mIncidents.Add(newIncident.ID, newIncident); mToolTipText += "MFB: "+MFBIncidentItem.IncidentTypeToString(newIncident.Type) + "." + newIncident.Location + "," + newIncident.Suburb + "\n"; //Add appliances foreach (string str in newIncident.Appliances) { mToolTipText += "\t" + MFBWatchNotification.DecodeApplianceCode(str).Trim() + "\n"; } } } //Check for Stops foreach (KeyValuePair<string,MFBIncidentItem> existingInci in mIncidents) { if (existingInci.Value.Status != MFBIncidentItem.MFBStatus.Stop) { //We arn't stopped so may be set to this if (latestIncidentsList.ContainsKey(existingInci.Key) == false) { //This incident is no longer in the list, so set its status to stop, and set the number of appliances to 0 existingInci.Value.Status = MFBIncidentItem.MFBStatus.Stop; existingInci.Value.ApplicanceString = "[]"; } } } //No Problems encountered if( fNewIncident == true && mFirstUpdate == false ) mParentSource.GetIncidentWatcher().PlayNoise(NoiseType.NewIncident); mFirstUpdate = false; return true; } catch { return false; } }
private bool CheckType(MFBIncidentItem Incident) { //Get Values from the list foreach (string s in mSourceSettings.AutoWatchTypes) { //Get the type MFBIncidentItem.MFBTypes watchType = (MFBIncidentItem.MFBTypes)Enum.Parse(typeof(MFBIncidentItem.MFBTypes), s); //Does it match if (Incident.Type == watchType) return true; } //No Matches return false; }
private bool CheckSuburb(MFBIncidentItem 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(MFBIncidentItem Incident) { //Get Values from the list foreach (string s in mSourceSettings.AutoWatchStatuses) { //Get the type MFBIncidentItem.MFBStatus watchStatus = (MFBIncidentItem.MFBStatus)Enum.Parse(typeof(MFBIncidentItem.MFBStatus), s); //Does it match if (Incident.Status == watchStatus) return true; } //No matches return false; }
private bool CheckApplianceAndCount(MFBIncidentItem Incident) { //Check the count first if (Incident.ApplianceCount_GENERIC >= mSourceSettings.AutoWatchApplianceCount) return true; //Check all the appliance names //Get Values from the list foreach (string s in mSourceSettings.AutoWatchAppliances) { foreach (string app in Incident.Appliances) { //Does it match if (s == "*")//Match all return true; if (Regex.IsMatch(app, s, RegexOptions.IgnoreCase)) return true; } } //No matches return false; }
internal string ReplaceInciWatchVarsInString(string oldString, MFBIncidentItem 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, MFBIncidentItem OldIncident,MFBIncidentItem 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; } //Appliance Stuff if (OldIncident.ApplicanceString != NewUpdate.ApplicanceString) { if (CheckApplianceAndCount(NewUpdate) == true) return true; } return false; }
public bool ShouldWeAutowatch(bool NewIncident, MFBIncidentItem 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; //Appliance Stuff if (CheckApplianceAndCount(Incident) == true) return true; return false; }