コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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));
            }
        }