async Task ExecuteLoadWorkersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                WorkersList.Clear();
                var workers = await WorkerStore.GetItemsAsync(true);

                foreach (var worker in workers)
                {
                    WorkersList.Add(worker);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        internal static bool LimitNumberOfWorkers(Address workerAddress)
        {
            if (WorkersList.Contains(workerAddress))
            {
                return(false);
            }
            var allowedWorkerNodes = LicenseManager.License.AllowedNumberOfWorkerNodes;

            if (WorkersList.Count < allowedWorkerNodes)
            {
                WorkersList.Add(workerAddress);
                return(false);
            }
            Logger.WarnFormat(
                "License limitation for [{0}] workers per distributor reached. To obtain a license that allows to add more workers, please visit http://particular.net/licensing",
                allowedWorkerNodes);
            return(true);
        }
Exemple #3
0
        public void BornNewBee()
        {
            int typeOfBee = random.Next(1, 6);
            int weight    = random.Next(100, 301);

            switch (typeOfBee)
            {
            case 1:
                WorkersList.Add(new NectarCollector(weight));
                NumberOfWorkers++; NumberOfNectarCollectors++;
                break;

            case 2:
                WorkersList.Add(new NectarConverter(weight));
                NumberOfWorkers++; NumberOfNectarConverters++;
                break;

            default:
                int        howManyAbilities   = random.Next(1, 5);
                List <Job> newWorkerAbilities = new List <Job>();
                for (int i = 0; i < howManyAbilities; i++)
                {
                    Job jobToAdd = (Job)Enum.Parse(typeof(Job), random.Next(0, 6).ToString());
                    if (newWorkerAbilities.Contains(jobToAdd))
                    {
                        i--;
                    }
                    else
                    {
                        newWorkerAbilities.Add(jobToAdd);
                    }
                }
                WorkersList.Add(new Worker(weight, newWorkerAbilities));
                NumberOfWorkers++;
                break;
            }
        }
Exemple #4
0
        public void BornNewBee(List <Job> jobNewWorkerCanDo)
        {
            int weight = random.Next(100, 301);

            WorkersList.Add(new Worker(weight, jobNewWorkerCanDo));
        }
Exemple #5
0
 public void AddWorker(Worker x)
 {
     WorkersList.Add(x);
 }