Beispiel #1
0
        private void SaveDirectoryProgPath_B_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(IP_TB.Text))
                {
                    IP_TB.Focus();
                    throw new Exception("Необходимо ввести адрес программы распознавания");
                }

                if (String.IsNullOrEmpty(Port_TB.Text))
                {
                    Port_TB.Focus();
                    throw new Exception("Необходимо ввести порт программы распознавания");
                }

                Int32 Port = Convert.ToInt32(Port_TB.Text);

                SystemArgs.ByteScout.Server = IP_TB.Text.Trim();
                SystemArgs.ByteScout.Port   = Port_TB.Text.Trim();

                if (SystemArgs.ByteScout.CheckConnect())
                {
                    if (SystemArgs.ByteScout.SetParametersConnect())
                    {
                        MessageBox.Show("Параметры успешно записаны", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        throw new Exception("Ошибка при записи директорий");
                    }
                }
                else
                {
                    throw new Exception("Ошибка при подключении к серверу распознавания");
                }
            }
            catch (FormatException)
            {
                Port_TB.Focus();
                MessageBox.Show("Порт подключения должен состоять из целых цифр", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void Generate_B_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(IP_TB.Text))
                {
                    IP_TB.Focus();
                    throw new Exception("Необходимо ввести IP - адрес");
                }

                if (String.IsNullOrEmpty(Port_TB.Text))
                {
                    Port_TB.Focus();
                    throw new Exception("Необходимо ввести порт");
                }

                Int32 Port = Convert.ToInt32(Port_TB.Text);

                if ((Port >= 48654 && Port <= 48999) || (Port >= 49152 && Port <= 65535))
                {
                    Port_TB.Focus();
                    throw new Exception("Необходимо использовать порты в диапазоне [48654..48999] или [49152..65535]");
                }

                SystemArgs.MobileApplication.Port = Port_TB.Text.Trim();

                if (SystemArgs.MobileApplication.SetParametersConnect())
                {
                    Zen.Barcode.CodeQrBarcodeDraw QrCode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
                    QR_PB.Image = QrCode.Draw($"{IP_TB.Text.Trim()}_{SystemArgs.MobileApplication.Port}", 100);
                    MessageBox.Show("Параметры подключения успешно обновлены", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (FormatException)
            {
                Port_TB.Focus();
                MessageBox.Show("Порт подключения должен состоять из целых цифр", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #3
0
        private void OK_B_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(IP_TB.Text))
                {
                    IP_TB.Focus();
                    throw new Exception("Необходимо ввести IP - адрес");
                }

                if (String.IsNullOrEmpty(Port_TB.Text))
                {
                    Port_TB.Focus();
                    throw new Exception("Необходимо ввести порт");
                }
                Int32 Port = Convert.ToInt32(Port_TB.Text);

                SystemArgs.Server._Port = Port_TB.Text.Trim();

                if (SystemArgs.Server.SetParametersConnect())
                {
                    SystemArgs.PrintLog("Обновлены параметры сервера порт: " + SystemArgs.Server._Port + " " + DateTime.Now.ToString());
                    MessageBox.Show("Параметры подключения успешно обновлены", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (FormatException)
            {
                Port_TB.Focus();
                MessageBox.Show("Порт подключения должен состоять из целых цифр", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (Exception E)
            {
                SystemArgs.PrintLog(E.Message);
                MessageBox.Show(E.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }