Guest User

Untitled

a guest
Jun 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Threading;
  4. using System.Data;
  5. using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
  6. using Microsoft.SqlServer.Dts.Runtime.Wrapper;
  7. using Microsoft.SqlServer.Dts.Pipeline;
  8.  
  9. [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
  10. public class ScriptMain : UserComponent
  11. {
  12.  
  13.  
  14. System.Collections.Generic.List<object> shared = null;
  15. System.Threading.ManualResetEvent sync;
  16.  
  17. public override void ProcessInput(int InputID, PipelineBuffer Buffer)
  18. {
  19. lock (this)
  20. {
  21. if (InputID == 82)
  22. {
  23. if (shared == null)
  24. {
  25. shared = new System.Collections.Generic.List<object>();
  26. sync = new System.Threading.ManualResetEvent(false);
  27. shared.Add(sync);
  28. shared.Add(Buffer);
  29. shared.Add(GetColumnIndexes(InputID));
  30.  
  31. IDTSVariables100 vars = null;
  32.  
  33. this.VariableDispenser.LockOneForWrite("Test", ref vars);
  34.  
  35. vars[0].Value = shared;
  36. vars.Unlock();
  37. sync.WaitOne();
  38. System.Windows.Forms.MessageBox.Show("Done");
  39. }
  40. }
  41. }
  42. }
  43. }
  44.  
  45. using System;
  46. using System.Data;
  47. using Microsoft.SqlServer.Dts.Pipeline;
  48. using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
  49. using Microsoft.SqlServer.Dts.Runtime.Wrapper;
  50.  
  51. [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
  52. public class ScriptMain : UserComponent
  53. {
  54. System.Threading.ManualResetEvent sync = null;
  55. InputXBuffer sharedBuffer = null;
  56.  
  57. public override void Input0_ProcessInput(Input0Buffer Buffer)
  58. {
  59. lock (this) // Only 1 thread at a time
  60. {
  61. if (sharedBuffer == null)
  62. {
  63. object Test = null;
  64. while (Test == null)
  65. {
  66. System.Threading.Thread.Sleep(100);
  67. IDTSVariables100 vars = null;
  68. this.VariableDispenser.LockOneForRead("Test", ref vars);
  69. Test = vars[0].Value;
  70. vars.Unlock();
  71. }
  72.  
  73. var sharedList = Test as System.Collections.Generic.List<object>;
  74.  
  75. if (sharedList != null)
  76. {
  77. sync = sharedList[0] as System.Threading.ManualResetEvent;
  78. var buffer = sharedList[1] as PipelineBuffer;
  79. var bufferColumnIndexes = sharedList[2] as int[];
  80. sharedBuffer = new InputXBuffer(buffer, bufferColumnIndexes);
  81. }
  82. }
  83. }
  84.  
  85. while (sharedBuffer.NextRow())
  86. {
  87. // ... do stuff with Script Component 1's shared input here...
  88. }
  89. sync.Set(); // Signal script 1 that we're done
  90. }
  91. }
Add Comment
Please, Sign In to add comment