Application.Upgrade 方法

定义

将一个或多个 Integration Services 包从指定的源位置升级到指定的目标位置。

public:
 Microsoft::SqlServer::Dts::Runtime::UpgradeResult ^ Upgrade(System::Collections::Generic::IEnumerable<Microsoft::SqlServer::Dts::Runtime::UpgradePackageInfo ^> ^ packages, Microsoft::SqlServer::Dts::Runtime::StorageInfo ^ source, Microsoft::SqlServer::Dts::Runtime::StorageInfo ^ destination, Microsoft::SqlServer::Dts::Runtime::BatchUpgradeOptions ^ options, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events);
public Microsoft.SqlServer.Dts.Runtime.UpgradeResult Upgrade (System.Collections.Generic.IEnumerable<Microsoft.SqlServer.Dts.Runtime.UpgradePackageInfo> packages, Microsoft.SqlServer.Dts.Runtime.StorageInfo source, Microsoft.SqlServer.Dts.Runtime.StorageInfo destination, Microsoft.SqlServer.Dts.Runtime.BatchUpgradeOptions options, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events);
member this.Upgrade : seq<Microsoft.SqlServer.Dts.Runtime.UpgradePackageInfo> * Microsoft.SqlServer.Dts.Runtime.StorageInfo * Microsoft.SqlServer.Dts.Runtime.StorageInfo * Microsoft.SqlServer.Dts.Runtime.BatchUpgradeOptions * Microsoft.SqlServer.Dts.Runtime.IDTSEvents -> Microsoft.SqlServer.Dts.Runtime.UpgradeResult
Public Function Upgrade (packages As IEnumerable(Of UpgradePackageInfo), source As StorageInfo, destination As StorageInfo, options As BatchUpgradeOptions, events As IDTSEvents) As UpgradeResult

参数

packages
IEnumerable<UpgradePackageInfo>

要升级的包的集合。

source
StorageInfo

一个 StorageInfo 对象,该对象指定要升级的包的源位置。

destination
StorageInfo

StorageInfo 对象,该对象指定要升级的包的目标位置。

options
BatchUpgradeOptions

一个 BatchUpgradeOptions 对象,该对象指定在升级过程中将应用于包的选项。

events
IDTSEvents

一个 IDTSEvents 对象。

返回

一个 UpgradeResult 对象,该对象指定升级一个或多个包的结果。

示例

以下示例演示如何升级包集合。 原始包和升级包存储在文件系统中的文件夹中。

using System;  
using System.Collections.Generic;  
using System.Collections.ObjectModel;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace ConsoleApplication1  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  

            Application app = new Application();  

            UpgradePackageInfo packinfo1 = new UpgradePackageInfo("C:\\temp\\Package.dtsx", "C:\\temp\\Package.dtsx", null);  
            UpgradePackageInfo packinfo2 = new UpgradePackageInfo("C:\\temp\\Package2.dtsx", "C:\\temp\\Package2.dtsx", null);  

            Collection<UpgradePackageInfo> packages = new Collection<UpgradePackageInfo>();  
            packages.Add(packinfo1);  
            packages.Add(packinfo2);  

            StorageInfo storeinfoSource = StorageInfo.NewFileStorage();  
            storeinfoSource.RootFolder = "C:\\temp";  

            StorageInfo storeinfoDest = StorageInfo.NewFileStorage();  
            BatchUpgradeOptions upgradeOpts = new BatchUpgradeOptions();  
            upgradeOpts.Validate = true;  
            upgradeOpts.BackupOldPackages = true;  
            upgradeOpts.ContinueOnError = true;  
            upgradeOpts.ValidationFailureAsError = true;          

            MyEventsClass eventsClass = new MyEventsClass();  

            app.Upgrade(packages, storeinfoSource, storeinfoDest, upgradeOpts, eventsClass);  

        }  
    }  

    class MyEventsClass : DefaultEvents  
    {  
        public override void OnPreExecute(Executable exec, ref bool fireAgain)  
        {  
            Console.WriteLine("The PreExecute event of the " + exec.ToString() + " has been raised.");  
            Console.Read();  
        }  
    }  
}  

适用于