private void RefreshFiles() { if (gridJobs.Rows.Count == 0) { dataGridView1.Rows.Clear(); return; } DataGridViewRow row = GetSelectedRowFromCell(gridJobs); if (row == null || row.Cells[0].Value == null) { return; } lblLoadingFiles.Visible = true; JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = bo.FindByName(row.Cells[0].Value.ToString()); if (container != null) { FileRefresher fr = new FileRefresher(container); fr.dataGridView1 = dataGridView1; fr.Finished += new FileRefresherFinishedEventHandler(fr_Finished); LatestJobForFiles = container; fr.Run(); } }
private void biMatchSelectedJob_Click(object sender, EventArgs e) { if (!MatchWarn()) { return; } pbProgress.Visible = true; lblProgress.Visible = true; DataGridViewRow row = GetSelectedRowFromCell(this.gridJobs); if (row != null) { JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = jbo.FindByName(row.Cells[0].Value.ToString()); if (container != null) { SynchronizeBO bo = (SynchronizeBO)SingletonManager.GetSingleton(typeof(SynchronizeBO)); bo.aSynchronizeDirectory( container.SourceDirectory, container.SourceDirectory, container.DestinationDirectory, container.WatchSubDirectories, true); //RefreshFiles(); } } else { MessageForm frm = new MessageForm(); frm.Msg = "No job was selected, please select a job by click on its name and try again."; frm.ShowDialog(); } }
private void SaveJob(DataGridView dgv, int rowIndex) { if (dgv.Rows.Count < rowIndex - 1) { return; } DataGridViewRow row = dgv.Rows[rowIndex]; if (row.Cells[0].Value != null && row.Cells[1].Value != null && row.Cells[2].Value != null && //row.Cells[3].Value != null && row.Cells[0].Value.ToString().CompareTo("") != 0 && row.Cells[1].Value.ToString().CompareTo("") != 0 && row.Cells[2].Value.ToString().CompareTo("") != 0 /*&& * row.Cells[3].Value.ToString().CompareTo("") != 0*/) { //ok to save JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = bo.FindByName(row.Cells[0].Value.ToString()); if (container == null) { JobContainer container2 = new JobContainer(); container2.Name = row.Cells[0].Value.ToString(); bo.Add(container2); container = bo.FindByName(row.Cells[0].Value.ToString()); } container.SourceDirectory = row.Cells[1].Value.ToString(); container.DestinationDirectory = row.Cells[2].Value.ToString(); container.WatchSubDirectories = (bool)row.Cells[3].EditedFormattedValue; bo.Save(); } }
private void Delete() { QuestionForm frm = new QuestionForm(); frm.Msg = "Delete this job?"; if (frm.ShowDialog() == DialogResult.OK) { DataGridViewRow row = GetSelectedRowFromCell(gridJobs); if (row == null) { return; } gridJobs.Rows.Remove(row); if (row.Cells[0].Value == null) { //RefreshFiles(); ClearFiles(); return; } string name = row.Cells[0].Value.ToString(); JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = bo.FindByName(name); if (container != null) { bo.Delete(container); bo.Save(); //RefreshFiles(); } } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; this.WindowState = FormWindowState.Minimized; } else { JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); jbo.Save(); } }
private void btnMMExit_Click(object sender, EventArgs e) { ListenerBO bo = (ListenerBO)SingletonManager.GetSingleton(typeof(ListenerBO)); bo.StopListeners(); JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); jbo.Save(); ConfigurationBO cbo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); cbo.Save(); //this.Close(); Application.Exit(); }
private void LoadJobs() { DataGridViewRow row = GetSelectedRowFromCell(gridJobs); string focused_name = ""; if (row != null) { row.Cells["Name"].Value.ToString(); } JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); gridJobs.Rows.Clear(); if (bo.JContainer.Jobs.Count == 0) { return; } foreach (JobContainer container in bo.JContainer.Jobs) { object[] objs = { container.Name, container.SourceDirectory, container.DestinationDirectory, container.WatchSubDirectories }; gridJobs.Rows.Add(objs); } FocusRow(focused_name, gridJobs); }