Ejemplo n.º 1
0
        /// <summary>
        /// Called when the service is stopped.
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                // Shut down each of the Web Services hosted by this Windows Service.
                foreach (ServiceHost serviceHost in this.serviceHosts)
                {
                    serviceHost.Close();
                }
            }
            catch (Exception exception)
            {
                // Any problems initializing should be sent to the Event Log.
                EventLog.WriteEntry(
                    Service.source,
                    string.Format("{0}: {1}", exception.Message, exception.StackTrace),
                    EventLogEntryType.Error);
            }

#if DEBUG
            // Start the business rules and crossing automatically when debugging.
            OperationParameters operationParameter = new OperationParameters();
            operationParameter.AreBusinessRulesActive = false;
            operationParameter.IsCrossingActive       = false;
            OperationManager.OperatingParameters      = operationParameter;
#endif

            // Log the end of the service.
            EventLog.WriteEntry(
                Service.source,
                string.Format(Properties.Resources.ServiceStoppingMessage, Service.serviceName),
                EventLogEntryType.Information);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This object will simulate an auction market on equities.
        /// </summary>
        static OperationManager()
        {
            // This object is used by the System.Monitor methods that control multithreaded access to the data in this class.
            OperationManager.syncRoot = new Object();

            // These are the initial operating parameters for the business rules.
            OperationParameters operatingParameters = new OperationParameters();

            operatingParameters.AreBusinessRulesActive = true;
            operatingParameters.IsCrossingActive       = true;
            operatingParameters.IsChatActive           = true;
            OperationManager.OperatingParameters       = operatingParameters;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start the service.
        /// </summary>
        /// <param name="args">Command line parameters.</param>
        protected override void OnStart(string[] args)
        {
            // Log the start of the service.
            EventLog.WriteEntry(
                Service.source,
                string.Format(Properties.Resources.ServiceStartingMessage, Service.serviceName),
                EventLogEntryType.Information);

            // Hack - This should eventually be implicit.  It seems to be required now because all the crossing is done dynamically.
            // Start the business rules and crossing automatically when debugging.
            OperationParameters operationParameter = new OperationParameters();

            operationParameter.AreBusinessRulesActive = true;
            operationParameter.IsCrossingActive       = true;
            operationParameter.IsChatActive           = true;
            OperationManager.OperatingParameters      = operationParameter;

            try
            {
                // Start each of the WCF Web Services hosted by this Windows Service.
                foreach (ServiceHost serviceHost in this.serviceHosts)
                {
                    serviceHost.Open();
                }
            }
            catch (Exception exception)
            {
                // Any problems initializing should be sent to the Event Log.
                EventLog.WriteEntry(
                    Service.source,
                    string.Format("{0}: {1}", exception.Message, exception.StackTrace),
                    EventLogEntryType.Error);
            }

            // Log the start of the service.
            EventLog.WriteEntry(
                Service.source,
                string.Format(Properties.Resources.ServiceStarted, Service.serviceName),
                EventLogEntryType.Information);
        }