Esempio n. 1
0
        private void WorkItemHandler(IBasicProperties props, IWork iWork)
        {
            var work = iWork as SampleWorkItem;
            if (work == null)
                throw new Exception($"Don't know how to work on '{iWork.GetType().FullName}' items");

            this.InternalState = InternalStateEnum.Busy;

            var currentStatus = new ServiceComponentStatus() { Process = this.Process, ServiceComponent = this.GetType().Name, Status = "Working", SubStatus = "Starting" };
            this.PublishEvent(currentStatus);

            var workItemType = work.ItemType;
            var workItemId = work.ItemId;
            var workDelay = work.WorkDelay;

            currentStatus.SubStatus = "Executing";
            this.PublishEvent(currentStatus);

            Thread.Sleep(workDelay);

            currentStatus.SubStatus = "Completing";
            this.PublishEvent(currentStatus);

            this.InternalState = InternalStateEnum.Idle;
            this.PublishEvent("Idle");
        }
Esempio n. 2
0
 private void PublishEvent(string status, string substatus = null)
 {
     var evnt = new ServiceComponentStatus() { Process = this.Process, ServiceComponent = this.ServiceComponent, Status = status, SubStatus = substatus };
     this.PublishEvent(evnt);
 }