feat: drive Preview automation through AutoCAD script
This commit is contained in:
@@ -40,9 +40,10 @@ public sealed class PilotExecutionService(
|
||||
if (!safety.IsAllowed) return new(null, safety);
|
||||
|
||||
var futureEntry = Path.Combine(request.PilotRoot, "packages", request.Manifest.PackageId, "versions", request.Manifest.Version, request.Manifest.EntryAssembly);
|
||||
var fixture = request.Configuration.AutomationMode is null ? null : ReadFixtureOrtho(request.Configuration.AutomationConfigurationPath);
|
||||
var content = request.Configuration.AutomationMode is null
|
||||
? $"_.NETLOAD\n\"{futureEntry.Replace("\"", "\\\"")}\"\n"
|
||||
: $"_.NETLOAD\n\"{futureEntry.Replace("\"", "\\\"")}\"\nPHP_REC_AUTOMATION_START\n";
|
||||
: $"_.OPEN\n\"{fixture!.Replace("\"", "\\\"")}\"\n_.NETLOAD\n\"{futureEntry.Replace("\"", "\\\"")}\"\nPHP_REC_AUTOMATION_PREPARE\nPXP-OA\nPXP-OA\nPHP_REC_AUTOMATION_FINALIZE\n";
|
||||
var scriptHash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(content)));
|
||||
var plan = PilotPlanFactory.Create(request.Product, profile, request.Manifest, request.ManifestHash, request.PilotRoot, request.StartupScriptPath, scriptHash, safety);
|
||||
var environment = new Dictionary<string, string> { ["P_REC_ANNOT_RUNTIME_MODE"] = request.Configuration.PluginExecutionMode.ToString() };
|
||||
@@ -50,6 +51,7 @@ public sealed class PilotExecutionService(
|
||||
environment["P_REC_ANNOT_APPLY_PERMIT_PATH"] = request.Configuration.ApplyPermitPath;
|
||||
if (request.Configuration.AutomationMode is not null)
|
||||
{
|
||||
environment["P_REC_ANNOT_LAUNCHER_MODE"] = "NextPilot";
|
||||
environment["P_REC_ANNOT_AUTOMATION"] = request.Configuration.AutomationMode;
|
||||
environment["P_REC_ANNOT_AUTOMATION_CONFIG"] = request.Configuration.AutomationConfigurationPath!;
|
||||
}
|
||||
@@ -104,7 +106,7 @@ public sealed class PilotExecutionService(
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(scriptPath)!);
|
||||
var script = request.Preparation.Configuration.AutomationMode is null
|
||||
? scriptBuilder.BuildNetloadScript(versionDirectory, request.Preparation.Manifest.EntryAssembly)
|
||||
: scriptBuilder.BuildAutomationScript(versionDirectory, request.Preparation.Manifest.EntryAssembly);
|
||||
: scriptBuilder.BuildAutomationScript(versionDirectory, request.Preparation.Manifest.EntryAssembly, ReadFixtureOrtho(request.Preparation.Configuration.AutomationConfigurationPath));
|
||||
await File.WriteAllTextAsync(scriptPath, script, cancellationToken);
|
||||
await WriteSession(plan.PilotRoot, (await ReadSession(plan.PilotRoot, cancellationToken))! with { State = "ProcessStarting", UpdatedAtUtc = DateTimeOffset.UtcNow }, cancellationToken);
|
||||
var result = new GuardedAutodeskProcessLauncher(gate, probe, invoker).Start(context, plan with { StartupScriptPath = scriptPath, Process = plan.Process with { Arguments = ["/product", "PLNT3D", "/language", "ru-RU", "/b", scriptPath], WorkingDirectory = plan.PilotRoot } }, request.Permit, permits);
|
||||
@@ -124,6 +126,14 @@ public sealed class PilotExecutionService(
|
||||
}
|
||||
}
|
||||
|
||||
private static string ReadFixtureOrtho(string? automationConfigurationPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(automationConfigurationPath) || !File.Exists(automationConfigurationPath)) throw new InvalidOperationException("AUTOMATION_CONFIG_MISSING");
|
||||
using var json = JsonDocument.Parse(File.ReadAllText(automationConfigurationPath));
|
||||
if (!json.RootElement.TryGetProperty("orthoDrawingPath", out var value) || string.IsNullOrWhiteSpace(value.GetString())) throw new InvalidOperationException("AUTOMATION_ORTHO_PATH_REQUIRED");
|
||||
return Path.GetFullPath(value.GetString()!);
|
||||
}
|
||||
|
||||
public async Task<PilotRollbackResult> RollbackAsync(PilotRollbackRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user