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; } }
public static void Serialize(WorkersList l) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using (Stream fStream = new FileStream("hospital_data.dat", FileMode.Create, FileAccess.Write)) { binaryFormatter.Serialize(fStream, l); } }
static void ReadDrivers() { WorkersList drivers = new WorkersList(Department.driver); drivers.Read(pathDriverData); if (drivers.ShowList()) { drivers.Save(pathDriverResultData); } }
static void ReadSellers() { WorkersList sellers = new WorkersList(Department.seller); sellers.Read(pathSellerData); if (sellers.ShowList()) { sellers.Save(pathSellerResultData); } }
public void LeaveWorker(Member Worker) { for (int i = 0; i < WorkersList.Count; i++) // перебрать список сотрудников { if (WorkersList[i] == Worker) //если сотрудник найден в списке { WorkersList.RemoveAt(i); //удалить его из списка WorkersLeaved++; //добавить +1 к кол-ву уволенных сотрудников return; } } }
public void GiveHoney(TownHall townHall) { for (int i = 0; i < NumberOfWorkers; i++) { double neededHoney = WorkersList.ElementAt(i).HoneyConsumptionRate(); if (!GetHoney(neededHoney)) { StarvationDeaths(townHall); break; } } }
private void FillList() { string text; list = MainWindow.Deserialize(); foreach (Pracownik record in list.ListOfWorkers) { text = $"Shifts: {record.shift_list.Count} | {record.GetFunction()} | {record.GetWorkerData()} "; cb_ShiftWorkersList.Items.Add(text); } }
private void FillList() { string text; list = MainWindow.Deserialize(); ArrayList itemsList = new ArrayList(); foreach (Pracownik record in list.ListOfWorkers) { text = $"{record.GetFunction()} | {record.GetWorkerData()} "; itemsList.Add(text); } ListBox.ItemsSource = itemsList; }
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); }
public void Update_Date(string d) { object test = cb_ShiftWorkersList.SelectedItem; string selected_listbox = ListBox.SelectedItem.ToString(); bool val_result; bool failed = false; string text; list = MainWindow.Deserialize(); foreach (var record in list.ListOfWorkers) { text = $"Shifts: {record.shift_list.Count} | {record.GetFunction()} | {record.GetWorkerData()} "; if (text.Equals(test)) { foreach (var item in record.shift_list) { string to_compare = $"{item.date.ToShortDateString()}"; DateTime new_date = Convert.ToDateTime(d); val_result = ns.ShiftValidate(record.shift_list, new_date); if (val_result.Equals(false)) { MessageBox.Show( "Can't update shift - 1 or 2 validation criterias failed\n1) Max 10 shifts in month\n2) Two or more cardiologist/urologist/etc. can't have shift at the same day"); failed = true; } else { item.date = new_date; mw.Serialize_NewShift(list); Refresh.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); break; } if (failed) { break; } } } } }
internal void KillBee() { if (NumberOfWorkers > 0) { int randomWorker = random.Next(0, WorkersList.Count); Worker worker = WorkersList.ElementAt(randomWorker); if (worker is NectarCollector) { NumberOfNectarCollectors--; } if (worker is NectarConverter) { NumberOfNectarConverters--; } WorkersList.Remove(worker); NumberOfWorkers--; } }
public static WorkersList Deserialize() { WorkersList list = new WorkersList(); BinaryFormatter binary = new BinaryFormatter(); if (File.Exists("hospital_data.dat")) { using (Stream fstream = new FileStream("hospital_data.dat", FileMode.Open, FileAccess.Read)) { list = (WorkersList)binary.Deserialize(fstream); } } else { List <Pracownik> newList = new List <Pracownik>(); list.ListOfWorkers = newList; } return(list); }
public static WorkersList Deserialize() { WorkersList list = new WorkersList(); BinaryFormatter binary = new BinaryFormatter(); if (File.Exists("hospital_data.dat")) { using (Stream fstream = new FileStream("hospital_data.dat", FileMode.Open, FileAccess.Read)) { list = (WorkersList)binary.Deserialize(fstream); } } else { List <Pracownik> newList = new List <Pracownik>(); list.ListOfWorkers = newList; MessageBox.Show("List not found - new list created, will be saved during this session"); } return(list); }
public List <Workers> getWorkers() { WorkersList dm = new WorkersList(); ListDictionary Params = new ListDictionary(); DataSet ds = dm.getWorkers(Params); List <Workers> l = new List <Workers>(); Workers w; foreach (DataRow item in ds.Tables[0].Rows) { w = new Workers(); w.Id = BLCtrl.getString(item, "Id", " "); w.FirstName = BLCtrl.getString(item, "FirstName", " "); w.LastName = BLCtrl.getString(item, "LastName", " "); w.Job = BLCtrl.getInt(item, "Job", 0); l.Add(w); } return(l); }
private void cb_ShiftWorkersList_SelectionChanged(object sender, SelectionChangedEventArgs e) { object test = cb_ShiftWorkersList.SelectedItem; string text; list = MainWindow.Deserialize(); foreach (Pracownik record in list.ListOfWorkers) { text = $"Shifts: {record.shift_list.Count} | {record.GetFunction()} | {record.GetWorkerData()} "; if (text.Equals(test)) { ListBox.Items.Clear(); foreach (var item in record.shift_list) { string to_display = $"{item.id} | {item.date.ToShortDateString()}"; ListBox.Items.Add(to_display); } } } }
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; } }
private void InitializeUsersTab() { WorkersList.SetDefaults(); WorkersAssignedList.SetDefaults(); ReloadWorkersLists(); }
public void Serialize_NewShift(WorkersList l) { Serialize(l); }
public void BornNewBee(List <Job> jobNewWorkerCanDo) { int weight = random.Next(100, 301); WorkersList.Add(new Worker(weight, jobNewWorkerCanDo)); }
public void AddWorker(Worker x) { WorkersList.Add(x); }