Created
December 29, 2017 20:56
-
-
Save BartekR/c32ccac38321811b7277cce87c2ee976 to your computer and use it in GitHub Desktop.
Microsoft.SqlServer.Dts.Runtime Application.Upgrade() original code from MSDN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.application.upgrade.aspx | |
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment