2024-03-01 13:14:46 +02:00
|
|
|
#required Path.sbsl
|
2024-02-07 21:47:42 +02:00
|
|
|
#required Net.sbsl
|
2024-03-05 09:17:19 +02:00
|
|
|
#required ConfigInfo.sbsl
|
|
|
|
#required FilesHelper.sbsl
|
|
|
|
#required Xml.sbsl
|
2024-02-07 21:47:42 +02:00
|
|
|
|
2024-02-19 14:50:38 +02:00
|
|
|
@Global
|
|
|
|
enum Arch
|
|
|
|
X86,
|
|
|
|
X64
|
|
|
|
;
|
|
|
|
|
|
|
|
@Global
|
|
|
|
structure V8Platform
|
|
|
|
var Version: String = ""
|
|
|
|
var Architecture: Arch = Arch.X64
|
|
|
|
var BinPath: String = ""
|
|
|
|
var ExecutablePath: String = ""
|
|
|
|
var HasStandaloneServer: Boolean = False
|
|
|
|
var IbsrvPath: String = ""
|
|
|
|
var IbcmdPath: String = ""
|
|
|
|
;
|
|
|
|
|
2024-02-29 21:18:18 +02:00
|
|
|
@Global
|
2024-03-04 17:44:41 +02:00
|
|
|
method ConfigurationVersionFromExtensionVersion(Version: String = "0.0.0.0"): String
|
|
|
|
val VS = Version.Split(".")
|
|
|
|
|
|
|
|
if VS.Size() == 4
|
|
|
|
return Version
|
|
|
|
else if VS.Size() == 5
|
|
|
|
VS.RemoveAt(VS.Bound())
|
|
|
|
return VS.Join(".")
|
|
|
|
else
|
|
|
|
throw new IllegalFormatException("Unexpected format of the version: %Version")
|
2024-02-29 21:18:18 +02:00
|
|
|
;
|
2024-03-04 17:44:41 +02:00
|
|
|
;
|
2024-02-29 21:18:18 +02:00
|
|
|
|
2024-03-05 09:17:19 +02:00
|
|
|
@Global
|
|
|
|
method ConfigInfoFromConfiguration(ConfigurationPath: String): ConfigInfo.Class
|
|
|
|
val Reader = new XmlReader(FilesHelper.ReadFileToEnd(ConfigurationPath))
|
|
|
|
val Namespace = "http://v8.1c.ru/8.3/MDClasses"
|
|
|
|
|
|
|
|
val Name = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, Name", Namespace)
|
|
|
|
val Synonym = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, Synonym, v8:item, v8:content", Namespace)
|
|
|
|
val Version = Xml.GetValue(Reader, "Version", Namespace) ?? "0.0.0.0"
|
|
|
|
|
|
|
|
val ExtensionCompatibilityMode = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, ConfigurationExtensionCompatibilityMode", Namespace)
|
|
|
|
|
|
|
|
return new ConfigInfo.Class(Name, Synonym, Version, ExtensionCompatibilityMode)
|
|
|
|
;
|
|
|
|
|
2024-03-04 17:44:41 +02:00
|
|
|
@Global
|
|
|
|
method VersionIsUpper(Version1: String = "0.0.0.0", Version2: String = "0.0.0.0"): Boolean
|
|
|
|
val VersionFirst = Version1.Split(".")
|
2024-02-29 21:18:18 +02:00
|
|
|
val VersionSecond = Version2.Split(".")
|
2024-03-04 17:44:41 +02:00
|
|
|
|
|
|
|
if VersionFirst.Size() != VersionSecond.Size()
|
|
|
|
throw new IllegalFormatException("Versions have no the same format: ${Version2}")
|
2024-02-29 21:18:18 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
var Result = 0
|
2024-03-04 17:44:41 +02:00
|
|
|
for Index = 0 to VersionSecond.Size() - 1
|
2024-02-29 21:18:18 +02:00
|
|
|
Result = new Number(VersionFirst[Index]) - new Number(VersionSecond[Index])
|
|
|
|
if Result != 0
|
|
|
|
return Result < 0
|
|
|
|
;
|
|
|
|
;
|
|
|
|
return Result < 0
|
|
|
|
;
|
|
|
|
|
2024-02-07 21:47:42 +02:00
|
|
|
@Global
|
|
|
|
method GetInstalledPlatforms(): Array<V8Platform>
|
|
|
|
val Items = new Array<V8Platform>()
|
|
|
|
|
2024-02-19 14:58:12 +02:00
|
|
|
val OnecRootFolder = new File("1cv8", ExecutionEnvironment.GetVariable("ProgramFiles"))
|
2024-02-07 21:47:42 +02:00
|
|
|
|
2024-02-19 14:58:12 +02:00
|
|
|
val Pattern = new Pattern("\\d+\\.\\d+\\.\\d+\\.\\d+")
|
|
|
|
val PlatfromPaths = OnecRootFolder.Children.Filter(c -> Pattern.FindMatches(c.Name, 1).Size() > 0)
|
2024-02-07 21:47:42 +02:00
|
|
|
|
2024-02-19 14:58:12 +02:00
|
|
|
for Child in PlatfromPaths
|
|
|
|
val Platform = new V8Platform()
|
|
|
|
Platform.Version = Child.Name
|
|
|
|
Platform.Architecture = Arch.X64
|
2024-03-01 13:14:46 +02:00
|
|
|
Platform.BinPath = Path.Join(Child.Path, "bin")
|
|
|
|
Platform.ExecutablePath = Path.Join(Platform.BinPath, "1cv8.exe")
|
2024-02-17 22:19:54 +02:00
|
|
|
|
2024-03-01 13:14:46 +02:00
|
|
|
val IbsrvExecutable = new File(Path.Join(Platform.BinPath, "ibsrv.exe"))
|
2024-02-19 14:58:12 +02:00
|
|
|
if IbsrvExecutable.Exists()
|
|
|
|
Platform.HasStandaloneServer = True
|
|
|
|
Platform.IbsrvPath = IbsrvExecutable.Path
|
2024-03-01 13:14:46 +02:00
|
|
|
Platform.IbcmdPath = Path.Join(Platform.BinPath, "ibcmd.exe")
|
2024-02-17 22:19:54 +02:00
|
|
|
;
|
2024-02-07 21:47:42 +02:00
|
|
|
|
2024-02-19 14:58:12 +02:00
|
|
|
Items.Add(Platform)
|
2024-02-07 21:47:42 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
return Items.SortBy(c -> c.Version)
|
|
|
|
;
|
|
|
|
|
|
|
|
@Global
|
|
|
|
method GetInstalledPlatform(Version: String = ""): V8Platform?
|
|
|
|
if Version == ""
|
|
|
|
return GetHighestInstalledPlatform()
|
|
|
|
else
|
|
|
|
return GetInstalledPlatforms().Filter(c -> c.Version == Version).Last()
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
@Global
|
|
|
|
method GetHighestInstalledPlatform(): V8Platform?
|
2024-02-19 14:58:12 +02:00
|
|
|
val Platforms = V8.GetInstalledPlatforms()
|
|
|
|
return Platforms.Last()
|
2024-02-07 21:47:42 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
@Global
|
|
|
|
method WaitSshAgentIsStarted(Port: Number = 1545, TimoutSeconds: Number): Boolean
|
|
|
|
return Net.LocalPortIsOpen(Port, TimoutSeconds)
|
|
|
|
;
|
|
|
|
|
2024-02-17 22:19:54 +02:00
|
|
|
@Global
|
|
|
|
method ThrowIfHasNoStandaloneServer(Platform: V8Platform)
|
|
|
|
if not Platform.HasStandaloneServer
|
|
|
|
throw new IllegalStateException("Platform installation doesn't contains standalone server executable")
|
|
|
|
;
|
2024-02-07 21:47:42 +02:00
|
|
|
;
|