|
@@ -1,10 +1,11 @@
|
|
|
using System;
|
|
using System;
|
|
|
-using System.Diagnostics;
|
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
using BO.AppServer.Metadata.Dto;
|
|
using BO.AppServer.Metadata.Dto;
|
|
|
using BO.ProcessServer.Business.Enums;
|
|
using BO.ProcessServer.Business.Enums;
|
|
|
using BO.ProcessServer.Options;
|
|
using BO.ProcessServer.Options;
|
|
|
using Quadarax.Foundation.Core.Logging;
|
|
using Quadarax.Foundation.Core.Logging;
|
|
|
|
|
+using Quadarax.Foundation.Core.Value.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace BO.ProcessServer.Business.Scenarios
|
|
namespace BO.ProcessServer.Business.Scenarios
|
|
@@ -13,12 +14,14 @@ namespace BO.ProcessServer.Business.Scenarios
|
|
|
{
|
|
{
|
|
|
private Configuration _configuration;
|
|
private Configuration _configuration;
|
|
|
private ILog _log;
|
|
private ILog _log;
|
|
|
|
|
+ private Random _rnd;
|
|
|
|
|
|
|
|
public Scenarios(Configuration configuration, ILogger logger)
|
|
public Scenarios(Configuration configuration, ILogger logger)
|
|
|
{
|
|
{
|
|
|
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
|
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
|
|
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
|
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
|
|
_log = logger.GetLogger(GetType());
|
|
_log = logger.GetLogger(GetType());
|
|
|
|
|
+ _rnd = new Random();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool ExistsScenario(DocumentRDto docInfo)
|
|
public bool ExistsScenario(DocumentRDto docInfo)
|
|
@@ -29,12 +32,37 @@ namespace BO.ProcessServer.Business.Scenarios
|
|
|
|
|
|
|
|
public Configuration.CfgScenario FindScenario(DocumentRDto docInfo)
|
|
public Configuration.CfgScenario FindScenario(DocumentRDto docInfo)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (_configuration.System.Mode == AppModeEnum.Proxy ||
|
|
|
|
|
+ _configuration.System.Mode == AppModeEnum.ProxyProcess)
|
|
|
|
|
+ {
|
|
|
|
|
+ var succ = _rnd.NextBool(Constants.CS_DEF_PROXY_SCENARIO_SUCC_PCT);
|
|
|
|
|
+ return new Configuration.CfgScenario()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Name = succ ? "DummySucc" : "DummyFail",
|
|
|
|
|
+ AcceptFilters = new List<Configuration.CfgScenarioAcceptFilter>(),
|
|
|
|
|
+ AcceptFiltersIfAll = true,
|
|
|
|
|
+ ExitCodeFail = 1,
|
|
|
|
|
+ ExitCodeSucc = 0,
|
|
|
|
|
+ RunHidden = true,
|
|
|
|
|
+ RunWindowsStyleRaw = "Minimized",
|
|
|
|
|
+ ShellCommand = succ ? Constants.CS_DEF_SCENARIO_SUCC : Constants.CS_DEF_SCENARIO_FAIL,
|
|
|
|
|
+ ShellCommandArguments = Constants.CS_TAG_P_OUT_EXT + " " + Constants.CS_TAG_INPUT_FILES,
|
|
|
|
|
+ TimeoutIntervalRaw = "00:00:10"
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
return _configuration.System.Scenarios.FirstOrDefault(x => MatchScenario(x, docInfo));
|
|
return _configuration.System.Scenarios.FirstOrDefault(x => MatchScenario(x, docInfo));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool MatchScenario(Configuration.CfgScenario scenario, DocumentRDto document)
|
|
private bool MatchScenario(Configuration.CfgScenario scenario, DocumentRDto document)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (_configuration.System.Mode == AppModeEnum.Proxy ||
|
|
|
|
|
+ _configuration.System.Mode == AppModeEnum.ProxyProcess)
|
|
|
|
|
+ {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
var match = scenario.AcceptFiltersIfAll;
|
|
var match = scenario.AcceptFiltersIfAll;
|
|
|
foreach (var filter in scenario.AcceptFilters)
|
|
foreach (var filter in scenario.AcceptFilters)
|