1
0
mirror of https://github.com/akpaevj/executor-scripts.git synced 2024-11-24 08:52:35 +02:00
This commit is contained in:
akpaevj 2024-03-05 10:17:19 +03:00
parent ad07dd2d97
commit 47f5f0a072
5 changed files with 49 additions and 103 deletions

View File

@ -4,27 +4,16 @@
#required SshAgentConnection.sbsl
#required Net.sbsl
#required Xml.sbsl
#required ConfigInfo.sbsl
@Global
method NeedUpdateConfiguration(
method GetConfigInfo(
Server: String,
Infobase: String,
User: String,
Password: String,
RequestedVersion: String,
PlatformVersion = ""): Boolean
val ConfigurationInfo = GetConfigurationInfo(Server, Infobase, User, Password, PlatformVersion)
return V8.VersionIsUpper(ConfigurationInfo.Version, RequestedVersion)
;
@Global
method GetConfigurationInfo(
Server: String,
Infobase: String,
User: String,
Password: String,
PlatformVersion = "",
Extension = ""): ConfigInfo?
Extension = "",
PlatformVersion = ""): ConfigInfo.Class?
val SshAgentBaseDir = Files.CreateTempDirectory("", True)
val SshAgent = StartSshAgent(PlatformVersion, Server, Infobase, SshAgentBaseDir.Path)
@ -53,13 +42,7 @@ method GetConfigurationInfo(
val ConfigurationFile = SshAgentConnection.DownloadFile(User, Password, "Configuration.xml")
SshAgent.Stop()
val Reader = new XmlReader(FilesHelper.ReadFileToEnd(ConfigurationFile))
val Namespace = "http://v8.1c.ru/8.3/MDClasses"
val Name = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, Name", Namespace)
val Version = Xml.GetValue(Reader, "Version", Namespace)
return new ConfigInfo(Name, Version)
return V8.ConfigInfoFromConfiguration(ConfigurationFile)
else
Console.Write("Waiting for the opening port timeout is expired")
;
@ -194,8 +177,3 @@ method DesignerBatchModeArguments(
return Args
;
structure ConfigInfo
val Name: String
val Version: String
;

7
Common/ConfigInfo.sbsl Normal file
View File

@ -0,0 +1,7 @@
@Global
structure Class
val Name: String
val Synonym: String
val Version: String
val CompatibilityMode: String
;

View File

@ -1,5 +1,8 @@
#required Path.sbsl
#required Net.sbsl
#required ConfigInfo.sbsl
#required FilesHelper.sbsl
#required Xml.sbsl
@Global
enum Arch
@ -32,6 +35,20 @@ method ConfigurationVersionFromExtensionVersion(Version: String = "0.0.0.0"): St
;
;
@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(".")

View File

@ -4,55 +4,21 @@
#required BytesHelper.sbsl
#required V8BracketsHelper.sbsl
#required AnotherFuckingOneCFormatReader.sbsl
@Global
enum DataLockingControlMode
None
Manual
Auto
AutoAndManual
;
@Global
structure ConfigInfo
val Name: String
val Synonym: String
val Comment: String
val Supplier: String
val Version: String
req val DataLockingControlMode: DataLockingControlMode
val CompatibilityMode: String
;
@Global
structure ExtensionInfo
val Name: String
val Synonym: String
val FileName: String
val ProtectFromDangerActions: Boolean
val GenerationVersion: Bytes
val SafeMode: Boolean
val Version: String
val Active: Boolean
val UseMainRolesForAllUsers: Boolean
;
#required ConfigInfo.sbsl
@Global
structure Class
req val Connection: SqlConnection
@Global
method GetConfigInfo(): ConfigInfo
method GetConfigInfo(): ConfigInfo.Class
val Root = GetConfigFileDataAsBracketsNode("root")
val Conf = GetConfigFileDataAsBracketsNode(Root.GetChildNode([1]).Value)
return new ConfigInfo(
return new ConfigInfo.Class(
Conf.GetChildNode([3, 1, 1, 1, 1, 2]).AsString(),
V8BracketsHelper.GetSysonym(Conf.GetChildNode([3, 1, 1, 1, 1, 3])),
Conf.GetChildNode([3, 1, 1, 1, 1, 4]).AsString(),
Conf.GetChildNode([3, 1, 1, 14]).AsString(),
Conf.GetChildNode([3, 1, 1, 15]).AsString(),
DataLockingControlMode.Items()[Conf.GetChildNode([3, 1, 1, 17]).AsNumber()],
V8BracketsHelper.GetCompatibilityMode(Conf.GetChildNode([3, 1, 1, 26]))
)
;
@ -68,19 +34,15 @@ structure Class
;
@Global
method GetExtensionInfo(ExtensionName: String): ExtensionInfo
method GetExtensionInfo(ExtensionName: String): ConfigInfo.Class
val RawData = GetExtensionZippedInfo(ExtensionName)
val Reader = AnotherFuckingOneCFormatReader.NewInstance(RawData, 2)
val FileName = Reader.ReadString()
val Root = GetConfigCASFileDataAsBracketsNode(FileName)
val ConfigCompatibilityMode = V8BracketsHelper.GetCompatibilityMode(Root[0].GetChildNode([1,2,0]))
val ProtectFromDangerActions = Reader.ReadByte() == Bytes {A2}
val GenerationVersion = Reader.ReadVarbinary()
val SafeMode = Reader.ReadBoolean()
Reader.ReadString() // FileName
Reader.ReadByte() // Protect from danger actions " == Bytes {A2}" - is true
Reader.ReadVarbinary() // Generation version
Reader.ReadBoolean() // safe mode
Reader.ReadBoolean() // unknown flag
val BracketsNode = Reader.ReadBracketsNode()
@ -92,25 +54,11 @@ structure Class
Version = new String(Reader.ReadVarbinary())
;
if V8.VersionIsUpper("8.3.21", ConfigCompatibilityMode)
Reader.ReadBoolean() // unknown flag
;
val Active = Reader.ReadBoolean()
val UseMainRolesForAllUsers = Reader.ReadBoolean()
Reader.ThrowIfNextIsNot(Bytes{20})
return new ExtensionInfo(
return new ConfigInfo.Class(
ExtensionName,
Synonym,
FileName,
ProtectFromDangerActions,
GenerationVersion,
SafeMode,
Version,
Active,
UseMainRolesForAllUsers)
"")
;
method GetParamsFileDataAsBracketsNode(FileName: String): BracketsParser.BracketsNode

View File

@ -38,35 +38,31 @@ method Script(
return 1
;
val Reader = new XmlReader(FilesHelper.ReadFileToEnd(ConfigurationFilePath))
val Namespace = "http://v8.1c.ru/8.3/MDClasses"
val NewExtensionInfo = V8.ConfigInfoFromConfiguration(ConfigurationFilePath)
val NewExtensionName = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, Name", Namespace)
val NewExtensionVersion = Xml.GetValue(Reader, "Version", Namespace) ?? "0.0.0.0"
if not Database.HasExtension(NewExtensionName)
Log.e("Extension \"%NewExtensionName\" is not connected to the infobase \"%Infobase\"")
if not Database.HasExtension(NewExtensionInfo.Name)
Log.e("Extension \"${NewExtensionInfo.Name}\" is not connected to the infobase \"%Infobase\"")
return 1
;
val ConfigInfo = Database.GetConfigInfo()
var ExpectingConfigVersion = V8.ConfigurationVersionFromExtensionVersion(NewExtensionVersion)
var ExpectingConfigVersion = V8.ConfigurationVersionFromExtensionVersion(NewExtensionInfo.Version)
if ConfigInfo.Version != ExpectingConfigVersion
Log.e("Extension version (%ExpectingConfigVersion) targets to other configuration version (${ConfigInfo.Version})")
return 1
;
val ConnectedExtensionInfo = Database.GetExtensionInfo(NewExtensionName)
if not V8.VersionIsUpper(ConnectedExtensionInfo.Version, NewExtensionVersion)
Log.e("It doesn't need to update extension (Current: ${ConnectedExtensionInfo.Version}, New: %NewExtensionVersion)")
val ConnectedExtensionInfo = Database.GetExtensionInfo(NewExtensionInfo.Name)
if not V8.VersionIsUpper(ConnectedExtensionInfo.Version, NewExtensionInfo.Version)
Log.e("It doesn't need to update extension (Current: ${ConnectedExtensionInfo.Version}, New: ${NewExtensionInfo.Version})")
return 1
;
Log.i("Blocking connections")
Ras.BlockConnections(Infobase, User, Password, AccessCode)
Log.i("Updating extension (%Server/%Infobase/%NewExtensionName)")
BatchMode.UpdateExtension(Server, Infobase, User, Password, AccessCode, NewExtensionName, ExtensionPath, PlatformVersion)
Log.i("Updating extension (%Server/%Infobase/${NewExtensionInfo.Name})")
BatchMode.UpdateExtension(Server, Infobase, User, Password, AccessCode, NewExtensionInfo.Name, ExtensionPath, PlatformVersion)
Log.i("Unblocking connections")
Ras.UnblockConnections(Infobase, User, Password)