Esempio n. 1
0
        private void BuildUserProfileBasedOnLdap()
        {
            var gameStockConfig = new StockGameConfiguration();

            var ldapService = new LdapService(gameStockConfig);
            ldapService.Init();
            var userProfile = ldapService.FindRuleEmployee("wasztemborski");
            //var a = ldapService.AuthenticateUser("RULE", "wasztemborski", "rule2financial!");

            var userProfileDao = new GenericDAO<UserProfile>();
            userProfile = userProfileDao.FindById(userProfileDao.Save(userProfile));

            var instrument = new Instrument();
            instrument.Ask = new Random().Next();
            instrument.Bid = new Random().Next();
            instrument.Name = "Procom " + new Random().Next();

            var orderDbo = new GenericDAO<Order>();

            var order = new Order();
            order.Owner = userProfile;
            order.OrderStategy = OrderStategy.StopLost;
            orderDbo.SaveOrUpdate(order);
        }
Esempio n. 2
0
        private void LoginAndTrade()
        {
            var userProfileId = _userProfileDAO.Save(_ldapService.FindRuleEmployee("wasztemborski"));
            var userProfile = _userProfileDAO.FindById(userProfileId);

            Console.WriteLine(userProfile);

            var orders = new List<Order>();
            var rnd = new Random();
            for (int i = 0; i< 10; i++)
            {
                var order = new Order();
                order.Owner = userProfile;
                order.Amount = rnd.Next(100);
                order.OrderStategy = OrderStategy.StopLost;
                orders.Add(order);
            }
            _orderDAO.Save(orders);

            var loadedOrders = _orderDAO.FindAll();

            loadedOrders.ForEach( x => Console.WriteLine(x));
        }
Esempio n. 3
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);
            }
        }