Saturday, 15 March 2014

.net - How to run multiple SSIS packages programmatically by C#? -



.net - How to run multiple SSIS packages programmatically by C#? -

guy, used code snippet, execute multiple ssis packages, when first 1 finished, takes long time execute one, run script command line on cmd, execute quickly. think it's problem of code, know why? code below:

ssishelper.executessispackage("/f \"c:\\users\\v-nashi\\documents\\visual studio 2010\\projects\\importexcel\\importexcel\\lyo_dailylogin.dtsx\""); ssishelper.executessispackage("/f \"c:\\users\\v-nashi\\documents\\visual studio 2010\\projects\\importexcel\\importexcel\\lyo_cosmos_activities.dtsx\""); /// <summary> /// excuete sql server integration services packages parameter. /// </summary> /// <param name="para">parameter</param> /// <returns>bool</returns> public static bool executepackage(string parameter) { if (file.exists(dtexec_path) == false) throw new exception("the file dtexec.exe not found, or file not exist."); process process = new process(); process.startinfo.filename = dtexec_path; process.startinfo.arguments = parameter; // true if shell should used when starting process; false if process should created straight // executable file. process.startinfo.useshellexecute = true; process.startinfo.redirectstandardoutput = true; process.startinfo.redirectstandarderror = true; console.writeline("{0} {1}", dtexec_path, parameter); process.start(); process.waitforexit(); string[] results = process.standardoutput.readtoend().split('\n'); foreach (string item in results) { if (item.contains("dtexec: bundle execution returned dtser_success (0).")) homecoming true; } homecoming false; }

i want run ssis bundle programmatically, or improve way?

another way can this.

microsoft.sqlserver.dts.runtime.application app = new microsoft.sqlserver.dts.runtime.application(); string packagepath = "path of ssis package"; bundle package = app.loadpackage(packagepath, null); //assign variables here. variables vars = package.variables; vars["filename"].value = variables.filename; microsoft.sqlserver.dts.runtime.dtsexecresult results = package.execute(); if (results == dtsexecresult.success) { //do u want after success. }

for u have utilize microsoft.sqlserver.manageddts library microsoft. seek find in gac or else site. single ssis service in same way u can execute multiple 1 one.

c# .net sql-server ssis

No comments:

Post a Comment