Beispiel #1
0
        public bool UpdateUser(IUser user, string sessionID, ISession sessionHandler)
        {
            try
            {
                XmlRpcStruct userStruct = ((User)user).toStruct();

                sysLog.Info("Request: UpdateUser - Requested User: '******', Userdata: FIRSTNAME=" + user.Firstname
                                                                                   + " LASTNAME=" + user.Lastname
                                                                                   + " EMAIL=" + user.Email);

                UserHandler privateUserHandler = HandlerHelper.getPrivateUserHandler(privateXmlRpcUrl, sessionID);
                privateUserHandler.Modify("NICKNAME == '" + user.Nickname + "'", userStruct);
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when updating user '" + user.Nickname + "'", e);

                return false;
            }

            return true;
        }
Beispiel #2
0
        public void CancelOrder(int orderId, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: CancelOrder - Requested OrderId: " + orderId);

                OrderHandler privateOrderHandler = HandlerHelper.getPrivateOrderHandler(privateXmlRpcUrl, sessionID);
                privateOrderHandler.Cancel("ID == '" + orderId + "'");
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when cancelling Order", e);
            }
        }
Beispiel #3
0
        /******************************************************
         * TRANSACTIONS
         ******************************************************/
        public List<ITransaction> GetUserTransactions(int id, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: UserTransactions - Requested UserID: '" + id + "'");

                List<ITransaction> userTransactions = new List<ITransaction>();

                TransactionHandler privateTransactionHandler = HandlerHelper.getPrivateTransactionHandler(privateXmlRpcUrl, sessionID);
                XmlRpcStruct[] transactionStruct = privateTransactionHandler.List("USERID == '" + id + "'");

                foreach (XmlRpcStruct userTransaction in transactionStruct)
                    userTransactions.Add(new Transaction(userTransaction));

                return userTransactions;
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when requesting UserTransactions", e);

                return new List<ITransaction>();
            }
        }
Beispiel #4
0
        public bool RemoveUser(string nickname, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: RemoveUser - Requested User: '******'");

                UserHandler privateUserHandler = HandlerHelper.getPrivateUserHandler(privateXmlRpcUrl, sessionID);
                privateUserHandler.Remove("NICKNAME == '" + nickname + "'");
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when removing user '" + nickname + "'", e);

                return false;
            }
            return false;
        }
Beispiel #5
0
        public List<IUserSecurity> GetUserSecurities(int id, string sessionID, ISession session)
        {
            try
            {
                sysLog.Info("Request: UserSecurities - Requested UserID: '" + id + "'");

                List<IUserSecurity> userSecurities = new List<IUserSecurity>();

                PortfolioHandler privatePortfolioHandler = HandlerHelper.getPrivatePortfolioHandler(privateXmlRpcUrl, sessionID);
                XmlRpcStruct[] portfolioStruct = privatePortfolioHandler.List("USERID == '" + id + "'");

                foreach (XmlRpcStruct userSecurity in portfolioStruct)
                    userSecurities.Add(new UserSecurity(userSecurity));

                return userSecurities;
            }
            catch (Exception e)
            {
                if(e.Message.Contains("Session Corrupt"))
                    session.handleSessionTimeout();
                else
                    sysLog.Error("Error when requesting UserSecurities", e);

                return new List<IUserSecurity>();
            }
        }
Beispiel #6
0
        public List<IOrder> GetUserOrders(int id, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: UserOrders - Requested User: "******"USERID == '" + id + "'");

                foreach (XmlRpcStruct userOrder in orderStruct)
                    userOrders.Add(new Order(userOrder));

                return userOrders;
            }
            catch (Exception e)
            {
                if(e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when requesting UserOrders", e);

                return new List<IOrder>();
            }
        }
Beispiel #7
0
        public IUser GetUserDetailsByNickname(string nickname, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: UserByNickname - Requested User: '******'");

                IUser user = null;

                UserHandler privateUserHandler = HandlerHelper.getPrivateUserHandler(privateXmlRpcUrl, sessionID);
                XmlRpcStruct[] userStruct = privateUserHandler.Details(); //Filter is niet nodig, deze wordt samengesteld in de backend adhv sessie
                if (userStruct.Length > 0)
                    user = new User(userStruct[0]);

                return user;
            }
            catch(Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when requesting user", e);

                return null;
            }
        }
Beispiel #8
0
        public List<IPointsTransaction> GetPointTransactions(int userID, string sessionId, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: GetPointTransactions - Requested UserID: '" + userID + "'");

                List<IPointsTransaction> pointTransactions = new List<IPointsTransaction>();

                PointsTransactionHandler privatePointsTransactionHandler = HandlerHelper.getPrivatePointsTransactionHandler(privateXmlRpcUrl, sessionId);
                XmlRpcStruct[] pointTransactionStruct = privatePointsTransactionHandler.List("USERID == '" + userID + "'");

                foreach (XmlRpcStruct pointTransaction in pointTransactionStruct)
                    pointTransactions.Add(new PointsTransaction(pointTransaction));

                return pointTransactions;
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                sysLog.Error("Error when getting rankings", e);

                return new List<IPointsTransaction>();
            }
        }
Beispiel #9
0
        /******************************************************
         * ORDERS
         ******************************************************/
        public void CreateOrder(int userId, string isin, int amount, double price, double alternativeOrder, string type, string sessionID, ISession sessionHandler)
        {
            try
            {
                sysLog.Info("Request: CreateOrder - Created Order: USERID=" + userId + " ISIN=" + isin + " AMOUNT=" + amount
                                                                   + " PRICE=" + price + " TYPE=" + type);

                OrderHandler privateOrderHandler = HandlerHelper.getPrivateOrderHandler(privateXmlRpcUrl, sessionID);
                Order order = new Order(-1, userId, isin, amount, price, alternativeOrder, type, "ACCEPTED", DateTime.Now, DateTime.MinValue, DateTime.MinValue);
                privateOrderHandler.Create(order.toStruct());
            }
            catch (Exception e)
            {
                if (e.Message.Contains(corruptSession) || e.Message.Contains(invalidSession))
                    sessionHandler.handleSessionTimeout();
                else
                    sysLog.Error("Error when creating Order", e);
            }
        }