Example #1
0
 public Worker(IOptionsMonitor <AccountSettings> settingsMonitor, ILogger <Worker> logger, IServiceProvider services, IHostApplicationLifetime appLifetime)
 {
     this.settings = settingsMonitor.CurrentValue;
     settingsMonitor.OnChange(changedSettings =>
     {
         this.settings     = changedSettings;
         this.AccountsData = new AccountsData {
             Items = this.settings.Accounts.Where(a => a.Enabled).ToList()
         };
     });
     this.logger                = logger;
     this.services              = services;
     this.appLifetime           = appLifetime;
     this.autoCompletionHandler = new AutoCompletionHandler(this);
 }
Example #2
0
        private static string GetSettingsFile()
        {
            if (!File.Exists(SettingsFile))
            {
                var settings = new AccountSettings {
                    Query = AzDoService.DefaultQuery, Slicers = "Tags,Priority,IterationPath", Accounts = new[] { new Account {
                                                                                                                      Name = "Account-1", Org = "Org-1", Project = "Project-1", Token = "PAT Token for Org-1/Project-1", Enabled = true
                                                                                                                  }, new Account {
                                                                                                                      Name = "Account-2", Type = AccountType.Jira, Org = "Org-2", Project = "Project-2", Token = "[email protected]:apiToken", Query = JiraService.DefaultQuery, Enabled = true
                                                                                                                  } }
                };
                SetSettings(settings);
                ColorConsole.WriteLine("Update settings here: ".Red(), SettingsFile);
            }

            return(SettingsFile);
        }
Example #3
0
 public JiraService(IOptionsMonitor <AccountSettings> settingsMonitor)
 {
     this.settings = settingsMonitor.CurrentValue;
     settingsMonitor.OnChange(changedSettings => { this.settings = changedSettings; });
 }
Example #4
0
 private static void SetSettings(AccountSettings settings)
 {
     File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(settings, new JsonSerializerSettings {
         Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore
     }));
 }