示例#1
0
        //+------------------------------------------------------------------+
        //| Get array of dealer balance operation                            |
        //+------------------------------------------------------------------+
        public bool GetUserDeal(out CIMTDealArray deals, UInt64 login, DateTime time_from, DateTime time_to)
        {
            deals = null;
            //--- request array
            MTRetCode res = m_manager.DealRequest(login, SMTTime.FromDateTime(time_from), SMTTime.FromDateTime(time_to), m_deal_array);

            if (res != MTRetCode.MT_RET_OK)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "DealRequest fail({0})", res);
                return(false);
            }
            //---
            deals = m_deal_array;
            return(true);
        }
示例#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);
        }
示例#3
0
 //+------------------------------------------------------------------+
 //| Shutdown                                                         |
 //+------------------------------------------------------------------+
 public void Shutdown()
 {
     if (m_deal_array != null)
     {
         m_deal_array.Dispose();
         m_deal_array = null;
     }
     if (m_manager != null)
     {
         m_manager.Dispose();
         m_manager = null;
     }
     if (m_user != null)
     {
         m_user.Dispose();
         m_user = null;
     }
     if (m_account != null)
     {
         m_account.Dispose();
         m_account = null;
     }
     SMTManagerAPIFactory.Shutdown();
 }
示例#4
0
        //+------------------------------------------------------------------+
        //|                                                                  |
        //+------------------------------------------------------------------+
        private void OnBnClickedButtonGetdeals(object sender = null, EventArgs e = null)
        {
            CIMTDealArray deal_array = null;
            CIMTDeal      deal       = null;
            UInt64        login      = 0;
            DateTime      from       = m_From.Value;
            DateTime      to         = m_To.Value;
            string        stype      = string.Empty;

            //--- user login
            UInt64.TryParse(m_User.Text, out login);
            //--- get deal array
            if (!m_manager.GetUserDeal(out deal_array, login, from, to))
            {
                //--- clear list
                m_List.Items.Clear();
                //---
                MessageBox.Show("Get user deal fail", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //--- clear list
            m_List.Items.Clear();
            //--- for all deal in array
            for (uint i = 0; i < deal_array.Total(); i++)
            {
                //--- get deal
                deal = deal_array.Next(i);
                //--- check error
                if (deal == null)
                {
                    break;
                }
                //--- check action
                switch ((CIMTDeal.EnDealAction)deal.Action())
                {
                case CIMTDeal.EnDealAction.DEAL_BALANCE:
                    stype = "Balance";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CREDIT:
                    stype = "Credit";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CHARGE:
                    stype = "Charge";
                    break;

                case CIMTDeal.EnDealAction.DEAL_CORRECTION:
                    stype = "Correction";
                    break;

                case CIMTDeal.EnDealAction.DEAL_BONUS:
                    stype = "Bonus";
                    break;

                case CIMTDeal.EnDealAction.DEAL_COMMISSION:
                    stype = "Commission";
                    break;

                default:
                    //--- skip other actions
                    continue;
                }
                //---
                string stime = SMTTime.ToDateTime(deal.Time()).ToString("yyyy.MM.dd HH:mm:ss.fff");
                //--- insert item
                string[] row = { deal.Deal().ToString(), stype, deal.Profit().ToString() };
                var      it  = m_List.Items.Insert(0, stime);
                it.SubItems.AddRange(row);
                m_List.EnsureVisible(0);
                m_List.Update();
            }
        }