Пример #1
0
 public void NotificatifyAlert(Alert alert)
 {
     var notification = new Notification();
     notification.Description = "Not jest notifikacja ponieważ był alert "  + alert;
     notification.Status = NotificationStatus.New;
     notification.Owner = alert.Owner;
     _notificationRepository.NotificantionDAO.Save(notification);
 }
Пример #2
0
        public void ProcessAlert(Alert alert)
        {
            alert.Status = AlertStatus.Executed;
            _alertRepository.AlertDAO.SaveOrUpdate(alert);

            _notificationManager.NotificatifyAlert(alert);

            Console.WriteLine("ProcessAlert:  " + alert);
        }
Пример #3
0
        private void ProcessAlert(Alert alert, InstrumentHistory instrumentHistory)
        {
            switch (alert.AlertType)
            {
                case AlertType.Above:
                {
                    if (alert.Instrument.Id == instrumentHistory.Instrument.Id
                        && alert.Treshhold > instrumentHistory.RefereceValue)
                    {
                        _alertManager.ProcessAlert(alert);

                        Console.WriteLine("Alert " + instrumentHistory.Instrument);
                    }
                    break;
                }
                case AlertType.LessThen:
                {

                    break;
                }
                default: throw new Exception("Unidefined alert type");
            }
        }
Пример #4
0
        private void FillDB()
        {
            Console.WriteLine("FillDB ");

               var random = new Random();

            // Create user porfiles
            for (var i= 0; i< 5; i++)
            {
                var userProfile = _ldapService.FindRuleEmployee("employee" + i);
                _userProfileDAO.Save(userProfile);
            }

            // Create Intruments
            for (var i = 0; i < 5; i++)
            {
                var instument = new Instrument();
                instument.Ask = random.Next(0, 100);
                instument.Bid = instument.Ask *1.1;
                instument.Name = "Company " +random.Next();
                _instrumentDAO.Save(instument);
            }

            // Create Intrument History
            var currentInstrument = _instrumentDAO.FindAll().FirstOrDefault<Instrument>();
            Console.WriteLine(currentInstrument);

            for (var i = 0; i < 5; i++)
            {
                var instumentHistory = new InstrumentHistory();
                instumentHistory.Instrument = currentInstrument;
                instumentHistory.RefereceValue = random.Next(20, 40);
                instumentHistory.Scope = ScopeKind.Kind1D;
                instumentHistory.Sales = random.Next(20);
                instumentHistory.DateStamp = DateTime.Now.AddDays(- i);
                _instrumentHistoryDAO.Save(instumentHistory);
            }

            for (var i = 0; i < 5; i++)
            {
                var instumentHistory = new InstrumentHistory();
                instumentHistory.Instrument = currentInstrument;
                instumentHistory.RefereceValue = random.Next(20, 40);
                instumentHistory.Scope = ScopeKind.Kind1M;
                instumentHistory.Sales = random.Next(20);
                instumentHistory.Sales = random.Next(20);
                instumentHistory.DateStamp = DateTime.Now.AddMinutes(-i*30);
                _instrumentHistoryDAO.Save(instumentHistory);
            }

            // Create Intrument History
            var currentUser = _userProfileDAO.FindAll().FirstOrDefault<UserProfile>();

            // Create Orders
            for (var i = 0; i < 5; i++)
            {
                var order = new Order();
                order.OrderStategy = OrderStategy.StopLost;
                order.Status = OrderStatus.Open;
                order.Owner = currentUser;
                order.Amount = random.Next(1, 20);
                _orderDAO.Save(order);
            }

            // Create Alerts
            for (var i = 0; i < 5; i++)
            {
                var alert = new Alert();
                alert.Status = AlertStatus.Open;
                alert.AlertType = AlertType.Above;
                alert.Owner = currentUser;
                alert.Instrument = currentInstrument;
                alert.Treshhold = 1000;
                alert.Description = "Alert Description " + i;
                _alertDAO.Save(alert);
            }
        }