Disable place_order without Enova credentials
This commit is contained in:
@@ -48,19 +48,22 @@ public sealed class ServiceSettings
|
||||
|
||||
public RuntimeSettings ResolveRuntimeSettings()
|
||||
{
|
||||
var enovaPassword = Enova.Password
|
||||
?? throw new ConfigurationException("Parametr 'enova.password' jest wymagany.");
|
||||
|
||||
var installationPath = Path.GetFullPath(
|
||||
Environment.ExpandEnvironmentVariables(Enova.InstallationPath));
|
||||
|
||||
return new RuntimeSettings(
|
||||
installationPath,
|
||||
new EnovaAdapterConfiguration(
|
||||
new EnovaConnectionOptions(Enova.Database, Enova.Operator, enovaPassword),
|
||||
EnovaAdapterConfiguration? enovaConfiguration = null;
|
||||
if (!string.IsNullOrWhiteSpace(Enova.Operator) && Enova.Password is not null)
|
||||
{
|
||||
enovaConfiguration = new EnovaAdapterConfiguration(
|
||||
new EnovaConnectionOptions(Enova.Database, Enova.Operator, Enova.Password),
|
||||
Enova.DocumentDefinition,
|
||||
Enova.DefaultWarehouseCode,
|
||||
Enova.SaveMode),
|
||||
Enova.SaveMode);
|
||||
}
|
||||
|
||||
return new RuntimeSettings(
|
||||
installationPath,
|
||||
enovaConfiguration,
|
||||
Sql.ConnectionString,
|
||||
Sql.CommandTimeoutSeconds,
|
||||
ResolvePath(Diagnostics.LogDirectory),
|
||||
@@ -78,8 +81,6 @@ public sealed class ServiceSettings
|
||||
}
|
||||
Require(Enova.InstallationPath, "enova.installationPath", errors);
|
||||
Require(Enova.Database, "enova.database", errors);
|
||||
Require(Enova.Operator, "enova.operator", errors);
|
||||
RequirePresent(Enova.Password, "enova.password", errors);
|
||||
Require(Enova.DocumentDefinition, "enova.documentDefinition", errors);
|
||||
Require(Sql.ConnectionString, "sql.connectionString", errors);
|
||||
if (Sql.CommandTimeoutSeconds <= 0)
|
||||
@@ -101,14 +102,6 @@ public sealed class ServiceSettings
|
||||
}
|
||||
}
|
||||
|
||||
private static void RequirePresent(string? value, string name, ICollection<string> errors)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
errors.Add($"Parametr '{name}' jest wymagany.");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ResolvePath(string path) =>
|
||||
Path.IsPathRooted(path) ? Path.GetFullPath(path) : Path.GetFullPath(path, AppContext.BaseDirectory);
|
||||
}
|
||||
@@ -126,7 +119,7 @@ public sealed class EnovaSettings
|
||||
|
||||
public string Database { get; init; } = string.Empty;
|
||||
|
||||
public string Operator { get; init; } = "Administrator";
|
||||
public string? Operator { get; init; }
|
||||
|
||||
public string? Password { get; init; }
|
||||
|
||||
@@ -153,7 +146,7 @@ public sealed class DiagnosticsSettings
|
||||
|
||||
public sealed record RuntimeSettings(
|
||||
string EnovaInstallationPath,
|
||||
EnovaAdapterConfiguration EnovaConfiguration,
|
||||
EnovaAdapterConfiguration? EnovaConfiguration,
|
||||
string SqlConnectionString,
|
||||
int SqlCommandTimeoutSeconds,
|
||||
string LogDirectory,
|
||||
|
||||
Reference in New Issue
Block a user