static void Main(string[] args) { var computers = new Dictionary <int, ComputerItem>(); var targetList = new List <long>(); for (int i = 0; i < 50; i++) { //the initialization loop var arr = new long[2500]; var st = new MachineStatus { memory = arr }; Day23Input.Day23Code.CopyTo(arr, 0); var wi = new ComputerItem { st = st }; computers.Add(i, wi); var m1input = new List <long>() { i, -1, -1 }; //address, X=unknown, Y=unknown wi.st = Machine.Calc(wi.st, m1input, (a, b, c) => { targetList.Add(c); Console.WriteLine(c); }); } var inputQueue = ProcessTargetList(targetList); long natX = 0; long natY = 0; while (true) { if (inputQueue.Count == 0) { Console.WriteLine($"Nat sending {natX}, {natY}"); inputQueue.Add((0, natX, natY)); } targetList = new List <long>(); var(a, x, y) = inputQueue[0]; inputQueue.RemoveAt(0); var winput = new List <long>() { x, y }; if (a == 255) { natX = x; natY = y; continue; } computers[(int)a].inputQueue.Add(x); computers[(int)a].inputQueue.Add(y); computers[(int)a].st = Machine.Calc(computers[(int)a].st, computers[(int)a].inputQueue, (a, b, c) => { targetList.Add(c); Console.WriteLine(c); }); var inputQueueNew = ProcessTargetList(targetList); inputQueue.AddRange(inputQueueNew); } // }
/// <summary> /// Добавление компьютера в БД /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Cf_btn_addComputer_Click(object sender, EventArgs e) { if (cf_tb_computerName.Text != "") { if (cf_lv_components.Items.Count != 0) { if (Regex.IsMatch(cf_tb_computerName.Text, regText)) { using (var transaction = cf_db.Database.BeginTransaction()) { try { //Сохранение компьютера в БД Computer comp = new Computer(); comp.Title = cf_tb_computerName.Text; comp.Price = Convert.ToDecimal(string.Format("{0:0.00}", totalPrice.ToString())); cf_db.Computer.Add(comp); cf_db.SaveChanges(); //Сохранение компонентов в БД foreach (ListViewItem item in cf_lv_components.Items) { ComputerItem ci = new ComputerItem(); ci.ComputerId = comp.Id; ci.ComponentId = Convert.ToInt32(item.Text.ToString()); cf_db.ComputerItem.Add(ci); cf_db.SaveChanges(); } transaction.Commit(); } catch (Exception ex) { ShowMessage(ex.Message); transaction.Rollback(); } } } else { ShowMessage("Ошибка в названии компьютера"); this.DialogResult = DialogResult.None; } } else { ShowMessage("Компоненты не добавлены!"); this.DialogResult = DialogResult.None; } } else { ShowMessage("Введите название компьютера!"); this.DialogResult = DialogResult.None; } }