You've already forked onecmonitor
mirror of
https://github.com/akpaevj/onecmonitor.git
synced 2025-11-25 22:22:15 +02:00
Добавлен слой интеграции с OScript
This commit is contained in:
15
oneswiss-agent/Oscript/EdtInstallationsProviderWrapper.cs
Normal file
15
oneswiss-agent/Oscript/EdtInstallationsProviderWrapper.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneScript.StandardLibrary.Collections;
|
||||||
|
using OneSwiss.Agent.Services;
|
||||||
|
using OneSwiss.OneScript.Oscript;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("ПровайдерИнсталляцийEDT", "EdtInstallationsProvider")]
|
||||||
|
public class EdtInstallationsProviderWrapper(EdtInstallationsProvider provider) : AutoContext<EdtInstallationsProviderWrapper>
|
||||||
|
{
|
||||||
|
[ContextMethod("ПолучитьИнсталляции", "GetInstallations")]
|
||||||
|
public ArrayImpl GetInstallations()
|
||||||
|
=> new(provider.GetInstallations().Select(c => new EdtInstallationWrapper(c)));
|
||||||
|
}
|
||||||
25
oneswiss-agent/Oscript/OscriptIntegrationContext.cs
Normal file
25
oneswiss-agent/Oscript/OscriptIntegrationContext.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.Agent.Services;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("КонтекстИнтеграцииOneSwiss", "OneSwissIntegrationContext")]
|
||||||
|
public class OscriptIntegrationContext(
|
||||||
|
V8PlatformsProvider platformsProvider,
|
||||||
|
V8ServicesProvider servicesProvider,
|
||||||
|
RasHolder rasHolder,
|
||||||
|
EdtInstallationsProvider edtInstallationsProvider) : AutoContext<OscriptIntegrationContext>
|
||||||
|
{
|
||||||
|
[ContextProperty("ПровайдерПлатформ", "PlatformsProvider", CanWrite = false)]
|
||||||
|
public V8PlatformsProviderWrapper PlatformsProvider { get; } = new(platformsProvider);
|
||||||
|
|
||||||
|
[ContextProperty("ПровайдерСлужб", "ServicesProvider", CanWrite = false)]
|
||||||
|
public V8ServicesProviderWrapper ServicesProvider { get; } = new(servicesProvider);
|
||||||
|
|
||||||
|
[ContextProperty("МенеджерRas", "RasManager", CanWrite = false)]
|
||||||
|
public RasHolderWrapper RasHolder { get; } = new(rasHolder);
|
||||||
|
|
||||||
|
[ContextProperty("ПровайдерИнсталляцийEdt", "EdtInstallationsProvider", CanWrite = false)]
|
||||||
|
public EdtInstallationsProviderWrapper EdtInstallationsProvider { get; } = new(edtInstallationsProvider);
|
||||||
|
}
|
||||||
11
oneswiss-agent/Oscript/OscriptIntegrationGlobalContext.cs
Normal file
11
oneswiss-agent/Oscript/OscriptIntegrationGlobalContext.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[GlobalContext(Category = "Методы интеграции с OneSwiss", ManualRegistration = true)]
|
||||||
|
public class OscriptIntegrationGlobalContext(OscriptIntegrationContext context) : GlobalContextBase<OscriptIntegrationGlobalContext>
|
||||||
|
{
|
||||||
|
[ContextMethod("ПолучитьКонтекстИнтеграцииOneSwiss", "GetOneSwissIntegrationContext")]
|
||||||
|
public OscriptIntegrationContext GetContext() => context;
|
||||||
|
}
|
||||||
19
oneswiss-agent/Oscript/RasHolderWrapper.cs
Normal file
19
oneswiss-agent/Oscript/RasHolderWrapper.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneScript.StandardLibrary.Collections;
|
||||||
|
using OneSwiss.Agent.Services;
|
||||||
|
using OneSwiss.OneScript.Oscript;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("МенеджерRas", "RasManager")]
|
||||||
|
public class RasHolderWrapper(RasHolder holder) : AutoContext<RasHolderWrapper>
|
||||||
|
{
|
||||||
|
[ContextMethod("ПолучитьСлужбыRas", "GetRasServices")]
|
||||||
|
public ArrayImpl GetRasServices()
|
||||||
|
=> new (holder.GetRasServices().Select(c => new RasServiceWrapper(c)));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьЗапущеннуюСлужбуRasДляRagent", "GetActiveRasForRagent")]
|
||||||
|
public RasServiceWrapper GetActiveRasForRagent(RagentServiceWrapper ragent)
|
||||||
|
=> new(holder.GetActiveRasForRagent(ragent.Service));
|
||||||
|
}
|
||||||
15
oneswiss-agent/Oscript/V8PlatformsProviderWrapper.cs
Normal file
15
oneswiss-agent/Oscript/V8PlatformsProviderWrapper.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneScript.StandardLibrary.Collections;
|
||||||
|
using OneSwiss.Agent.Services;
|
||||||
|
using OneSwiss.OneScript.Oscript;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("ПровайдерПлатформV8", "V8PlatformsProvider")]
|
||||||
|
public class V8PlatformsProviderWrapper(V8PlatformsProvider provider) : AutoContext<V8PlatformsProviderWrapper>
|
||||||
|
{
|
||||||
|
[ContextMethod("ПолучитьУстановленныеПлатформы", "GetInstalledPlatforms")]
|
||||||
|
public ArrayImpl GetInstalledPlatforms()
|
||||||
|
=> new (provider.GetInstalledPlatforms().Select(c => new V8PlatformWrapper(c)));
|
||||||
|
}
|
||||||
39
oneswiss-agent/Oscript/V8ServicesProviderWrapper.cs
Normal file
39
oneswiss-agent/Oscript/V8ServicesProviderWrapper.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneScript.StandardLibrary.Collections;
|
||||||
|
using OneSwiss.Agent.Services;
|
||||||
|
using OneSwiss.OneScript.Oscript;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.Agent.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("ПровайдерСлужб", "ServicesProvider")]
|
||||||
|
public class V8ServicesProviderWrapper(V8ServicesProvider provider) : AutoContext<V8ServicesProviderWrapper>
|
||||||
|
{
|
||||||
|
[ContextMethod("ПолучитьСлужбыRas", "GetRasServices")]
|
||||||
|
public ArrayImpl GetRasServices()
|
||||||
|
=> new(provider.GetRasServices().Select(c => new RasServiceWrapper(c)));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьЗапущеннуюСлужбуRagentДляПортаКластера", "GetActiveRagentForClusterPort")]
|
||||||
|
public RagentServiceWrapper GetActiveRagentForClusterPort(int port)
|
||||||
|
=> new(provider.GetActiveRagentForClusterPort(port));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьЗапущенныеСлужбыRas", "GetActiveRagentServices")]
|
||||||
|
public ArrayImpl GetActiveRagentServices()
|
||||||
|
=> new(provider.GetActiveRagentServices().Select(c => new RagentServiceWrapper(c)));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьСлужбыRagent", "GetRagentServices")]
|
||||||
|
public ArrayImpl GetRagentServices()
|
||||||
|
=> new(provider.GetRagentServices().Select(c => new RagentServiceWrapper(c)));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьСлужбуCrServerДляПорта", "GetCrServerForPort")]
|
||||||
|
public CrServerWrapper GetCrServerForPort(int port)
|
||||||
|
=> new(provider.GetCrServerForPort(port));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьЗапущенныеСлужбыCrServer", "GetActiveCrServerServices")]
|
||||||
|
public ArrayImpl GetActiveCrServerServices()
|
||||||
|
=> new(provider.GetActiveCrServerServices().Select(c => new CrServerWrapper(c)));
|
||||||
|
|
||||||
|
[ContextMethod("ПолучитьСлужбыCrServer", "GetCrServerServices")]
|
||||||
|
public ArrayImpl GetCrServerServices()
|
||||||
|
=> new(provider.GetCrServerServices().Select(c => new CrServerWrapper(c)));
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using OneSwiss.Agent;
|
using OneSwiss.Agent;
|
||||||
using OneSwiss.Agent.Models;
|
using OneSwiss.Agent.Models;
|
||||||
|
using OneSwiss.Agent.Oscript;
|
||||||
using OneSwiss.Agent.Services;
|
using OneSwiss.Agent.Services;
|
||||||
using OneSwiss.Agent.Services.EventLog;
|
using OneSwiss.Agent.Services.EventLog;
|
||||||
using OneSwiss.Agent.Services.MaintenanceTasks;
|
using OneSwiss.Agent.Services.MaintenanceTasks;
|
||||||
@@ -43,6 +44,9 @@ var host = Host.CreateDefaultBuilder(args)
|
|||||||
services.AddSingleton<TechLogManager>();
|
services.AddSingleton<TechLogManager>();
|
||||||
|
|
||||||
services.AddSingleton<CommandsWatcher>();
|
services.AddSingleton<CommandsWatcher>();
|
||||||
|
|
||||||
|
services.AddSingleton<OscriptIntegrationContext>();
|
||||||
|
services.AddSingleton<OscriptIntegrationGlobalContext>();
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ using OneSwiss.V8.Platform.RemoteAdministration;
|
|||||||
|
|
||||||
namespace OneSwiss.Agent.Services.MaintenanceTasks;
|
namespace OneSwiss.Agent.Services.MaintenanceTasks;
|
||||||
|
|
||||||
[ContextClass("КонтекстШагаОбслуживания", "MaintenanceStepContext")]
|
|
||||||
public class MaintenanceStepContext
|
public class MaintenanceStepContext
|
||||||
{
|
{
|
||||||
[ContextProperty("ЗадачаОбслуживания", "MaintenanceTask")]
|
|
||||||
public MaintenanceTaskDto Task { get; set; } = null!;
|
public MaintenanceTaskDto Task { get; set; } = null!;
|
||||||
public InfoBaseDto InfoBase { get; set; } = null!;
|
public InfoBaseDto InfoBase { get; set; } = null!;
|
||||||
public MaintenanceStepDto Step { get; set; } = null!;
|
public MaintenanceStepDto Step { get; set; } = null!;
|
||||||
@@ -22,7 +20,6 @@ public class MaintenanceStepContext
|
|||||||
public V8Platform Platform { get; set; } = null!;
|
public V8Platform Platform { get; set; } = null!;
|
||||||
public bool UseDesignerAgent { get; set; }
|
public bool UseDesignerAgent { get; set; }
|
||||||
public DesignerAgentClient? DesignerAgentClient { get; set; }
|
public DesignerAgentClient? DesignerAgentClient { get; set; }
|
||||||
public CancellationToken CancellationToken { get; set; }
|
|
||||||
|
|
||||||
public OnecV8BatchMode GetBatchDesigner()
|
public OnecV8BatchMode GetBatchDesigner()
|
||||||
=> OnecV8BatchMode.CreateDesignerBatch(Platform, $"{InfoBase.Cluster.Host}:{InfoBase.Cluster.Port}", InfoBase.InfoBaseName);
|
=> OnecV8BatchMode.CreateDesignerBatch(Platform, $"{InfoBase.Cluster.Host}:{InfoBase.Cluster.Port}", InfoBase.InfoBaseName);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.CommandLine.Parsing;
|
using System.CommandLine.Parsing;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using OneSwiss.Agent.Extensions;
|
using OneSwiss.Agent.Extensions;
|
||||||
|
using OneSwiss.Agent.Oscript;
|
||||||
using OneSwiss.Common.DTO;
|
using OneSwiss.Common.DTO;
|
||||||
using OneSwiss.Common.DTO.MaintenanceTasks;
|
using OneSwiss.Common.DTO.MaintenanceTasks;
|
||||||
using OneSwiss.Common.Extensions;
|
using OneSwiss.Common.Extensions;
|
||||||
@@ -9,6 +10,7 @@ using OneSwiss.OneScript;
|
|||||||
using OneSwiss.V8.Designer.Agent;
|
using OneSwiss.V8.Designer.Agent;
|
||||||
using OneSwiss.V8.Designer.Batch;
|
using OneSwiss.V8.Designer.Batch;
|
||||||
using OneSwiss.V8.Platform.RemoteAdministration;
|
using OneSwiss.V8.Platform.RemoteAdministration;
|
||||||
|
using ScriptEngine.Hosting;
|
||||||
|
|
||||||
namespace OneSwiss.Agent.Services.MaintenanceTasks;
|
namespace OneSwiss.Agent.Services.MaintenanceTasks;
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ public class MaintenanceTaskExecutor : BackgroundService
|
|||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private readonly RasHolder _rasHolder;
|
private readonly RasHolder _rasHolder;
|
||||||
private readonly V8ServicesProvider _v8ServicesProvider;
|
private readonly V8ServicesProvider _v8ServicesProvider;
|
||||||
|
private OscriptIntegrationGlobalContext _oscriptIntegrationGlobalContext;
|
||||||
private readonly ILogger<MaintenanceTaskExecutor> _logger;
|
private readonly ILogger<MaintenanceTaskExecutor> _logger;
|
||||||
private readonly ILogger<Rac> _racLogger;
|
private readonly ILogger<Rac> _racLogger;
|
||||||
|
|
||||||
@@ -28,10 +31,12 @@ public class MaintenanceTaskExecutor : BackgroundService
|
|||||||
MonitorQueue<MaintenanceTaskDto> queue,
|
MonitorQueue<MaintenanceTaskDto> queue,
|
||||||
RasHolder rasHolder,
|
RasHolder rasHolder,
|
||||||
V8ServicesProvider v8ServicesProvider,
|
V8ServicesProvider v8ServicesProvider,
|
||||||
|
OscriptIntegrationGlobalContext oscriptIntegrationGlobalContext,
|
||||||
ILogger<MaintenanceTaskExecutor> logger,
|
ILogger<MaintenanceTaskExecutor> logger,
|
||||||
ILogger<Rac> racLogger)
|
ILogger<Rac> racLogger)
|
||||||
{
|
{
|
||||||
_racLogger = racLogger;
|
_racLogger = racLogger;
|
||||||
|
_oscriptIntegrationGlobalContext = oscriptIntegrationGlobalContext;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_scope = serviceProvider.CreateAsyncScope();
|
_scope = serviceProvider.CreateAsyncScope();
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
@@ -219,7 +224,7 @@ public class MaintenanceTaskExecutor : BackgroundService
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task HandleTaskStepNode(MaintenanceStepContext context)
|
private async Task HandleTaskStepNode(MaintenanceStepContext context)
|
||||||
{
|
{
|
||||||
AddStepLogItem(context, $"Обработка шага \"{context.Step.Kind.GetDisplay()}\"");
|
AddStepLogItem(context, $"Обработка шага \"{context.Step.Kind.GetDisplay()}\"");
|
||||||
|
|
||||||
@@ -478,7 +483,7 @@ public class MaintenanceTaskExecutor : BackgroundService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ExecuteOneScript(MaintenanceStepContext context)
|
private void ExecuteOneScript(MaintenanceStepContext context)
|
||||||
{
|
{
|
||||||
var scriptPath = Directory.CreateTempSubdirectory().FullName;
|
var scriptPath = Directory.CreateTempSubdirectory().FullName;
|
||||||
|
|
||||||
@@ -498,7 +503,11 @@ public class MaintenanceTaskExecutor : BackgroundService
|
|||||||
var cmdParser = new Parser();
|
var cmdParser = new Parser();
|
||||||
var parsingResult = cmdParser.Parse(context.Step.CommandLineArguments);
|
var parsingResult = cmdParser.Parse(context.Step.CommandLineArguments);
|
||||||
|
|
||||||
scriptHost.ExecutePackageScript(scriptPath, opmMetadata!, []);
|
scriptHost.ExecutePackageScript(scriptPath, opmMetadata!, [], e =>
|
||||||
|
{
|
||||||
|
e.AddAssembly(typeof(OscriptIntegrationGlobalContext).Assembly);
|
||||||
|
e.AddGlobalContext(_oscriptIntegrationGlobalContext);
|
||||||
|
});
|
||||||
|
|
||||||
Directory.Delete(scriptPath, true);
|
Directory.Delete(scriptPath, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
using OneSwiss.V8.Platform.Services;
|
using OneSwiss.V8.Platform.Services;
|
||||||
|
|
||||||
namespace OneSwiss.Agent.Services;
|
namespace OneSwiss.Agent.Services;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Reflection;
|
||||||
using OneScript.Sources;
|
using OneScript.Sources;
|
||||||
using OneScript.StandardLibrary;
|
using OneScript.StandardLibrary;
|
||||||
using OneSwiss.OneScript.Oscript;
|
using OneSwiss.V8.Platform;
|
||||||
using ScriptEngine;
|
using ScriptEngine;
|
||||||
using ScriptEngine.HostedScript;
|
using ScriptEngine.HostedScript;
|
||||||
using ScriptEngine.Hosting;
|
using ScriptEngine.Hosting;
|
||||||
|
using ExecutionContext = ScriptEngine.Machine.ExecutionContext;
|
||||||
|
|
||||||
namespace OneSwiss.OneScript;
|
namespace OneSwiss.OneScript;
|
||||||
|
|
||||||
@@ -14,13 +16,13 @@ public class OneScriptExecutor : IHostApplication
|
|||||||
public EventHandler<Exception>? OnError = null;
|
public EventHandler<Exception>? OnError = null;
|
||||||
private string[] _args;
|
private string[] _args;
|
||||||
|
|
||||||
public void ExecutePackageScript(string path, OpmMetadata metadata, string[] args)
|
public void ExecutePackageScript(string path, OpmMetadata metadata, string[] args, Action<ExecutionContext> engineBuilder)
|
||||||
{
|
{
|
||||||
_args = args;
|
_args = args;
|
||||||
var executablePath = Path.Combine(path, metadata.Executable);
|
var executablePath = Path.Combine(path, metadata.Executable);
|
||||||
var librariesPath = Path.Combine(path, "oscript_modules");
|
var librariesPath = Path.Combine(path, "oscript_modules");
|
||||||
|
|
||||||
using var engine = CreateEngine(librariesPath);
|
using var engine = CreateEngine(librariesPath, engineBuilder);
|
||||||
engine.Initialize();
|
engine.Initialize();
|
||||||
|
|
||||||
var source = SourceCodeBuilder
|
var source = SourceCodeBuilder
|
||||||
@@ -35,7 +37,7 @@ public class OneScriptExecutor : IHostApplication
|
|||||||
throw new Exception("Ошибка выполнения скрипта");
|
throw new Exception("Ошибка выполнения скрипта");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HostedScriptEngine CreateEngine(string librariesPath)
|
private static HostedScriptEngine CreateEngine(string librariesPath, Action<ExecutionContext> engineBuilder)
|
||||||
{
|
{
|
||||||
var builder = DefaultEngineBuilder
|
var builder = DefaultEngineBuilder
|
||||||
.Create()
|
.Create()
|
||||||
@@ -44,6 +46,8 @@ public class OneScriptExecutor : IHostApplication
|
|||||||
.SetupEnvironment(e =>
|
.SetupEnvironment(e =>
|
||||||
{
|
{
|
||||||
e.AddStandardLibrary();
|
e.AddStandardLibrary();
|
||||||
|
e.AddAssembly(typeof(OneScriptExecutor).Assembly);
|
||||||
|
engineBuilder.Invoke(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.RegisterSingleton<IDependencyResolver>(new FileSystemDependencyResolver
|
builder.Services.RegisterSingleton<IDependencyResolver>(new FileSystemDependencyResolver
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using OneSwiss.OneScript.Oscript;
|
|
||||||
|
|
||||||
namespace OneSwiss.OneScript;
|
namespace OneSwiss.OneScript;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
namespace OneSwiss.OneScript.Oscript;
|
namespace OneSwiss.OneScript;
|
||||||
|
|
||||||
public class OpmMetadataRoot
|
public class OpmMetadataRoot
|
||||||
{
|
{
|
||||||
|
|||||||
29
oneswiss-oscript-integration/Oscript/CrServerWrapper.cs
Normal file
29
oneswiss-oscript-integration/Oscript/CrServerWrapper.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneScript.StandardLibrary.Collections;
|
||||||
|
using OneScript.Values;
|
||||||
|
using OneSwiss.V8.Platform.Services;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("СлужбаCrServer", "CrServerService")]
|
||||||
|
public class CrServerWrapper(CrServer service) : AutoContext<CrServerWrapper>
|
||||||
|
{
|
||||||
|
[ContextProperty("Имя", "Name", CanWrite = false)]
|
||||||
|
public string Name => service.Name;
|
||||||
|
|
||||||
|
[ContextProperty("Запущена", "IsActive", CanWrite = false)]
|
||||||
|
public bool IsActive => service.IsActive;
|
||||||
|
|
||||||
|
[ContextProperty("Порт", "Port", CanWrite = false)]
|
||||||
|
public int Port { get; set; }
|
||||||
|
|
||||||
|
[ContextProperty("Каталог", "Directory", CanWrite = false)]
|
||||||
|
public string Directory { get; set; } = null!;
|
||||||
|
|
||||||
|
[ContextProperty("Платформа", "Platform", CanWrite = false)]
|
||||||
|
public V8PlatformWrapper Platform { get; } = new(service.Platform);
|
||||||
|
|
||||||
|
[ContextProperty("Хранилища", "Repositories", CanWrite = false)]
|
||||||
|
public ArrayImpl Repositories { get; } = new(service.Repositories.Select(BslStringValue.Create));
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.V8.Edt;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("ИнсталляцияEDT", "EdtInstallation")]
|
||||||
|
public class EdtInstallationWrapper(EdtInstallation item) : AutoContext<EdtInstallationWrapper>
|
||||||
|
{
|
||||||
|
[ContextProperty("Версия", "Version", CanWrite = false)]
|
||||||
|
public string Version => item.Version;
|
||||||
|
[ContextProperty("Путь", "Path", CanWrite = false)]
|
||||||
|
public string Path => item.Path;
|
||||||
|
[ContextProperty("СуществуетEdtCli", "ExistsEdtCli", CanWrite = false)]
|
||||||
|
public bool HasEdtCli => item.HasEdtCli;
|
||||||
|
[ContextProperty("ПутьEdtCli", "PathEdtCli", CanWrite = false)]
|
||||||
|
public string EdtCliPath => item.EdtCliPath;
|
||||||
|
[ContextProperty("ИзСтартера", "FromStarter", CanWrite = false)]
|
||||||
|
public bool FromStarter => item.FromStarter;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using OneScript.Contexts.Enums;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[EnumerationType("ТипОтладкиRagent", "RagentDebugType")]
|
||||||
|
public enum RagentDebugTypeWrapper
|
||||||
|
{
|
||||||
|
[EnumValue("Отключена", "Disabled")]
|
||||||
|
None,
|
||||||
|
[EnumValue("TCP")]
|
||||||
|
Tcp,
|
||||||
|
[EnumValue("HTTP")]
|
||||||
|
Http
|
||||||
|
}
|
||||||
32
oneswiss-oscript-integration/Oscript/RagentServiceWrapper.cs
Normal file
32
oneswiss-oscript-integration/Oscript/RagentServiceWrapper.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.V8.Platform.Services;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("СервисRagent", "RagentService")]
|
||||||
|
public class RagentServiceWrapper(RagentService service) : AutoContext<RagentServiceWrapper>
|
||||||
|
{
|
||||||
|
public readonly RagentService Service = service;
|
||||||
|
|
||||||
|
[ContextProperty("Имя", "Name", CanWrite = false)]
|
||||||
|
public string Name => Service.Name;
|
||||||
|
|
||||||
|
[ContextProperty("Запущена", "IsActive", CanWrite = false)]
|
||||||
|
public bool IsActive => Service.IsActive;
|
||||||
|
|
||||||
|
[ContextProperty("Порт", "Port", CanWrite = false)]
|
||||||
|
public int Port => Service.Port;
|
||||||
|
|
||||||
|
[ContextProperty("ПортReg", "RegPort", CanWrite = false)]
|
||||||
|
public int RegPort => Service.RegPort;
|
||||||
|
|
||||||
|
[ContextProperty("КаталогКластера", "ClusterCatalog", CanWrite = false)]
|
||||||
|
public string ClusterCatalog => Service.ClusterCatalog;
|
||||||
|
|
||||||
|
[ContextProperty("Платформа", "Platform", CanWrite = false)]
|
||||||
|
public V8PlatformWrapper Platform { get; } = new(service.Platform);
|
||||||
|
|
||||||
|
[ContextProperty("ТипОтладки", "DebugType", CanWrite = false)]
|
||||||
|
public RagentDebugTypeWrapper DebugType { get; } = (RagentDebugTypeWrapper)service.DebugType;
|
||||||
|
}
|
||||||
30
oneswiss-oscript-integration/Oscript/RasServiceWrapper.cs
Normal file
30
oneswiss-oscript-integration/Oscript/RasServiceWrapper.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.V8.Platform;
|
||||||
|
using OneSwiss.V8.Platform.Services;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("СервисRas", "RasService")]
|
||||||
|
public class RasServiceWrapper(RasService service) : AutoContext<RasServiceWrapper>
|
||||||
|
{
|
||||||
|
[ContextProperty("Имя", "Name", CanWrite = false)]
|
||||||
|
public string Name => service.Name;
|
||||||
|
|
||||||
|
[ContextProperty("Запущена", "IsActive", CanWrite = false)]
|
||||||
|
public bool IsActive => service.IsActive;
|
||||||
|
|
||||||
|
[ContextProperty("ХостRagent", "RagentHost", CanWrite = false)]
|
||||||
|
public string RagentHost => service.RagentHost;
|
||||||
|
|
||||||
|
[ContextProperty("ПортRagent", "RagentPort", CanWrite = false)]
|
||||||
|
public int RagentPort => service.Port;
|
||||||
|
|
||||||
|
[ContextProperty("Порт", "Port", CanWrite = false)]
|
||||||
|
public int Port => service.Port;
|
||||||
|
|
||||||
|
[ContextProperty("Платформа", "Platform", CanWrite = false)]
|
||||||
|
public V8PlatformWrapper Platform { get; } = new V8PlatformWrapper(service.Platform);
|
||||||
|
}
|
||||||
32
oneswiss-oscript-integration/Oscript/V8PlatformWrapper.cs
Normal file
32
oneswiss-oscript-integration/Oscript/V8PlatformWrapper.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.V8.Platform;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("ПлатформаV8", "V8Platform")]
|
||||||
|
public class V8PlatformWrapper(V8Platform platform) : AutoContext<V8PlatformWrapper>
|
||||||
|
{
|
||||||
|
[ContextProperty("Путь", "Path", CanWrite = false)]
|
||||||
|
public string PlatformPath => platform.PlatformPath;
|
||||||
|
[ContextProperty("Существует1CV8", "Exists1CV8", CanWrite = false)]
|
||||||
|
public bool HasOnecV8 => platform.HasOnecV8;
|
||||||
|
[ContextProperty("Путь1CV8", "Path1CV8", CanWrite = false)]
|
||||||
|
public string OnecV8Path => platform.OnecV8Path;
|
||||||
|
[ContextProperty("СуществуетRac", "ExistsRac", CanWrite = false)]
|
||||||
|
public bool HasRac => platform.HasRac;
|
||||||
|
[ContextProperty("ПутьRac", "PathRac", CanWrite = false)]
|
||||||
|
public string RacPath => platform.RacPath;
|
||||||
|
[ContextProperty("СуществуетRas", "ExistsRas", CanWrite = false)]
|
||||||
|
public bool HasRas => platform.HasRas;
|
||||||
|
[ContextProperty("ПутьRas", "PathRas", CanWrite = false)]
|
||||||
|
public string RasPath => platform.RasPath;
|
||||||
|
[ContextProperty("СуществуетIbcmd", "ExistsIbcmd", CanWrite = false)]
|
||||||
|
public bool HasIbcmd => platform.HasIbcmd;
|
||||||
|
[ContextProperty("ПутьIbcmd", "PathIbcmd", CanWrite = false)]
|
||||||
|
public string IbcmdPath => platform.IbcmdPath;
|
||||||
|
[ContextProperty("Версия", "Version", CanWrite = false)]
|
||||||
|
public string Version => platform.Version;
|
||||||
|
}
|
||||||
14
oneswiss-oscript-integration/Oscript/V8ServiceWrapper.cs
Normal file
14
oneswiss-oscript-integration/Oscript/V8ServiceWrapper.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using OneScript.Contexts;
|
||||||
|
using OneSwiss.V8.Platform.Services;
|
||||||
|
using ScriptEngine.Machine.Contexts;
|
||||||
|
|
||||||
|
namespace OneSwiss.OneScript.Oscript;
|
||||||
|
|
||||||
|
[ContextClass("СлужбаV8", "V8Service")]
|
||||||
|
public class V8ServiceWrapper(V8Service item) : AutoContext<V8ServiceWrapper>
|
||||||
|
{
|
||||||
|
[ContextProperty("Имя", "Name", CanWrite = false)]
|
||||||
|
public string Name => item.Name;
|
||||||
|
[ContextProperty("Запущена", "IsActive", CanWrite = false)]
|
||||||
|
public bool IsActive => item.IsActive;
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Oscript\" />
|
<ProjectReference Include="..\oneswiss-v8\oneswiss-v8.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -39,13 +39,18 @@ public static class EdtDiscoverer
|
|||||||
|
|
||||||
var edtCliPath = Path.Join(binPath, "1cedtcli" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".exe" : ""));
|
var edtCliPath = Path.Join(binPath, "1cedtcli" + (Environment.OSVersion.Platform == PlatformID.Win32NT ? ".exe" : ""));
|
||||||
|
|
||||||
items.Add(new EdtInstallation
|
var edtItem = new EdtInstallation
|
||||||
{
|
{
|
||||||
Version = version,
|
Version = version,
|
||||||
HasEdtCli = File.Exists(edtCliPath),
|
HasEdtCli = File.Exists(edtCliPath),
|
||||||
Path = binPath,
|
Path = binPath,
|
||||||
FromStarter = item.IsStarter
|
FromStarter = item.IsStarter
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (edtItem.HasEdtCli)
|
||||||
|
edtItem.EdtCliPath = edtCliPath;
|
||||||
|
|
||||||
|
items.Add(edtItem);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,7 @@ public class EdtInstallation
|
|||||||
[Key(2)]
|
[Key(2)]
|
||||||
public bool HasEdtCli { get; set; }
|
public bool HasEdtCli { get; set; }
|
||||||
[Key(3)]
|
[Key(3)]
|
||||||
|
public string EdtCliPath { get; set; }
|
||||||
|
[Key(4)]
|
||||||
public bool FromStarter { get; set; }
|
public bool FromStarter { get; set; }
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ public class RagentService : V8Service
|
|||||||
[Key(5)]
|
[Key(5)]
|
||||||
[DisplayName("Платформа")]
|
[DisplayName("Платформа")]
|
||||||
public V8Platform Platform { get; set; } = null!;
|
public V8Platform Platform { get; set; } = null!;
|
||||||
[Key(6)] [DisplayName("Тип отладки")]
|
[Key(6)]
|
||||||
|
[DisplayName("Тип отладки")]
|
||||||
public RagentDebugType DebugType { get; set; } = RagentDebugType.None;
|
public RagentDebugType DebugType { get; set; } = RagentDebugType.None;
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,28 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
|
using OneScript.Contexts;
|
||||||
|
|
||||||
namespace OneSwiss.V8.Platform.Services;
|
namespace OneSwiss.V8.Platform.Services;
|
||||||
|
|
||||||
[DisplayName("Служба сервера удаленного администрирования 1С")]
|
[DisplayName("Служба сервера удаленного администрирования 1С")]
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
|
[ContextClass("СервисRas", "RasService")]
|
||||||
public class RasService : V8Service
|
public class RasService : V8Service
|
||||||
{
|
{
|
||||||
[Key(2)]
|
[Key(2)]
|
||||||
[DisplayName("Хост агента кластера")]
|
[DisplayName("Хост агента кластера")]
|
||||||
|
[ContextProperty("ХостRagent", "RagentHost", CanWrite = false)]
|
||||||
public string RagentHost { get; set; } = string.Empty;
|
public string RagentHost { get; set; } = string.Empty;
|
||||||
[Key(3)]
|
[Key(3)]
|
||||||
[DisplayName("Порт агента кластера")]
|
[DisplayName("Порт агента кластера")]
|
||||||
|
[ContextProperty("ПортRagent", "RagentPort", CanWrite = false)]
|
||||||
public int RagentPort { get; set; }
|
public int RagentPort { get; set; }
|
||||||
[Key(4)]
|
[Key(4)]
|
||||||
[DisplayName("Порт")]
|
[DisplayName("Порт")]
|
||||||
|
[ContextProperty("Порт", "Port", CanWrite = false)]
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
[Key(5)]
|
[Key(5)]
|
||||||
[DisplayName("Платформа")]
|
[DisplayName("Платформа")]
|
||||||
|
[ContextProperty("Платформа", "Platform", CanWrite = false)]
|
||||||
public V8Platform Platform { get; set; } = null!;
|
public V8Platform Platform { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
|
using OneScript.Contexts;
|
||||||
|
|
||||||
namespace OneSwiss.V8.Platform;
|
namespace OneSwiss.V8.Platform;
|
||||||
|
|
||||||
@@ -11,31 +12,44 @@ public class V8Platform
|
|||||||
public string PlatformPath { get; init; } = string.Empty;
|
public string PlatformPath { get; init; } = string.Empty;
|
||||||
[DisplayName("1Cv8 установлена")]
|
[DisplayName("1Cv8 установлена")]
|
||||||
[Key(1)]
|
[Key(1)]
|
||||||
|
[ContextProperty("Существует1CV8", "Exists1CV8", CanWrite = false)]
|
||||||
public bool HasOnecV8 { get; init; }
|
public bool HasOnecV8 { get; init; }
|
||||||
[DisplayName("Путь к 1Cv8")]
|
[DisplayName("Путь к 1Cv8")]
|
||||||
[Key(2)]
|
[Key(2)]
|
||||||
|
[ContextProperty("Путь1CV8", "Path1CV8", CanWrite = false)]
|
||||||
public string OnecV8Path { get; init; } = string.Empty;
|
public string OnecV8Path { get; init; } = string.Empty;
|
||||||
[DisplayName("RAC установлен")]
|
[DisplayName("RAC установлен")]
|
||||||
[Key(3)]
|
[Key(3)]
|
||||||
|
[ContextProperty("СуществуетRac", "ExistsRac", CanWrite = false)]
|
||||||
public bool HasRac { get; init; }
|
public bool HasRac { get; init; }
|
||||||
[DisplayName("Путь к RAC")]
|
[DisplayName("Путь к RAC")]
|
||||||
[Key(4)]
|
[Key(4)]
|
||||||
|
[ContextProperty("ПутьRac", "PathRac", CanWrite = false)]
|
||||||
public string RacPath { get; init; } = string.Empty;
|
public string RacPath { get; init; } = string.Empty;
|
||||||
[DisplayName("RAS установлен")]
|
[DisplayName("RAS установлен")]
|
||||||
[Key(5)]
|
[Key(5)]
|
||||||
|
[ContextProperty("СуществуетRas", "ExistsRas", CanWrite = false)]
|
||||||
public bool HasRas { get; init; }
|
public bool HasRas { get; init; }
|
||||||
[DisplayName("Путь к RAS")]
|
[DisplayName("Путь к RAS")]
|
||||||
[Key(6)]
|
[Key(6)]
|
||||||
|
[ContextProperty("ПутьRas", "PathRas", CanWrite = false)]
|
||||||
public string RasPath { get; init; } = string.Empty;
|
public string RasPath { get; init; } = string.Empty;
|
||||||
[Key(7)]
|
[Key(7)]
|
||||||
|
[ContextProperty("СуществуетIbcmd", "ExistsIbcmd", CanWrite = false)]
|
||||||
public bool HasIbcmd { get; init; }
|
public bool HasIbcmd { get; init; }
|
||||||
[DisplayName("Путь к ibcmd")]
|
[DisplayName("Путь к ibcmd")]
|
||||||
[Key(8)]
|
[Key(8)]
|
||||||
|
[ContextProperty("ПутьIbcmd", "PathIbcmd", CanWrite = false)]
|
||||||
public string IbcmdPath { get; init; } = string.Empty;
|
public string IbcmdPath { get; init; } = string.Empty;
|
||||||
[DisplayName("Версия")]
|
[DisplayName("Версия")]
|
||||||
[Key(9)]
|
[Key(9)]
|
||||||
|
[ContextProperty("Версия", "Version", CanWrite = false)]
|
||||||
public string Version { get; init; } = string.Empty;
|
public string Version { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
[ScriptConstructor]
|
||||||
|
public static V8Platform Constructor()
|
||||||
|
=> new V8Platform();
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
=> obj is V8Platform platform &&
|
=> obj is V8Platform platform &&
|
||||||
PlatformPath.ToUpper().Equals(platform.PlatformPath.ToUpper());
|
PlatformPath.ToUpper().Equals(platform.PlatformPath.ToUpper());
|
||||||
|
|||||||
@@ -16,6 +16,12 @@
|
|||||||
<Reference Include="MessagePack.Annotations">
|
<Reference Include="MessagePack.Annotations">
|
||||||
<HintPath>..\..\..\.nuget\packages\messagepack.annotations\3.1.2\lib\netstandard2.0\MessagePack.Annotations.dll</HintPath>
|
<HintPath>..\..\..\.nuget\packages\messagepack.annotations\3.1.2\lib\netstandard2.0\MessagePack.Annotations.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.Abstractions">
|
||||||
|
<HintPath>..\..\..\.nuget\packages\microsoft.extensions.configuration.abstractions\9.0.7\lib\net9.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OneScript.Core">
|
||||||
|
<HintPath>..\..\..\.nuget\packages\onescript.corelib\2.0.0-rc.7\lib\net6.0\OneScript.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.ServiceProcess.ServiceController">
|
<Reference Include="System.ServiceProcess.ServiceController">
|
||||||
<HintPath>..\..\..\.nuget\packages\system.serviceprocess.servicecontroller\9.0.1\lib\net8.0\System.ServiceProcess.ServiceController.dll</HintPath>
|
<HintPath>..\..\..\.nuget\packages\system.serviceprocess.servicecontroller\9.0.1\lib\net8.0\System.ServiceProcess.ServiceController.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
Reference in New Issue
Block a user