示例#1
0
        //return user balance
        public double GetUserBalance(ulong UserLogin)
        {
            List <CIMTUser> result        = new List <CIMTUser>();
            var             requestResult = MTRetCode.MT_RET_ERROR;

            if (!CheckIfMannagerWorks())
            {
                return(0);
            }

            try
            {
                var userAccount = m_manager.UserCreateAccount();
                requestResult = m_manager.UserAccountGet(UserLogin, userAccount);


                if (requestResult == MTRetCode.MT_RET_OK)
                {
                    return(userAccount.Balance());
                }
                else
                {
                    LogOut($"Error getting user account: user_={UserLogin} error msg={requestResult}");
                }
            }
            catch (Exception ex)
            {
                LogOut($"Error getting user balance:  error={ex}");
            }

            return(0);
        }
示例#2
0
        //+------------------------------------------------------------------+
        //| Initialize library                                               |
        //+------------------------------------------------------------------+
        public bool Initialize()
        {
            string    message = string.Empty;
            MTRetCode res     = MTRetCode.MT_RET_OK_NONE;

            //--- loading manager API
            if ((res = SMTManagerAPIFactory.Initialize(null)) != MTRetCode.MT_RET_OK)
            {
                message = string.Format("Loading manager API failed ({0})", res);
                System.Console.WriteLine(message);
                return(false);
            }
            //--- creating manager interface
            m_manager = SMTManagerAPIFactory.CreateManager(SMTManagerAPIFactory.ManagerAPIVersion, out res);
            if ((res != MTRetCode.MT_RET_OK) || (m_manager == null))
            {
                SMTManagerAPIFactory.Shutdown();
                message = string.Format("Creating manager interface failed ({0})", (res == MTRetCode.MT_RET_OK ? "Managed API is null" : res.ToString()));
                System.Console.WriteLine(message);
                return(false);
            }
            //--- create deal array
            if ((m_deal_array = m_manager.DealCreateArray()) == null)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "DealCreateArray fail");
                System.Console.WriteLine("DealCreateArray fail");
                return(false);
            }
            //--- create user interface
            if ((m_user = m_manager.UserCreate()) == null)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "UserCreate fail");
                System.Console.WriteLine("UserCreate fail");
                return(false);
            }
            //--- create account interface
            if ((m_account = m_manager.UserCreateAccount()) == null)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "UserCreateAccount fail");
                System.Console.WriteLine("UserCreateAccount fail");
                return(false);
            }
            //--- all right
            return(true);
        }