mirror of
https://github.com/akpaevj/executor-scripts.git
synced 2024-11-28 09:33:50 +02:00
125 lines
3.8 KiB
Plaintext
125 lines
3.8 KiB
Plaintext
#required Path.sbsl
|
|
#required Net.sbsl
|
|
#required ConfigInfo.sbsl
|
|
#required FilesHelper.sbsl
|
|
#required Xml.sbsl
|
|
|
|
@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 = ""
|
|
;
|
|
|
|
@Global
|
|
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")
|
|
;
|
|
;
|
|
|
|
@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)
|
|
;
|
|
|
|
@Global
|
|
method VersionIsUpper(Version1: String = "0.0.0.0", Version2: String = "0.0.0.0"): Boolean
|
|
val VersionFirst = Version1.Split(".")
|
|
val VersionSecond = Version2.Split(".")
|
|
|
|
if VersionFirst.Size() != VersionSecond.Size()
|
|
throw new IllegalFormatException("Versions have no the same format: ${Version2}")
|
|
;
|
|
|
|
var Result = 0
|
|
for Index = 0 to VersionSecond.Size() - 1
|
|
Result = new Number(VersionFirst[Index]) - new Number(VersionSecond[Index])
|
|
if Result != 0
|
|
return Result < 0
|
|
;
|
|
;
|
|
return Result < 0
|
|
;
|
|
|
|
@Global
|
|
method GetInstalledPlatforms(): Array<V8Platform>
|
|
val Items = new Array<V8Platform>()
|
|
|
|
val OnecRootFolder = new File("1cv8", ExecutionEnvironment.GetVariable("ProgramFiles"))
|
|
|
|
val Pattern = new Pattern("\\d+\\.\\d+\\.\\d+\\.\\d+")
|
|
val PlatfromPaths = OnecRootFolder.Children.Filter(c -> Pattern.FindMatches(c.Name, 1).Size() > 0)
|
|
|
|
for Child in PlatfromPaths
|
|
val Platform = new V8Platform()
|
|
Platform.Version = Child.Name
|
|
Platform.Architecture = Arch.X64
|
|
Platform.BinPath = Path.Join(Child.Path, "bin")
|
|
Platform.ExecutablePath = Path.Join(Platform.BinPath, "1cv8.exe")
|
|
|
|
val IbsrvExecutable = new File(Path.Join(Platform.BinPath, "ibsrv.exe"))
|
|
if IbsrvExecutable.Exists()
|
|
Platform.HasStandaloneServer = True
|
|
Platform.IbsrvPath = IbsrvExecutable.Path
|
|
Platform.IbcmdPath = Path.Join(Platform.BinPath, "ibcmd.exe")
|
|
;
|
|
|
|
Items.Add(Platform)
|
|
;
|
|
|
|
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?
|
|
val Platforms = V8.GetInstalledPlatforms()
|
|
return Platforms.Last()
|
|
;
|
|
|
|
@Global
|
|
method WaitSshAgentIsStarted(Port: Number = 1545, TimoutSeconds: Number): Boolean
|
|
return Net.LocalPortIsOpen(Port, TimoutSeconds)
|
|
;
|
|
|
|
@Global
|
|
method ThrowIfHasNoStandaloneServer(Platform: V8Platform)
|
|
if not Platform.HasStandaloneServer
|
|
throw new IllegalStateException("Platform installation doesn't contains standalone server executable")
|
|
;
|
|
; |