-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEzCollection.cs
312 lines (268 loc) · 11.6 KB
/
EzCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
// Stand-alone version forked by KoureasS & GitHub.
using Microsoft.SqlServer.Dts.Runtime;
using System;
using System.Collections.Generic;
namespace Microsoft.SqlServer.SSIS.EzAPI
{
public class EzDataFlowPackage : EzPackage
{
public EzDataFlow DataFlow;
public EzDataFlowPackage() : base() { DataFlow = new EzDataFlow(this); }
public EzDataFlowPackage(Package p) : base(p) { }
public static implicit operator EzDataFlowPackage(Package p) { return new EzDataFlowPackage(p); }
}
public class EzForLoopPackage : EzPackage
{
public EzForLoop ForLoop;
public EzForLoopPackage()
: base()
{
ForLoop = new EzForLoop(this);
}
public EzForLoopPackage(Package p) : base(p) { }
public static implicit operator EzForLoopPackage(Package p) { return new EzForLoopPackage(p); }
}
public class EzForLoopDFPackage : EzForLoopPackage
{
public EzDataFlow DataFlow;
public EzForLoopDFPackage()
: base()
{
DataFlow = new EzDataFlow(ForLoop);
}
public EzForLoopDFPackage(Package p) : base(p) { }
public static implicit operator EzForLoopDFPackage(Package p) { return new EzForLoopDFPackage(p); }
}
public class EzSrcPackage<SrcType, SrcConnType> : EzDataFlowPackage
where SrcType : EzAdapter
where SrcConnType : EzConnectionManager
{
public SrcConnType SrcConn;
public SrcType Source;
public EzSrcPackage()
: base()
{
SrcConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType;
Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType;
Source.Connection = SrcConn;
}
public EzSrcPackage(Package p) : base(p) { }
public static implicit operator EzSrcPackage<SrcType, SrcConnType>(Package p)
{
return new EzSrcPackage<SrcType, SrcConnType>(p);
}
}
public class EzSrcDestMultiStreamPackage<SrcType, SrcConnType, DestType, DestConnType> : EzDataFlowPackage
where SrcType : EzAdapter
where SrcConnType : EzConnectionManager
where DestType : EzAdapter
where DestConnType : EzConnectionManager
{
public DestConnType DestConn;
public DestType Dest;
public SrcConnType SourceConn;
public SrcType Source;
public List<KeyValuePair<EzAdapter, EzAdapter>> SourceDestPairs = new List<KeyValuePair<EzAdapter, EzAdapter>>();
public EzSrcDestMultiStreamPackage(int streamCount)
: base()
{
SourceConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType;
DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType;
for (int i = 0; i < streamCount; i++)
{
Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType;
Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType;
KeyValuePair<EzAdapter, EzAdapter> connectionPair = new KeyValuePair<EzAdapter, EzAdapter>(Source, Dest);
SourceDestPairs.Add(connectionPair);
}
}
public void AttachConnections(SrcConnType sourceConnection, DestConnType destConnection)
{
foreach (KeyValuePair<EzAdapter, EzAdapter> connectionPair in SourceDestPairs)
{
SrcType source = (SrcType)connectionPair.Key;
DestType dest = (DestType)connectionPair.Value;
source.Connection = sourceConnection;
dest.Connection = destConnection;
dest.AttachTo(source);
}
}
public EzSrcDestMultiStreamPackage(Package p) : base(p) { }
public static implicit operator EzSrcDestMultiStreamPackage<SrcType, SrcConnType, DestType, DestConnType>(Package p)
{
return new EzSrcDestMultiStreamPackage<SrcType, SrcConnType, DestType, DestConnType>(p);
}
}
public class EzSrcDestPackage<SrcType, SrcConnType, DestType, DestConnType> : EzSrcPackage<SrcType, SrcConnType>
where SrcType : EzAdapter
where SrcConnType : EzConnectionManager
where DestType : EzAdapter
where DestConnType : EzConnectionManager
{
public DestConnType DestConn;
public DestType Dest;
public EzSrcDestPackage()
: base()
{
DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType;
Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType;
Dest.Connection = DestConn;
Dest.AttachTo(Source);
}
public EzSrcDestPackage(Package p) : base(p) { }
public static implicit operator EzSrcDestPackage<SrcType, SrcConnType, DestType, DestConnType>(Package p)
{
return new EzSrcDestPackage<SrcType, SrcConnType, DestType, DestConnType>(p);
}
}
public class EzTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>
: EzSrcPackage<SrcType, SrcConnType>
where SrcType : EzAdapter
where SrcConnType : EzConnectionManager
where TransType : EzComponent
where DestType : EzAdapter
where DestConnType : EzConnectionManager
{
public DestConnType DestConn;
public DestType Dest;
public TransType Transform;
public EzTransformPackage()
: base()
{
Transform = Activator.CreateInstance(typeof(TransType), new object[] { DataFlow }) as TransType;
DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType;
Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType;
Dest.Connection = DestConn;
Transform.AttachTo(Source);
Dest.AttachTo(Transform);
}
public EzTransformPackage(Package p) : base(p) { }
public static implicit operator EzTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>(Package p)
{
return new EzTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>(p);
}
}
public class EzLoopTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>
: EzForLoopDFPackage
where SrcType : EzAdapter
where SrcConnType : EzConnectionManager
where TransType : EzComponent
where DestType : EzAdapter
where DestConnType : EzConnectionManager
{
public SrcType Source;
public SrcConnType SrcConn;
public DestConnType DestConn;
public DestType Dest;
public TransType Transform;
public EzLoopTransformPackage()
: base()
{
SrcConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType;
Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType;
Source.Connection = SrcConn;
Transform = Activator.CreateInstance(typeof(TransType), new object[] { DataFlow }) as TransType;
DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType;
Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType;
Dest.Connection = DestConn;
Transform.AttachTo(Source);
Dest.AttachTo(Transform);
}
public EzLoopTransformPackage(Package p) : base(p) { }
public static implicit operator EzLoopTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>(Package p)
{
return new EzLoopTransformPackage<SrcType, SrcConnType, TransType, DestType, DestConnType>(p);
}
}
public class EzPkgWithExec<T> : EzPackage where T : EzExecutable
{
public T Exec;
public EzPkgWithExec() : base()
{
Exec = Activator.CreateInstance(typeof(T), new object[] { this }) as T;
}
public EzPkgWithExec(Package p) : base(p) { }
public static implicit operator EzPkgWithExec<T>(Package p) { return new EzPkgWithExec<T>(p); }
}
public class EzExecForLoop<T> : EzForLoop where T : EzExecutable
{
public T Exec;
public EzExecForLoop(EzPackage pkg, DtsContainer c) : base(pkg, c) { }
public EzExecForLoop(EzContainer parent)
: base(parent)
{
Exec = Activator.CreateInstance(typeof(T), new object[] { this }) as T;
}
}
public class EzSrcDF<SrcComp> : EzDataFlow where SrcComp : EzComponent
{
public SrcComp Source;
public EzSrcDF(EzContainer parent)
: base(parent)
{
Source = Activator.CreateInstance(typeof(SrcComp), new object[] { this }) as SrcComp;
}
public EzSrcDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { }
}
public class EzSrcConnDF<SrcComp, SrcCM> : EzSrcDF<SrcComp>
where SrcComp : EzAdapter
where SrcCM : EzConnectionManager
{
public SrcCM SrcConn;
public EzSrcConnDF(EzContainer parent)
: base(parent)
{
SrcConn = Activator.CreateInstance(typeof(SrcCM), new object[] { Package }) as SrcCM;
Source.Connection = SrcConn;
}
public EzSrcConnDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { }
}
public class EzTransformDF<SrcComp, SrcCM, Trans> : EzSrcConnDF<SrcComp, SrcCM>
where SrcComp : EzAdapter
where SrcCM : EzConnectionManager
where Trans : EzComponent
{
public Trans Transform;
public EzTransformDF(EzContainer parent)
: base(parent)
{
Transform = Activator.CreateInstance(typeof(Trans), new object[] { this }) as Trans;
Transform.AttachTo(Source);
}
public EzTransformDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { }
}
public class EzTransDestDF<SrcComp, SrcCM, Trans, DestComp> : EzTransformDF<SrcComp, SrcCM, Trans>
where SrcComp : EzAdapter
where SrcCM : EzConnectionManager
where Trans : EzComponent
where DestComp : EzComponent
{
public DestComp Dest;
public EzTransDestDF(EzContainer parent)
: base(parent)
{
Dest = Activator.CreateInstance(typeof(DestComp), new object[] { this }) as DestComp;
Dest.AttachTo(Transform);
}
public EzTransDestDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { }
}
public class EzTransDestConnDF<SrcComp, SrcCM, Trans, DestComp, DestCM> : EzTransDestDF<SrcComp, SrcCM, Trans, DestComp>
where SrcComp : EzAdapter
where SrcCM : EzConnectionManager
where Trans : EzComponent
where DestComp : EzAdapter
where DestCM : EzConnectionManager
{
public DestCM DestConn;
public EzTransDestConnDF(EzContainer parent)
: base(parent)
{
DestConn = Activator.CreateInstance(typeof(DestCM), new object[] { Package }) as DestCM;
Dest.Connection = DestConn;
}
public EzTransDestConnDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { }
}
}