Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceProcess"/> class.
 /// </summary>
 /// <param name="executionMethod"><see cref="Delegate"/> that gets invoked when <see cref="Start()"/> is called.</param>
 /// <param name="name">Name of the <see cref="ServiceProcess"/>.</param>
 /// <param name="arguments">Arguments to be passed in to the <paramref name="executionMethod"/>.</param>
 public ServiceProcess(Action <string, object[]> executionMethod, string name, params object[] arguments)
 {
     m_name            = name;
     m_arguments       = arguments;
     m_executionMethod = executionMethod;
     m_currentState    = ServiceProcessState.Unprocessed;
 }
Exemplo n.º 2
0
        public ServiceStateUnit(string binding, ServiceProcessState _reportSeverity, string _name, Dictionary <string, string> param)
        {
            udpBinding = binding == "UDP";

            if (binding.ToLower() == "site")
            {
                siteBinding = true;
                if (param.ContainsKey("url"))
                {
                    siteUrl = param["url"];
                }
                if (param.ContainsKey("regexp"))
                {
                    regExp = param["regexp"];
                }
            }
            else
            {
                if (!udpBinding)
                {
                    proxy = new ModuleStatusProxy(binding);
                }
                //wrapper = new ServiceStateWrapper(binding);
            }


            ReportSeverity = _reportSeverity;
            Name           = _name;
            LastUpdated    = DateTime.Now;
        }
Exemplo n.º 3
0
        /// <summary>
        /// снять ошибку. состояние устанавливается в пред. состояние
        /// (ОК если других ошибок в списке нет)
        /// пример: получение котировки после приостанова потока котировок
        /// </summary>
        public void RemoveError(ServiceProcessState _state, string errorCode)
        {
            var errorWithCode = new ServiceProcessErrorWithCode {
                code = errorCode, error = _state
            };

            errorCodes.TryRemove(errorWithCode, LockTimeout);
            var count = errorCodes.Count ?? 0;

            State = count == 0 ? ServiceProcessState.OK : errorCodes[count - 1].error;
        }
Exemplo n.º 4
0
        /// <summary>
        /// установить ошибку, добавить ее в список ошибок для возможности снять
        /// </summary>
        public void AddError(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured, string errorCode)
        {
            State = _state;
            var errorWithCode = new ServiceProcessErrorWithCode {
                code = errorCode, error = _state
            };

            if (_state == ServiceProcessState.HasCriticalErrors ||
                _state == ServiceProcessState.HasErrors ||
                _state == ServiceProcessState.HasWarnings)
            {
                LastError        = _lastError;
                LastErrorOccured = _lastErrorOccured;
                errorCodes.TryRemove(errorWithCode, LockTimeout);
            }
        }
Exemplo n.º 5
0
        public ServiceStateUnit(string binding, ServiceProcessState _reportSeverity, string _name, Dictionary<string, string> param)
        {
            udpBinding = binding == "UDP";

            if (binding.ToLower() == "site")
            {
                siteBinding = true;
                if (param.ContainsKey("url")) siteUrl = param["url"];
                if (param.ContainsKey("regexp")) regExp = param["regexp"];
            }
            else
            {
                if (!udpBinding)
                    proxy = new ModuleStatusProxy(binding);
                    //wrapper = new ServiceStateWrapper(binding);
            }

            ReportSeverity = _reportSeverity;
            Name = _name;
            LastUpdated = DateTime.Now;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Raises the <see cref="ProcessStateChanged"/> event.
        /// </summary>
        /// <param name="processName">Name of the <see cref="ServiceProcess"/> whose state changed.</param>
        /// <param name="processState">New <see cref="ServiceProcessState"/> of the <see cref="ServiceProcess"/>.</param>
        protected virtual void OnProcessStateChanged(string processName, ServiceProcessState processState)
        {
            // Notify all service event consumer of change in process state
            if ((object)ProcessStateChanged != null)
                ProcessStateChanged(this, new EventArgs<string, ServiceProcessState>(processName, processState));

            // Notify all remote clients of change in process state
            SendProcessStateChangedResponse(processName, processState);
        }
Exemplo n.º 7
0
 public ServiceStateInfo(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured)
 {
     State = _state;
     LastError = _lastError;
     LastErrorOccured = _lastErrorOccured;
 }
Exemplo n.º 8
0
 public ServiceStateInfo(ServiceProcessState _state)
 {
     State = _state;
 }
Exemplo n.º 9
0
 public void SetState(ServiceProcessState _state)
 {
     State = _state;
 }
Exemplo n.º 10
0
 /// <summary>
 /// снять ошибку. состояние устанавливается в пред. состояние
 /// (ОК если других ошибок в списке нет)
 /// пример: получение котировки после приостанова потока котировок
 /// </summary>        
 public void RemoveError(ServiceProcessState _state, string errorCode)
 {
     var errorWithCode = new ServiceProcessErrorWithCode { code = errorCode, error = _state };
     errorCodes.TryRemove(errorWithCode, LockTimeout);
     var count = errorCodes.Count ?? 0;
     State = count == 0 ? ServiceProcessState.OK : errorCodes[count - 1].error;
 }
Exemplo n.º 11
0
        /// <summary>
        /// установить ошибку, добавить ее в список ошибок для возможности снять
        /// </summary>        
        public void AddError(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured, string errorCode)
        {
            State = _state;
            var errorWithCode = new ServiceProcessErrorWithCode { code = errorCode, error = _state };

            if (_state == ServiceProcessState.HasCriticalErrors ||
                _state == ServiceProcessState.HasErrors ||
                _state == ServiceProcessState.HasWarnings)
            {
                LastError = _lastError;
                LastErrorOccured = _lastErrorOccured;
                errorCodes.TryRemove(errorWithCode, LockTimeout);
            }
        }
Exemplo n.º 12
0
 public void AddError(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured)
 {
     AddError(_state, _lastError, _lastErrorOccured, "");
 }
Exemplo n.º 13
0
 public ServiceStateInfo(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured)
 {
     State            = _state;
     LastError        = _lastError;
     LastErrorOccured = _lastErrorOccured;
 }
Exemplo n.º 14
0
 public ServiceStateInfo(ServiceProcessState _state)
 {
     State = _state;
 }
Exemplo n.º 15
0
 private void SendProcessStateChangedResponse(string processName, ServiceProcessState currentState)
 {
     ServiceResponse response = new ServiceResponse("PROCESSSTATECHANGED");
     response.Attachments.Add(new ObjectState<ServiceProcessState>(processName, currentState));
     SendResponse(response);
 }
Exemplo n.º 16
0
 public void AddError(ServiceProcessState _state, string _lastError, DateTime _lastErrorOccured)
 {
     AddError(_state, _lastError, _lastErrorOccured, "");
 }
Exemplo n.º 17
0
 public void SetState(ServiceProcessState _state)
 {
     State = _state;
 }