示例#1
0
        public WorkPackage FetchWork(OSEnum pOS, String pAssignedClient)
        {
            if (!QueuedWorkItems.Any())
            {
                return(null);
            }

            //get first item in list and create package for it
            var item    = QueuedWorkItems.First();
            var package = item.Start(pOS, pAssignedClient);

            //move from queued to active
            QueuedWorkItems.Remove(item);
            ActiveWorkItems.Add(item);

            return(package);
        }
示例#2
0
        private void AddNewWorkItem(String pParameters)
        {
            var newitem = new WorkItem(pParameters);

            newitem.OnTimeoutHappenedEvent += sender =>
            {
                //remove
                ActiveWorkItems.Remove(sender);

                //check if result items already exist; if it does, skip it
                if (_resultManager.CheckIfResultExists(pParameters))
                {
                    return;
                }

                //create new
                AddNewWorkItem(sender.Parameters);
            };
            QueuedWorkItems.Add(newitem);
        }
示例#3
0
        public void SendResults(ResultPackage pResults)
        {
            //if save results have been successfully saved, remove item from active operations
            if (_resultManager.VerifyAndSave(pResults))
            {
                NotifyNewLogMessageEvent($"Attempt to remove \"{pResults.WorkPackage.Commands.First().Parameters}\" from queue.");

                //remove from active
                var workitem = ActiveWorkItems.FirstOrDefault(t => t.Parameters == pResults.WorkPackage.Commands.First().Parameters);
                if (workitem != null)
                {
                    ActiveWorkItems.Remove(workitem);
                    NotifyNewLogMessageEvent($"Removed {workitem.Parameters} from active work.");
                }

                //(edge case): remove from queued (e.g. restarting server)
                var queueitem = QueuedWorkItems.FirstOrDefault(t => t.Parameters == pResults.WorkPackage.Commands.First().Parameters);
                if (queueitem != null)
                {
                    QueuedWorkItems.Remove(queueitem);
                    NotifyNewLogMessageEvent($"Removed {queueitem.Parameters} from queue.");
                }
            }
        }
示例#4
0
 private bool IsAlreadyInList(String pParameters)
 {
     return(QueuedWorkItems.Any(t => t.Parameters == pParameters) || ActiveWorkItems.Any(t => t.Parameters == pParameters));
 }