Пример #1
0
        /// <summary>
        /// Set things in motion so your Dataphor service can do its work. Checks to see if the ServerSettings.dst file exists
        /// in the directory containing the service before deserializing the settings from the file stream.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            // The args passed here are only coming in from the arguments to the service
            // as a result of a manual start from the service control panel, not the
            // arguments to the actual service. The InstanceName is pulled from
            // those arguments in the Main static and passed to the constructor of
            // the service.
            try
            {
                if (_instanceName == null)
                {
                    _instanceName = GetInstanceName(args);
                }

                if (_instanceName == null)
                {
                    _instanceName = Server.Engine.DefaultServerName;
                }

                _dataphorServiceHost = new DataphorServiceHost();
                _dataphorServiceHost.InstanceName = _instanceName;
                _dataphorServiceHost.Start();
            }
            catch (Exception exception)
            {
                LogException(exception);
                throw;
            }
        }
Пример #2
0
 protected override void OnStop()
 {
     try
     {
         if (_dataphorServiceHost != null)
         {
             if (_dataphorServiceHost.IsActive)
             {
                 _dataphorServiceHost.Stop();
             }
             _dataphorServiceHost = null;
         }
     }
     catch (Exception exception)
     {
         LogException(exception);
     }
 }