Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: TSQL, Created At: 10/24/2016 7:56:08 PMViews:

HTML view:
Copy Source | Copy HTML
  1. Option Explicit
  2. Dim UserName
  3. Dim UserPass
  4. Dim ServerName
  5. 'имя пользователя базы 1С:Предприятия
    UserName = "backup"
    'пароль пользователя базы 1С:Предприятия
  6. UserPass = "rgn357plm"
  7. 'имя кластера 1С:Предприятия
    ServerName  =  "localhost"


    Dim Connector
    Dim AgentConnection
    Dim Cluster
    Dim Clusters
    Dim WorkingProcess
    Dim WorkingProcesses
    Dim WorkingProcessConnection
    Dim ibDesc
    Dim InfoBases
    Dim BaseName
    Dim Connections
    Dim Connection
    Dim ConnectString
    Set Connector = CreateObject("V83.COMConnector")    ' указать в зависимости от вашей версии платформы V8, V81, V82, V83
  8. Set AgentConnection = Connector.ConnectAgent(ServerName)
  9. Clusters = AgentConnection.GetClusters()
  10. Dim Q,W,I,e,Base
  11. For Q = LBound(Clusters) to UBound(Clusters)
  12.     Set Cluster = Clusters(Q)
  13. 'Указываем доступ к консоли 1С:Предприятия (только в том случае если определён администратор кластера, иначе прописать просто " " (пробелы))
        AgentConnection.Authenticate Cluster, "Администратор", "Welcome1c83"
        WorkingProcesses = AgentConnection.GetWorkingProcesses(Cluster)
        Set WorkingProcess = WorkingProcesses(0)
        ConnectString = WorkingProcess.HostName & ":" & WorkingProcess.MainPort
        Set WorkingProcessConnection = Connector.ConnectWorkingProcess(ConnectString)
        WorkingProcessConnection.AddAuthentication UserName, UserPass
        InfoBases = WorkingProcessConnection.GetInfoBases()
        For e = LBound(InfoBases) To UBound(InfoBases)
            Set Base = InfoBases(e)
            BaseName = Base.Name
            msgbox "Name - " + Base.Name
            For W = LBound(WorkingProcesses) to UBound(WorkingProcesses)
                Set WorkingProcess = WorkingProcesses(W)
                ConnectString = WorkingProcess.HostName & ":" & WorkingProcess.MainPort
                Set WorkingProcessConnection = Connector.ConnectWorkingProcess(ConnectString)
                WorkingProcessConnection.AddAuthentication UserName, UserPass
                ibDesc.Name = BaseName
                Connections = WorkingProcessConnection.GetInfoBaseConnections(ibDesc)
                For I = LBound(Connections) To UBound(Connections)
                    Set Connection = Connections(I)
                    If (Connection.AppID("COMConsole")) then
                        'WorkingProcessConnection.Disconnect Connection
  14.                     msgbox "delete"
  15.                 End if
  16.             Next
  17.         Next
  18.     Next
  19. Next

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017