Exemplo n.º 1
0
        private void Settings_function_register_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Indicator == false)
            {
                MessageBox.Show("Немає з'єднання! \n Спершу встановіть з'єднання!");
            }
            else
            {
                Settings_functions_registers = new Settings_functions_registers();
                Settings_functions_registers.ShowDialog();

                //Thread.Sleep(3000);
                //sftp.DeleteFile(remove_filename_1);
                string upload_filename = "data1.txt";
                string remove_filename = "Settings_register.txt";
                sftp.UploadFile(upload_filename, remove_filename);
                //Date
                string   upload_filename_date = "Date.txt";
                string   remove_filename_date = "date.txt";
                DateTime date1      = DateTime.Now;
                string   year_now   = Convert.ToString(date1.Year - 2000);
                string   second_now = Convert.ToString(date1.Second + 5);
                string   month_now  = Convert.ToString(date1.Month);
                string   day_now    = Convert.ToString(date1.Day);
                string   hour_now   = Convert.ToString(date1.Hour);
                string   min_now    = Convert.ToString(date1.Minute);
                if (Convert.ToInt32(month_now) < 10)
                {
                    month_now = "0" + month_now;
                }
                if (Convert.ToInt32(day_now) < 10)
                {
                    day_now = "0" + day_now;
                }
                if (Convert.ToInt32(hour_now) < 10)
                {
                    hour_now = "0" + hour_now;
                }
                if (Convert.ToInt32(min_now) < 10)
                {
                    min_now = "0" + min_now;
                }
                string text_1 = "" + month_now + "" + day_now + "" + hour_now + "" + min_now + "" + year_now + "." + second_now;
                System.IO.File.WriteAllText(@"Date.txt", text_1);
                sftp.UploadFile(upload_filename_date, remove_filename_date);
                //
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == String.Empty)
            {
                MessageBox.Show("Please select IP-adress,username and password");
            }
            else
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    int device_number   = Convert.ToInt32(numericUpDown1.Value);
                    int register_number = Convert.ToInt32(numericUpDown2.Value);
                    int value_register  = Convert.ToInt32(textBox1.Text);

                    DialogResult result = MessageBox.Show("Ви обрали: " + "\nФункцію: 1" + "\nНомер приладу:" + device_number + "\nНомер регістру:" + register_number + "\nЗначення:" + value_register + "\n", "Data_information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (result == DialogResult.No)
                    {
                    }
                    else
                    {
                        Close();
                    }

                    string text = "255\n" + "1" + "\n" + device_number + "\n" + register_number + "\n" + value_register + "\n";
                    System.IO.File.WriteAllText(@"data1.txt", text);
                }
                if (comboBox1.SelectedIndex == 1)
                {
                    int device_number   = Convert.ToInt32(numericUpDown1.Value);
                    int register_number = Convert.ToInt32(numericUpDown2.Value);


                    DialogResult result = MessageBox.Show("Ви обрали: " + "\nФункцію: 2" + "\nНомер приладу:" + device_number + "\nНомер регістру:" + register_number + "\n", "Data_information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (result == DialogResult.No)
                    {
                    }
                    else
                    {
                        Close();
                    }

                    string text = "255\n" + "2" + "\n" + device_number + "\n" + register_number + "\n";
                    System.IO.File.WriteAllText(@"data1.txt", text);
                }
            }
            string upload_filename = "data1.txt";
            string remove_filename = "Settings_register.txt";

            sftp.UploadFile(upload_filename, remove_filename);
            //  string upload_filename = "data1.txt";
            //  string remove_filename = "Settings_register.txt";
            //  sftp.UploadFile(upload_filename, remove_filename);
            //Thread.Sleep(19000);
            //sftp.DownloadFile("Instant_data.txt", "data2.txt");
            //string[] x = sftp.getFile("data2.txt");
            //Register[] instant_data = ConverDataRegister(x);
            //if (instant_data.Length == 0)
            //    return;
            //label5.Text = instant_data[instant_data.Length - 1].Value_register.ToString();
            //sftp.DeleteFile("Instant_data.txt");
        }