示例#1
0
 public ServiceEventArgs(ServiceEventType serviceEventType, ServiceParameter p, string id = null)
 {
     Id = id;
     ServiceParameter = p;
     FactoryName = p.Factory;
     ServiceEventType = serviceEventType;
 }
示例#2
0
        protected Device MatchEvent <SERVICE>(ServiceEvent serviceEvent, ServiceEventType eventType) where SERVICE : class
        {
            if (serviceEvent.ServiceEventType != eventType)
            {
                return(null);
            }

            var device = serviceEvent.Subject as Device;

            if (device == null)
            {
                return(null);
            }

            var service = device.DeviceDriver as SERVICE;

            if (service == null)
            {
                return(null);
            }

            //HAL.DebugWriteLine("BaseService:MatchEvent()-Z");
            //HAL.Pause();

            return(device);
        }
示例#3
0
 internal ServiceEventArgs(string serviceType, object[] serviceInstances, ServiceEventType eventType)
 {
     if ((serviceType == null) || (serviceType.Length == 0))
     {
         throw new ArgumentException("Service type can no be null or empty.", "serviceType");
     }
     ServiceInstances = (serviceInstances == null) ? new object[0] : serviceInstances;
     ServiceType      = serviceType;
     ServiceEventType = eventType;
 }
 public void WriteServiceEvent(string sessionId, ServiceEventType type, ServiceName service, string msg, int?exchangeId = null)
 {
     WriteServiceEvent(new ServiceEventData
     {
         ServiceName = service,
         SessionId   = sessionId,
         EventType   = type,
         Message     = msg,
         ExchangeId  = exchangeId
     });
 }
示例#5
0
        void Unsubscribe(ServiceEventType eventType)
        {
            List <IServiceSubscriber> subscribers;

            if (!_subscribers.TryGetValue(eventType, out subscribers))
            {
                return;                 // Nothing to unsubscribe
            }
            IServiceSubscriber subscriber = OperationContext.Current.GetCallbackChannel <IServiceSubscriber>();

            if (subscribers.Contains(subscriber))
            {
                subscribers.Remove(subscriber);
            }
        }
        /// <summary>
        /// Create a new ServiceEvent.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="guid"></param>
        /// <param name="message"></param>
        public ServiceEvent(ServiceEventType type, Guid?guid, String message)
        {
            _eventIndex = _indexCount++;
            _eventTime  = DateTime.Now;
            _eventType  = type;
            if (guid != null)
            {
                _guidStr = guid.ToString();
            }
            else
            {
                _guidStr = "";
            }

            _message = message;
        }
        public async Task <bool> RunServiceEvent(ServiceEventType serviceEvent)
        {
            if (serviceEvent.Equals(ServiceEventType.Calculation))
            {
                _calculationHandler.Calculate(this.Skjema);
            }
            else if (serviceEvent.Equals(ServiceEventType.Validation))
            {
                _validationHandler.Validate(this.Skjema, this._requestContext, this._modelState);
            }
            else if (serviceEvent.Equals(ServiceEventType.Instantiation))
            {
                _instantiationHandler.Instansiate(this.Skjema);
            }

            return(true);
        }
示例#8
0
        public void WriteServiceEvent(string sessionId, ServiceEventType type, ServiceName name, string msg, int?exchangeId = null)
        {
            var cmd = new ServiceEventCommand
            {
                CommandType = RemoteCommandType.DbWriteServiceEvent,
                SessionId   = sessionId,
                ServiceName = name,
                EventType   = type,
                Message     = msg,
                ExchangeId  = exchangeId
            };

            SendMessage <ServiceEventCommand>(
                () => cmd,
                () => RemoteCommandType.DbWriteServiceEvent
                );
        }
示例#9
0
        void Subscribe(ServiceEventType eventType)
        {
            List <IServiceSubscriber> subscribers;

            if (!_subscribers.TryGetValue(eventType, out subscribers))
            {
                subscribers = new List <IServiceSubscriber>();
                _subscribers.Add(eventType, subscribers);
            }

            IServiceSubscriber subscriber = OperationContext.Current.GetCallbackChannel <IServiceSubscriber>();

            if (!subscribers.Contains(subscriber))
            {
                subscribers.Add(subscriber);
            }
        }
示例#10
0
        public ApiResult WriteLog(string sessionId, string message, ServiceEventType eventType = ServiceEventType.Info, int?exchangeId = null)
        {
            Message    = message;
            SessionId  = sessionId;
            ExchangeId = exchangeId;

            var json = JsonConvert.SerializeObject(this);
            var url  = "/v1/log";

            switch (eventType)
            {
            case ServiceEventType.Info: url += "/info"; break;

            case ServiceEventType.Warn: url += "/warn"; break;

            case ServiceEventType.Fail: url += "/fail"; break;

            default: throw new InvalidOperationException();
            }
            return(_api.UserQuery(url, HttpMethod.Post, json, true));
        }
示例#11
0
        protected Device MatchEvent <SERVICE>(ServiceEvent serviceEvent, ServiceEventType eventType) where SERVICE : class
        {
            if (serviceEvent.ServiceEventType != eventType)
            {
                return(null);
            }

            var device = serviceEvent.Subject as Device;

            if (device == null)
            {
                return(null);
            }

            var service = device.DeviceDriver as SERVICE;

            if (service == null)
            {
                return(null);
            }

            return(device);
        }
        /// <summary>
        /// Create and dispatch a new local <see cref="ServiceEventArgs"/>
        /// with the given type to the registered event handlers.
        /// </summary>
        /// <param name="eventType">
        /// The type of <b>ServiceEventArgs</b> to create and dispatch.
        /// </param>
        protected virtual void DispatchServiceEvent(ServiceEventType eventType)
        {
            ServiceEventArgs evt = new ServiceEventArgs(this, eventType);

            switch (evt.EventType)
            {
            case ServiceEventType.Starting:
                InvokeServiceEvent(ServiceStarting, evt);
                break;

            case ServiceEventType.Started:
                InvokeServiceEvent(ServiceStarted, evt);
                break;

            case ServiceEventType.Stopping:
                InvokeServiceEvent(ServiceStopping, evt);
                break;

            case ServiceEventType.Stopped:
                InvokeServiceEvent(ServiceStopped, evt);
                break;
            }
        }
示例#13
0
 /// <summary>
 /// Constructs a new ServiceEventArgs.
 /// </summary>
 /// <param name="service">
 /// The <see cref="IService"/> that fired the event.
 /// </param>
 /// <param name="eventType">
 /// This event's type, one of the <see cref="ServiceEventType"/> enum
 /// values.
 /// </param>
 public ServiceEventArgs(IService service, ServiceEventType eventType)
 {
     m_source    = service;
     m_eventType = eventType;
 }
示例#14
0
 private void WriteEvent(ServiceEventType type, ServiceName service, string msg)
 {
     _dbRepo.WriteServiceEvent(new ServiceEventData {
         SessionId = _sessionId, EventType = type, ServiceName = Service, Message = msg
     });
 }
示例#15
0
 private void WriteEvent(ServiceEventType type, ServiceName service, string msg, int?exchangeId = null)
 {
     _dbRepo.WriteServiceEvent(SessionId, type, service, msg, exchangeId);
 }
示例#16
0
 public ServiceEventArgs(ServiceEventType serviceEventType, string factoryName, string id = null)
 {
     Id = id;
     FactoryName = factoryName;
     ServiceEventType = serviceEventType;
 }
示例#17
0
 public ServiceEvent(ServiceEventType serviceEventType, object subject = null)
 {
     ServiceEventType = serviceEventType;
     Subject          = subject;
 }