Ejemplo n.º 1
0
        public Core()
        {
            LoadNewMarketActionEventHandler = LoadNewMarket;
            MarketProcessorThreadStatusChangedEventHandler = MarketProcessorThreadStatusChanged;
            MarketDataUpdatedEventHandler = MarketDataUpdated;
            EngineMessageEventHandler = NewMessage;
            MarketProcessorMessageEventHandler = NewMessage;
            AutoMarketLoaderMessageEventHandler = NewMessage;

            // Clear and create the event broker
            SubscribeToPublicEvents();

            if (File.Exists(Directory.GetCurrentDirectory() + "\\lignite.configuration.xml"))
            {
                // Load the config settings
                settings = new XmlFileOperations().Read(Directory.GetCurrentDirectory() + "\\lignite.configuration.xml");

                //Load plugins
                Loadplugins();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Basically all we are doing is aborting all the currently active threads
        /// </summary>
        /// <returns></returns>
        public bool Stop()
        {
            try
            {
                /*** Stop and clear the core timer ***/
                EngineCoreTimer.Enabled = false;
                EngineCoreTimer.Elapsed -= __TimersElapsedEventHandler;

                /*** Send the shutdown message to all listeners ***/
                OnSystemShutdownEvent(this, new EventArgs());

                /*** Kill the API session ***/
                betfairAPI.Logout();

                /*** Clear the loaded settings ***/
                settings = new Settings();

                return true;
            }
            catch (Exception ex)
            {
                SendMessage(String.Format("EXCEPTION: {0}\n", ex.Message));
                return false;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The system initialization function, this preps and loads
        /// all the required child elements and services. It also does
        /// sanity check on the entire system
        /// </summary>
        /// <param name="configurationFile">The configuration file.</param>
        public void Start(string configurationFile)
        {
            try
            {
                // Write out to the console
                SendMessage("Lignite Engine Initializing");

                // Load the config settings
                settings = new XmlFileOperations().Read(configurationFile);

                // Load the Betfair data provider
                betfairAPI = new BetfairAPI(
                    settings.Betfair.Username,
                    settings.Betfair.Password,
                    settings.Betfair.ProductId,
                    settings.Betfair.VendorSoftwareId,
                    settings.Betfair.EndPointGlobalAPI,
                    settings.Betfair.EndPointExchangeAPIs[0],
                    settings.Betfair.EndPointExchangeAPIs[1],
                    settings.Betfair.AutoKeepAliveFrequency
                    );

                // make sure the hashtable used for thread tracking is empty and create instance
                if (LigniteEngineThreads != null)
                {
                    LigniteEngineThreads.Clear();
                }
                else
                {
                    LigniteEngineThreads = new Dictionary<string, Thread>();
                }

                // Start the timer
                EngineCoreTimer = new Timer(100);
                __TimersElapsedEventHandler = OnTimedEvent;
                EngineCoreTimer.Elapsed += __TimersElapsedEventHandler;
                EngineCoreTimer.Interval = 100;
                EngineCoreTimer.Enabled = true;

                // Start the market loader
                StartAutoMarketLoaderThread();

                //Load plugins
                Loadplugins();
            }
            catch (Exception ex)
            {
                SendMessage(String.Format("EXCEPTION: {0}", ex.Message));
            }
        }