Serial and parallel call child package
my soulation as below. I set up a table to restore the child package run sequence. ====================================== ========================================== one-1 and one-2 is children package. master package i put two script task for it . one for Serial, one for parallel Serial script =============================== public voidMain() { stringconnstring = "Data Source=.;Initial Catalog=one;Integrated Security=SSPI;"; DataSetds; using(SqlConnectioncon = newSqlConnection(connstring)) { SqlCommandcmd = newSqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from PackageSequence where isenable=1"; SqlDataAdapterda = newSqlDataAdapter(cmd); ds = newDataSet(); da.Fill(ds); } Microsoft.SqlServer.Dts.Runtime. Applicationok = newMicrosoft.SqlServer.Dts.Runtime.Application(); Packageok1; foreach(DataRowdr inds.Tables[0].Rows) { stringpackagelocate = @"E:\Temp\Integration Services Project6\Integration Services Project6\"+ dr["packname"].ToString() + ".dtsx"; ok1 = ok.LoadPackage(packagelocate, null); try { ok1.Variables[ "ThreadName"].Value = "212"; ok1.Execute(); } catch(Exceptione) { // bool pbCancel = false; Dts.Events.FireError(0, "myscript", e.Message, null, 0); } } Dts.TaskResult = ( int)ScriptResults.Success; =============================== parallel script ======================== public class RunPerallerPackage { Microsoft.SqlServer.Dts.Runtime.Application ok = new Microsoft.SqlServer.Dts.Runtime.Application(); Package ok1; private DataTable dt; private bool RunContiute; public DataTable Dt { get { return dt; } set { dt = value; } } public void RunPackge() { string filepath = getname(); while (filepath != null) { ok1 = ok.LoadPackage(filepath, null); try { ok1.Variables["ThreadName"].Value = Thread.CurrentThread.Name.ToString(); ok1.Execute(); } catch (Exception e) { throw; } filepath = getname(); } } public string getname() { string name = ""; lock (this) { if (dt.Rows.Count > 0) { name = dt.Rows[0]["packname"].ToString(); dt.Rows.Remove(dt.Rows[0]); } else { return null; } } return @"E:\Temp\Integration Services Project6\Integration Services Project6\" + name + ".dtsx"; } } public void Main() { string connstring = "Data Source=.;Initial Catalog=one;Integrated Security=SSPI;"; DataSet ds; using (SqlConnection con = new SqlConnection(connstring)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from PackageSequence where isenable=1"; SqlDataAdapter da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); } RunPerallerPackage one = new RunPerallerPackage(); one.Dt = ds.Tables[0]; Thread[] T = new Thread[2]; for(int i=0;i<T.Length;i++) { T[i] = new Thread(one.RunPackge); T[i].Name = "this is a thread NO." + i.ToString(); } for (int i = 0; i < T.Length; i++) { T[i].Start(); } for (int i = 0; i < T.Length; i++) { T[i].Join(); } Dts.TaskResult = (int)ScriptResults.Success; } ===================
July 9th, 2012 6:53am

the import code Thread[] T = new Thread[2]; for(int i=0;i<T.Length;i++) { T[i] = new Thread(one.RunPackge); T[i].Name = "this is a thread NO." + i.ToString(); } for (int i = 0; i < T.Length; i++) { T[i].Start(); } for (int i = 0; i < T.Length; i++) { T[i].Join(); }
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2012 6:54am

What is the issue that you are facing?Please vote as helpful or mark as answer, if it helps Cheers, Raunak | t: @raunakjhawar | My Blog
July 9th, 2012 7:36am

it can more flexible to invoke the child package. in ssis master package has many child package. it is more flexible. If you want to disable one package ,you can set the isEnable filed "False", if you want to add some function,you can add a child pack ,then add the record on the table. what do you think?
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2012 12:03pm

Sounds appropriate. But are all child packages realted to master (as in are values passed from one package to another)?Please vote as helpful or mark as answer, if it helps Cheers, Raunak | t: @raunakjhawar | My Blog
July 9th, 2012 12:23pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics