public async Task ListsAlerts(int propertyAlertCount, int personAlertCount) { // Arrange string expectedPropertyReference = new Faker().Random.Number().ToString(); AlertList alertList = new AlertList { PropertyAlerts = StubPropertyAlertList(expectedPropertyReference, propertyAlertCount), PersonAlerts = new PersonAlertList { Alerts = StubAlerts().Generate(personAlertCount) } }; _listAlertsUseCaseMock.Setup(m => m.ExecuteAsync(It.IsAny <string>())).ReturnsAsync(alertList); // Act var result = await _classUnderTest.ListCautionaryAlerts(expectedPropertyReference); var alertResult = GetResultData <CautionaryAlertResponseList>(result); var statusCode = GetStatusCode(result); // Assert statusCode.Should().Be(200); alertResult.LocationAlert.Should().HaveCount(propertyAlertCount); alertResult.PersonAlert.Should().HaveCount(personAlertCount); alertResult.PropertyReference.Should().Be(expectedPropertyReference); }
private void BtnAlertList_Click(object sender, EventArgs e) { using (AlertList alertList = new AlertList()) { alertList.ShowDialog(); } }
public void PlayAlert(AlertList alert) { AudioSource emitterAvailable = null; foreach (AudioSource emitter in emitters) { if (!emitter.isPlaying) { emitterAvailable = emitter; emitterAvailable.volume = 1.0f; break; } } if (emitterAvailable != null) { emitterAvailable.loop = false; switch (alert) { case AlertList.BTN_VALIDATION: emitterAvailable.clip = ButtonValidation; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; case AlertList.GOLD_HAMMER: emitterAvailable.volume = 0.8f; emitterAvailable.clip = Winner; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; case AlertList.POINT_LVL1: emitterAvailable.clip = PointLvl1; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; case AlertList.POINT_LVL2: emitterAvailable.clip = PointLvl2; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; case AlertList.POINT_LVL3: emitterAvailable.clip = PointLvl3; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; case AlertList.EXIT_GAME: emitterAvailable.clip = ExitGame; emitterAvailable.outputAudioMixerGroup = AudioConfig.Instance.alert; break; } emitterAvailable.Play(); } else { Debug.Log("no emitter available"); } }
public static CautionaryAlertResponseList ToResponse(this AlertList domain) { return(new CautionaryAlertResponseList() { PropertyReference = domain.PropertyAlerts.PropertyReference, LocationAlert = domain.PropertyAlerts.Alerts.Select(alert => alert.ToResponse()).ToList(), PersonAlert = domain.PersonAlerts.Alerts.Select(alert => alert.ToResponse()).ToList() }); }
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)); }
/// OnAlerted (event) - Jacob Monger /// <summary> /// adds or removes flag stating if alert limit was excided /// </summary> /// <param name="source"> alert view model.</param> /// <param name="e"> data structure see alert view model.</param> public void OnAlerted(object source, AlertEventArgs e) { if (e.NewAlert == true) // is there a new alert { for (int ListPosition = 0; ListPosition < AlertList.Count(); ListPosition++) { if (AlertList[ListPosition].AlertName == e.AlertName) // find alert limit { if (e.AlertName.Contains("Max")) { if (e.AlertValue > AlertList[ListPosition].Threshold || AlertList[ListPosition].ThresholdToDisplay == null) // if bigger up date { App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(e.AlertName, " (Exceeded ", e.AlertValue.ToString("0.00") + ")", e.AlertValue)); }); } } if (e.AlertName.Contains("Min")) { if (e.AlertValue < AlertList[ListPosition].Threshold || AlertList[ListPosition].ThresholdToDisplay == null) // if smaller upadte { App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(e.AlertName, " (Exceeded ", e.AlertValue.ToString("0.00") + ")", e.AlertValue)); }); } } return; } } } else { for (int ListPosition = 0; ListPosition < AlertList.Count(); ListPosition++) // clear all flags { if (AlertList[ListPosition].Exceeded != null) { string temporyName = AlertList[ListPosition].AlertName; App.Current.Dispatcher.Invoke((Action) delegate { AlertList.Remove(AlertList[ListPosition]); AlertList.Insert(ListPosition, new AlertListItemModel(temporyName)); }); } } } }
private void BtnNew_Click(GameObject map) { Cancel(); CameraControls cameraControls = new CameraControls(Camera.main); new Inventory(); MapGenerator mapGenerator = new MapGenerator(map); new AI.Waypoint(map, canvas); new AI.Road(map, canvas); new Menu(map, canvas); AlertList alertList = new AlertList(canvas); AlertList.NewAlert("UI_ALERT_TEST", "mug", null); }
// 자바스크립트에 배열로 데이터를 만들어줘야하기때문에 // 챠트의 데이터를 각각의 템플릿필드 헤더값으로 패핑해서 뿌려주게 만듬 dictionary<헤더값,챠트데이터배열> override protected void Page_Load(object sender, EventArgs e) { //strGroupName = HttpUtility.HtmlDecode(Request["grname"].ToString()); cloud = new DB.Cloud(); litScript.Text = ""; base.Page_Load(sender, e); base.ReDirect(); BindData(); if (!IsPostBack) { AlertList.InitControl(); } AlertList.Company = CompanyNum; AlertList.Member = MemberNum; AlertList.dt_AlertList = dt_Alert; }
public async Task <ActionResult> ListSubmit(AlertList model) { var actionData = this.GetActionData(); switch (actionData?.ActionName) { case Actions.MarkAllComplete: await AlertAdminService.AcknowledgeAlertsAsync(); break; } this.SetPagingState(ModelFactory.CreatePagingStateFilter(model.Filter)); model = await GetAlertListAsync(); return(View("List", model)); }
/// UpdateAlert (command) - Jacob Monger /// <summary> /// if valid updates setting, removes alert from alert list if flagged /// </summary> /// <param name="message"> user input</param> public void UpdateAlert(object message) { if (SelectedAlertsIndex != -1) { if (double.TryParse(message.ToString(), out double newValue)) { if (AlertList[SelectedAlertsIndex].ThresholdToDisplay != null) { AlertViewModelInstance.RemoveAlert(AlertList[SelectedAlertsIndex].AlertName); } String AlertName = AlertList[SelectedAlertsIndex].AlertName; Properties.Settings.Default[AlertName] = newValue; //convert.ToDouble(null); Properties.Settings.Default.Save(); AlertList.Remove(AlertList[SelectedAlertsIndex]); AlertList.Insert(SelectedAlertsIndex, new AlertListItemModel(AlertName)); } } }
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(); } } }
public async static Task <List <Alert> > getAlerts() { if (Database.alertsLoaded) { return(Database.alertList); } string url = globalURL + "/alerts?sort=-severity&include=stops,routes,trips&filter[activity]" + "=BOARD,EXIT,RIDE"; string response = await DataFetcher.fetchData(url); AlertList raw_data = JsonConvert.DeserializeObject <AlertList>(response); List <Alert> alertList = new List <Alert>(); for (int i = 0; i < raw_data.data.Length; i++) { alertList.Add(raw_data.data[i]); } Database.alertsLoaded = true; return(alertList); }
public AlertList(GameObject gameObject) { alertPrefab = Resources.Load("Prefabs/Alert", typeof(GameObject)) as GameObject; GameObject alertContainer = new GameObject("alertContainer"); RectTransform rectTransform = alertContainer.AddComponent <RectTransform>(); rectTransform.sizeDelta = new Vector2(400, 0); rectTransform.anchorMin = new Vector2(1, 0); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.pivot = new Vector2(1, 0.5f); rectTransform.localPosition = new Vector2(0, 0); VerticalLayoutGroup verticalLayoutGroup = alertContainer.AddComponent <VerticalLayoutGroup>(); verticalLayoutGroup.childControlHeight = false; verticalLayoutGroup.childControlWidth = false; verticalLayoutGroup.childForceExpandHeight = false; verticalLayoutGroup.childForceExpandWidth = false; verticalLayoutGroup.childAlignment = TextAnchor.LowerRight; alertContainer.transform.SetParent(gameObject.transform, false); this.alertContainer = alertContainer; _Instance = this; }
public List <Action> Activate(Character _character, Vector3 _dir) { if (_alertList.Count == 0) { return(null); } if (_requiredItems == null || _requiredItems.HasRequiredItems(_character)) { if (_index < _alertList.Count) { AlertList _alerts = _alertList[_index]; foreach (AlertActions _alert in _alerts.alerts) { _alert.Interactable.ExternalTrigger(_alert.EnterTask, _alert.Enter, _character); } Debug.Log("Triggered: " + _index); _index++; } else { if (_loop) { _index = 0; Activate(_character, Vector3.zero); } else { _index++; } } if (_requiredItems != null) { return(_requiredItems.UseItems()); } } return(null); }
/// <summary> /// Called as the alert timer expires to check for any alerts having been generated and reporting them /// optionally sending emails if these have been configured /// /// Alert checking is done daily and will result in a number of entries being added to the ALERT table /// These entries are in turn /// </summary> public void CheckForAlerts() { LogFile ourLog = LogFile.Instance; ourLog.Write("CheckForAlerts", true); // try { SettingsDAO lSettingsDao = new SettingsDAO(); string fileName = String.Empty; string selectedFileName = String.Empty; System.Xml.Serialization.XmlSerializer serializer; AlertDefinition definition; // We need to be sure that we do not email the same alerts multiple times so we recover the date at // which we last send an email alert and only add alerts which occurred after that date to our email DateTime dateLastAlertEmail; string lastAlertDate = lSettingsDao.GetSettingAsString(DatabaseSettings.Setting_LastAlertEmailDate, ""); // If we have not previously checked alerts then look for alerts in the last day if (lastAlertDate == "") { dateLastAlertEmail = DateTime.Now.AddDays(-1); } else { dateLastAlertEmail = Convert.ToDateTime(lastAlertDate); } // Log the last alert date (if any) ourLog.Write("Checking For Alerts generated since " + dateLastAlertEmail.ToString(), true); // Allocate a list to hold the alerts so that they can be emailed in one go AlertList listAlerts = new AlertList(); // +8.3.3 // Now check the email frequency as if this is set to daily and we have already emailed today then we do not email again string mailFrequency = lSettingsDao.GetSetting(DatabaseSettings.Setting_AlertMonitorEmailFrequency, false); if (mailFrequency == DatabaseSettings.Setting_AlertMonitorEmailDaily) { string mailtime = lSettingsDao.GetSetting(DatabaseSettings.Setting_AlertMonitorEmailTime, false); if (mailtime == "") { mailtime = "18:00"; } DateTime emailTime = DateTime.Parse(mailtime); ourLog.Write("Daily checking set for " + emailTime.ToString("HH:mm") + " - Current time is " + DateTime.Now.ToString("HH:mm") + " Last Check Date was " + dateLastAlertEmail.Date.ToShortDateString(), true); // Are we still prior to the checking time? if (DateTime.Now.TimeOfDay < emailTime.TimeOfDay) { ourLog.Write("Check time not reached so exiting", true); return; } // We are past the check date - we check if we have not previously checked today else if (dateLastAlertEmail.Date == DateTime.Now.Date) { ourLog.Write("Check yime reached but already checked today so exiting", true); return; } } // Populate the Alert date so that we do not re-do this process lSettingsDao.SetSetting(DatabaseSettings.Setting_LastAlertEmailDate, DateTime.Now.ToString(), false); // Now we read all alerts created since the specified date listAlerts.Populate(dateLastAlertEmail); if (listAlerts.Count != 0) { // read the alert definitions as we need to know which if any of these alerts should be emailed // first get the AuditScanner object // Loop through the alerts and weed out any AM alerts which do not require email for (int index = 0; index < listAlerts.Count;) { Alert alert = listAlerts[index]; if (alert.Type == Alert.AlertType.alertmonitor) { fileName = alert.AlertName; selectedFileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "scanners\\alertmonitors\\") + fileName + ".xml"; serializer = new System.Xml.Serialization.XmlSerializer(typeof(AlertDefinition)); definition = (AlertDefinition)serializer.Deserialize(new StreamReader(selectedFileName)); //if ((definition.Name != alert.AlertName) || (!definition.EmailAlert)) if (!definition.EmailAlert) { listAlerts.Remove(alert); continue; } } index++; } // If we still have some alerts left then email them if (listAlerts.Count != 0) { // get the Email Controller Task EmailController emailController = _service.GetEmailController(); // and request it to send an Alerts email on our behalf ourLog.Write("....an alerts email is required", true); emailController.SendStatusEmail(true, false, listAlerts); } } } catch (Exception ex) { ourLog.Write("Exception occurred in [CheckForAlerts], Exception Text is " + ex.Message, true); } }
protected AccountPageModel() { MyAlerts = new AlertList(); LocalizationResourceType = typeof(AccountResource); }
/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { try { AlertFilter filter = new AlertFilter(); if (ParameterPresent("CreatedAfter")) { filter.CreatedAfter = CreatedAfter; } if (ParameterPresent("CreatedBefore")) { filter.CreatedBefore = CreatedBefore; } if (ParameterPresent("ResourceId")) { filter.ResourceID = ResourceId; } if (ParameterPresent("ResourceType")) { filter.ResourceType = ResourceType; } if (ParameterPresent("Severity")) { filter.Severity = Severity; } if (ParameterPresent("Status")) { filter.Status = Status; } PageInput page = PageInput.First; AlertList list = Connection.GetOpenAlerts(page, filter); foreach (Alert alert in list.Items) { WriteObject(alert); } while (list.More) { // advance the page page.Page = page.Page + 1; list = Connection.GetOpenAlerts(page); foreach (Alert alert in list.Items) { WriteObject(alert); } } } catch (AggregateException exceptions) { foreach (Exception ex in exceptions.InnerExceptions) { ErrorRecord record = new ErrorRecord( ex, ex.GetType().ToString(), ErrorCategory.NotSpecified, null); WriteError(record); } } catch (Exception ex) { ErrorRecord record = new ErrorRecord( ex, ex.GetType().ToString(), ErrorCategory.NotSpecified, null); WriteError(record); } }
/// 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; }
// Use this for initialization void Start() { alertList = GameObject.Find("GameManagers").GetComponent <AlertList>(); }
public AlertManager() { Alerts = new AlertList(); }
protected void Page_PreRender(object sender, EventArgs e) { List <string> alertList; DateTime cacheDate; CacheWrapper alertWrapper = Cache.Get("AdminAlerts") as CacheWrapper; if (alertWrapper == null) { alertList = new List <string>(); //Check if installation directory still exists if (System.IO.Directory.Exists(Request.MapPath("~/Install"))) { string alertText = "The 'Install' directory still exists in your store. It should be removed immediately after the Installation is complete."; alertList.Add(alertText); } // CHECK IF EMAIL TEMPLATES ARE CONFIGURED, WITHOUT EMAIL SERVER SETTINGS Store store = AbleContext.Current.Store; if ((store.EmailTemplates.Count > 0)) { if (string.IsNullOrEmpty(store.Settings.SmtpServer)) { string alertText = "You have email templates configured, but you have not provided an SMTP (mail) server. Without a serv" + "er, email notifications cannot be sent. <a href=\'Store/EmailTemplates/Settings.aspx\'>Click here</a> to configure " + "email now."; alertList.Add(alertText); } } //VALIDATE ORDER STATUSES //CHECK FOR A STATUS ATTACHED TO THE ORDER PLACED EVENT OrderStatus status = OrderStatusTriggerDataSource.LoadForStoreEvent(StoreEvent.OrderPlaced); if (status == null) { status = new OrderStatus(); status.Name = "Payment Pending"; status.DisplayName = "Payment Pending"; status.IsActive = false; status.IsValid = true; status.Triggers.Add(new OrderStatusTrigger(StoreEvent.OrderPlaced, status)); status.Save(); alertList.Add("You did not have an order status assigned to the 'Order Placed' event, so one was created for you. <a href=\"Store/OrderStatuses/Default.aspx\">Click here</a> to check the order status configuration for your store."); } //CHECK FOR A STATUS ATTACHED TO THE ORDER CANCELLED EVENT status = OrderStatusTriggerDataSource.LoadForStoreEvent(StoreEvent.OrderCancelled); if (status == null) { status = new OrderStatus(); status.Name = "Cancelled"; status.DisplayName = "Cancelled"; status.IsActive = false; status.IsValid = false; status.Triggers.Add(new OrderStatusTrigger(StoreEvent.OrderCancelled, status)); status.Save(); alertList.Add("You did not have an order status assigned to the 'Order Cancelled' event, so one was created for you. <a href=\"Store/OrderStatuses/Default.aspx\">Click here</a> to check the order status configuration for your store."); } //MAKE SURE AT LEAST ONE PRODUCT EXISTS int productCount = ProductDataSource.CountAll(); if (productCount == 0) { alertList.Add("You have not yet added any products in your store. <a href=\"Catalog/Browse.aspx\">Click here</a> to manage your catalog now."); } //MAKE SURE AT LEAST ONE SHIPPING METHOD EXISTS int shipMethodCount = ShipMethodDataSource.CountAll(); if (shipMethodCount == 0) { alertList.Add("You do not have any shipping methods configured. Your customers will not be able to complete checkout if the order contains any shippable products. <a href=\"Shipping/Methods/Default.aspx\">Click here</a> to manage shipping methods now."); } //CHECK FOR LOW INVENTORY PRODUCTS int lowInventoryProducts = ProductInventoryDataSource.GetLowProductInventoryCount(); if (lowInventoryProducts > 0) { alertList.Add("One or more products are at or below their low inventory warning level. You can view these products <a href=\"Reports/LowInventory.aspx\">here</a>."); } //CHECK FOR PRESENCE OF ERRORS int errorCount = ErrorMessageDataSource.CountAll(); if (errorCount > 0) { string errorAlert = string.Format("There are {0} messages in your <a href=\"Help/ErrorLog.aspx\">error log</a>. You should review these messages and take corrective action if necessary.", errorCount); alertList.Add(errorAlert); } //Check of SSL is not enabled StoreSettingsManager storeSettings = AbleContext.Current.Store.Settings; if (!storeSettings.SSLEnabled) { string alertText = "SSL is not enabled. Your store is currently being accessed over an insecure connection. <a href=\"Store/Security/Default.aspx\">Click Here</a> to change SSL settings."; alertList.Add(alertText); } //MAKE SURE ORDER NUMBER INCREMENT IS VALID if (store.OrderIdIncrement < 1) { string alertText = "The order number increment for your store was " + store.OrderIdIncrement + " (invalid). The increment has been updated to 1. <a href=\"Store/StoreSettings.aspx\">Click Here</a> to review this setting."; alertList.Add(alertText); store.OrderIdIncrement = 1; store.Save(); } //ALERT FOR ORDER NUMBER PROBLEM int maxOrderNumber = StoreDataSource.GetMaxOrderNumber(); int nextOrderNumber = StoreDataSource.GetNextOrderNumber(false); if (maxOrderNumber >= nextOrderNumber) { int newOrderNumber = maxOrderNumber + store.OrderIdIncrement; StoreDataSource.SetNextOrderNumber(newOrderNumber); string alertText = "The next order number of {0} is less than the highest assigned order number of {1}. We have automatically increased your next order number to {2} to prevent errors. <a href=\"Store/StoreSettings.aspx\">Click Here</a> to review this setting."; alertList.Add(string.Format(alertText, nextOrderNumber, maxOrderNumber, newOrderNumber)); } //MAKE SURE A VALID ENCRYPTION KEY IS PRESENT bool encryptionKeyValid; try { encryptionKeyValid = EncryptionKeyManager.IsKeyValid(EncryptionKeyManager.Instance.CurrentKey.KeyData); } catch { encryptionKeyValid = false; } if (!encryptionKeyValid) { //ENCRYPTION KEY IS MISSING OR INVALID, SEE WHETHER WE ARE STORING CARD DATA if (storeSettings.EnableCreditCardStorage) { string alertText = "Your store encryption key is missing or invalid, and you have not disabled storage of card data. You should either <a href=\"Store/Security/EncryptionKey.aspx\">set the encryption key</a> or <a href=\"Store/Security/Default.aspx\">disable credit card storage</a>."; alertList.Add(alertText); } } // ALERT FOR PRODUCT IMAGE LOOKUP BY SKU if (storeSettings.ImageSkuLookupEnabled) { // SEARCH FOR PRODUCTS MISSING SKU AND MISSING IMAGE URLs ICriteria productCriteria = NHibernateHelper.CreateCriteria <Product>() .Add(new Disjunction() .Add(Restrictions.IsNull("Sku")) .Add(Restrictions.Eq("Sku", string.Empty))) .Add(new Disjunction() .Add(Restrictions.IsNull("ImageUrl")) .Add(Restrictions.IsNull("IconUrl")) .Add(Restrictions.IsNull("ThumbnailUrl"))) .Add(Restrictions.Eq("VisibilityId", (byte)CatalogVisibility.Public)); IList <Product> products = ProductDataSource.LoadForCriteria(productCriteria); if (products != null && products.Count > 0) { StringBuilder textBuilder = new StringBuilder(); textBuilder.Append("Following product(s) are missing SKU, and also do not have image paths provided:<br/>"); textBuilder.Append("<ul>"); int counter = 0; // PRODUCT COUNTER, SHOW ONLY FIRST FIVE PRODUCTS foreach (Product product in products) { counter++; textBuilder.Append("<li><a href=\"products/EditProduct.aspx?ProductId=" + product.Id + "\">" + product.Name + "</a>.</li>"); if (counter >= 5) { break; } } textBuilder.Append("<ul>"); alertList.Add(textBuilder.ToString()); } } // LOOK FOR UNREAD NOTES ICriteria orderNoteCriteria = NHibernateHelper.CreateCriteria <OrderNote>() .Add(Restrictions.Eq("IsRead", false)) .Add(Restrictions.Not(Restrictions.Eq("NoteTypeId", (byte)NoteType.SystemPublic))) .Add(Restrictions.Not(Restrictions.Eq("NoteTypeId", (byte)NoteType.SystemPrivate))); int unreadNoteCount = OrderNoteDataSource.CountForCriteria(orderNoteCriteria); if (unreadNoteCount > 0) { string alertText = "There are {0} unread order note(s). <a href=\"Orders/OrderNotesManager.aspx\">review now</a>"; alertList.Add(string.Format(alertText, unreadNoteCount)); } // CHECK ANON USER MAINTENANCE SETTINGS if (store.Settings.AnonymousUserLifespan < 1 || store.Settings.AnonymousAffiliateUserLifespan < 1) { alertList.Add("You have not configured the number of days to save anonymous user records. You should visit the <a href=\"Store/Maintenance.aspx\">Configure > Maintenance</a> menu, view the status of the anonymous user database, and update your anonymous user maintenance settings."); } // ALERT FOR DUPLICATE COUPON CODES IList <Coupon> duplicateCoupons = NHibernateHelper.CreateSQLQuery("SELECT * FROM ac_Coupons WHERE CouponCode IN (SELECT LOWER(CouponCode) FROM ac_Coupons GROUP BY CouponCode HAVING COUNT(*) > 1)").AddEntity(typeof(Coupon)).List <Coupon>(); if (duplicateCoupons.Count > 0) { Dictionary <string, List <Coupon> > codeCounts = new Dictionary <string, List <Coupon> >(); foreach (Coupon coupon in duplicateCoupons) { string normalizedKey = coupon.CouponCode.ToUpperInvariant(); if (!codeCounts.ContainsKey(normalizedKey)) { codeCounts[normalizedKey] = new List <Coupon>(); } codeCounts[normalizedKey].Add(coupon); } StringBuilder alertText = new StringBuilder(); alertText.Append("<p>You have coupons that have duplicate codes. Duplicates should be eliminated as a unique constraint will be applied in a future release:</p>"); foreach (string couponCode in codeCounts.Keys) { alertText.Append("<p><b>" + couponCode + ":</b> "); string delimiter = string.Empty; foreach (Coupon coupon in codeCounts[couponCode]) { alertText.Append(delimiter); alertText.Append("<a href=\"Marketing/Coupons/EditCoupon.aspx?CouponId=" + coupon.Id + "\">" + coupon.Name + "</a>"); delimiter = ", "; } alertText.Append("</p>"); } alertList.Add(alertText.ToString()); } //UPDATE CACHE alertWrapper = new CacheWrapper(alertList); Cache.Remove("AdminAlerts"); Cache.Add("AdminAlerts", alertWrapper, null, DateTime.UtcNow.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } else { alertList = (List <string>)alertWrapper.CacheValue; } cacheDate = alertWrapper.CacheDate; if (alertList.Count == 0) { alertList.Add("no action items available"); } AlertList.DataSource = alertList; AlertList.DataBind(); CachedAt.Text = string.Format("{0:g}", cacheDate); }