Exemplo n.º 1
0
        public void SaveSettings()
        {
            if (m_servers.Any(x => !x.IsValid) || !HasInternetConnection)
            {
                return;
            }

            UserSettings settings = new UserSettings {
                Servers = new List <SavedJenkinsServers>()
            };

            foreach (ServerViewModel server in Servers)
            {
                List <SavedJob> jobs = server.Jobs.Where(x => x.IsSubscribed).Select(x => new SavedJob {
                    Name = x.Name
                }).ToList();
                settings.Servers.Add(new SavedJenkinsServers {
                    DomainUrl = server.DomainUrl, Jobs = jobs, RequiresAuthentication = server.RequiresAuthentication
                });
            }

            PersistedUserSettings.Save(settings);
            Settings.Default.ViewMode          = ViewMode.ToString();
            Settings.Default.JobUpdateInterval = UpdateTimerInterval;
            Settings.Default.Servers           = new StringCollection();
            Settings.Default.Servers.AddRange(Servers.Select(x => x.DomainUrl).ToArray());
            Settings.Default.Save();
        }
Exemplo n.º 2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (Model.AllowExit)
            {
                UserSettings settings = new UserSettings {
                    Servers = new List <SavedJenkinsServers>()
                };
                foreach (ServerViewModel server in Model.Servers)
                {
                    List <SavedJob> jobs = server.Jobs.Where(x => x.IsSubscribed).Select(x => new SavedJob {
                        Name = x.Name
                    }).ToList();
                    settings.Servers.Add(new SavedJenkinsServers {
                        DomainUrl = server.DomainUrl, Jobs = jobs
                    });
                }

                PersistedUserSettings.Save(settings);
                Settings.Default.ViewMode = Model.ViewMode.ToString();
                Settings.Default.Servers  = new StringCollection();
                Settings.Default.Servers.AddRange(Model.Servers.Select(x => x.DomainUrl).ToArray());
                Settings.Default.Save();
            }
            else
            {
                e.Cancel    = true;
                WindowState = WindowState.Minimized;
            }
            base.OnClosing(e);
        }
Exemplo n.º 3
0
        public AppModel(TaskbarIcon notifyIcon, TaskbarItemInfo taskbarItemInfo)
        {
            m_isAddServerUrlValid = true;
            m_updateManager       = new AutoUpdater();
            m_notifyIcon          = notifyIcon;
            Enum.TryParse(Settings.Default.ViewMode, true, out m_viewMode);
            m_taskbarItemInfo = taskbarItemInfo;
            m_servers         = new ObservableCollection <ServerViewModel>();
            m_settings        = PersistedUserSettings.Open <UserSettings>() ?? new UserSettings {
                Servers = new List <SavedJenkinsServers>()
            };
            m_timer          = new DispatcherTimer(TimeSpan.FromSeconds(c_projectUpdateInterval), DispatcherPriority.Background, (sender, args) => Update(), Dispatcher.CurrentDispatcher);
            Status           = new StatusViewModel();
            m_subscribedJobs = new ObservableCollection <JobViewModel>();

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                m_updateManager.CheckForUpdate();
                m_updateManager.PropertyChanged += UpdateManager_PropertyChanged;
                m_updateTimer = new DispatcherTimer(TimeSpan.FromHours(4), DispatcherPriority.Background, CheckForUpdate, Dispatcher.CurrentDispatcher);
            }
            AutoStartOnStartup = IsAutoStartRegistered;

            Initialize();
        }
Exemplo n.º 4
0
        public void SaveSettings()
        {
            UserSettings settings = new UserSettings {
                Servers = new List <SavedJenkinsServers>()
            };

            foreach (ServerViewModel server in Servers)
            {
                List <SavedJob> jobs = server.Jobs.Where(x => x.IsSubscribed).Select(x => new SavedJob {
                    Name = x.Name
                }).ToList();
                settings.Servers.Add(new SavedJenkinsServers {
                    DomainUrl = server.DomainUrl, Jobs = jobs, RequiresAuthentication = server.RequiresAuthentication
                });
            }

            PersistedUserSettings.Save(settings);
            Settings.Default.ViewMode = ViewMode.ToString();
            Settings.Default.Servers  = new StringCollection();
            Settings.Default.Servers.AddRange(Servers.Select(x => x.DomainUrl).ToArray());
            Settings.Default.Save();
        }