Improve DeliveryAdminWindow
This commit is contained in:
@ -15,6 +15,8 @@ namespace Elwig {
|
||||
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
||||
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
||||
public static readonly Config Config = new(DataPath + "config.ini");
|
||||
|
||||
public static string ZwstId { get; private set; }
|
||||
public static IEnumerable<IScale> Scales { get; private set; }
|
||||
public static ClientParameters Client { get; private set; }
|
||||
|
||||
@ -30,10 +32,13 @@ namespace Elwig {
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs evt) {
|
||||
IEnumerable<string> branches = Array.Empty<string>();
|
||||
using (var ctx = new AppDbContext()) {
|
||||
if (!ctx.Database.CanConnect()) {
|
||||
MessageBox.Show($"Invalid Database:\n\n{Config.DatabaseFile}", "Invalid Database", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
} else {
|
||||
branches = ctx.Branches.Select(b => b.ZwstId).ToList();
|
||||
}
|
||||
}
|
||||
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
||||
@ -62,6 +67,20 @@ namespace Elwig {
|
||||
}
|
||||
Scales = list;
|
||||
|
||||
if (Config.ZwstId != null) {
|
||||
if (!branches.Contains(Config.ZwstId)) {
|
||||
MessageBox.Show("Invalid branch id in config!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
} else {
|
||||
ZwstId = Config.ZwstId;
|
||||
}
|
||||
} else if (branches.Count() == 1) {
|
||||
ZwstId = branches.First();
|
||||
} else {
|
||||
MessageBox.Show("Unable to determine local branch!", "Invalid Branch Config", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
base.OnStartup(evt);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user