private Schedule BuildSchedule() { string[] parts = serverSettings.Split(','); string serverType = parts[0]; string host = parts[1]; string port = parts[2]; string username = parts[3]; Ftp ftpServer = new Ftp(serverType, host, port, username);//edw bale ta xaraktitistika tou ftp server, wste meta na ta parei to scedule, ola ta pedia ftpServer.Password = Upload.password; Schedule schedule = new Schedule() { FullAutomatic = fullAutomaticRadio.Checked, BackupNow = nowRadio.Checked, BackupOnce = onceRadio.Checked, WithCompress = compressCheckBox.Checked, FtpServer = ftpServer, DBName = backupDatabaseName.Text, DBFilePath = databaseFilePath.Text, DBpassword = Upload.dbPassword, DBusername = Upload.dbUsername, MySqlBinFolderPath = generalVariables.GetVariable("dbBinFolder").ToString() }; if (schedule.BackupOnce && !schedule.BackupNow) { schedule.BackupDateTime = onceDatetimePicker.Value; } else { DateTime tempDateTime = DateTime.Now; tempDateTime = tempDateTime.AddDays(Convert.ToDouble(daysNumber.Value)); tempDateTime = tempDateTime.AddHours(Convert.ToDouble(hoursNumber.Value)); tempDateTime = tempDateTime.AddMinutes(Convert.ToDouble(minutesNumber.Value)); schedule.BackupDateTime = tempDateTime; } return(schedule); }
//CUSTOM METHODS private void MenuClick(object sender, EventArgs e) { switch ((sender as Button).Name) { case "databaseButton": SwitchPanels(0, "Database"); break; case "serversButton": SwitchPanels(1, "Servers"); break; case "backupButton": SwitchPanels(2, "Backup"); break; case "logButton": SwitchPanels(3, "Log"); log1.updateGridView(dataGridView1); textBox2.Text = logVariables.GetVariable("email").ToString(); if (logVariables.GetVariable("errorLogs").ToString() == "true") { checkBox1.Checked = true; } else { checkBox1.Checked = false; } if (logVariables.GetVariable("successLogs").ToString() == "true") { checkBox3.Checked = true; } else { checkBox3.Checked = false; } if (logVariables.GetVariable("infoLogs").ToString() == "true") { checkBox2.Checked = true; } else { checkBox2.Checked = false; } break; case "downloadDatabase": SwitchPanels(4, "Download DB"); break; } }
public static string serverSettings; //mia static gia na krataw to server pou epelexse o xristis. public Form1() { InitializeComponent(); //gia to logfiles folder Directory.CreateDirectory(Path.GetFullPath(@".\LogFiles")); Directory.CreateDirectory(Path.GetFullPath(@".\var")); Directory.CreateDirectory(@".\servers"); logVariables = new VariableStorage(Path.GetFullPath(@".\LogFiles\logV")); generalVariables = new VariableStorage(Path.GetFullPath(@".\var\genV")); stream = new ObjectStream(@".\servers\saveServer"); Fillinit(); try { //gia to service ServiceController serviceController = new ServiceController("ScheduleService"); switch (serviceController.Status) { case ServiceControllerStatus.Paused: serviceController.Start(); break; case ServiceControllerStatus.Stopped: serviceController.Start(); break; } serviceController.Refresh(); //end service } catch (Exception ex) { } //stream.ClearFile(); SetDownloadPanelNotVisble(); //kanw not visible ta download panel //ola ta nea panels prepei na mpoun se auton ton pinaka, kai meta sthn switch (method MenuClick) panels = new Panel[] { databasePanel, serversPanel, backupPanel, logPanel, downloadPanel }; //krata ola ta panel gia na mporeis na ta allazeis currentPanel = databasePanel; //einai to arxiko //declare gia ta panels for (int i = 1; i < panels.Length; i++) { panels[i].Visible = false; } currentPanel.Visible = true; //end panels serverType.SelectedIndex = 0; //VariableStorage logVariables = new VariableStorage(System.IO.Path.GetFullPath(@"..\..\LogFiles\logV")); try { ScheduleClient.SetLogFile(new LogFile());//stelnw to log file sto service } catch (Exception ex) { Debug.Print("Error"); } //giati ksekina me to database panel gemizw to textbox object dbBinFolder = generalVariables.GetVariable("dbBinFolder"); if (dbBinFolder != null) { binFolderPath.TextBox.Text = dbBinFolder.ToString(); } //TestService test = new TestService(); }