private void TransferPackageButton_Click(object sender, EventArgs e) { try { Server server = new Server(_server); IntegrationServices isServer = new IntegrationServices(server); Catalog catalog = isServer.Catalogs["SSISDB"]; CatalogFolder folder = new CatalogFolder(catalog, "Test", "Test description");// catalog.Folders["ProSSIS"]; folder.Create(); Project localProject = CreateNewProject("newproject.ispac", "New Project"); folder.DeployProject("New Project", System.IO.File.ReadAllBytes("newprojects.ispac")); folder.Alter(); ProjectInfo newProject = folder.Projects["New Project"]; newProject.Move("ProSSIS"); newProject.Alter(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main(string[] args) { string targetFolderName = "dailyClosedJobs"; string projectName = "dailyClosedJobs.dtsx"; string projectFilePath = @"" + ConfigurationManager.AppSettings["FolderPath"]; try { // Create a connection to the server// Create the Integration Services object string conStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlConnection sqlConnection = new SqlConnection(conStr); using (var con = sqlConnection) { IntegrationServices integrationServices = new IntegrationServices(con); // Get the Integration Services catalog Catalog catalog = integrationServices.Catalogs["SSISDB"]; // Create the target folder CatalogFolder folder = new CatalogFolder(catalog, targetFolderName, "Folder description"); Console.WriteLine("Deploying " + projectName + " project."); byte[] projectFile = File.ReadAllBytes(projectFilePath); folder.DeployProject(projectName, projectFile); Console.WriteLine("Done."); } } catch (Exception ex) { Console.WriteLine(ex); } }
private ProjectInfo DeployProject(CatalogFolder catalogFolder, string ispacFile) { byte[] bytes = File.ReadAllBytes(ispacFile); string projectName = Path.GetFileNameWithoutExtension(ispacFile); var results = catalogFolder.DeployProject(projectName, bytes); DateTime messageDate = results.CreatedTime.GetValueOrDefault(DateTime.Now).DateTime; foreach (var message in results.GetLatestMessages(messageDate)) { Log.LogMessage(message.Message); } if (results.Status != Operation.ServerOperationStatus.Success) { throw new Exception($"Deployment failed for project: '{projectName}"); } return(catalogFolder.Projects[projectName]); }
private void DeployProject_Click(object sender, EventArgs e) { try { Server server = new Server(_server); IntegrationServices isServer = new IntegrationServices(server); Catalog catalog = isServer.Catalogs["SSISDB"]; CatalogFolder folder = catalog.Folders["ProSSIS"]; string projectFileName = "myproject.ispac"; folder.DeployProject("My ProSSIS Project", System.IO.File.ReadAllBytes(projectFileName)); folder.Alter(); ProjectInfo p = folder.Projects["My ProSSIS Project"]; p.References.Add("Environment1", folder.Name); p.Alter(); MessageBox.Show("Project deployed"); //using (Project project = Project.OpenProject(projectFileName)) //{ // MessageBox.Show("Project deployed"); //} } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main(string[] args) { // Connect to the default instance on localhost var server = new Server("localhost"); var store = new IntegrationServices(server); // Check that we have a catalog if (store.Catalogs.Count == 0) { Console.WriteLine("SSIS catalog not found on localhost."); } // Get the SSISDB catalog - note that there should only // be one, but the API may support multiple catalogs // in the future var catalog = store.Catalogs["SSISDB"]; // Create a new folder var folder = new CatalogFolder(catalog, "MyFolder", "Folder that holds projects"); folder.Create(); // Make sure the project file exists if (!File.Exists(ProjectFileLocation)) { Console.WriteLine("Project file not found at: {0}", ProjectFileLocation); } // Load the project using the SSIS API var project = Project.OpenProject(ProjectFileLocation); // Deploy the project to the folder we just created folder.DeployProject(project); }
private static void CreateProjectAndDeploy(CatalogFolder catalogFolder, string strProjectLocation, Package package) { byte[] projectStream = null; if (catalogFolder.Name != "CHEFFolder") { return; } //Create temporary location if it doesn't exist if (!Directory.Exists(strProjectLocation)) { Directory.CreateDirectory(strProjectLocation); } //Create Project and add the Package to it using (Project project = Project.CreateProject(strProjectLocation + @"\TempProject.ispac")) { project.Name = processID + "_" + processName + "_" + processType; project.Description = "Project Description"; //package.Parameters.Add("logValue", TypeCode.Boolean); //package.Parameters["logValue"].Value = true; project.PackageItems.Add(package, "Package.dtsx"); project.PackageItems[0].Package.Description = "Package Description"; //project.Parameters.Add("logValue", TypeCode.Boolean); project.Save(); } //Convert the Project to equivalent byte stream using (FileStream fileStream = new FileStream(strProjectLocation + @"\TempProject.ispac", FileMode.Open, FileAccess.Read)) { byte[] stream = new byte[fileStream.Length]; int numberOfBytesLeft = (int)fileStream.Length; int numberOfBytesRead = 0; while (numberOfBytesLeft > 0) { int n = fileStream.Read(stream, numberOfBytesRead, numberOfBytesLeft); if (n == 0) //end of file { break; } numberOfBytesRead += n; numberOfBytesLeft -= n; } projectStream = stream; } //Deploy the Project using (Project project = Project.OpenProject(strProjectLocation + @"\TempProject.ispac")) { catalogFolder.DeployProject(processID + "_" + processName + "_" + processType, projectStream); catalogFolder.Alter(); } //Delete temporary location Directory.Delete(strProjectLocation, true); //SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CHEF"].ConnectionString); //conn.Open(); //SqlCommand comm = conn.CreateCommand(); //comm.CommandType = CommandType.Text; //comm.CommandText = "INSERT INTO [CHEF].[RequestQueue] VALUES(MONTH(SYSDATETIME()), YEAR(SYSDATETIME()), " + processID + ", " + strStartStepID + ", 1, NEWID(), SUSER_SNAME(), SYSDATETIME(), SYSDATETIME())"; //comm.ExecuteNonQuery(); //conn.Close(); //comm.Dispose(); }