コード例 #1
0
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        public Monitor()
        {
            InitializeComponent();

            //Misty.Lib.Application.AppInfo appInfo = Misty.Lib.Application.AppInfo.GetInstance("Monitor",true);
            string currentPath = System.IO.Directory.GetCurrentDirectory();

            Log = new LogHub("Monitor", string.Format("{0}\\Logs\\", currentPath), true, LogLevel.ShowAllMessages);
            DateTime now = Log.GetTime();

            m_Writer = new DropQueueWriter(string.Format("{0}\\Logs\\", currentPath), string.Format("data_{0}_{1}.txt", now.ToString("yyyyMMdd"), now.ToString("HHmmss")), this.Log);
            m_Writer.Start();

            string s = string.Format("{0}\\user_female.ico", currentPath);

            if (System.IO.File.Exists(s))
            {
                this.Icon = Icon.ExtractAssociatedIcon(s);
            }

            // Instantiate TT API.
            m_TTService = TTServices.TTApiService.GetInstance();
            m_TTService.ServiceStateChanged += new EventHandler(TTService_ServiceStateChanged);
            m_TTService.Start(true);
        }
コード例 #2
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        //
        public HedgeOptionsDatabaseWriterTest()
        {
            m_Log = new LogHub("BRELibLog", string.Format("{0}{1}", UV.Lib.Application.AppInfo.GetInstance().BasePath,
                                                          UV.Lib.Application.AppInfo.GetInstance().LogDirectory), true, LogLevel.ShowAllMessages);
            InitializeComponent();
            m_UIDispatcher = Dispatcher.CurrentDispatcher;

            DatabaseInfo dbInfo = DatabaseInfo.Create(DatabaseInfo.DatabaseLocation.bredev);

            dbInfo.UserName        = "******";
            dbInfo.UserPW          = "test";
            m_DatabaseReaderWriter = new DatabaseReaderWriter(dbInfo);
            m_DatabaseReaderWriter.QueryResponse += new EventHandler(DatabaseReaderWriter_QueryResponse);

            this.textBoxExchangeName.Text = "CME";
            this.textBoxProductName.Text  = "GE";
            this.textBoxProductType.Text  = "Spread";

            m_TTAPIService = TTApiService.GetInstance();
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTApiService_ServiceStateChanged);
            m_TTAPIService.Start(true);

            m_Market = new MarketTTAPI();
            m_Market.MarketStatusChanged += new EventHandler(MarketTTAPI_MarketStatusChanged);
            m_Market.FoundResource       += new EventHandler(MarketTTAPI_MarketFoundServiceResource);
            m_Market.Start();
            m_Market.Connect();                             // initialize connection to API.
        }
コード例 #3
0
        //
        //
        #endregion//Private Event Handlers


        #region Form Event Handlers
        // *****************************************************************
        // ****                     Event Handlers                     ****
        // *****************************************************************
        //
        //
        private void button_Click(object sender, EventArgs e)
        {
            // Validate
            if (!(sender is Button))
            {
                return;
            }
            Button button = (Button)sender;

            //
            // Process button click
            //
            if (button == buttonStart)
            {
                TTApiService service = TTApiService.GetInstance();
                service.Start(this.checkBoxUseXTraderFollowLogin.Checked);
            }
            else if (button == buttonGetProducts)
            {
                int selectedIndex = listBoxMarkets.SelectedIndex;
                if (selectedIndex >= 0 && selectedIndex < listBoxMarkets.Items.Count)
                {
                    listBoxProducts.ClearSelected();                               // deselect any selected products.
                    listBoxProducts.Items.Clear();                                 // remove products from list.
                    m_Market.RequestProducts((string)listBoxMarkets.SelectedItem); // Request new products.
                }
            }
            else if (button == buttonGetInstruments)
            {
                int selectedIndex = listBoxProducts.SelectedIndex;
                if (selectedIndex >= 0 && selectedIndex < listBoxProducts.Items.Count)
                {
                    listBoxInstruments.ClearSelected();                                 // deselect any selected products.
                    listBoxInstruments.Items.Clear();                                   // remove products from list.
                    string  productUniqueName = ((string)listBoxProducts.SelectedItem); // Request new products.
                    Product product;
                    if (m_Products.TryGetValue(productUniqueName, out product))
                    {
                        m_Market.RequestInstruments(product);
                    }
                }
            }
            else if (button == buttonStop)
            {
            }
            else if (button == buttonExit)
            {
                Shutdown();
                this.Close();
            }
            else if (button == buttonUpdate)
            {
                ToggleUpdateState();
                //UpdateMarket();
            }
            else
            {   // unknown button
                return;
            }
        }
コード例 #4
0
        /// <summary>
        /// GUI constructor to have both of the paths as members and log as well as drop file player, audit trail player.
        /// </summary>
        public AmbreRecoveryViewer()
        {
            InitializeComponent();
            typeof(MarketTTAPI).ToString();

            // Create log viewer.
            bool isLogViewerVisible = true;

            Log = new LogHub(ApplicationName, AppInfo.GetInstance().LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);

            // Create app service and get useful paths.
            AppServices appAmbreMaintenanceServices = AppServices.GetInstance(ApplicationName, true);

            m_RepositoryDropFilePath = appAmbreMaintenanceServices.Info.DropPath;
            m_AuditTrailFilePath     = appAmbreMaintenanceServices.Info.DropPath;
            if (m_DebugMode)
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, ReferenceApplicationName);
            }
            else
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(string.Format("\\{0}", ApplicationName), "");
            }

            Log.NewEntry(LogLevel.Minor, "The default paths to operate are {0} and {1}.", m_RepositoryDropFilePath, m_ReferenceDropFilePath);
            if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, "Ambre");
                Log.NewEntry(LogLevel.Major, "The default path for reference Ambre system does not exist, and the operating path becomes {0}.", m_ReferenceDropFilePath);
                if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
                {
                    Log.NewEntry(LogLevel.Major, "The changed path still does not exist. and the program can not proceed.");
                    return;
                }
            }

            // Create market tt api service and tt api service.
            m_MarketTTAPIService = new MarketTTAPI();
            m_MarketTTAPIService.Start();
            m_TTAPIService     = TTApiService.GetInstance();
            m_TTAPIService.Log = this.Log;
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTAPIService_ServiceStateChanged);
            m_TTAPIService.Start();

            // Sample for the user login name and fill hub name.
            textBoxUserName.Text    = "BETSIM";
            textBoxFillHubName.Text = "2014";
            m_UserName = textBoxUserName.Text;
            m_FillHubOrFillManagerName = textBoxFillHubName.Text;

            // Create file players.
            m_DropFilePlayer = new DropFilePlayer(m_ReferenceDropFilePath, Log);

            // Add closing form event trigger.
            this.FormClosing += new FormClosingEventHandler(AmbreRecoveryViewer_Closing);

            // Find all existing audit trail files. Also in this block, toggle the earliest and latest date time to the GUI.
            m_RepoFileList = new List <string>();
            LoadAllAuditTrailFiles();
        }//AmbreRecoveryViewer()
コード例 #5
0
        }//constructor

        //
        //
        private void InitializeServices()
        {
            AppInfo info = AppInfo.GetInstance("Bret");

            bool isLogViewerVisible = false;

            #if (DEBUG)
            isLogViewerVisible = true;
            #endif

            Log = new LogHub("TalkerForm", info.LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);

            // Instantiate TT API.
            m_TTServices = TTServices.TTApiService.GetInstance();
            m_TTServices.ServiceStateChanged += new EventHandler(TTServices_ServiceStateChanged);
            m_TTServices.Start(true);

            // Instantiate hubs
            m_MarketHub = new MarketTTAPI();
            m_MarketHub.Log.IsViewActive = isLogViewerVisible;
            //m_MarketHub.InstrumentChanged += new EventHandler(MarketHub_InstrumentChanged);
            m_MarketHub.Start();

            m_FillHub           = new FillHub(string.Empty, isLogViewerVisible);
            m_FillHub.MarketHub = m_MarketHub;
            //m_FillHub.PositionBookCreated += new EventHandler(FillHub_PositionBookCreated);
            //m_FillHub.PositionBookChanged += new EventHandler(FillHub_PositionBookChanged);
            //m_FillHub.PositionBookPnLChanged += new EventHandler(FillHub_PositionBookPnLChanged);
            m_FillHub.Start();


            m_TalkerHub = new TalkerHub(isLogViewerVisible);
            m_TalkerHub.ServiceStateChanged += new EventHandler(TalkerHub_ServiceStateChanged);
            m_TalkerHub.RequestAddHub(m_FillHub);
            m_TalkerHub.Start();
        }