public HostConfiguration(DSMHost host) { InitializeComponent(); Host = host; txtPassword.Text = ""; txtHost.Text = Host.Host; txtPort.Text = host.Port.ToString(); txtUser.Text = Host.UserName; chkUser.Checked = !txtUser.Text.Equals(DSMHost.DefaultUserName); txtSynoReportHome.Text = string.IsNullOrWhiteSpace(host.SynoReportHome) ? DSMHost.SynoReportHomeDefault(host.UserName) : host.SynoReportHome; chkSynoReportHome.Checked = !txtSynoReportHome.Text.Equals(DSMHost.SynoReportHomeDefault(host.UserName)); chkKeep.Checked = Host.KeepDsmFilesCustom; txtKeep.Text = Host.KeepDsmCount.ToString(); optAnalyzerDbKeep.Checked = Host.KeepAllDsmFiles; optAnalyzerDbRemove.Checked = !Host.KeepAllDsmFiles; chkKeep_CheckedChanged(null, null); for (int i = 0; i < Host.AuthenticationSection.Count; i++) { var am = Host.AuthenticationSection[i]; switch (am.Method) { case DSMAuthenticationMethod.PrivateKeyFile: { chkKeyFiles.Checked = true; for (int k = 0; k < am.AuthenticationKeys.Items.Count; k++) { var pkf = am.AuthenticationKeys.Items[k]; listView1.Items.Add(pkf.FileName); } } break; case DSMAuthenticationMethod.KeyboardInteractive: chkKeyBoardInteractive.Checked = true; break; case DSMAuthenticationMethod.Password: chkPassword.Checked = true; txtPassword.Text = ""; break; // if you press Ok with a saved password, you have just reset your password to 'blank', unless you typed a new one. default: break; } } }
private void txtSynoReportHome_Validating(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = !ValidateHomePath(); if (!e.Cancel && (sender as TextBox).Text.Equals(DSMHost.SynoReportHomeDefault(txtUser.Text))) { if (chkSynoReportHome.Checked) { chkSynoReportHome.Checked = false; } } }
public HostConfiguration(DSMHost host) { InitializeComponent(); Host = host; txtPassword.Text = ""; txtUser.Text = Host.UserName.ToLower(); txtHost.Text = Host.Host; txtSynoReportHome.Text = string.IsNullOrWhiteSpace(host.SynoReportHome) ? "/volume1/homes/" + host.UserName + "/synoreport/" : host.SynoReportHome; txtPort.Text = host.Port.ToString(); }
public HostConfiguration() { InitializeComponent(); Host = new DSMHost(); txtSynoReportHome.Text = "/volume1/homes/admin/synoreport/"; txtUser.Text = "admin"; chkSynoReportHome.CheckState = CheckState.Unchecked; chkUser.CheckState = CheckState.Unchecked; txtPort.Text = Host.ElementInformation.Properties["port"].DefaultValue.ToString(); }
private void chkSynoReportHome_CheckedChanged(object sender, EventArgs e) { bool custom = chkSynoReportHome.CheckState != CheckState.Unchecked; lblReports.Enabled = custom; txtSynoReportHome.Enabled = custom; if (!custom) { txtSynoReportHome.Text = DSMHost.SynoReportHomeDefault(txtUser.Text); } else { txtSynoReportHome.Focus(); } }
public HostConfiguration() { InitializeComponent(); Host = new DSMHost(); txtSynoReportHome.Text = DSMHost.SynoReportHomeDefault(DSMHost.DefaultUserName); txtUser.Text = DSMHost.DefaultUserName; chkSynoReportHome.CheckState = CheckState.Unchecked; chkUser.CheckState = CheckState.Unchecked; txtPort.Text = Host.ElementInformation.Properties["port"].DefaultValue.ToString(); Host.KeepDsmFilesCustom = false; chkKeep.Checked = Host.KeepDsmFilesCustom; txtKeep.Text = Host.KeepDsmCount.ToString(); optAnalyzerDbKeep.Checked = Host.KeepAllDsmFiles; optAnalyzerDbRemove.Checked = !Host.KeepAllDsmFiles; chkKeep_CheckedChanged(null, null); }
private void SynoReportClient_CacheUpdate(string host) { try { Invoke(new Action(ProgressUpdateProcessing)); DSMHost h = config.DSMHosts.Items[host]; SynoReportViaSSH connection = null; if (Default.UseProxy && h.Proxy == null) { connection = new SynoReportViaSSH(h, new DefaultProxy()); } else { if (h.Proxy != null) { connection = new SynoReportViaSSH(h, h.Proxy); } else { connection = new SynoReportViaSSH(h); } } connection.RmExecutionMode = Default.RmExecutionMode; cache = connection; if (!string.IsNullOrEmpty(Default.CacheFolder)) { cache.Path = Path.Combine(Default.CacheFolder, h.Host); } else { cache.Path = Path.Combine(GetFolderPath(SpecialFolder.MyDocuments), Application.ProductName, h.Host); } if (Default.KeepAnalyzerDb == true) { cache.KeepAnalyzerDbCount = -1; } else { cache.KeepAnalyzerDbCount = Default.KeepAnalyzerDbCount; } cache.DownloadUpdate += Cache_StatusUpdate; connection.DownloadCSVFiles(); connection.ScanCachedReports(); if (CacheUpdateCompleted != null) { CacheUpdateCompleted.Invoke(string.Format("{0} ({1})", connection.Host, connection.Version)); duplicateCandidatesView1.HostName = connection.Host; } if (cache.GetReports(SynoReportType.DuplicateCandidates).Count > 0) { dupes = cache.GetReport(SynoReportType.DuplicateCandidates) as SynoReportDuplicateCandidates; } if (DuplicatesAnalysisCompleted != null) { DuplicatesAnalysisCompleted.Invoke(); } } catch (SynoReportViaSSHLoginFailure ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SynoReportClient_CacheUpdate(string host) { try { Invoke(new Action(ProgressUpdateProcessing)); DSMHost h = Profile.DSMHosts.Items.TryGet(host); h.StorePassPhrases = Default.StorePassPhrases; SynoReportViaSSH connection = null; if (Default.UseProxy && h.Proxy == null) { connection = new SynoReportViaSSH(h, GetPassPhrase, GetInteractiveMethod, new DefaultProxy()); } else { if (h.Proxy != null) { connection = new SynoReportViaSSH(h, GetPassPhrase, GetInteractiveMethod, h.Proxy); } else { connection = new SynoReportViaSSH(h, GetPassPhrase, GetInteractiveMethod); } } connection.HostKeyChange += Connection_HostKeyChange; connection.RmExecutionMode = Default.RmExecutionMode; cache = connection; if (!string.IsNullOrEmpty(Default.CacheFolder)) { cache.Path = Path.Combine(Default.CacheFolder, h.Host); } else { cache.Path = Path.Combine(GetFolderPath(SpecialFolder.MyDocuments), Application.ProductName, h.Host); } var k = h as IKeepDSMFiles; if (k.Custom) { if (k.KeepAll == true) { cache.KeepAnalyzerDbCount = -1; } else { cache.KeepAnalyzerDbCount = k.KeepCount; } } else { if (Default.KeepAnalyzerDb == true) { cache.KeepAnalyzerDbCount = -1; } else { cache.KeepAnalyzerDbCount = Default.KeepAnalyzerDbCount; } } cache.DownloadUpdate += Cache_StatusUpdate; connection.DownloadCSVFiles(); connection.ScanCachedReports(); if (CacheUpdateCompleted != null) { CacheUpdateCompleted.Invoke(string.Format("{0} ({1})", connection.Host, connection.Version)); duplicateCandidatesView1.HostName = connection.Host; } if (_PassPhraseUpdate) { Profile.Save(); } if (cache.GetReports(SynoReportType.DuplicateCandidates).Count > 0) { dupes = cache.GetReport(SynoReportType.DuplicateCandidates) as SynoReportDuplicateCandidates; } if (DuplicatesAnalysisCompleted != null) { DuplicatesAnalysisCompleted.Invoke(); } } catch (SynoReportViaSSHLoginFailure ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } finally { Invoke(new Action(ProgressUpdateFailed)); } }