示例#1
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);
        }
示例#2
0
        //return list of all Deals at given UserLogin
        public List <CIMTDeal> GetAllDeals(ulong UserLogin, out MTRetCode requestResult, DateTime StartDate, DateTime EndDate)
        {
            List <CIMTDeal> result = new List <CIMTDeal>();

            requestResult = MTRetCode.MT_RET_ERROR;
            if (!CheckIfMannagerWorks())
            {
                return(result);
            }

            DateTime ZeroDate    = new DateTime(1970, 1, 1);
            long     startSecond = (long)(StartDate - ZeroDate).TotalSeconds;
            long     stopSecond  = (long)(EndDate - ZeroDate).TotalSeconds;

            try
            {
                var dealsList = m_manager.DealCreateArray();
                //requestResult = m_manager.DealRequest(UserLogin, 1, 3153600000, dealsList);
                requestResult = m_manager.DealRequest(UserLogin, startSecond, stopSecond, dealsList);

                if (requestResult == MTRetCode.MT_RET_OK)
                {
                    var realdeal = dealsList.ToArray();
                    foreach (var actDeal in realdeal)
                    {
                        result.Add(actDeal);
                    }
                }
                else
                {
                    LogOut($"Error getting Deals for user: user_Login={UserLogin} error msg={requestResult}");
                }
            }
            catch (Exception ex)
            {
                LogOut($"Error getting Deals for user: user_Login={UserLogin} error msg={ex}");
            }

            return(result);
        }