private void RefreshAlerts() { AlertList.Clear(); var alerts = _requestService.GetAlerts(FromDate, ToDate, null, OnlyActive); foreach (var alert in alerts) { AlertList.Add(alert); } AlertCount = AlertList.Count; OnPropertyChanged(nameof(AlertList)); }
private void OnTimedEvent(object source, ElapsedEventArgs e) { //AlertList.Add(new Alerts()); if (MonitorFlag) { foreach (UrlInfo ainfo in UrlList) { Task UpdateStatus = new Task(() => { try { ainfo.Latency += 1; string tmp = ainfo.Domain.Replace("http://", ""); ainfo.IpAddr = Dns.GetHostAddresses(tmp)[0].ToString(); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(ainfo.Domain); webRequest.AllowAutoRedirect = false; HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); //Returns "MovedPermanently", not 301 which is what I want. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); string header = Regex.Match(content, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; if (header != "") { ainfo.SiteTitle = header; } // MessageBox.Show(header); if ((ainfo.Status != response.StatusCode.ToString()) && (ainfo.Status != "-1")) { AlertList.Add(new Alerts(ainfo.Domain, "Status changes from " + ainfo.Status + " To " + response.StatusCode.ToString())); } ainfo.Status = response.StatusCode.ToString(); } catch (Exception exx) { ainfo.Status = exx.Message; //MessageBox.Show(exx.Message); } }); UpdateStatus.Start(); } } }
/// SettingsViewModel (Constructor)- Jacob Monger /// <summary> /// Sets up commands, add settings and alert limits to respective lists /// </summary> public SettingsViewModel() { UpdateSettingsCommand = new RelayCommand(UpdateSettings); UpdateAlertCommand = new RelayCommand(UpdateAlert); App.Current.Dispatcher.Invoke((Action) delegate //delegate to UI thread { SettingsList.Add(new SettingsListItemModel("ECULeftTorqueDemandXLagSpacing")); SettingsList.Add(new SettingsListItemModel("ECULeftTorqueDemandXLagMax")); SettingsList.Add(new SettingsListItemModel("ECULeftTorqueDemandXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("ECURightTorqueDemandXLagSpacing")); SettingsList.Add(new SettingsListItemModel("ECURightTorqueDemandXLagMax")); SettingsList.Add(new SettingsListItemModel("ECURightTorqueDemandXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("ECUAcclerationDemandXLagSpacing")); SettingsList.Add(new SettingsListItemModel("ECUAcclerationDemandXLagMax")); SettingsList.Add(new SettingsListItemModel("ECUAcclerationDemandXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("ECUFrontBrakeDemandXLagSpacing")); SettingsList.Add(new SettingsListItemModel("ECUFrontBrakeDemandXLagMax")); SettingsList.Add(new SettingsListItemModel("ECUFrontBrakeDemandXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("KistlerVelXXLagSpacing")); SettingsList.Add(new SettingsListItemModel("KistlerVelXXLagMax")); SettingsList.Add(new SettingsListItemModel("KistlerVelXXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("KistlerVelYXLagSpacing")); SettingsList.Add(new SettingsListItemModel("KistlerVelYXLagMax")); SettingsList.Add(new SettingsListItemModel("KistlerVelYXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationXXLagSpacing")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationXXLagMax")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationXXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationYXLagSpacing")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationYXLagMax")); SettingsList.Add(new SettingsListItemModel("KistlerAcclerationYXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("RightInverterSpeedXLagSpacing")); SettingsList.Add(new SettingsListItemModel("RightInverterSpeedXLagMax")); SettingsList.Add(new SettingsListItemModel("RightInverterSpeedXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("RightInverterMechanicalPowerXLagSpacing")); SettingsList.Add(new SettingsListItemModel("RightInverterMechanicalPowerXLagMax")); SettingsList.Add(new SettingsListItemModel("RightInverterMechanicalPowerXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("RightInverterAbsolutePhaseCurrentXLagSpacing")); SettingsList.Add(new SettingsListItemModel("RightInverterAbsolutePhaseCurrentXLagMax")); SettingsList.Add(new SettingsListItemModel("RightInverterAbsolutePhaseCurrentXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("RightInverterLinkVoltageDCXLagSpacing")); SettingsList.Add(new SettingsListItemModel("RightInverterLinkVoltageDCXLagMax")); SettingsList.Add(new SettingsListItemModel("RightInverterLinkVoltageDCXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("LeftInverterSpeedXLagSpacing")); SettingsList.Add(new SettingsListItemModel("LeftInverterSpeedXLagMax")); SettingsList.Add(new SettingsListItemModel("LeftInverterSpeedXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("LeftInverterMechanicalPowerXLagSpacing")); SettingsList.Add(new SettingsListItemModel("LeftInverterMechanicalPowerXLagMax")); SettingsList.Add(new SettingsListItemModel("LeftInverterMechanicalPowerXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("LeftInverterAbsolutePhaseCurrentXLagSpacing")); SettingsList.Add(new SettingsListItemModel("LeftInverterAbsolutePhaseCurrentXLagMax")); SettingsList.Add(new SettingsListItemModel("LeftInverterAbsolutePhaseCurrentXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("LeftInverterLinkVoltageDCXLagSpacing")); SettingsList.Add(new SettingsListItemModel("LeftInverterLinkVoltageDCXLagMax")); SettingsList.Add(new SettingsListItemModel("LeftInverterLinkVoltageDCXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("RightPCBTempXLagSpacing")); SettingsList.Add(new SettingsListItemModel("RightPCBTempXLagMax")); SettingsList.Add(new SettingsListItemModel("RightPCBTempXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("LeftPCBTempXLagSpacing")); SettingsList.Add(new SettingsListItemModel("LeftPCBTempXLagMax")); SettingsList.Add(new SettingsListItemModel("LeftPCBTempXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("TotalAverageBatteryTempXLagSpacing")); SettingsList.Add(new SettingsListItemModel("TotalAverageBatteryTempXLagMax")); SettingsList.Add(new SettingsListItemModel("TotalAverageBatteryTempXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("GearBoxTempXLagSpacing")); SettingsList.Add(new SettingsListItemModel("GearBoxTempXLagMax")); SettingsList.Add(new SettingsListItemModel("GearBoxTempXNofDataPoint")); SettingsList.Add(new SettingsListItemModel("GaugeLeftInverterSpeedMin")); SettingsList.Add(new SettingsListItemModel("GaugeLeftInverterSpeedMax")); SettingsList.Add(new SettingsListItemModel("GaugeRightInverterSpeedMin")); SettingsList.Add(new SettingsListItemModel("GaugeRightInverterSpeedMax")); SettingsList.Add(new SettingsListItemModel("GaugeLeftMechanicalPowerMin")); SettingsList.Add(new SettingsListItemModel("GaugeLeftMechanicalPowerMax")); SettingsList.Add(new SettingsListItemModel("GaugeRightMechanicalPowerMin")); SettingsList.Add(new SettingsListItemModel("GaugeRightMechanicalPowerMax")); SettingsList.Add(new SettingsListItemModel("GaugeVelocityXMin")); SettingsList.Add(new SettingsListItemModel("GaugeVelocityXMax")); SettingsList.Add(new SettingsListItemModel("GaugeVelocityYMin")); SettingsList.Add(new SettingsListItemModel("GaugeVelocityYMax")); SettingsList.Add(new SettingsListItemModel("LenghtOfAlertList")); // number of items in alert list SettingsList.Add(new SettingsListItemModel("WriteToDataLog")); // enable data logging }); App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Add(new AlertListItemModel("ECULeftTorqueDemandMax")); AlertList.Add(new AlertListItemModel("ECULeftTorqueDemandMin")); AlertList.Add(new AlertListItemModel("ECURightTorqueDemandMax")); AlertList.Add(new AlertListItemModel("ECURightTorqueDemandMin")); AlertList.Add(new AlertListItemModel("ECUAcclerationDemandMax")); AlertList.Add(new AlertListItemModel("ECUAcclerationDemandMin")); AlertList.Add(new AlertListItemModel("ECUFrontBrakeDemandMax")); AlertList.Add(new AlertListItemModel("ECUFrontBrakeDemandMin")); AlertList.Add(new AlertListItemModel("KistlerVelXMax")); AlertList.Add(new AlertListItemModel("KistlerVelXMin")); AlertList.Add(new AlertListItemModel("KistlerVelYMax")); AlertList.Add(new AlertListItemModel("KistlerVelYMin")); AlertList.Add(new AlertListItemModel("KistlerAcclerationXMax")); AlertList.Add(new AlertListItemModel("KistlerAcclerationXMin")); AlertList.Add(new AlertListItemModel("KistlerAcclerationYMax")); AlertList.Add(new AlertListItemModel("KistlerAcclerationYMin")); AlertList.Add(new AlertListItemModel("RightInverterSpeedMax")); AlertList.Add(new AlertListItemModel("RightInverterSpeedMin")); AlertList.Add(new AlertListItemModel("RightInverterMechanicalPowerMax")); AlertList.Add(new AlertListItemModel("RightInverterMechanicalPowerMin")); AlertList.Add(new AlertListItemModel("RightInverterAbsolutePhaseCurrentMax")); AlertList.Add(new AlertListItemModel("RightInverterAbsolutePhaseCurrentMin")); AlertList.Add(new AlertListItemModel("RightInverterLinkVoltageDCMax")); AlertList.Add(new AlertListItemModel("RightInverterLinkVoltageDCMin")); AlertList.Add(new AlertListItemModel("LeftInverterSpeedMax")); AlertList.Add(new AlertListItemModel("LeftInverterSpeedMin")); AlertList.Add(new AlertListItemModel("LeftInverterMechanicalPowerMax")); AlertList.Add(new AlertListItemModel("LeftInverterMechanicalPowerMin")); AlertList.Add(new AlertListItemModel("LeftInverterAbsolutePhaseCurrentMax")); AlertList.Add(new AlertListItemModel("LeftInverterAbsolutePhaseCurrentMin")); AlertList.Add(new AlertListItemModel("LeftInverterLinkVoltageDCMax")); AlertList.Add(new AlertListItemModel("LeftInverterLinkVoltageDCMin")); AlertList.Add(new AlertListItemModel("RightPCBTempMax")); AlertList.Add(new AlertListItemModel("RightPCBTempMin")); AlertList.Add(new AlertListItemModel("LeftPCBTempMax")); AlertList.Add(new AlertListItemModel("LeftPCBTempMin")); AlertList.Add(new AlertListItemModel("TotalAverageBatteryTempMax")); AlertList.Add(new AlertListItemModel("TotalAverageBatteryTempMin")); AlertList.Add(new AlertListItemModel("GearBoxTempMax")); AlertList.Add(new AlertListItemModel("GearBoxTempMin")); }); SelectAlertValue = "ECULeftTorqueDemandMax"; SelectIndexValue = "ECULeftTorqueDemandXLagSpacing"; SelectedAlertsIndex = 0; SelectedSettingsIndex = 0; }