private void delete_plu() { int count = 0; string EntryTime = DateTime.Now.ToLongTimeString().Replace(":", "_"); string EntryDate = DateTime.Today.ToShortDateString().Replace(".", "_"); this.Invoke((Action) delegate { label2.Text = String.Empty; }); while (count <= count_error) { //checked this this.Invoke((Action) delegate { label2.Text = count + " / " + count_error; }); if (BalanceModule.Visible == true) { BalanceModule.ShowBalloonTip(1, "", label2.Text, ToolTipIcon.None); } if (cas.Connection(m_ip, m_port, 1, m_model) == -1) { list_msg("Соединение с весами " + m_ip + ": " + m_port + " не удалось!"); int i = 3; while (i != 0) { list_msg("Пробуем еще раз..."); Thread.Sleep(2000); if (cas.Connection(m_ip, m_port, 1, m_model) != -1) { i = 0; } else { list_msg("Соединение с весами " + m_ip + ": " + m_port + " не удалось!"); i--; } } } string articul = data_delete[count].ToString(); if (articul == "0") { count++; cas.DisconnectAll(); continue; } int pluno = int.Parse(articul); if (cas.DeletePLU(1, pluno) != 1) { list_msg("Удалить товар с весов не удалось:" + m_ip); cas.DisconnectAll(); count++; //check this continue; } else { list_msg("C Весов : " + m_ip + " удален товар:" + articul); Log.articul_write(articul, "remove_" + m_ip + "_" + EntryDate + "_" + EntryTime); } int r = cas.GetState(); while (!(r == 99 || r == 55)) { r = cas.GetState(); string str = String.Empty; cas.GetTransStatus(m_ip, ref str); list_msg(str); Thread.Sleep(300); } count++; cas.DisconnectAll(); } this.Invoke((Action) delegate { label2.Text = String.Empty; }); this.Invoke((Action) delegate { label2.Refresh(); }); return; }
static async Task Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (_, e) => { Application.Top.Running = false; Application.RequestStop(); Application.Shutdown(); Console.WriteLine($"There was an error.{Environment.NewLine}{e.ExceptionObject}"); }; Application.Init(); var httpClient = new HttpClient(); var urls = new[] { DefaultUrl }; var jsonRpcClientProxyMaxRetries = new JsonRpcClientProxy(new DefaultHttpClient(httpClient, new EthereumJsonSerializer(), LimboLogs.Instance, int.MaxValue), urls, LimboLogs.Instance); var ethJsonRpcClientProxyMaxRetries = new EthJsonRpcClientProxy(jsonRpcClientProxyMaxRetries); var jsonRpcWalletClientProxyMaxRetries = new JsonRpcWalletClientProxy(jsonRpcClientProxyMaxRetries); var runnerValidator = new RunnerValidator(httpClient, DefaultUrl); var networkModule = new NetworkModule(); networkModule.NetworkSelected += async(_, network) => { var initModule = new InitModule(ethJsonRpcClientProxyMaxRetries, runnerValidator, network); initModule.OptionSelected += async(_, optionInfo) => { var addressesModule = new AddressesModule(optionInfo, jsonRpcWalletClientProxyMaxRetries); addressesModule.AddressesSelected += async(_, addressesEvent) => { urls = new[] { addressesEvent.NodeAddress }; AddAuthorizationHeader(httpClient, addressesEvent.NodeAddress); Application.MainLoop.Invoke(async() => { var balanceModule = new BalanceModule(ethJsonRpcClientProxyMaxRetries, addressesEvent.AccountAddress); balanceModule.TransferClicked += async(_, transferEvent) => { var transferModule = new TransferModule(ethJsonRpcClientProxyMaxRetries, jsonRpcWalletClientProxyMaxRetries, transferEvent.Address, transferEvent.Balance); var transferWindow = await transferModule.InitAsync(); Application.Top.Add(transferWindow); Application.Run(transferWindow); }; var balanceWindow = await balanceModule.InitAsync(); Application.Top.Add(balanceWindow); Application.Run(balanceWindow); }); }; var addressesWindow = await addressesModule.InitAsync(); Application.Top.Add(addressesWindow); Application.Run(addressesWindow); }; var initWindow = await initModule.InitAsync(); Application.Top.Add(initWindow); Application.Run(initWindow); }; var networkWindow = await networkModule.InitAsync(); Application.Top.Add(networkWindow); Application.Run(); }