mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-19 09:43:15 +00:00
sync interval setting
This commit is contained in:
@@ -220,6 +220,7 @@ namespace Bit.Console
|
||||
{
|
||||
Con.WriteLine("{0}. {1}", i + 1, result.Organizations[i].Name);
|
||||
}
|
||||
Con.WriteLine();
|
||||
Con.Write("Select your organization: ");
|
||||
var orgIndexInput = Con.ReadLine().Trim();
|
||||
int orgIndex;
|
||||
@@ -488,6 +489,12 @@ namespace Bit.Console
|
||||
config.SyncGroups = parameters.ContainsKey("g");
|
||||
config.SyncUsers = parameters.ContainsKey("u");
|
||||
|
||||
int intervalMinutes;
|
||||
if(parameters.ContainsKey("i") && int.TryParse(parameters["i"], out intervalMinutes))
|
||||
{
|
||||
config.IntervalMinutes = intervalMinutes;
|
||||
}
|
||||
|
||||
if(Core.Services.SettingsService.Instance.Server.Type != Core.Enums.DirectoryType.AzureActiveDirectory)
|
||||
{
|
||||
if(parameters.ContainsKey("gf"))
|
||||
@@ -607,6 +614,15 @@ namespace Bit.Console
|
||||
}
|
||||
}
|
||||
|
||||
Con.Write("Sync interval (minutes, minimum {1}) [{0}]: ", config.IntervalMinutes,
|
||||
SettingsService.Instance.Server.Type == Core.Enums.DirectoryType.Other ? "30" : "1");
|
||||
input = Con.ReadLine();
|
||||
int intervalMinutes;
|
||||
if(!string.IsNullOrEmpty(input) && int.TryParse(input, out intervalMinutes))
|
||||
{
|
||||
config.IntervalMinutes = intervalMinutes;
|
||||
}
|
||||
|
||||
input = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Bit.Core.Models
|
||||
UserEmailSuffix = null;
|
||||
break;
|
||||
case DirectoryType.Other:
|
||||
IntervalMinutes = 30;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -51,5 +52,6 @@ namespace Bit.Core.Models
|
||||
public string UserEmailSuffix { get; set; } = "@companyname.com";
|
||||
public string CreationDateAttribute { get; set; }
|
||||
public string RevisionDateAttribute { get; set; }
|
||||
public int IntervalMinutes { get; set; } = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,19 @@ namespace Service
|
||||
return;
|
||||
}
|
||||
|
||||
var intervalMinutes = SettingsService.Instance.Sync.IntervalMinutes;
|
||||
if(SettingsService.Instance.Server.Type == Bit.Core.Enums.DirectoryType.Other && intervalMinutes < 30)
|
||||
{
|
||||
intervalMinutes = 30;
|
||||
}
|
||||
else if(intervalMinutes < 1)
|
||||
{
|
||||
intervalMinutes = 1;
|
||||
}
|
||||
|
||||
_eventLog.WriteEntry($"Starting timer with {intervalMinutes} minute interval.", EventLogEntryType.Information);
|
||||
var timerDelegate = new TimerCallback(Callback);
|
||||
_timer = new Timer(timerDelegate, null, 1000, 60 * 1000);
|
||||
_timer = new Timer(timerDelegate, null, 1000, 60 * 1000 * intervalMinutes);
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
|
||||
Reference in New Issue
Block a user