Exemplo n.º 1
0
 public void LoadFromFile()
 {
     try
     {
         OpenFileDialog openfile = new OpenFileDialog();
         openfile.ShowDialog();
         String filename = openfile.FileName;
         StreamReader readfromLoad = new StreamReader(filename);
         ConnectToServer connection = new ConnectToServer();
         //connection.setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
         //connection.setUsername(readfromLoad.ReadLine());
         //connection.setPassword(readfromLoad.ReadLine());
         setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
         setUsername(readfromLoad.ReadLine());
         setPassword(readfromLoad.ReadLine());
         tcpclnt.Connect(this.hostname, Convert.ToInt32(this.port));
     }catch(Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
 public void LoadFromFile()
 {
     try
     {
         OpenFileDialog openfile = new OpenFileDialog();
         openfile.ShowDialog();
         String          filename     = openfile.FileName;
         StreamReader    readfromLoad = new StreamReader(filename);
         ConnectToServer connection   = new ConnectToServer();
         //connection.setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
         //connection.setUsername(readfromLoad.ReadLine());
         //connection.setPassword(readfromLoad.ReadLine());
         setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
         setUsername(readfromLoad.ReadLine());
         setPassword(readfromLoad.ReadLine());
         tcpclnt.Connect(this.hostname, Convert.ToInt32(this.port));
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
        public void LoadFromFile()
        {
            try
            {

                StreamReader read = new StreamReader(local_path2);
                string schedulefile = null;
                string setpath = read.ReadLine();
                Directory.SetCurrentDirectory(setpath);
                string schedulefile2 = Directory.GetCurrentDirectory();
                //orismos tou path pou einai to arxeio p tha diabazoume
                string[] dirs = Directory.GetFiles(schedulefile2);
                //trexei gia osa arxeia exei o fakelos
                foreach (string dir in dirs)
                {
                    if (dbBackUp.Any()) {
                        dbBackUp.Clear();
                    }
                    stringsave = new StringBuilder();
                    schedulefile = dir;
                    tcpclnt = new TcpClient();
                    //anoigma tou areiou
                    StreamReader readfromLoad = new StreamReader(schedulefile);
                    ConnectToServer connection = new ConnectToServer();

                    //diabasma apo arxeio
                    setTime(readfromLoad.ReadLine());
                    setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
                    setUsername(readfromLoad.ReadLine());
                    setPassword(readfromLoad.ReadLine());
                    setFtpHostname(readfromLoad.ReadLine());
                    setFtpusername(readfromLoad.ReadLine());
                    setFtppassword(readfromLoad.ReadLine());
                    setEmail(readfromLoad.ReadLine());
                    int i = 0;
                    do{

                        setbackup(readfromLoad.ReadLine());
                        i++;
                    } while (!(readfromLoad.EndOfStream)) ;
                    tcpclnt.Connect(hostname, Convert.ToInt32(port));
                    if (tcpclnt.Connected)
                    {
                        BackupDb back = new BackupDb(getHostname(), getUsername(), getPassword(), getbackup(), @local_path, getFtphostname(), getFtpusername(), getFtppassword());
                        string respone  =  back.downloadDb();
                        if (respone.Equals("Backup completed successfully!") &&(getEmaiil()!=String.Empty))
                        {
                            mail = new SendEmail(getEmaiil(), respone);
                            mail.PrepareEmail();
                            mail.setEmail();
                        }
                        else if (getEmaiil() != String.Empty)
                        {
                            mail = new SendEmail(getEmaiil(), respone);
                            mail.PrepareEmail();
                            mail.setEmail();
                        }
                        tcpclnt.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.Source);
                Application.Exit();
            }
        }
Exemplo n.º 4
0
        public void LoadFromFile()
        {
            try
            {
                StreamReader read         = new StreamReader(local_path2);
                string       schedulefile = null;
                string       setpath      = read.ReadLine();
                Directory.SetCurrentDirectory(setpath);
                string schedulefile2 = Directory.GetCurrentDirectory();
                //orismos tou path pou einai to arxeio p tha diabazoume
                string[] dirs = Directory.GetFiles(schedulefile2);
                //trexei gia osa arxeia exei o fakelos
                foreach (string dir in dirs)
                {
                    if (dbBackUp.Any())
                    {
                        dbBackUp.Clear();
                    }
                    stringsave   = new StringBuilder();
                    schedulefile = dir;
                    tcpclnt      = new TcpClient();
                    //anoigma tou areiou
                    StreamReader    readfromLoad = new StreamReader(schedulefile);
                    ConnectToServer connection   = new ConnectToServer();

                    //diabasma apo arxeio
                    setTime(readfromLoad.ReadLine());
                    setHostname(readfromLoad.ReadLine(), readfromLoad.ReadLine());
                    setUsername(readfromLoad.ReadLine());
                    setPassword(readfromLoad.ReadLine());
                    setFtpHostname(readfromLoad.ReadLine());
                    setFtpusername(readfromLoad.ReadLine());
                    setFtppassword(readfromLoad.ReadLine());
                    setEmail(readfromLoad.ReadLine());
                    int i = 0;
                    do
                    {
                        setbackup(readfromLoad.ReadLine());
                        i++;
                    } while (!(readfromLoad.EndOfStream));
                    tcpclnt.Connect(hostname, Convert.ToInt32(port));
                    if (tcpclnt.Connected)
                    {
                        BackupDb back    = new BackupDb(getHostname(), getUsername(), getPassword(), getbackup(), @local_path, getFtphostname(), getFtpusername(), getFtppassword());
                        string   respone = back.downloadDb();
                        if (respone.Equals("Backup completed successfully!") && (getEmaiil() != String.Empty))
                        {
                            mail = new SendEmail(getEmaiil(), respone);
                            mail.PrepareEmail();
                            mail.setEmail();
                        }
                        else if (getEmaiil() != String.Empty)
                        {
                            mail = new SendEmail(getEmaiil(), respone);
                            mail.PrepareEmail();
                            mail.setEmail();
                        }
                        tcpclnt.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.Source);
                Application.Exit();
            }
        }