public VarianceTests() { _developers = new Workers <Developer>(); _developers.Add(new Developer { Name = "Bob" }); _developers.Add(new Developer { Name = "Tom" }); _developers.Add(new CSharpDeveloper { Name = "Amy" }); }
public GameObject SpawnWorker(Fire fire, bool randomize = true) { if (Workers.Count > generationParameters.resources.workerCapPerFire * Fires.Count) { return(null); } // This order by with weighed random will shuffle the list but segregate the shuffle grass tiled as more important than the others Vector2Int pos = Vector2Int.zero; try { pos = fire.GetInfluence().OrderBy(t => Random.value * (t.TileType == Tile.Type.Grass ? 1f : 10f)).ToList().Find(t => t.TileType == Tile.Type.Grass || t.TileType == Tile.Type.Tree).Coordinates; } catch { pos = fire.TilePosition(); } GameObject worker = Instantiate <GameObject>(workerPrefabs[Random.Range(0, workerPrefabs.Length)], GetWorldLocation(pos), Quaternion.identity); Workers.Add(worker); AgentJobHandler jobsScript = worker.GetComponent <AgentJobHandler>(); if (jobsScript == null) { Debug.LogError("Worker had no job handler?!"); return(null); } jobsScript.Fire = fire; return(worker); }
public WorkGroup(int amountOfWorkers) { for (var i = 0; i < amountOfWorkers; i++) { Workers.Add(new Worker()); } }
private void CreateWorkers() { Workers.Add(new Worker("Шванов Сергій Володимирович", Posts.FirstOrDefault(el => el.Name == "Програміст"), ".Net Розробник", 5) { Id = 1, Bio = "Новий працівник" }); Workers.Add(new Worker("Лозова Аліна Анатоліївна", Posts.FirstOrDefault(el => el.Name == "Дизайнер"), "3D-Дизайнер", 4) { Id = 2 }); Workers.Add(new Worker("Кріпак Олександр Макарович", Posts.FirstOrDefault(el => el.Name == "Програміст"), "Веб-розробник", null) { Id = 3 }); Workers.Add(new Worker("Возілевський Леонід Андрійович", Posts.FirstOrDefault(el => el.Name == "Тестувальник"), "Тестувальник ПО", 3) { Id = 4 }); Workers.Add(new Worker("Ломаченко Олександр Іванович", Posts.FirstOrDefault(el => el.Name == "Тестувальник"), null, 7) { Id = 5 }); Workers.Add(new Worker("Федоренко Оксана Василівна", Posts.FirstOrDefault(el => el.Name == "Дизайнер"), null, null) { Id = 6 }); Workers.Add(new Worker("Баланов Руслан Ігорович", Posts.FirstOrDefault(el => el.Name == "Програміст"), null, 8) { Id = 7 }); Workers.Add(new Worker("Харченко Іван Іванович", Posts.FirstOrDefault(el => el.Name == "Менеджер"), "Менеджер по рекламі", 4) { Id = 8 }); }
public void StartWork(IWork work) { WorkerThread worker = new WorkerThread(work, InvokingThread); worker.BeforeCallback += OnBefore; worker.WorkEndedCallback += OnWorkEnded; worker.AfterCallback += OnAfter; lock (Workers) { Workers.Add(worker); } worker.Before(); if (SingleThreaded) { worker.RunSingleThreaded(); } else { if (work.Type == IWorkType.Invisible) { Thread thread = new Thread(worker.Run); thread.Priority = ThreadPriority.Lowest; thread.Start(); } else { Debug.Assert(!Object.ReferenceEquals(InvokingThread, null)); ThreadPool.QueueUserWorkItem(worker.Run); } } }
/// <summary> /// Assign a worker to the shift. /// </summary> /// <param name="worker"></param> public void Assign(TestWorker worker) { log.Debug("{0} shift assigned worker {1}", _name, worker.Name); Workers.Add(worker); worker.Busy += (s, ea) => Interlocked.Increment(ref _busyCount); worker.Idle += (s, ea) => { // Quick check first using Interlocked.Decrement if (Interlocked.Decrement(ref _busyCount) == 0) { lock (_syncRoot) { // Check busy count again under the lock if (_busyCount == 0 && !HasWork) { this.EndShift(); } } } }; worker.Start(); }
public static void ReadWorkers() { string queryString = "select worker_id, fio, login, password, position, house_id from workers"; using (NpgsqlConnection connection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString)) { NpgsqlCommand command = new NpgsqlCommand(queryString, connection); connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { int house = 0; if (reader[5].ToString() != "") { house = int.Parse(reader[5].ToString()); } Worker new_Worker = new Worker { Worker_id = (int)reader[0], FIO = reader[1].ToString(), Login = reader[2].ToString(), Password = reader[3].ToString(), Position = reader[4].ToString(), House_id = house }; Workers.Add(new_Worker); new_Worker = null; } } finally { reader.Close(); } } }
/// <summary> /// Добавить сотрудника в отдел /// </summary> /// <param name="worker">сотрудник</param> public void AddWorker(Worker worker) { if (worker.GetType() != typeof(Manager)) { Workers.Add(worker); } }
public void Work(params string[] queues) { var worker = new Worker(JobCreator, FailureService, Client, queues); Workers.Add(worker); worker.Work(); }
//metoda kupująca robotnika private void buttonBuyWorker_Click(object sender, EventArgs e) { //Warunek kupna robotnika: aktualna ilość złota > 30 oraz gra nie może być zapauzowana if (money >= 30 && Counter % 2 == 0) { if (workerUpgrade == 0) { //tworzenie nowego obiektu klasy Worker Worker worker = new Worker(); //dodanie obiektu do listy pracowników Workers.Add(worker); } if (workerUpgrade == 1) { //tworzenie nowego obiektu klasy UpgradedWorker UpgradedWorker upgradedWorker = new UpgradedWorker(); //dodanie do listy Workers.Add(upgradedWorker); } if (workerUpgrade == 2) { //tworzenie obiektu klasy MasterWorker MasterWorker masterWorker = new MasterWorker(); //dodanie do listy Workers.Add(masterWorker); } //liczba elementów listy howManyWorkers = Workers.Count; //zmiana liczby aktualnych robotników wyświeltanych w textboxie textBoxHowManyWorkers.Text = howManyWorkers.ToString(); } }
/// <summary> /// Меняет менеджера отдела /// </summary> /// <param name="manager">новый менеджер</param> public void СhangeManager(Manager manager) { Workers.Remove(Manager); Manager = manager; Workers.Add(Manager); manager.AssignDepartmentToManagement(this); }
public IConsoleWorker AddWorker(ConsoleWorker newWorker) { WorkerManager manager = new WorkerManager(Writer, newWorker); Workers.Add(manager); return(manager); }
private void CreateFakeWorker(BlobJob BlobJob) { var worker = new Worker() { BlobJob = BlobJob, SizeInBytes = BlobJob.SizeInBytes, }; ExecuteOnUI(() => { Workers.Add(worker); }); var random = new Random(); worker.SizeInBytes = (Convert.ToInt64(1000000 * random.NextDouble()) + 1000000); var backgroundWorker = new Thread(new ThreadStart(() => { while (worker.TransferedInBytes < worker.SizeInBytes) { ExecuteOnUI(() => { worker.SpeedInBytes = random.Next(100000); worker.TransferedInBytes += worker.SpeedInBytes; worker.TimeRemaining = TimeSpan.FromSeconds((worker.SizeInBytes - worker.TransferedInBytes) / worker.SpeedInBytes); }); Thread.Sleep(1000); } worker.Message = "Success"; ArchiveWorker(worker); })); backgroundWorker.Start(); }
private void GetAllWorkers() { conn = new MySqlConnection("Server=localhost;Database=szakdoga_db;Uid=root;Pwd=;SslMode=none"); string q_select = "SELECT * FROM workers"; Workers.Clear(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(q_select, conn); MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { Workers.Add(new Model.Workers { Worker_ID = Convert.ToInt32(dataReader["Worker_ID"]), Username = (dataReader["Username"]).ToString(), Password = (dataReader["Password"]).ToString(), Registration_Date = DateTime.Parse(dataReader["Registration_Date"].ToString()), Salary = Convert.ToInt32(dataReader["Salary"]), Title = (dataReader["Title"]).ToString(), Realname = (dataReader["Realname"]).ToString() }); } dataReader.Close(); this.DisplayPage = new Menu_users(); conn.Close(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } }
} // SendMessage // ----------------------------------------------------------------------------- #region Обновление данных // обновление данных из базы данных public void RefreshData() { _context.GetOrders().ToList().ForEach(o => Orders.Add(o)); _context.GetClients().ToList().ForEach(c => Clients.Add(c)); _context.GetCars().ToList().ForEach(c => Cars.Add(c)); _context.GetWorkersNotFired().ToList().ForEach(w => Workers.Add(w)); } // RefreshData
public Thread Post(string msg) { Log("> " + msg); Thread thread = null; thread = new Thread(() => { try { Process(msg); } catch (TargetInvocationException ex) { ExceptionProcessor(ex.InnerException); } catch (Exception ex) { ExceptionProcessor(ex); } finally { Workers.Remove(thread); } }); Workers.Add(thread); thread.Start(); return(thread); }
/// <summary> /// Добавление сотрудника /// </summary> private void AddWorker() { Console.Clear(); int id = Workers.Count; Console.WriteLine("Добавление сотрудника в базу:"); Console.Write("Имя: "); string name = Console.ReadLine(); Console.Write("Фамилия: "); string surname = Console.ReadLine(); Console.Write("Возраст: "); int age = InputInt(); Console.Write("Департамент: "); string departament = Console.ReadLine(); AddWorkersDepartament(departament); Console.Write("Зарплата: "); int salary = InputInt(); Console.Write("Количество проектов: "); int projectsAmount = InputInt(); Workers.Add(new Worker { Id = id, Age = age, Departament = departament, Name = name, ProjectsAmount = projectsAmount, Salary = salary, Surname = surname }); }
public int StartWork( uint noOfWorkers, string srcDir, string dstDir, Action <string> updateStatus = null) { InitialiseWork(srcDir, dstDir); Workers.Clear(); for (int i = 0; i < 2; i++) { CancellationTokenSource ctk = new CancellationTokenSource(); Tuple <Task, CancellationTokenSource> tp = Tuple.Create( Task.Run(() => Work( ctk, updateStatus), ctk.Token), ctk); Workers.Add(tp); } Task.WaitAll(Workers.Select(x => x.Item1).ToArray()); return(FilesProcessed.Count); }
public System.Threading.Tasks.Task WorkAsync(params string[] queues) { var worker = new Worker(JobCreator, FailureService, Client, queues); Workers.Add(worker); return(System.Threading.Tasks.Task.Factory.StartNew(() => worker.Work())); }
public void AddWorker(CozyWorker worker) { worker.MessageCallback = MsgCallback; lock (Locker) { Workers.Add(worker); } }
/// <summary> /// create a new worker and addes it to the manager /// </summary> /// <returns></returns> public Worker NewWorker() { Worker worker = new Worker(); Workers.Add(worker); return(worker); }
public void AddWorker(Colonist colonist) { if (WorkerCapacity == Workers.Count) { throw new GameException($"{Name} is full"); } Workers.Add(colonist); }
public ParameterlessFiberArray(int noW) : base(noW) { for (int i = 0; i < NumberOfWorkers; i++) { Workers.Add(new TWorker()); } }
internal void Add(int divisionId, string persNum, string fullName, string birthday, string hiringDay, decimal salary, string profArea, string gender) { int id = WorkerSQL.Add(divisionId, persNum, fullName, birthday, hiringDay, salary, profArea, gender); Workers.Add(new Worker { Id = id, DivisionId = divisionId, PersNum = persNum, FullName = fullName, Birthday = Convert.ToDateTime(birthday), HiringDay = Convert.ToDateTime(hiringDay), Salary = Decimal.Round(salary, 2), ProfArea = profArea, Gender = gender }); }
public void Add() { Worker w = new Worker(); w.SetIndex(count); count++; Workers.Add(w); }
public Project AddWorkers(params Worker[] workers) { foreach (var worker in workers) { Workers.Add(worker); } return(this); }
private MovableWorker <T> HireMovableWorker <T>(List <Path <T> > wareHouses) where T : Movable, new() { var worker = new MovableWorker <T> { Paths = wareHouses }; Workers.Add(worker); return(worker); }
public void AddWorker(Settler.Settler worker) { if (IsFull) { return; //Can't add worker if full } Workers.Add(worker); worker.Workplace = this; ; }
public ParameterizedFiberArray(int noW, TParameters parameters) : base(noW) { _parameters = parameters; for (int i = 0; i < NumberOfWorkers; i++) { Workers.Add(new TWorker { Parameters = _parameters }); } }
void OnUnitCreated(Unit u) { if (u.info.isCivil) { Workers.Add(u); } else { addToArmy(u); } }