예제 #1
0
        /// <summary>
        /// This method stops the service. If the service is not running, no action is taken.
        /// </summary>
        public void Stop()
        {
            switch (ServiceStatus)
            {
                case XimuraServiceStatus.Started:
                case XimuraServiceStatus.Paused:
                case XimuraServiceStatus.Pausing:
                case XimuraServiceStatus.Resuming:
                    try
                    {
                        server.Stop();
                    }
                    catch (Exception ex)
                    {

                    }
                    server = null;

                    AppDomain.Unload(dom);
                    dom = null;
                    break;
            }

            ServiceStatus = XimuraServiceStatus.NotStarted;
            NotifyPropertyChanged("ServiceStatus");

            ErrorDescription = "";
            NotifyPropertyChanged("ErrorDescription");

            CanEdit = true;
            NotifyPropertyChanged("CanEdit");
        }
예제 #2
0
        /// <summary>
        /// This method starts the service.
        /// </summary>
        /// <exception cref="Ximura.Windows.ServiceStartException">This exception is thrown if the service generates an unhandled exception.</exception>
        public void Start()
        {
            bool throwError = false;

            CanEdit = false;
            ErrorInStart = false;
            NotifyPropertyChanged("CanEdit");
            NotifyPropertyChanged("ErrorInStart");

            if (!ServiceEnabled)
            {
                ErrorDescription = "Service Disabled";
                NotifyPropertyChanged("ErrorDescription");
                ServiceStatus = XimuraServiceStatus.Disabled;
                NotifyPropertyChanged("ServiceStatus");
                return;
            }

            ErrorDescription = "Starting";
            NotifyPropertyChanged("ErrorDescription");

            ServiceStatus = XimuraServiceStatus.Starting;
            NotifyPropertyChanged("ServiceStatus");

            try
            {
                dom = AppDomain.CreateDomain(Name);

                object obj = dom.CreateInstanceAndUnwrap(ServerType.Assembly.FullName, ServerType.FullName);
                server = obj as IXimuraService;

                server.Start();

                ServiceStatus = XimuraServiceStatus.Started;
                NotifyPropertyChanged("ServiceStatus");
                ErrorDescription = "";
                NotifyPropertyChanged("ErrorDescription");
            }
            catch (Exception ex)
            {
                ErrorDescription = string.Format("Error: {0}",ex.Message);
                ErrorInStart = true;
                ServiceStatus = XimuraServiceStatus.Failed;

                if (dom != null)
                {
                    AppDomain.Unload(dom);
                    dom = null;
                }

                NotifyPropertyChanged("ErrorInStart");
                NotifyPropertyChanged("ServiceStatus");
                NotifyPropertyChanged("ErrorDescription");

                if (RaiseMessage != null)
                {
                    throwError = RaiseMessage(this,
                        string.Format("Service '{0}' cannot start. Do you wish to continue?", Name),
                        "Start error.", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes;
                }
                else
                    throwError = true;
            }


            if (throwError)
                throw new ServiceStartException(ErrorDescription);
        }
예제 #3
0
		/// <summary>
		/// This method is called after the status of the service has been changed.
		/// </summary>
		/// <param name="action">The action, i.e. start, stop, etc.</param>
		/// <param name="service">The component service to change.</param>
		protected virtual void ComponentsStatusAfterChange(
			XimuraServiceStatusAction action,IXimuraService service)
		{

		}
예제 #4
0
        /// <summary>
        /// This overriden method checks on start whether the command has a priority set, 
        /// if it does has a priority set, the command is not started.
        /// </summary>
        /// <param name="action">The service action.</param>
        /// <param name="service">The service.</param>
        /// <returns>Returns true if the service can start.</returns>
        protected override bool ComponentsStatusBeforeChange(XimuraServiceStatusAction action, IXimuraService service)
        {
            //We only want to start commands that do not have a priority.
            if (action == XimuraServiceStatusAction.Start &&
                CommandExtender.CommandHasPriority(service))
                return false;

            return base.ComponentsStatusBeforeChange(action, service);
        }
예제 #5
0
		/// <summary>
		/// This method is called before the status of a component is changed. You may override 
		/// this method to make additional checks before the component status is changed.
		/// </summary>
		/// <param name="action">The action, i.e. start, stop, etc.</param>
		/// <param name="service">The component service to change.</param>
		/// <returns>This method should return true if you want the status to change. 
		/// If this method returns false the status of the service will not change.</returns>
		protected virtual bool ComponentsStatusBeforeChange(
			XimuraServiceStatusAction action,IXimuraService service)
		{
			return true;
		}