You've already forked akpaevj-executor-scripts
mirror of
https://github.com/akpaevj/executor-scripts.git
synced 2025-07-15 06:54:18 +02:00
r
This commit is contained in:
@ -4,27 +4,16 @@
|
|||||||
#required SshAgentConnection.sbsl
|
#required SshAgentConnection.sbsl
|
||||||
#required Net.sbsl
|
#required Net.sbsl
|
||||||
#required Xml.sbsl
|
#required Xml.sbsl
|
||||||
|
#required ConfigInfo.sbsl
|
||||||
|
|
||||||
@Global
|
@Global
|
||||||
method NeedUpdateConfiguration(
|
method GetConfigInfo(
|
||||||
Server: String,
|
Server: String,
|
||||||
Infobase: String,
|
Infobase: String,
|
||||||
User: String,
|
User: String,
|
||||||
Password: String,
|
Password: String,
|
||||||
RequestedVersion: String,
|
Extension = "",
|
||||||
PlatformVersion = ""): Boolean
|
PlatformVersion = ""): ConfigInfo.Class?
|
||||||
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?
|
|
||||||
val SshAgentBaseDir = Files.CreateTempDirectory("", True)
|
val SshAgentBaseDir = Files.CreateTempDirectory("", True)
|
||||||
val SshAgent = StartSshAgent(PlatformVersion, Server, Infobase, SshAgentBaseDir.Path)
|
val SshAgent = StartSshAgent(PlatformVersion, Server, Infobase, SshAgentBaseDir.Path)
|
||||||
|
|
||||||
@ -53,13 +42,7 @@ method GetConfigurationInfo(
|
|||||||
val ConfigurationFile = SshAgentConnection.DownloadFile(User, Password, "Configuration.xml")
|
val ConfigurationFile = SshAgentConnection.DownloadFile(User, Password, "Configuration.xml")
|
||||||
SshAgent.Stop()
|
SshAgent.Stop()
|
||||||
|
|
||||||
val Reader = new XmlReader(FilesHelper.ReadFileToEnd(ConfigurationFile))
|
return V8.ConfigInfoFromConfiguration(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)
|
|
||||||
else
|
else
|
||||||
Console.Write("Waiting for the opening port timeout is expired")
|
Console.Write("Waiting for the opening port timeout is expired")
|
||||||
;
|
;
|
||||||
@ -194,8 +177,3 @@ method DesignerBatchModeArguments(
|
|||||||
|
|
||||||
return Args
|
return Args
|
||||||
;
|
;
|
||||||
|
|
||||||
structure ConfigInfo
|
|
||||||
val Name: String
|
|
||||||
val Version: String
|
|
||||||
;
|
|
7
Common/ConfigInfo.sbsl
Normal file
7
Common/ConfigInfo.sbsl
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
@Global
|
||||||
|
structure Class
|
||||||
|
val Name: String
|
||||||
|
val Synonym: String
|
||||||
|
val Version: String
|
||||||
|
val CompatibilityMode: String
|
||||||
|
;
|
@ -1,5 +1,8 @@
|
|||||||
#required Path.sbsl
|
#required Path.sbsl
|
||||||
#required Net.sbsl
|
#required Net.sbsl
|
||||||
|
#required ConfigInfo.sbsl
|
||||||
|
#required FilesHelper.sbsl
|
||||||
|
#required Xml.sbsl
|
||||||
|
|
||||||
@Global
|
@Global
|
||||||
enum Arch
|
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
|
@Global
|
||||||
method VersionIsUpper(Version1: String = "0.0.0.0", Version2: String = "0.0.0.0"): Boolean
|
method VersionIsUpper(Version1: String = "0.0.0.0", Version2: String = "0.0.0.0"): Boolean
|
||||||
val VersionFirst = Version1.Split(".")
|
val VersionFirst = Version1.Split(".")
|
||||||
|
@ -4,55 +4,21 @@
|
|||||||
#required BytesHelper.sbsl
|
#required BytesHelper.sbsl
|
||||||
#required V8BracketsHelper.sbsl
|
#required V8BracketsHelper.sbsl
|
||||||
#required AnotherFuckingOneCFormatReader.sbsl
|
#required AnotherFuckingOneCFormatReader.sbsl
|
||||||
|
#required ConfigInfo.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
|
|
||||||
;
|
|
||||||
|
|
||||||
@Global
|
@Global
|
||||||
structure Class
|
structure Class
|
||||||
req val Connection: SqlConnection
|
req val Connection: SqlConnection
|
||||||
|
|
||||||
@Global
|
@Global
|
||||||
method GetConfigInfo(): ConfigInfo
|
method GetConfigInfo(): ConfigInfo.Class
|
||||||
val Root = GetConfigFileDataAsBracketsNode("root")
|
val Root = GetConfigFileDataAsBracketsNode("root")
|
||||||
val Conf = GetConfigFileDataAsBracketsNode(Root.GetChildNode([1]).Value)
|
val Conf = GetConfigFileDataAsBracketsNode(Root.GetChildNode([1]).Value)
|
||||||
|
|
||||||
return new ConfigInfo(
|
return new ConfigInfo.Class(
|
||||||
Conf.GetChildNode([3, 1, 1, 1, 1, 2]).AsString(),
|
Conf.GetChildNode([3, 1, 1, 1, 1, 2]).AsString(),
|
||||||
V8BracketsHelper.GetSysonym(Conf.GetChildNode([3, 1, 1, 1, 1, 3])),
|
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(),
|
Conf.GetChildNode([3, 1, 1, 15]).AsString(),
|
||||||
DataLockingControlMode.Items()[Conf.GetChildNode([3, 1, 1, 17]).AsNumber()],
|
|
||||||
V8BracketsHelper.GetCompatibilityMode(Conf.GetChildNode([3, 1, 1, 26]))
|
V8BracketsHelper.GetCompatibilityMode(Conf.GetChildNode([3, 1, 1, 26]))
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
@ -68,19 +34,15 @@ structure Class
|
|||||||
;
|
;
|
||||||
|
|
||||||
@Global
|
@Global
|
||||||
method GetExtensionInfo(ExtensionName: String): ExtensionInfo
|
method GetExtensionInfo(ExtensionName: String): ConfigInfo.Class
|
||||||
val RawData = GetExtensionZippedInfo(ExtensionName)
|
val RawData = GetExtensionZippedInfo(ExtensionName)
|
||||||
val Reader = AnotherFuckingOneCFormatReader.NewInstance(RawData, 2)
|
val Reader = AnotherFuckingOneCFormatReader.NewInstance(RawData, 2)
|
||||||
|
|
||||||
val FileName = Reader.ReadString()
|
Reader.ReadString() // FileName
|
||||||
|
|
||||||
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.ReadByte() // Protect from danger actions " == Bytes {A2}" - is true
|
||||||
|
Reader.ReadVarbinary() // Generation version
|
||||||
|
Reader.ReadBoolean() // safe mode
|
||||||
Reader.ReadBoolean() // unknown flag
|
Reader.ReadBoolean() // unknown flag
|
||||||
|
|
||||||
val BracketsNode = Reader.ReadBracketsNode()
|
val BracketsNode = Reader.ReadBracketsNode()
|
||||||
@ -92,25 +54,11 @@ structure Class
|
|||||||
Version = new String(Reader.ReadVarbinary())
|
Version = new String(Reader.ReadVarbinary())
|
||||||
;
|
;
|
||||||
|
|
||||||
if V8.VersionIsUpper("8.3.21", ConfigCompatibilityMode)
|
return new ConfigInfo.Class(
|
||||||
Reader.ReadBoolean() // unknown flag
|
|
||||||
;
|
|
||||||
|
|
||||||
val Active = Reader.ReadBoolean()
|
|
||||||
val UseMainRolesForAllUsers = Reader.ReadBoolean()
|
|
||||||
|
|
||||||
Reader.ThrowIfNextIsNot(Bytes{20})
|
|
||||||
|
|
||||||
return new ExtensionInfo(
|
|
||||||
ExtensionName,
|
ExtensionName,
|
||||||
Synonym,
|
Synonym,
|
||||||
FileName,
|
|
||||||
ProtectFromDangerActions,
|
|
||||||
GenerationVersion,
|
|
||||||
SafeMode,
|
|
||||||
Version,
|
Version,
|
||||||
Active,
|
"")
|
||||||
UseMainRolesForAllUsers)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
method GetParamsFileDataAsBracketsNode(FileName: String): BracketsParser.BracketsNode
|
method GetParamsFileDataAsBracketsNode(FileName: String): BracketsParser.BracketsNode
|
||||||
|
@ -38,35 +38,31 @@ method Script(
|
|||||||
return 1
|
return 1
|
||||||
;
|
;
|
||||||
|
|
||||||
val Reader = new XmlReader(FilesHelper.ReadFileToEnd(ConfigurationFilePath))
|
val NewExtensionInfo = V8.ConfigInfoFromConfiguration(ConfigurationFilePath)
|
||||||
val Namespace = "http://v8.1c.ru/8.3/MDClasses"
|
|
||||||
|
|
||||||
val NewExtensionName = Xml.GetValue(Reader, "MetaDataObject, Configuration, Properties, Name", Namespace)
|
if not Database.HasExtension(NewExtensionInfo.Name)
|
||||||
val NewExtensionVersion = Xml.GetValue(Reader, "Version", Namespace) ?? "0.0.0.0"
|
Log.e("Extension \"${NewExtensionInfo.Name}\" is not connected to the infobase \"%Infobase\"")
|
||||||
|
|
||||||
if not Database.HasExtension(NewExtensionName)
|
|
||||||
Log.e("Extension \"%NewExtensionName\" is not connected to the infobase \"%Infobase\"")
|
|
||||||
return 1
|
return 1
|
||||||
;
|
;
|
||||||
|
|
||||||
val ConfigInfo = Database.GetConfigInfo()
|
val ConfigInfo = Database.GetConfigInfo()
|
||||||
var ExpectingConfigVersion = V8.ConfigurationVersionFromExtensionVersion(NewExtensionVersion)
|
var ExpectingConfigVersion = V8.ConfigurationVersionFromExtensionVersion(NewExtensionInfo.Version)
|
||||||
if ConfigInfo.Version != ExpectingConfigVersion
|
if ConfigInfo.Version != ExpectingConfigVersion
|
||||||
Log.e("Extension version (%ExpectingConfigVersion) targets to other configuration version (${ConfigInfo.Version})")
|
Log.e("Extension version (%ExpectingConfigVersion) targets to other configuration version (${ConfigInfo.Version})")
|
||||||
return 1
|
return 1
|
||||||
;
|
;
|
||||||
|
|
||||||
val ConnectedExtensionInfo = Database.GetExtensionInfo(NewExtensionName)
|
val ConnectedExtensionInfo = Database.GetExtensionInfo(NewExtensionInfo.Name)
|
||||||
if not V8.VersionIsUpper(ConnectedExtensionInfo.Version, NewExtensionVersion)
|
if not V8.VersionIsUpper(ConnectedExtensionInfo.Version, NewExtensionInfo.Version)
|
||||||
Log.e("It doesn't need to update extension (Current: ${ConnectedExtensionInfo.Version}, New: %NewExtensionVersion)")
|
Log.e("It doesn't need to update extension (Current: ${ConnectedExtensionInfo.Version}, New: ${NewExtensionInfo.Version})")
|
||||||
return 1
|
return 1
|
||||||
;
|
;
|
||||||
|
|
||||||
Log.i("Blocking connections")
|
Log.i("Blocking connections")
|
||||||
Ras.BlockConnections(Infobase, User, Password, AccessCode)
|
Ras.BlockConnections(Infobase, User, Password, AccessCode)
|
||||||
|
|
||||||
Log.i("Updating extension (%Server/%Infobase/%NewExtensionName)")
|
Log.i("Updating extension (%Server/%Infobase/${NewExtensionInfo.Name})")
|
||||||
BatchMode.UpdateExtension(Server, Infobase, User, Password, AccessCode, NewExtensionName, ExtensionPath, PlatformVersion)
|
BatchMode.UpdateExtension(Server, Infobase, User, Password, AccessCode, NewExtensionInfo.Name, ExtensionPath, PlatformVersion)
|
||||||
|
|
||||||
Log.i("Unblocking connections")
|
Log.i("Unblocking connections")
|
||||||
Ras.UnblockConnections(Infobase, User, Password)
|
Ras.UnblockConnections(Infobase, User, Password)
|
||||||
|
Reference in New Issue
Block a user