示例#1
0
        /// <summary>
        /// Creates alert from modified data that user specified when creating alert.
        /// </summary>
        /// <param name="panel">Panel with filled controls.</param>
        /// <param name="edited">If alert is edited don't add it to list (already in it).</param>
        /// <returns></returns>
        public bool CreateAlert(AlertData alertData, Notification notification, MetroPanel panel, bool edited = false, AbstractAlert newAlert = null)
        {
            // Alert type is changed
            if (newAlert != null)
            {
                newAlert.AlertData     = alertData;
                newAlert._notification = notification;
                if (newAlert.Create(panel))
                {
                    Alerts[Alerts.IndexOf(this)] = newAlert;
                    newAlert.Subscribe(newAlert.CandlesLength.MinLength, newAlert.CandlesLength.MaxLength);
                    SaveAlertsAsync();
                    return(true);
                }
            }

            AlertData     = alertData;
            _notification = notification;
            if (Create(panel))
            {
                // initializing alert
                if (!edited)
                {
                    Alerts.Add(this);
                }
                Subscribe(CandlesLength.MinLength, CandlesLength.MaxLength);
                SaveAlertsAsync();
                return(true);
            }
            return(false);
        }
示例#2
0
        public async Task <ActionResult> Recover(AccountRecoveryView account)
        {
            if (Service.IsLoggedIn(User))
            {
                return(RedirectToDefault());
            }

            if (!Validator.CanRecover(account))
            {
                return(View(account));
            }

            String token = Service.Recover(account);

            if (token != null)
            {
                String url = Url.Action("Reset", "Auth", new { token }, Request.Url.Scheme);

                await MailClient.SendAsync(
                    account.Email,
                    Messages.RecoveryEmailSubject,
                    String.Format(Messages.RecoveryEmailBody, url));
            }

            Alerts.Add(AlertType.Info, Messages.RecoveryInformation, 0);

            return(RedirectToAction("Login"));
        }
 public AlertCollection(IEnumerable <Alert> alerts)
 {
     foreach (Alert alert in alerts)
     {
         Alerts.Add(alert);
     }
 }
 public async Task AddAlert(JhiAlert alert)
 {
     Alerts.Add(alert);
     if (alert.Timeout != 0)
     {
         RemoveAfter(alert, alert.Timeout);
     }
     await InvokeAsync(StateHasChanged);
 }
示例#5
0
 /// <summary>
 /// Check process data with alert rules.
 /// </summary>
 /// <param name="p">Process data prepared by ProcessMonitor</param>
 public void Check(ProcessData p)
 {
     foreach (var rule in _rules)
     {
         var alert = rule.Check(p);
         if (alert != null)
         {
             Alerts.Add(alert);
         }
     }
 }
示例#6
0
        public ActionResult Delete()
        {
            if (!Service.AccountExists(CurrentAccountId))
            {
                return(LogOut());
            }

            Alerts.Add(AlertTypes.Danger, Messages.ProfileDeleteDisclaimer, 0);

            return(View());
        }
        public ActionResult Delete()
        {
            if (!Service.IsActive(CurrentAccountId))
            {
                return(RedirectToAction("Logout", "Auth"));
            }

            Alerts.Add(AlertType.Danger, Messages.ProfileDeleteDisclaimer, 0);

            return(View());
        }
示例#8
0
        public void Merge_DoesNotMergeItself()
        {
            alerts.Add(new Alert());
            IEnumerable <Alert> original = alerts.ToArray();

            alerts.Merge(alerts);

            IEnumerable <Alert> expected = alerts;
            IEnumerable <Alert> actual   = original;

            Assert.Equal(expected, actual);
        }
        public ResponseResult <Guid> SetUpAlert(TradingRule rule, bool callOnce = true)
        {
            var currentRate = _bitfinexClient.GetTrades(rule.Pair.Name.ToUpper(), 1).Data.First().Price;
            var wasShown    = false;

            var subscription = _bitfinexSocketClient.SubscribeToTradeUpdates("t" + rule.Pair.Name.ToUpper(), (data) =>
            {
                var input = data.Select(d => new TradeSimple()
                {
                    Price  = d.Price,
                    Amount = d.Amount
                }).First();

                if (!wasShown || !callOnce)
                {
                    if (currentRate < rule.Boundary)
                    {
                        if (input.Price >= rule.Boundary)
                        {
                            rule.Callback?.Invoke();
                            wasShown = true;
                        }
                    }
                    else if (currentRate > rule.Boundary)
                    {
                        if (input.Price <= rule.Boundary)
                        {
                            rule.Callback?.Invoke();
                            wasShown = true;
                        }
                    }
                    else
                    {
                        rule.Callback?.Invoke();
                        wasShown = true;
                    }
                }
            });

            if (!subscription.Success)
            {
                return(new ResponseResult <Guid>(subscription.Error.Message));
            }
            else
            {
                var id = Guid.NewGuid();
                Alerts.Add(id, subscription.Data);

                return(new ResponseResult <Guid>(id));
            }
        }
        private void GenerateAlertsCollection()
        {
            foreach (var alert in _checkList.Alerts)
            {
                Alerts.Add(alert);
            }

            if (Alerts.Count == 0)
            {
                Alerts.Add(new Alert {
                    AlertMessage = Properties.Resources.NoAlert, IsChecked = true, IsWhite = true, IsImportant = false
                });
            }
        }
示例#11
0
        public ActionResult Edit(ProfileEditView profile)
        {
            if (!Service.AccountExists(CurrentAccountId))
            {
                return(LogOut());
            }

            if (Validator.CanEdit(profile))
            {
                Service.Edit(profile);
                Alerts.Add(AlertTypes.Success, Messages.ProfileUpdated);
            }

            return(View(profile));
        }
        private void AddAlert(Models.AlertModel alert)
        {
            Models.AlertModel alertCopy = alert.Clone() as Models.AlertModel;

            if (!alertCopy.Time.Offset.Equals(_settings.Alerts.TimeZone.BaseUtcOffset))
            {
                alertCopy.Time = alert.Time.ToOffset(_settings.Alerts.TimeZone.BaseUtcOffset);
            }

            alertCopy.Price = Math.Round(alertCopy.Price, Settings.Alerts.MaxPriceDecimalPlacesNumber);

            Alerts.Add(alertCopy);

            VisibleAlert = alertCopy;
        }
示例#13
0
        public ActionResult Reset(AccountResetView account)
        {
            if (Service.IsLoggedIn())
            {
                return(RedirectToDefault());
            }

            if (!Validator.CanReset(account))
            {
                return(RedirectToAction("Recover"));
            }

            Service.Reset(account);
            Alerts.Add(AlertTypes.Success, Messages.SuccesfulReset);

            return(RedirectToAction("Login"));
        }
示例#14
0
        public ActionResult Register([Bind(Exclude = "Id")] AccountView account)
        {
            if (Service.IsLoggedIn())
            {
                return(RedirectToDefault());
            }

            if (!Validator.CanRegister(account))
            {
                return(View(account));
            }

            Service.Register(account);
            Alerts.Add(AlertTypes.Success, Messages.SuccesfulRegistration);

            return(RedirectToAction("Login"));
        }
示例#15
0
        public ActionResult DeleteConfirmed(AccountView profile)
        {
            if (!Service.AccountExists(CurrentAccountId))
            {
                return(LogOut());
            }

            if (!Validator.CanDelete(profile))
            {
                Alerts.Add(AlertTypes.Danger, Messages.ProfileDeleteDisclaimer, 0);
                return(View());
            }

            Service.Delete(CurrentAccountId);

            return(LogOut());
        }
示例#16
0
        public ActionResult Recover(AccountRecoveryView account)
        {
            if (Service.IsLoggedIn())
            {
                return(RedirectToDefault());
            }

            if (!Validator.CanRecover(account))
            {
                return(View(account));
            }

            Service.Recover(account);
            Alerts.Add(AlertTypes.Info, Messages.RecoveryInformation, 0);

            return(RedirectToAction("Login"));
        }
示例#17
0
        public ActionResult Register(AccountRegisterView account)
        {
            if (Service.IsLoggedIn(User))
            {
                return(RedirectToDefault());
            }

            if (!Validator.CanRegister(account))
            {
                return(View(account));
            }

            Service.Register(account);

            Alerts.Add(AlertType.Success, Messages.SuccessfulRegistration);

            return(RedirectIfAuthorized("Login"));
        }
示例#18
0
        private bool FetchAlertsForProcessing()
        {
            bool b = false;
            var  c = Criterion.GenerateStrategy("for.processing");

            c.AddItem("CurrentStatus", "none");
            var alertResponse = Service.GetAll <eXAlert>(c);

            if (alertResponse.IsOkay)
            {
                foreach (var item in alertResponse)
                {
                    Alerts.Add(item);
                }
                b = true;
            }
            return(b);
        }
示例#19
0
 internal AlertsReadout_Patch()
 {
     foreach (Type type in typeof(Alert).AllLeafSubclasses())
     {
         Alert alert = (Alert)Activator.CreateInstance(type);
         DebugUtil.Log("Attempting to create Alert: " + Format(alert));
         if (!Alerts.Contains(alert))
         {
             Alerts.Add(alert);
         }
         Alerts.Add(alert);
         ToggleManager.Add(
             label: Format(alert),
             root: ButtonCat.Events,
             group: ButtonCat.Alerts
             );
     }
 }
        public ActionResult Edit([BindExcludeId] ProfileEditView profile)
        {
            if (!Service.IsActive(CurrentAccountId))
            {
                return(RedirectToAction("Logout", "Auth"));
            }

            if (!Validator.CanEdit(profile))
            {
                return(View(profile));
            }

            Service.Edit(profile);

            Alerts.Add(AlertType.Success, Messages.ProfileUpdated);

            return(RedirectToAction("Edit"));
        }
        public ActionResult Error()
        {
            Response.StatusCode = StatusCodes.Status500InternalServerError;

            if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                Alerts.Add(new Alert
                {
                    Id      = "SystemError",
                    Type    = AlertType.Danger,
                    Message = Resource.ForString("SystemError", HttpContext.TraceIdentifier)
                });

                return(Json(new { alerts = Alerts }));
            }

            return(View());
        }
        public ActionResult DeleteConfirmed([BindExcludeId] ProfileDeleteView profile)
        {
            if (!Service.IsActive(CurrentAccountId))
            {
                return(RedirectToAction("Logout", "Auth"));
            }

            if (!Validator.CanDelete(profile))
            {
                Alerts.Add(AlertType.Danger, Messages.ProfileDeleteDisclaimer, 0);

                return(View());
            }

            Service.Delete(CurrentAccountId);

            return(RedirectToAction("Logout", "Auth"));
        }
示例#23
0
        private void UpdateAlerts()
        {
            Server.Value.DocumentStore.OpenAsyncSession(Server.Value.SelectedDatabase.Value.Name).LoadAsync <AlertsDocument>(Constants.RavenAlerts).ContinueOnSuccessInTheUIThread(
                alertsDoc =>
            {
                Alerts.Clear();
                if (alertsDoc != null)
                {
                    foreach (var alert in alertsDoc.Alerts)
                    {
                        Alerts.Add(alert);
                    }
                }

                OnPropertyChanged(() => Alerts);
                OnPropertyChanged(() => UnOnserverdAlerts);
                OnPropertyChanged(() => AlertsTitle);
            });
        }
        public ActionResult Edit([Bind(Exclude = "Id")] ProfileEditView profile)
        {
            if (!Service.IsActive(CurrentAccountId))
            {
                return(LogOut());
            }

            profile.Id = CurrentAccountId;
            if (!Validator.CanEdit(profile))
            {
                return(View(profile));
            }

            Service.Edit(profile);

            Alerts.Add(AlertType.Success, Messages.ProfileUpdated);

            return(RedirectToAction("Edit"));
        }
        public ActionResult DeleteConfirmed([Bind(Exclude = "Id")] ProfileDeleteView profile)
        {
            if (!Service.IsActive(CurrentAccountId))
            {
                return(LogOut());
            }

            profile.Id = CurrentAccountId;
            if (!Validator.CanDelete(profile))
            {
                Alerts.Add(AlertType.Danger, Messages.ProfileDeleteDisclaimer, 0);

                return(View());
            }

            Service.Delete(CurrentAccountId);

            return(LogOut());
        }
示例#26
0
        public void RegisterComponent(IComponent component)
        {
            if (!Components.TryAdd(component.ComponentName, component))
            {
                // TODO: what should I do in this case?
                //Console.WriteLine($"Unable to register component '{component.ComponentName}' in page '{GetType().Name}'");
            }

            if (component is IHtmlAlert)
            {
                Alerts.Add(component as IHtmlAlert);
            }
            else if (component is IOverlay)
            {
                Overlays.Add(component as IOverlay);
            }
            else if (component is IProgressBar)
            {
                ProgressBars.Add(component as IProgressBar);
            }
        }
示例#27
0
        // loads all alerts
        public static async Task LoadAlertsAsync()
        {
            if (!Directory.Exists(SAVE_DIR))
            {
                Directory.CreateDirectory(SAVE_DIR);
            }
            if (!File.Exists(SAVE_PATH))
            {
                File.Create(SAVE_PATH);
            }
            else
            {
                IOManager ioManager = new IOManager(SAVE_PATH);
                await ioManager.LoadByLineAsync(line =>
                {
                    Alerts.Add(FromLine(line));
                });
            }

            _allSubscribed = SubscribeAll();
        }
示例#28
0
        private void RegisterToChanges()
        {
            ShowObserved.PropertyChanged += (sender, args) =>
            {
                AlertsToSee = ShowObserved.Value ? Alerts : UnobservedAlerts;
                OnPropertyChanged(() => AlertsToSee);
            };

            ServerAlerts.CollectionChanged += (sender, args) =>
            {
                Alerts.Clear();
                foreach (var serverAlert in ServerAlerts)
                {
                    Alerts.Add(new AlertProxy(serverAlert));
                }
            };

            ShowObserved.Value = false;

            Alerts.CollectionChanged += (sender, args) => UpdateUnobserved();

            OnPropertyChanged(() => ServerAlerts);
        }
 private void AddItem(SingleAlertItem item)
 {
     Alerts.Add(item);
 }
示例#30
0
        public void setAlertListValue()
        {
            if (_context.PulseSekv.Any())
            {
                var all = _context.PulseSekv.OrderBy(x => x.TimeStart).ToList();
                all.Reverse();
                Tep_Sekvencia ts = null;
                foreach (var a in all)
                {
                    ts = a;
                    if (a.Upozornenie != 0)
                    {
                        break;
                    }
                }

                // Tep_Sekvencia ts = _context.PulseSekv.FirstOrDefault(t => t.TepSekvId == _context.PulseSekv.Max(x => x.TepSekvId));

                Helpers.SekvenceHelper.LimitCheck loader = new Helpers.SekvenceHelper.LimitCheck();
                if (ts.Upozornenie != 0)
                {
                    DateTime convertedDate = DateTime.Parse(ts.TimeStart);

                    AlertSequenceObj myObj = new AlertSequenceObj
                    {
                        Name  = "Tep",
                        Value = ts.Sekvencia + " BPM",
                        Date  = convertedDate.ToShortDateString(),
                        Time  = convertedDate.ToLongTimeString(),
                        Alert = loader.getStringValuePulseAndTempLimit(ts.Upozornenie)
                    };
                    Alerts.Add(myObj);
                }
                else
                {
                    AlertSequenceObj myObj = new AlertSequenceObj
                    {
                        Name  = "Tep",
                        Alert = "Neexistuje upozornenie"
                    };
                    Alerts.Add(myObj);
                }


                //String tepSekvString = "Tep " + ts.Sekvencia + " " + ts.TimeStart + " " + loader.getStringValuePulseAndTempLimit(ts.Upozornenie);
            }
            else
            {
                AlertSequenceObj myObj = new AlertSequenceObj
                {
                    Name  = "Tep",
                    Alert = "Neexistuje sekvencia"
                };
                Alerts.Add(myObj);
            }



            if (_context.TemperatureSekv.Any())
            {
                var all = _context.TemperatureSekv.OrderBy(x => x.TimeStart).ToList();
                all.Reverse();
                Teplota_Sekvencia ts = null;
                foreach (var a in all)
                {
                    ts = a;
                    if (a.Upozornenie != 0)
                    {
                        break;
                    }
                }

                Helpers.SekvenceHelper.LimitCheck loader = new Helpers.SekvenceHelper.LimitCheck();
                if (ts.Upozornenie != 0)
                {
                    DateTime convertedDate = DateTime.Parse(ts.TimeStart);

                    AlertSequenceObj myObj = new AlertSequenceObj
                    {
                        Name  = "Teplota",
                        Value = ts.Sekvencia.ToString("n2") + " °C",
                        Date  = convertedDate.ToShortDateString(),
                        Time  = convertedDate.ToLongTimeString(),
                        Alert = loader.getStringValuePulseAndTempLimit(ts.Upozornenie)
                    };
                    Alerts.Add(myObj);
                }
                else
                {
                    AlertSequenceObj myObj = new AlertSequenceObj
                    {
                        Name  = "Teplota",
                        Alert = "Neexistuje upozornenie"
                    };
                    Alerts.Add(myObj);
                }
            }
            else
            {
                AlertSequenceObj myObj = new AlertSequenceObj
                {
                    Name  = "Teplota",
                    Alert = "Neexistuje sekvencia"
                };
                Alerts.Add(myObj);
            }



            if (_context.MovementSekv.Any())
            {
                var all = _context.MovementSekv.OrderBy(x => x.TimeStamp).ToList();
                all.Reverse();

                Pohyb_Sekvencia ps = null;
                foreach (var a in all)
                {
                    if (a.Upozornenie_Cas != 0)
                    {
                        ps = a;
                        break;
                    }
                    if (a.Upozornenie_Hranica != 0)
                    {
                        ps = a;
                        break;
                    }
                }

                if (ps != null)
                {
                    DateTime convertedDate = DateTime.Parse(ps.TimeStamp);

                    if (ps.Upozornenie_Cas != 0)
                    {
                        AlertSequenceObj myObj = new AlertSequenceObj
                        {
                            Name  = "Pohyb",
                            Date  = convertedDate.ToShortDateString(),
                            Time  = convertedDate.ToLongTimeString(),
                            Alert = "Čas"
                        };
                        Alerts.Add(myObj);
                    }
                    else if (ps.Upozornenie_Hranica != 0)
                    {
                        AlertSequenceObj myObj = new AlertSequenceObj
                        {
                            Name  = "Pohyb",
                            Date  = convertedDate.ToShortDateString(),
                            Time  = convertedDate.ToLongTimeString(),
                            Alert = "Hranica"
                        };
                        Alerts.Add(myObj);
                    }
                    else
                    {
                        AlertSequenceObj myObj = new AlertSequenceObj
                        {
                            Name  = "Pohyb",
                            Alert = "Neexistuje upozornenie"
                        };
                        Alerts.Add(myObj);
                    }
                }
                else
                {
                    AlertSequenceObj myObj = new AlertSequenceObj
                    {
                        Name  = "Pohyb",
                        Alert = "Neexistuje upozornenie"
                    };
                    Alerts.Add(myObj);
                }
            }
            else
            {
                AlertSequenceObj myObj = new AlertSequenceObj
                {
                    Name  = "Pohyb",
                    Alert = "Neexistuje sekvencia"
                };
                Alerts.Add(myObj);
            }



            if (_context.Akcelerometers.Any())
            {
                var pad = _context.Akcelerometers.FirstOrDefault(t => t.AkcelerometerID == _context.Akcelerometers.Max(x => x.AkcelerometerID));

                DateTime       convertedDate  = DateTime.Parse(pad.TimeStamp);
                RoomsDetection roomsDetection = new RoomsDetection();


                Izby   izba     = roomsDetection.findRoomByCoord(pad.Xhodnota, pad.Yhodnota);
                string izbameno = "Vonku";
                try
                {
                    izbameno = izba.Nazov;
                }catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("EXCEPTION " + e.ToString());
                }


                AlertSequenceObj myObj = new AlertSequenceObj
                {
                    Name  = "Pád",
                    Date  = convertedDate.ToShortDateString(),
                    Time  = convertedDate.ToLongTimeString(),
                    Value = izbameno,
                    Alert = "Nastal pád"
                };
                Alerts.Add(myObj);
            }
            else
            {
                AlertSequenceObj myObj = new AlertSequenceObj
                {
                    Name  = "Pád",
                    Alert = "Pád nenastal"
                };
                Alerts.Add(myObj);
            }


            //TODO: ZOBRAZENIE POHYBU
        }