MTS management automation

zhaozj2021-02-08  231

MTS management automation

Keywords: VBScript

MTS (Microsoft Transactin Server) is the basis for building security, stable Internet / intranet applications. After introducing the concept of transactions, you don't have to worry about your application in the incompleteness of data when you crash. MTS can be easily applied in ASP, you can write components that support MTS and register to MTS. The premise is that you must start the DTC (Distributed Transaction Manager) service. Registering the MTS component is a more trouble-time process, especially when you have to do it on multiple machines, but fortunately MTS provides management objects, you can automatically register with simple programs. The following paragraph is copied from the MTS document: MTS Management Automation Visual Basic Sample Application Visual Basic version 5.0 version of the sample application demonstrates how to use Catalog, CatalogObject, and CatalogCollections objects to automate the management of one name "" scriptization Example "Basic Management Features of the package. Note You must configure your Visual Basic engineering to reference the MTS management type library (MTSADMIN Type Library). To reference the MTSADMIN type library, select" Reference "from the Visual Basic Engineering toolbar. Option. Then look for the "MTS 2.0 Management Type Library" can be referenced. For later binding variables (binding when running the program), if the MTXAdmin.dll file is registered on the local machine, Visual Basic only records the type library Location, without further configuration. Delete software packages called "Scriptable Admin Demo" CreateObject Method Instant Directory Object. DIM Catalog As ObjectSet Catalog = CreateObject ("MTSADMIN.CATALOG.1") Call GetCollection Method Get a packages collection object. The return package does not get any data from the directory, so the collection returned from the GetCollection method is empty .dim packages as objectset packages = catalog.getCollection ("packages) populate this packages collection, read All packages and find the "Scriptable Admin Demo" package to get the existing version of the package. Enumerate this collection, you can call the REMOVE method inside the cycle .Remove method is responsible for release the object, from The object is removed in the collection, and the object in the mobile collection changes the (N 1) object into sub-object, where n is greater than or equal to the index being deleted. The REMOVE method of the collection object is immediate To take effect. Calling the item and count methods after the Remove method will reflect the index change. However, the deletion of the package is not reflected until the SaveChanges method is called (see Step 4). Packages.PopulateDim Pack As Ob JECTN = Packages.countfor i = n - 1 to 0 step -1 if packages.Item (i) .value ("name") = "scriptable admin" the package .Remove (i) end ifnext calls the SaveChanges method to save the pair Data changes.

Packages.saveChanges created a new package called "Scriptable Admin Demo" to add a package using the Add method, and note that the package identifier is specified. The Add method adds the object to a collection, but then applies the change to the directory after calling the SaveChanges method (see Step 3). Note that the Add method will set all properties to the default. The default identifier is a new unique identifier. DIM NewPack As Objectdim NewPackID As VariantSet NewPack = package.addnewPackID = NewPack.Value ("ID") updates the Name and SecurityEnabled properties. NewPack.Value ("name") = "Scriptable admin" newPack.Value ("securityenabled") = "n" calls the SaveChanges method Save the new package to the directory. The returned value of this call is the number of objects that changes, add, or delete. This method returns 0 if there is no change. N = package.saveChanges Update the properties of the Scriptable Admin Demo package and get the ComponentsInpackage collection. Call the PopulateByKey method and read the package from the directory. This needs to be transmitted an array containing keywords used to read. In the sample code, an array containing a single element (an identifier of a package that is created) is used. DIM Keys (0) As VariantKeys (0) = NewPackIdPackages.PopulateByKey Keys Gets the package object Dim Package as ObjectSet package = packages.Item (0) Update the SecurityEnableD property of the package from the collection. Package.Value ("SecurityEnabled") = "y" calls the getCollection method to get the ComponentsInpackage collection. The keywords of the Scriptable Admin Demo package are one of the parameters. SET Components = package.getCollection ("ComponentsInpackage", _ package.key) Call the SaveChanges method Save the change to the directory. Packages.SAVECHANGES "Install a component to" Scriptable Admin Demo "package: Call the GetIlInterFace method to get the component utility object. This object is typically used to install the component. DIM Util As ObjectSet Util = Components.getutiLinterFaceon Error Goto InstallFailed Calls the InstallComponent method, passed with a string that contains the name of the dynamic link library (DLL) to install the component. If the component does not have an external type library or Proxy-Stub DLL, an empty string is passed as the second and third parameters. Note that after installing a new component, you don't have to call the SaveChanges method. The InstallComponent method will install all the components contained in the DLL, and these components are immediately written to the directory. You can call the getClsids method to get the class identifier of the installed components.

转载请注明原文地址:https://www.9cbs.com/read-1550.html

New Post(0)