/// <summary>
 /// Initialize TT API
 /// </summary>
 public void Init()
 {
     // Use "Universal Login" Login Mode
     TTAPI.UniversalLoginModeDelegate ulDelegate = new
                                                   TTAPI.UniversalLoginModeDelegate(ttApiInitComplete);
     TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, ulDelegate);
 }
Example #2
0
        /// <summary>
        /// Initialize TT API
        /// </summary>
        public void Init()
        {
            // Use "Universal Login" Login Mode
            ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete);

            TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, m_username, m_password, h);
        }
Example #3
0
        /// <summary>
        /// Initialize TT API
        /// </summary>
        public void Init()
        {
            cout("TengineTT::Init: Initializing TTAPI...");
            // Use "Universal Login" Login Mode
            ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete);

            TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, Username, Password, h);
        }
Example #4
0
 /// <summary>
 /// Initialize TT API
 /// </summary>
 private void Init()
 {
     log.Info("Connecting to TT API...");
     try
     {
         // Use "Universal Login" Login Mode
         ApiInitializeHandler h = InitComplete;
         TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, _username, _password, h);
     }
     catch (Exception)
     {
         log.Info("Connection failed");
     }
 }
        public void Init(Form1 f, bool sim)
        {
            MainForm = f;
            //Init details
            if (!sim)
            {
                m_username = "******"; m_password = "******";
            }
            //API connection
            m_disp = Dispatcher.AttachUIDispatcher();
            ApiInitializeHandler h = new ApiInitializeHandler(ttApiInitComplete);

            TTAPI.CreateUniversalLoginTTAPI(Dispatcher.Current, m_username, m_password, h);
        }
Example #6
0
        /// <summary>
        /// Attempt to authenticate the user.
        /// </summary>
        private void btnConnect_Click(object sender, EventArgs e)
        {
            // Check to ensure that values have been entered for all fields
            if (txtUsername.Text == String.Empty)
            {
                MessageBox.Show("Please enter a username");
                return;
            }
            if (txtPassword.Text == String.Empty)
            {
                MessageBox.Show("Please enter a Password");
                return;
            }

            ApiInitializeHandler handler = new ApiInitializeHandler(ttApiInitHandler);

            TTAPI.CreateUniversalLoginTTAPI(m_dispatcher, txtUsername.Text, txtPassword.Text, handler);
        }
Example #7
0
        }// StartInitAPI().

        //
        /// <summary>
        /// Create UniversalLogin or XTrader API instance.
        /// Called by the TTService worker thread.
        /// </summary>
        private void InitAPI()
        {
            if (m_UseXTraderLogin)
            {   // Follow the local XTrader login.
                // Note: This will not fail even if no XTrader is running.
                // Rather, the call m_XAPI.ConnectToXTrader(), below, will get stuck forever if there is not XTrader running.
                //System.Windows.Forms.MessageBox.Show("test TT1");
                // Check for Xtrader process, postpone connecting if its NOT running.
                //System.Windows.Forms.MessageBox.Show("test5");
                System.Diagnostics.Process[] procs = null;
                try
                {
                    if (m_CheckXTraderProcessExists)
                    {
                        procs = System.Diagnostics.Process.GetProcessesByName("x_trader");
                    }
                }
                catch (Exception e)
                {
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Exception {0}.  Turning off XTrader searching.  Will try to start API directly.", e.Message);
                    }
                    m_CheckXTraderProcessExists = false;                    // Ok, security issues may have caused this to fail.  Nothing to do be proceed.
                }
                if (m_CheckXTraderProcessExists && procs != null && procs.Length < 1)
                {   // There is NO Xtrader running.
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Found NO XTrader process. Waiting {0} secs to look again.", m_WaitForAPISeconds);
                    }
                    Thread.Sleep(1000 * m_WaitForAPISeconds);
                    try
                    {
                        if (!m_Stopping && m_Dispatcher != null)
                        {
                            m_Dispatcher.BeginInvoke(new Action(InitAPI));
                        }
                    }
                    catch (Exception e)
                    {   // This exception can happen when we are shutting down, before we connect.
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Exception when re-invoking. Exiting. Exception = {0}.", e.Message);
                    }
                }
                else
                {   // XTrader is running, connect to it.
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: Creating XTrader mode API.");
                    }
                    ApiInitializeHandler d = new ApiInitializeHandler(TT_XTraderInitComplete);              // new method for 7.17.X TTAPI

                    //TTAPI.XTraderModeDelegate d = new TTAPI.XTraderModeDelegate(TT_XTraderInitComplete);  // old method for 7.2.X TTAPI
                    XTraderModeTTAPIOptions options = new XTraderModeTTAPIOptions();
                    options.XTServicesConnectionTimeout = new TimeSpan(0, 0, 20);
                    try
                    {
                        TTAPI.CreateXTraderModeTTAPI(m_Dispatcher, options, d);
                    }
                    catch (Exception e)
                    {
                        if (m_Log != null)
                        {
                            m_Log.NewEntry(LogLevel.Warning, "InitAPI: TT Exception {0}.", e.Message);
                        }
                    }
                }
            }
            else
            {                                                                                         // Use "Universal Login" Login Mode
                ApiInitializeHandler ulDelegate = new ApiInitializeHandler(TT_UniversalInitComplete); // Call back after API is created.
                try
                {
                    TTAPI.CreateUniversalLoginTTAPI(m_Dispatcher, m_UserName, m_Password, ulDelegate);
                }
                catch (Exception e)
                {
                    if (m_Log != null)
                    {
                        m_Log.NewEntry(LogLevel.Warning, "InitAPI: TT Exception {0}.", e.Message);
                    }
                    if (m_AlertManager != null)
                    {
                        m_AlertManager.RequestEmailAlert(AlertLevel.High, "InitAPI: TT Exception {0}.", e.Message);
                    }
                }
            }
            //System.Windows.Forms.MessageBox.Show("test TT2");
        }// InitAPI()