Example #1
0
        internal List <WorkerTask> CreateTasks(StatementOfWork newSow)
        {
            var newTasks = new List <WorkerTask>();

            foreach (var task in newSow)
            {
                var workerTask = new WorkerTask
                {
                    Id             = worker.GetNextTaskId(),
                    Description    = task.Description,
                    RequiredSkills = task.RequiredSkills,
                    DueDateTime    = task.DueDateTime,
                };

                workerTask.WorkItems = new List <WorkItem>();
                foreach (var wi in task.EstimatedWork)
                {
                    var workItem = this.worker.AddWorkItem(wi.Skill, wi.Minutes);
                    workerTask.WorkItems.Add(workItem);
                }
                if (this.worker.CurrentTasks.TryAdd(workerTask.Id, workerTask))
                {
                    newTasks.Add(workerTask);
                }
            }
            return(newTasks);
        }
Example #2
0
        internal WorkerPeer CreatePeer(CooperatingWorker cow)
        {
            var workerPeer = new WorkerPeer
            {
                Id          = worker.GetNextTaskId(),
                TasksUrl    = cow.TasksUrl,
                CapacityUrl = cow.CapacityUrl
            };


            if (this.worker.Peers.TryAdd(workerPeer.Id, workerPeer))
            {
                return(workerPeer);
            }
            else
            {
                return(null);
            }
        }