Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Threading;
- using System.Data;
- using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
- using Microsoft.SqlServer.Dts.Runtime.Wrapper;
- using Microsoft.SqlServer.Dts.Pipeline;
- [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
- public class ScriptMain : UserComponent
- {
- System.Collections.Generic.List<object> shared = null;
- System.Threading.ManualResetEvent sync;
- public override void ProcessInput(int InputID, PipelineBuffer Buffer)
- {
- lock (this)
- {
- if (InputID == 82)
- {
- if (shared == null)
- {
- shared = new System.Collections.Generic.List<object>();
- sync = new System.Threading.ManualResetEvent(false);
- shared.Add(sync);
- shared.Add(Buffer);
- shared.Add(GetColumnIndexes(InputID));
- IDTSVariables100 vars = null;
- this.VariableDispenser.LockOneForWrite("Test", ref vars);
- vars[0].Value = shared;
- vars.Unlock();
- sync.WaitOne();
- System.Windows.Forms.MessageBox.Show("Done");
- }
- }
- }
- }
- }
- using System;
- using System.Data;
- using Microsoft.SqlServer.Dts.Pipeline;
- using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
- using Microsoft.SqlServer.Dts.Runtime.Wrapper;
- [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
- public class ScriptMain : UserComponent
- {
- System.Threading.ManualResetEvent sync = null;
- InputXBuffer sharedBuffer = null;
- public override void Input0_ProcessInput(Input0Buffer Buffer)
- {
- lock (this) // Only 1 thread at a time
- {
- if (sharedBuffer == null)
- {
- object Test = null;
- while (Test == null)
- {
- System.Threading.Thread.Sleep(100);
- IDTSVariables100 vars = null;
- this.VariableDispenser.LockOneForRead("Test", ref vars);
- Test = vars[0].Value;
- vars.Unlock();
- }
- var sharedList = Test as System.Collections.Generic.List<object>;
- if (sharedList != null)
- {
- sync = sharedList[0] as System.Threading.ManualResetEvent;
- var buffer = sharedList[1] as PipelineBuffer;
- var bufferColumnIndexes = sharedList[2] as int[];
- sharedBuffer = new InputXBuffer(buffer, bufferColumnIndexes);
- }
- }
- }
- while (sharedBuffer.NextRow())
- {
- // ... do stuff with Script Component 1's shared input here...
- }
- sync.Set(); // Signal script 1 that we're done
- }
- }
Add Comment
Please, Sign In to add comment