示例#1
0
 private void IPSetButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / IDSetButton_Click event) Запускаю окно задачи ID для отправки комманд\r\n";
         IDSet IDset = new IDSet();
         IDset.Show();
     }
     catch (Exception ex)
     {
         ExceptionHandler.RegisterNew(ex);
     }
 }
示例#2
0
        public async void Send_Command()
        {
            try
            {
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Начата отправка команды\r\n";
                if (Command.Text == "")
                {
                    m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Ошибка: поле с командой пустое\r\n";
                    MessageBox.Show("(2) Постарайтесь ввести все значения правильно!");
                    return;
                }
                if (!ipsall)
                {
                    bool isArrayValid = false;
                    try
                    {
                        Array.ConvertAll(ips, x => int.Parse(x));
                        isArrayValid = true;
                    }
                    catch (Exception)
                    {
                        if (ips == null)
                        {
                        }
                        else if (ips[0] == "all" || ips[0] == "null")
                        {
                            isArrayValid = true;
                        }
                    }
                    if (ips == null || !isArrayValid)
                    {
                        m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Программа запустилось впервые и не имеет заданного списка ID\r\n";
                        IDSet iPSet = new IDSet(true);
                        iPSet.Show();
                        m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Запущено IDSet окно\r\n";
                        return;
                    }
                }
                string showcommand = Command.Text;
                string command     = Command.Text;
                var    textargs    = args.OfType <TextBox>().ToArray();
                foreach (var item in textargs)
                {
                    showcommand += " " + item.Text;
                    command     += "^" + item.Text;
                }
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Заданная команда {command} / {showcommand}\r\n";
                Command message = new Command()
                {
                    command = command,
                    Clients = ipsall ? arr.Where(x => x.nameofpc != string.Empty).ToList() : Array.FindAll(arr, x => Array.Find(ips, y => y == Convert.ToString(x.id)) != null).ToList()
                };
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Создан экземпляр Message: Команда {message.command} / ID {message.Clients}\r\n";
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Отправлен ApiRequest.Create(command) на command\r\n";
                Uri res = await ApiRequest.CreateProductAsync(message, "command");

                LogPanel.Text += $"({DateTime.Now.ToLongTimeString()}) Команда {showcommand} (id: {await ApiRequest.GetProductAsync<uint>($"api/command") - 1}) отправлена.\r\n";
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event to MainWindow.LogPanel) Команда {command} / {showcommand} отправлена.\r\n";
                ListenInfo();
                m3md2.StaticVariables.Diagnostics.ProgramInfo += $"{DateTime.Now.ToLongTimeString()}(MainWindow / Send_Command event) Обновлена информация API\r\n";
            }
            catch (Exception ex)
            {
                ExceptionHandler.RegisterNew(ex);
            }
        }