├── .gitignore ├── EzAPI.csproj ├── EzAPI.nuspec ├── EzAPI.sln ├── EzCollection.cs ├── EzComponents.cs ├── EzConnections.cs ├── EzExecutables.cs ├── EzHelpers.cs ├── EzProject.cs ├── License └── License.md ├── Properties └── AssemblyInfo.cs ├── README.md ├── _config.yml └── app.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | *.vcxproj.filters 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | Output/ 28 | 29 | # Visual Studio 2015 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # MSTest test Results 35 | [Tt]est[Rr]esult*/ 36 | [Bb]uild[Ll]og.* 37 | 38 | # NUNIT 39 | *.VisualState.xml 40 | TestResult.xml 41 | 42 | # Build Results of an ATL Project 43 | [Dd]ebugPS/ 44 | [Rr]eleasePS/ 45 | dlldata.c 46 | 47 | # .NET Core 48 | project.lock.json 49 | project.fragment.lock.json 50 | artifacts/ 51 | **/Properties/launchSettings.json 52 | 53 | *_i.c 54 | *_p.c 55 | *_i.h 56 | *.ilk 57 | *.meta 58 | *.obj 59 | *.pch 60 | *.pdb 61 | *.pgc 62 | *.pgd 63 | *.rsp 64 | *.sbr 65 | *.tlb 66 | *.tli 67 | *.tlh 68 | *.tmp 69 | *.tmp_proj 70 | *.log 71 | *.vspscc 72 | *.vssscc 73 | .builds 74 | *.pidb 75 | *.svclog 76 | *.scc 77 | 78 | # Chutzpah Test files 79 | _Chutzpah* 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opendb 86 | *.opensdf 87 | *.sdf 88 | *.cachefile 89 | *.VC.db 90 | *.VC.VC.opendb 91 | 92 | # Visual Studio profiler 93 | *.psess 94 | *.vsp 95 | *.vspx 96 | *.sap 97 | 98 | # TFS 2012 Local Workspace 99 | $tf/ 100 | 101 | # Guidance Automation Toolkit 102 | *.gpState 103 | 104 | # ReSharper is a .NET coding add-in 105 | _ReSharper*/ 106 | *.[Rr]e[Ss]harper 107 | *.DotSettings.user 108 | 109 | # JustCode is a .NET coding add-in 110 | .JustCode 111 | 112 | # TeamCity is a build add-in 113 | _TeamCity* 114 | 115 | # DotCover is a Code Coverage Tool 116 | *.dotCover 117 | 118 | # Visual Studio code coverage results 119 | *.coverage 120 | *.coveragexml 121 | 122 | # NCrunch 123 | _NCrunch_* 124 | .*crunch*.local.xml 125 | nCrunchTemp_* 126 | 127 | # MightyMoose 128 | *.mm.* 129 | AutoTest.Net/ 130 | 131 | # Web workbench (sass) 132 | .sass-cache/ 133 | 134 | # Installshield output folder 135 | [Ee]xpress/ 136 | 137 | # DocProject is a documentation generator add-in 138 | DocProject/buildhelp/ 139 | DocProject/Help/*.HxT 140 | DocProject/Help/*.HxC 141 | DocProject/Help/*.hhc 142 | DocProject/Help/*.hhk 143 | DocProject/Help/*.hhp 144 | DocProject/Help/Html2 145 | DocProject/Help/html 146 | 147 | # Click-Once directory 148 | publish/ 149 | 150 | # Publish Web Output 151 | *.[Pp]ublish.xml 152 | *.azurePubxml 153 | # TODO: Comment the next line if you want to checkin your web deploy settings 154 | # but database connection strings (with potential passwords) will be unencrypted 155 | *.pubxml 156 | *.publishproj 157 | 158 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 159 | # checkin your Azure Web App publish settings, but sensitive information contained 160 | # in these scripts will be unencrypted 161 | PublishScripts/ 162 | 163 | # NuGet Packages 164 | *.nupkg 165 | # The packages folder can be ignored because of Package Restore 166 | **/packages/* 167 | # except build/, which is used as an MSBuild target. 168 | !**/packages/build/ 169 | # Uncomment if necessary however generally it will be regenerated when needed 170 | #!**/packages/repositories.config 171 | # NuGet v3's project.json files produces more ignoreable files 172 | *.nuget.props 173 | *.nuget.targets 174 | 175 | # Microsoft Azure Build Output 176 | csx/ 177 | *.build.csdef 178 | 179 | # Microsoft Azure Emulator 180 | ecf/ 181 | rcf/ 182 | 183 | # Windows Store app package directories and files 184 | AppPackages/ 185 | BundleArtifacts/ 186 | Package.StoreAssociation.xml 187 | _pkginfo.txt 188 | 189 | # Visual Studio cache files 190 | # files ending in .cache can be ignored 191 | *.[Cc]ache 192 | # but keep track of directories ending in .cache 193 | !*.[Cc]ache/ 194 | 195 | # Others 196 | ClientBin/ 197 | ~$* 198 | *~ 199 | *.dbmdl 200 | *.dbproj.schemaview 201 | *.jfm 202 | *.pfx 203 | *.publishsettings 204 | node_modules/ 205 | orleans.codegen.cs 206 | 207 | # Since there are multiple workflows, uncomment next line to ignore bower_components 208 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 209 | #bower_components/ 210 | 211 | # RIA/Silverlight projects 212 | Generated_Code/ 213 | 214 | # Backup & report files from converting an old project file 215 | # to a newer Visual Studio version. Backup files are not needed, 216 | # because we have git ;-) 217 | _UpgradeReport_Files/ 218 | Backup*/ 219 | UpgradeLog*.XML 220 | UpgradeLog*.htm 221 | 222 | # SQL Server files 223 | *.mdf 224 | *.ldf 225 | 226 | # Business Intelligence projects 227 | *.rdl.data 228 | *.bim.layout 229 | *.bim_*.settings 230 | 231 | # Microsoft Fakes 232 | FakesAssemblies/ 233 | 234 | # GhostDoc plugin setting file 235 | *.GhostDoc.xml 236 | 237 | # Node.js Tools for Visual Studio 238 | .ntvs_analysis.dat 239 | 240 | # Visual Studio 6 build log 241 | *.plg 242 | 243 | # Visual Studio 6 workspace options file 244 | *.opt 245 | 246 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 247 | *.vbw 248 | 249 | # Visual Studio LightSwitch build output 250 | **/*.HTMLClient/GeneratedArtifacts 251 | **/*.DesktopClient/GeneratedArtifacts 252 | **/*.DesktopClient/ModelManifest.xml 253 | **/*.Server/GeneratedArtifacts 254 | **/*.Server/ModelManifest.xml 255 | _Pvt_Extensions 256 | 257 | # Paket dependency manager 258 | .paket/paket.exe 259 | paket-files/ 260 | 261 | # FAKE - F# Make 262 | .fake/ 263 | 264 | # JetBrains Rider 265 | .idea/ 266 | *.sln.iml 267 | 268 | # CodeRush 269 | .cr/ 270 | 271 | # Python Tools for Visual Studio (PTVS) 272 | __pycache__/ 273 | *.pyc 274 | 275 | # Cake - Uncomment if you are using it 276 | # tools/ 277 | 278 | *.bak 279 | -------------------------------------------------------------------------------- /EzAPI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F} 9 | Library 10 | Properties 11 | Microsoft.SqlServer.SSIS.EzAPI 12 | EzAPI 13 | v4.0 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | publish\ 23 | true 24 | Disk 25 | false 26 | Foreground 27 | 7 28 | Days 29 | false 30 | false 31 | true 32 | 0 33 | 1.0.0.%2a 34 | false 35 | false 36 | true 37 | 38 | 39 | true 40 | full 41 | false 42 | Output\ 43 | DEBUG;TRACE 44 | prompt 45 | 4 46 | AllRules.ruleset 47 | AnyCPU 48 | 49 | 50 | pdbonly 51 | true 52 | bin\Release\ 53 | TRACE 54 | prompt 55 | 4 56 | AllRules.ruleset 57 | bin\Release\EzAPI.XML 58 | 59 | 60 | 61 | 62 | True 63 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.DataTransformationServices.Controls\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.DataTransformationServices.Controls.DLL 64 | 65 | 66 | ..\..\..\..\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.ConnectionInfo\13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ConnectionInfo.dll 67 | 68 | 69 | True 70 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.DataProfilingTask.dll 71 | 72 | 73 | True 74 | C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Diagnostics.STrace\13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Diagnostics.STrace.dll 75 | 76 | 77 | False 78 | 79 | 80 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\Microsoft.SqlServer.DTSRuntimeWrap\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.DTSRuntimeWrap.dll 81 | True 82 | 83 | 84 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ExecPackageTaskWrap\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ExecPackageTaskWrap.dll 85 | True 86 | 87 | 88 | True 89 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.ExecProcTask.dll 90 | 91 | 92 | True 93 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.ExpressionTask.dll 94 | 95 | 96 | True 97 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.FileSystemTask.dll 98 | 99 | 100 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedConnections\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedConnections.dll 101 | 102 | 103 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedDTS.dll 104 | 105 | 106 | ..\..\..\..\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Management.Sdk.Sfc\13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Management.Sdk.Sfc.dll 107 | 108 | 109 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.PipelineHost.dll 110 | 111 | 112 | True 113 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.ScriptTask.dll 114 | 115 | 116 | ..\..\..\..\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Smo.dll 117 | 118 | 119 | 120 | True 121 | C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.TransferDatabasesTask.dll 122 | 123 | 124 | ..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.TxScript\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.TxScript.dll 125 | 126 | 127 | True 128 | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.VSTAScriptingLib\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.VSTAScriptingLib.dll 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | False 149 | .NET Framework 3.5 SP1 Client Profile 150 | false 151 | 152 | 153 | False 154 | .NET Framework 3.5 SP1 155 | true 156 | 157 | 158 | False 159 | Windows Installer 3.1 160 | true 161 | 162 | 163 | 164 | 165 | License.md 166 | 167 | 168 | 169 | 170 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /EzAPI.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | EzAPI 2016 7 | fpvmorais 8 | fpvmorais 9 | https://github.com/fpvmorais/EzApi2016 10 | License.md 11 | false 12 | Fork of EzApi http://sqlsrvintegrationsrv.codeplex.com/releases/view/21238 adapted for SQL Server 2016 13 | First release 14 | Copyright © Microsoft Corporation. All Rights Reserved. 15 | EzApi SSIS Automation 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /EzAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EzAPI", "EzAPI.csproj", "{1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1BFEE854-8F82-49C7-A2A7-3E94A9DCE47F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /EzCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Microsoft Corporation. All Rights Reserved. 2 | // This code released under the terms of the 3 | // Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) 4 | 5 | 6 | using Microsoft.SqlServer.Dts.Runtime; 7 | using System; 8 | using System.Collections.Generic; 9 | 10 | namespace Microsoft.SqlServer.SSIS.EzAPI 11 | { 12 | public class EzDataFlowPackage : EzPackage 13 | { 14 | public EzDataFlow DataFlow; 15 | 16 | public EzDataFlowPackage() : base() { DataFlow = new EzDataFlow(this); } 17 | public EzDataFlowPackage(Package p) : base(p) { } 18 | 19 | public static implicit operator EzDataFlowPackage(Package p) { return new EzDataFlowPackage(p); } 20 | } 21 | 22 | public class EzForLoopPackage : EzPackage 23 | { 24 | public EzForLoop ForLoop; 25 | public EzForLoopPackage() 26 | : base() 27 | { 28 | ForLoop = new EzForLoop(this); 29 | } 30 | 31 | public EzForLoopPackage(Package p) : base(p) { } 32 | public static implicit operator EzForLoopPackage(Package p) { return new EzForLoopPackage(p); } 33 | } 34 | 35 | public class EzForLoopDFPackage : EzForLoopPackage 36 | { 37 | public EzDataFlow DataFlow; 38 | public EzForLoopDFPackage() 39 | : base() 40 | { 41 | DataFlow = new EzDataFlow(ForLoop); 42 | } 43 | 44 | public EzForLoopDFPackage(Package p) : base(p) { } 45 | public static implicit operator EzForLoopDFPackage(Package p) { return new EzForLoopDFPackage(p); } 46 | } 47 | 48 | public class EzSrcPackage : EzDataFlowPackage 49 | where SrcType : EzAdapter 50 | where SrcConnType : EzConnectionManager 51 | { 52 | public SrcConnType SrcConn; 53 | public SrcType Source; 54 | 55 | public EzSrcPackage() 56 | : base() 57 | { 58 | SrcConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType; 59 | Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType; 60 | Source.Connection = SrcConn; 61 | } 62 | 63 | public EzSrcPackage(Package p) : base(p) { } 64 | 65 | public static implicit operator EzSrcPackage(Package p) 66 | { 67 | return new EzSrcPackage(p); 68 | } 69 | } 70 | 71 | public class EzSrcDestMultiStreamPackage : EzDataFlowPackage 72 | where SrcType : EzAdapter 73 | where SrcConnType : EzConnectionManager 74 | where DestType : EzAdapter 75 | where DestConnType : EzConnectionManager 76 | { 77 | public DestConnType DestConn; 78 | public DestType Dest; 79 | public SrcConnType SourceConn; 80 | public SrcType Source; 81 | public List> SourceDestPairs = new List>(); 82 | 83 | public EzSrcDestMultiStreamPackage(int streamCount) 84 | : base() 85 | { 86 | SourceConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType; 87 | DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType; 88 | 89 | for (int i = 0; i < streamCount; i++) 90 | { 91 | Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType; 92 | Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType; 93 | 94 | KeyValuePair connectionPair = new KeyValuePair(Source, Dest); 95 | SourceDestPairs.Add(connectionPair); 96 | } 97 | } 98 | 99 | public void AttachConnections(SrcConnType sourceConnection, DestConnType destConnection) 100 | { 101 | foreach (KeyValuePair connectionPair in SourceDestPairs) 102 | { 103 | SrcType source = (SrcType)connectionPair.Key; 104 | DestType dest = (DestType)connectionPair.Value; 105 | 106 | source.Connection = sourceConnection; 107 | dest.Connection = destConnection; 108 | 109 | dest.AttachTo(source); 110 | } 111 | } 112 | 113 | public EzSrcDestMultiStreamPackage(Package p) : base(p) { } 114 | 115 | public static implicit operator EzSrcDestMultiStreamPackage(Package p) 116 | { 117 | return new EzSrcDestMultiStreamPackage(p); 118 | } 119 | } 120 | 121 | public class EzSrcDestPackage : EzSrcPackage 122 | where SrcType : EzAdapter 123 | where SrcConnType : EzConnectionManager 124 | where DestType : EzAdapter 125 | where DestConnType : EzConnectionManager 126 | { 127 | public DestConnType DestConn; 128 | public DestType Dest; 129 | 130 | public EzSrcDestPackage() 131 | : base() 132 | { 133 | DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType; 134 | Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType; 135 | Dest.Connection = DestConn; 136 | Dest.AttachTo(Source); 137 | } 138 | 139 | public EzSrcDestPackage(Package p) : base(p) { } 140 | 141 | public static implicit operator EzSrcDestPackage(Package p) 142 | { 143 | return new EzSrcDestPackage(p); 144 | } 145 | } 146 | 147 | public class EzTransformPackage 148 | : EzSrcPackage 149 | where SrcType : EzAdapter 150 | where SrcConnType : EzConnectionManager 151 | where TransType : EzComponent 152 | where DestType : EzAdapter 153 | where DestConnType : EzConnectionManager 154 | { 155 | public DestConnType DestConn; 156 | public DestType Dest; 157 | public TransType Transform; 158 | 159 | public EzTransformPackage() 160 | : base() 161 | { 162 | Transform = Activator.CreateInstance(typeof(TransType), new object[] { DataFlow }) as TransType; 163 | DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType; 164 | Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType; 165 | Dest.Connection = DestConn; 166 | Transform.AttachTo(Source); 167 | Dest.AttachTo(Transform); 168 | } 169 | 170 | public EzTransformPackage(Package p) : base(p) { } 171 | 172 | public static implicit operator EzTransformPackage(Package p) 173 | { 174 | return new EzTransformPackage(p); 175 | } 176 | } 177 | 178 | public class EzLoopTransformPackage 179 | : EzForLoopDFPackage 180 | where SrcType : EzAdapter 181 | where SrcConnType : EzConnectionManager 182 | where TransType : EzComponent 183 | where DestType : EzAdapter 184 | where DestConnType : EzConnectionManager 185 | { 186 | public SrcType Source; 187 | public SrcConnType SrcConn; 188 | public DestConnType DestConn; 189 | public DestType Dest; 190 | public TransType Transform; 191 | 192 | public EzLoopTransformPackage() 193 | : base() 194 | { 195 | SrcConn = Activator.CreateInstance(typeof(SrcConnType), new object[] { this }) as SrcConnType; 196 | Source = Activator.CreateInstance(typeof(SrcType), new object[] { DataFlow }) as SrcType; 197 | Source.Connection = SrcConn; 198 | Transform = Activator.CreateInstance(typeof(TransType), new object[] { DataFlow }) as TransType; 199 | DestConn = Activator.CreateInstance(typeof(DestConnType), new object[] { this }) as DestConnType; 200 | Dest = Activator.CreateInstance(typeof(DestType), new object[] { DataFlow }) as DestType; 201 | Dest.Connection = DestConn; 202 | Transform.AttachTo(Source); 203 | Dest.AttachTo(Transform); 204 | } 205 | 206 | public EzLoopTransformPackage(Package p) : base(p) { } 207 | 208 | public static implicit operator EzLoopTransformPackage(Package p) 209 | { 210 | return new EzLoopTransformPackage(p); 211 | } 212 | } 213 | 214 | public class EzPkgWithExec : EzPackage where T : EzExecutable 215 | { 216 | public T Exec; 217 | public EzPkgWithExec() : base() 218 | { 219 | Exec = Activator.CreateInstance(typeof(T), new object[] { this }) as T; 220 | } 221 | public EzPkgWithExec(Package p) : base(p) { } 222 | public static implicit operator EzPkgWithExec(Package p) { return new EzPkgWithExec(p); } 223 | } 224 | 225 | public class EzExecForLoop : EzForLoop where T : EzExecutable 226 | { 227 | public T Exec; 228 | public EzExecForLoop(EzPackage pkg, DtsContainer c) : base(pkg, c) { } 229 | public EzExecForLoop(EzContainer parent) 230 | : base(parent) 231 | { 232 | Exec = Activator.CreateInstance(typeof(T), new object[] { this }) as T; 233 | } 234 | } 235 | 236 | public class EzSrcDF : EzDataFlow where SrcComp : EzComponent 237 | { 238 | public SrcComp Source; 239 | public EzSrcDF(EzContainer parent) 240 | : base(parent) 241 | { 242 | Source = Activator.CreateInstance(typeof(SrcComp), new object[] { this }) as SrcComp; 243 | } 244 | public EzSrcDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { } 245 | } 246 | 247 | public class EzSrcConnDF : EzSrcDF 248 | where SrcComp : EzAdapter 249 | where SrcCM : EzConnectionManager 250 | { 251 | public SrcCM SrcConn; 252 | public EzSrcConnDF(EzContainer parent) 253 | : base(parent) 254 | { 255 | SrcConn = Activator.CreateInstance(typeof(SrcCM), new object[] { Package }) as SrcCM; 256 | Source.Connection = SrcConn; 257 | } 258 | public EzSrcConnDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { } 259 | } 260 | 261 | public class EzTransformDF : EzSrcConnDF 262 | where SrcComp : EzAdapter 263 | where SrcCM : EzConnectionManager 264 | where Trans : EzComponent 265 | { 266 | public Trans Transform; 267 | public EzTransformDF(EzContainer parent) 268 | : base(parent) 269 | { 270 | Transform = Activator.CreateInstance(typeof(Trans), new object[] { this }) as Trans; 271 | Transform.AttachTo(Source); 272 | } 273 | public EzTransformDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { } 274 | } 275 | 276 | public class EzTransDestDF : EzTransformDF 277 | where SrcComp : EzAdapter 278 | where SrcCM : EzConnectionManager 279 | where Trans : EzComponent 280 | where DestComp : EzComponent 281 | { 282 | public DestComp Dest; 283 | 284 | public EzTransDestDF(EzContainer parent) 285 | : base(parent) 286 | { 287 | Dest = Activator.CreateInstance(typeof(DestComp), new object[] { this }) as DestComp; 288 | Dest.AttachTo(Transform); 289 | } 290 | 291 | public EzTransDestDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { } 292 | } 293 | 294 | public class EzTransDestConnDF : EzTransDestDF 295 | where SrcComp : EzAdapter 296 | where SrcCM : EzConnectionManager 297 | where Trans : EzComponent 298 | where DestComp : EzAdapter 299 | where DestCM : EzConnectionManager 300 | { 301 | public DestCM DestConn; 302 | 303 | public EzTransDestConnDF(EzContainer parent) 304 | : base(parent) 305 | { 306 | DestConn = Activator.CreateInstance(typeof(DestCM), new object[] { Package }) as DestCM; 307 | Dest.Connection = DestConn; 308 | } 309 | 310 | public EzTransDestConnDF(EzPackage pkg, TaskHost pipe) : base(pkg, pipe) { } 311 | } 312 | } -------------------------------------------------------------------------------- /EzConnections.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Microsoft Corporation. All Rights Reserved. 2 | // This code released under the terms of the 3 | // Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) 4 | 5 | 6 | using System; 7 | using System.Collections; 8 | using System.Collections.Generic; 9 | using System.Globalization; 10 | using System.Reflection; 11 | using System.Text; 12 | using Microsoft.SqlServer.Dts.Runtime; 13 | using RunWrap=Microsoft.SqlServer.Dts.Runtime.Wrapper; 14 | 15 | namespace Microsoft.SqlServer.SSIS.EzAPI 16 | { 17 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 18 | public sealed class ConnMgrIDAttribute : Attribute 19 | { 20 | private string m_id; 21 | public ConnMgrIDAttribute(string id) 22 | { 23 | m_id = id; 24 | } 25 | public string ID { get { return m_id; } } 26 | } 27 | 28 | public class EzConnectionManager 29 | { 30 | protected ConnectionManager m_conn; 31 | protected EzProject m_parentProject; 32 | protected string m_streamName; 33 | protected EzPackage m_parent; 34 | 35 | public static implicit operator ConnectionManager(EzConnectionManager c) 36 | { 37 | if (c == null) 38 | return null; 39 | return c.m_conn; 40 | } 41 | 42 | public EzConnectionManager(EzPackage parent) 43 | { 44 | if (parent == null) 45 | throw new ArgumentNullException("parent"); 46 | m_parent = parent; 47 | m_conn = parent.Connections.Add(GetConnMgrID()); 48 | Name = GetType().Name + ID; 49 | } 50 | 51 | public EzConnectionManager(EzProject parentProject, string streamName) 52 | { 53 | if (parentProject == null) 54 | throw new ArgumentNullException("parentProject"); 55 | m_parentProject = parentProject; 56 | if (!parentProject.ConnectionManagerItems.Contains(streamName)) 57 | { 58 | m_conn = parentProject.ConnectionManagerItems.Add(GetConnMgrID(), streamName).ConnectionManager; 59 | m_conn.Name = GetType().Name + ID; 60 | Name = m_conn.Name; 61 | m_streamName = streamName; 62 | return; 63 | } 64 | 65 | m_conn = parentProject.ConnectionManagerItems[streamName].ConnectionManager; 66 | 67 | if (m_conn.CreationName != GetConnMgrID()) 68 | throw new IncorrectAssignException(string.Format("Connection manager with streamName {0} of type {1} already exists and is incompatible with type {2}", 69 | streamName, m_conn.CreationName, GetConnMgrID())); 70 | 71 | } 72 | 73 | public EzConnectionManager(EzPackage parent, string name) 74 | { 75 | if (parent == null) 76 | throw new ArgumentNullException("parent"); 77 | m_parent = parent; 78 | if (!parent.ConnectionExists(name)) 79 | { 80 | m_conn = parent.Connections.Add(GetConnMgrID()); 81 | Name = name; 82 | return; 83 | } 84 | m_conn = parent.Connections[name]; 85 | if (m_conn.CreationName != GetConnMgrID()) 86 | throw new IncorrectAssignException(string.Format("Connection manager with name {0} of type {1} already exists and is incompatible with type {2}", 87 | name, m_conn.CreationName, GetConnMgrID())); 88 | } 89 | 90 | public EzConnectionManager(EzProject parentProject, string streamName, string name) 91 | { 92 | if (parentProject == null) 93 | throw new ArgumentNullException("parentProject"); 94 | m_parentProject = parentProject; 95 | if (!parentProject.ConnectionManagerItems.Contains(streamName)) 96 | { 97 | m_conn = parentProject.ConnectionManagerItems.Add(GetConnMgrID(), streamName).ConnectionManager; 98 | m_conn.Name = name; 99 | Name = name; 100 | m_streamName = streamName; 101 | return; 102 | } 103 | m_conn = parentProject.ConnectionManagerItems[streamName].ConnectionManager; 104 | if (m_conn.CreationName != GetConnMgrID()) 105 | throw new IncorrectAssignException(string.Format("Connection manager with name {0} of type {1} already exists and is incompatible with type {2}", 106 | streamName, m_conn.CreationName, GetConnMgrID())); 107 | } 108 | 109 | public EzConnectionManager(EzPackage parent, ConnectionManager c) { Assign(parent, c); } 110 | public EzConnectionManager(EzProject parentProject, ConnectionManager c) { Assign(parentProject, c); } 111 | 112 | public string GetConnMgrID() 113 | { 114 | object[] cmids = GetType().GetCustomAttributes(typeof(ConnMgrIDAttribute), true); 115 | if (cmids.Length == 0) 116 | return null; 117 | return (cmids[0] as ConnMgrIDAttribute).ID; 118 | } 119 | 120 | /// 121 | /// Returns the member name of the current component, if it exists in the parent package 122 | /// 123 | public string EzName 124 | { 125 | get 126 | { 127 | if (Parent == null) 128 | return null; 129 | FieldInfo[] m = Parent.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 130 | foreach (FieldInfo mi in m) 131 | { 132 | EzConnectionManager cur = mi.GetValue(Parent) as EzConnectionManager; 133 | if (cur == null) 134 | continue; 135 | if (cur.ID == ID) 136 | return mi.Name; 137 | } 138 | return null; 139 | } 140 | } 141 | 142 | public virtual EzConnectionManager Assign(EzPackage parent, ConnectionManager c) 143 | { 144 | m_conn = c; 145 | m_parent = parent; 146 | return this; 147 | } 148 | 149 | public virtual EzConnectionManager Assign(EzProject parentProject, ConnectionManager c) 150 | { 151 | m_conn = c; 152 | m_parentProject = parentProject; 153 | return this; 154 | } 155 | 156 | public void PromoteToSCM(EzProject project, string streamName) 157 | { 158 | bool found = false; 159 | int CMPackageLocation = 0; 160 | if (m_parent == null) 161 | throw new ArgumentNullException("CM not attached to a package"); 162 | if (project == null) 163 | throw new ArgumentNullException("Project Null"); 164 | 165 | for (int i = 0; i {0}{1}", EzName, value); } 200 | } 201 | 202 | public ConnectionManager CM { get { return m_conn; } } 203 | public EzPackage Parent { get { return m_parent; } } 204 | public EzProject ParentProject { get { return m_parentProject; } } 205 | public string Name { get { return m_conn.Name; } set { m_conn.Name = value; } } 206 | public string ID { get { return m_conn.ID; } } 207 | public string StreamName { get { return m_streamName; } } 208 | public DTSProtectionLevel ProtectionLevel { get { return m_conn.ProtectionLevel; } } 209 | public bool DelayValidation { get { return m_conn.DelayValidation; } set { m_conn.DelayValidation = value; } } 210 | 211 | public string ConnectionString 212 | { 213 | get { return m_conn.ConnectionString; } 214 | set 215 | { 216 | if (CompareConnectionStrings(m_conn.ConnectionString, value)) 217 | return; 218 | m_conn.ConnectionString = value; 219 | if (Parent != null) 220 | Parent.ReinitializeMetaData(); 221 | } 222 | } 223 | 224 | public void SetExpression(string property, string expression) 225 | { 226 | m_conn.Properties[property].SetExpression(m_conn, expression); 227 | } 228 | 229 | 230 | public static bool CompareConnectionStrings(string conn1, string conn2) 231 | { 232 | if (conn1 == null && conn2 == null) 233 | return true; 234 | if ((conn1 == null && conn2 != null) || (conn2 == null && conn1 != null)) 235 | return false; 236 | string[] c1 = conn1.ToUpper(CultureInfo.InvariantCulture).Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); 237 | string[] c2 = conn2.ToUpper(CultureInfo.InvariantCulture).Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); 238 | if (c1.Length != c2.Length) 239 | return false; 240 | Array.Sort(c1); 241 | Array.Sort(c2); 242 | for (int i = 0; i < c1.Length; i++) 243 | if (c1[i] != c2[i]) 244 | return false; 245 | return true; 246 | } 247 | } 248 | 249 | [ConnMgrID("OLEDB")] 250 | public class EzOleDbConnectionManager : EzConnectionManager 251 | { 252 | public EzOleDbConnectionManager(EzPackage parent) : base(parent) { } 253 | public EzOleDbConnectionManager(EzPackage parent, string name) : base(parent, name) { } 254 | public EzOleDbConnectionManager(EzPackage parent, ConnectionManager c) : base(parent, c) { } 255 | public EzOleDbConnectionManager(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 256 | public EzOleDbConnectionManager(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 257 | 258 | public string InitialCatalog 259 | { 260 | get { return (string)m_conn.Properties["InitialCatalog"].GetValue(m_conn); } 261 | set { m_conn.Properties["InitialCatalog"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 262 | } 263 | 264 | public string ServerName 265 | { 266 | get { return (string)m_conn.Properties["ServerName"].GetValue(m_conn); } 267 | set { m_conn.Properties["ServerName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 268 | } 269 | 270 | public string UserName 271 | { 272 | get { return (string)m_conn.Properties["UserName"].GetValue(m_conn); } 273 | set { m_conn.Properties["UserName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 274 | } 275 | 276 | public string Password 277 | { 278 | get { return (string)m_conn.Properties["Password"].GetValue(m_conn); } 279 | set { m_conn.Properties["Password"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 280 | } 281 | 282 | public string DataSourceID 283 | { 284 | get { return (string)m_conn.Properties["DataSourceID"].GetValue(m_conn); } 285 | set { m_conn.Properties["DataSourceID"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 286 | } 287 | 288 | public bool RetainSameConnection 289 | { 290 | get { return (bool)m_conn.Properties["RetainSameConnection"].GetValue(m_conn); } 291 | set { m_conn.Properties["RetainSameConnection"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 292 | } 293 | } 294 | 295 | [ConnMgrID("EXCEL")] 296 | public class EzExcelCM : EzConnectionManager 297 | { 298 | public EzExcelCM(EzPackage parent) : base(parent) { } 299 | public EzExcelCM(EzPackage parent, string name) : base(parent, name) { } 300 | public EzExcelCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 301 | public EzExcelCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 302 | public EzExcelCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 303 | } 304 | 305 | /// 306 | /// OleDb connection manager for SQL Server 307 | /// 308 | public class EzSqlOleDbCM : EzOleDbConnectionManager 309 | { 310 | public EzSqlOleDbCM(EzPackage parent) : base(parent) { } 311 | public EzSqlOleDbCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 312 | public EzSqlOleDbCM(EzPackage parent, string name) : base(parent, name) { } 313 | public EzSqlOleDbCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 314 | public EzSqlOleDbCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 315 | 316 | public void SetConnectionString(string server, string db) 317 | { 318 | ConnectionString = string.Format("provider=sqlncli11;integrated security=sspi;database={0};server={1};OLE DB Services=-2;Auto Translate=False;Connect Timeout=300;", 319 | db, server); 320 | } 321 | } 322 | 323 | public class EzDb2OleDbCM : EzOleDbConnectionManager 324 | { 325 | public EzDb2OleDbCM(EzPackage parent) : base(parent) { } 326 | public EzDb2OleDbCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 327 | public EzDb2OleDbCM(EzPackage parent, string name) : base(parent, name) { } 328 | public EzDb2OleDbCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 329 | public EzDb2OleDbCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 330 | 331 | 332 | public void SetConnectionString(string server, string db, string user, string pwd) 333 | { 334 | SetConnectionString(server, db, user, pwd, server, user, user, user); 335 | } 336 | 337 | public void SetConnectionString(string server, string db, string user, string pwd, string catalog, 338 | string pkgCollection, string schema, string qualifier) 339 | { 340 | ConnectionString = string.Format("Provider=DB2OLEDB;Password={0};Persist Security Info=True;User ID={1};" + 341 | "Initial Catalog={2};Data Source={3};Network Transport Library=TCPIP;Network Address={4};" + 342 | "Package Collection={5};Default Schema={6};Default Qualifier={7};Connect Timeout=300;", pwd, user, catalog, db, server, 343 | pkgCollection, schema, qualifier); 344 | } 345 | } 346 | 347 | public class EzOracleOleDbCM : EzOleDbConnectionManager 348 | { 349 | public EzOracleOleDbCM(EzPackage parent) : base(parent) { } 350 | public EzOracleOleDbCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 351 | public EzOracleOleDbCM(EzPackage parent, string name) : base(parent, name) { } 352 | public EzOracleOleDbCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 353 | public EzOracleOleDbCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 354 | 355 | /// 356 | /// Builds connection string for Oracle OLEDB provider 357 | /// 358 | /// tns name 359 | /// user name 360 | /// password 361 | public void SetConnectionString(string server, string user, string pwd) 362 | { 363 | ConnectionString = string.Format("Provider=OraOLEDB.Oracle;User ID={0};Password={1};Data Source={2};Connect Timeout=300;", 364 | user, pwd, server); 365 | /* 366 | ConnectionString = string.Format("Data Source={0};User ID={1};Password={2};Provider=OraOLEDB.Oracle.1;Persist Security Info=True;", 367 | server, user, pwd); 368 | * */ 369 | } 370 | } 371 | 372 | public enum FileUsageType : int 373 | { 374 | ExistingFile = 0, 375 | CreateFile = 1, 376 | ExistingFolder = 2, 377 | CreateFolder = 3 378 | } 379 | 380 | [ConnMgrID("FILE")] 381 | public class EzFileCM: EzConnectionManager 382 | { 383 | public EzFileCM(EzPackage parent) : base(parent) { } 384 | public EzFileCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 385 | public EzFileCM(EzPackage parent, string name) : base(parent, name) { } 386 | public EzFileCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 387 | public EzFileCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 388 | 389 | // DataSourceID property does not exist. Using the property throws an exception, so 390 | // the property was removed. 391 | /* 392 | [System.Obsolete("DTSProperty DataSourceID does not exist.", true)] 393 | public string DataSourceID 394 | { 395 | get { return (string)m_conn.Properties["DataSourceID"].GetValue(m_conn); } 396 | set { m_conn.Properties["DataSourceID"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 397 | } 398 | */ 399 | public FileUsageType FileUsageType 400 | { 401 | get { return (FileUsageType)m_conn.Properties["FileUsageType"].GetValue(m_conn); } 402 | set { m_conn.Properties["FileUsageType"].SetValue(m_conn, value); } 403 | } 404 | } 405 | 406 | public enum FlatFileFormat 407 | { 408 | Delimited = 0, 409 | FixedWidth = 1, 410 | RaggedRight = 2, 411 | Mixed = 3 412 | } 413 | 414 | public enum FlatFileColumnType 415 | { 416 | Delimited = 0, 417 | FixedWidth = 1 418 | } 419 | 420 | [ConnMgrID("FLATFILE")] 421 | public class EzFlatFileCM : EzConnectionManager 422 | { 423 | public EzFlatFileCM(EzPackage parent) : base(parent) { } 424 | public EzFlatFileCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 425 | public EzFlatFileCM(EzPackage parent, string name) : base(parent, name) { } 426 | public EzFlatFileCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 427 | public EzFlatFileCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 428 | 429 | public int CodePage 430 | { 431 | get { return (int)m_conn.Properties["CodePage"].GetValue(m_conn); } 432 | set { m_conn.Properties["CodePage"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 433 | } 434 | 435 | public bool ColumnNamesInFirstDataRow 436 | { 437 | get { return (bool)m_conn.Properties["ColumnNamesInFirstDataRow"].GetValue(m_conn); } 438 | set { m_conn.Properties["ColumnNamesInFirstDataRow"].SetValue(m_conn, value); } 439 | } 440 | 441 | public int DataRowsToSkip 442 | { 443 | get { return (int)m_conn.Properties["DataRowsToSkip"].GetValue(m_conn); } 444 | set { m_conn.Properties["DataRowsToSkip"].SetValue(m_conn, value); } 445 | } 446 | 447 | public string HeaderRowDelimiter 448 | { 449 | get { return (string)m_conn.Properties["HeaderRowDelimiter"].GetValue(m_conn); } 450 | set { m_conn.Properties["HeaderRowDelimiter"].SetValue(m_conn, value); } 451 | } 452 | 453 | public int HeaderRowsToSkip 454 | { 455 | get { return (int)m_conn.Properties["HeaderRowsToSkip"].GetValue(m_conn); } 456 | set { m_conn.Properties["HeaderRowsToSkip"].SetValue(m_conn, value); } 457 | } 458 | 459 | public int LocaleID 460 | { 461 | get { return (int)m_conn.Properties["LocaleID"].GetValue(m_conn); } 462 | set { m_conn.Properties["LocaleID"].SetValue(m_conn, value); } 463 | } 464 | 465 | public bool Unicode 466 | { 467 | get { return (bool)m_conn.Properties["Unicode"].GetValue(m_conn); } 468 | set { m_conn.Properties["Unicode"].SetValue(m_conn, value); } 469 | } 470 | 471 | public string TextQualifier 472 | { 473 | get { return (string)m_conn.Properties["TextQualifier"].GetValue(m_conn); } 474 | set { m_conn.Properties["TextQualifier"].SetValue(m_conn, value); } 475 | } 476 | 477 | public FlatFileFormat Format 478 | { 479 | get 480 | { 481 | string fmt = (string)m_conn.Properties["Format"].GetValue(m_conn); 482 | for (FlatFileFormat i = FlatFileFormat.Delimited; i <= FlatFileFormat.Mixed; i++) 483 | if (string.Compare(i.ToString(), fmt, StringComparison.OrdinalIgnoreCase) == 0) 484 | return i; 485 | return FlatFileFormat.Delimited; 486 | } 487 | set 488 | { 489 | m_conn.Properties["Format"].SetValue(m_conn, value.ToString()); 490 | } 491 | } 492 | 493 | public RunWrap.IDTSConnectionManagerFlatFileColumns100 Columns 494 | { 495 | get { return m_conn.Properties["Columns"].GetValue(m_conn) as RunWrap.IDTSConnectionManagerFlatFileColumns100; } 496 | } 497 | 498 | public string RowDelimiter 499 | { 500 | get 501 | { 502 | if (Columns.Count > 0) 503 | return Columns[Columns.Count - 1].ColumnDelimiter; 504 | else 505 | return (string)m_conn.Properties["RowDelimiter"].GetValue(m_conn); 506 | } 507 | set 508 | { 509 | if (Columns.Count > 0) 510 | Columns[Columns.Count - 1].ColumnDelimiter = value; 511 | 512 | m_conn.Properties["RowDelimiter"].SetValue(m_conn, value); 513 | } 514 | } 515 | 516 | // Sets delimiter for all the columns 517 | public string ColumnDelimiter 518 | { 519 | get 520 | { 521 | if (Columns.Count > 1) 522 | return Columns[0].ColumnDelimiter; 523 | else 524 | return ","; 525 | } 526 | set 527 | { 528 | for (int i = 0; i < Columns.Count - 1; i++) 529 | Columns[i].ColumnDelimiter = value; 530 | } 531 | } 532 | 533 | public int ColumnWidth 534 | { 535 | get 536 | { 537 | if (Columns.Count > 0) 538 | return Columns[0].ColumnWidth; 539 | else 540 | return 0; 541 | } 542 | set 543 | { 544 | for (int i = 0; i < Columns.Count; i++) 545 | Columns[i].ColumnWidth = value; 546 | } 547 | } 548 | 549 | public FlatFileColumnType ColumnType 550 | { 551 | get 552 | { 553 | string res; 554 | if (Columns.Count > 0) 555 | res = Columns[0].ColumnType; 556 | else 557 | res = FlatFileColumnType.Delimited.ToString(); 558 | if (string.Compare(res, "FIXEDWIDTH", StringComparison.OrdinalIgnoreCase) != 0) 559 | return FlatFileColumnType.FixedWidth; 560 | else 561 | return FlatFileColumnType.Delimited; 562 | } 563 | set 564 | { 565 | for (int i = 0; i < Columns.Count; i++) 566 | Columns[i].ColumnType = value.ToString(); 567 | } 568 | } 569 | 570 | //automatically define flat file columns from connection string and 571 | public void DefineColumnsInCM(FlatFileFormat format = FlatFileFormat.Delimited, bool reinitmetadata = false) 572 | { 573 | string strline = string.Empty; 574 | string[] strVal = null; 575 | string[] strSamples = null; 576 | int intCount = 0; 577 | List ColumnsLength = new List(); 578 | 579 | if (ConnectionString == null) 580 | return; 581 | 582 | using (System.IO.StreamReader csStreamReader = new System.IO.StreamReader(ConnectionString)) 583 | { 584 | while (csStreamReader.EndOfStream == false) 585 | { 586 | strline = csStreamReader.ReadLine(); 587 | 588 | if (strVal == null) 589 | { 590 | strVal = strline.Split(this.ColumnDelimiter.ToCharArray()); 591 | 592 | int intColumnLength = 0; 593 | while (intColumnLength <= strVal.Length - 1) 594 | { 595 | intColumnLength = intColumnLength + 1; 596 | ColumnsLength.Add(50); 597 | 598 | } 599 | 600 | } 601 | else if (intCount <= 100) 602 | { 603 | 604 | strSamples = null; 605 | strSamples = strline.Split(this.ColumnDelimiter.ToCharArray()); 606 | 607 | intCount = intCount + 1; 608 | 609 | int intColumnLength = 0; 610 | while (intColumnLength <= ColumnsLength.Count - 1) 611 | { 612 | 613 | if (strSamples[intColumnLength].Length > ColumnsLength[intColumnLength]) 614 | { 615 | ColumnsLength[intColumnLength] = strSamples[intColumnLength].Length; 616 | } 617 | 618 | intColumnLength = intColumnLength + 1; 619 | 620 | 621 | } 622 | 623 | } 624 | else 625 | break; 626 | } 627 | } 628 | 629 | int intLength = 0; 630 | 631 | foreach (string strColumn in strVal) 632 | { 633 | RunWrap.IDTSConnectionManagerFlatFileColumn100 fc = null; 634 | if (fc == null) 635 | fc = this.Columns.Add(); 636 | fc.DataType = RunWrap.DataType.DT_STR; 637 | fc.DataPrecision = 0; 638 | fc.DataScale = 0; 639 | fc.ColumnWidth = ColumnsLength[intLength]; 640 | fc.MaximumWidth = ColumnsLength[intLength]; 641 | (fc as RunWrap.IDTSName100).Name = strColumn; 642 | intLength = intLength + 1; 643 | } 644 | 645 | this.ColumnNamesInFirstDataRow = true; 646 | this.RowDelimiter = "\r\n"; 647 | 648 | switch (format) 649 | { 650 | case FlatFileFormat.Delimited: 651 | this.ColumnType = FlatFileColumnType.Delimited; 652 | this.ColumnDelimiter = ","; 653 | break; 654 | case FlatFileFormat.FixedWidth: 655 | this.ColumnType = FlatFileColumnType.FixedWidth; 656 | this.ColumnDelimiter = null; 657 | break; 658 | case FlatFileFormat.Mixed: // "FixedWidth with row delimiters" 659 | this.ColumnType = FlatFileColumnType.FixedWidth; 660 | this.ColumnDelimiter = null; 661 | 662 | RunWrap.IDTSConnectionManagerFlatFileColumn100 fc = this.Columns.Add(); 663 | fc.DataType = RunWrap.DataType.DT_WSTR; 664 | fc.ColumnType = FlatFileColumnType.Delimited.ToString(); 665 | fc.ColumnDelimiter = "\r\n"; 666 | fc.ColumnWidth = 0; 667 | (fc as RunWrap.IDTSName100).Name = "Row delimiter column"; 668 | break; 669 | case FlatFileFormat.RaggedRight: 670 | this.ColumnType = FlatFileColumnType.FixedWidth; 671 | this.ColumnDelimiter = null; 672 | 673 | // update the last column to be delimited 674 | this.Columns[this.Columns.Count - 1].ColumnType = FlatFileColumnType.Delimited.ToString(); 675 | this.Columns[this.Columns.Count - 1].ColumnDelimiter = "\r\n"; 676 | break; 677 | } 678 | 679 | if (reinitmetadata) 680 | this.Parent.ReinitializeMetaData(); 681 | 682 | } 683 | } 684 | 685 | public abstract class EzAdoNetCM : EzConnectionManager 686 | { 687 | public EzAdoNetCM(EzPackage parent) : base(parent) { } 688 | public EzAdoNetCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 689 | public EzAdoNetCM(EzPackage parent, string name) : base(parent, name) { } 690 | public EzAdoNetCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 691 | public EzAdoNetCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 692 | 693 | public string InitialCatalog 694 | { 695 | get { return (string)m_conn.Properties["InitialCatalog"].GetValue(m_conn); } 696 | set { m_conn.Properties["InitialCatalog"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 697 | } 698 | 699 | public string ServerName 700 | { 701 | get { return (string)m_conn.Properties["ServerName"].GetValue(m_conn); } 702 | set { m_conn.Properties["ServerName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 703 | } 704 | 705 | public string UserName 706 | { 707 | get { return (string)m_conn.Properties["UserName"].GetValue(m_conn); } 708 | set { m_conn.Properties["UserName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 709 | } 710 | 711 | public string Password 712 | { 713 | get { return (string)m_conn.Properties["Password"].GetValue(m_conn); } 714 | set { m_conn.Properties["Password"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 715 | } 716 | 717 | public string DataSourceID 718 | { 719 | get { return (string)m_conn.Properties["DataSourceID"].GetValue(m_conn); } 720 | set { m_conn.Properties["DataSourceID"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 721 | } 722 | 723 | public string Qualifier 724 | { 725 | get { return (string)m_conn.Properties["Qualifier"].GetValue(m_conn); } 726 | set { m_conn.SetQualifier(value); } 727 | } 728 | } 729 | 730 | [ConnMgrID("ADO.NET:SQL")] 731 | public class EzSqlAdoNetCM : EzAdoNetCM 732 | { 733 | public EzSqlAdoNetCM(EzPackage parent) : base(parent) { } 734 | public EzSqlAdoNetCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 735 | public EzSqlAdoNetCM(EzPackage parent, string name) : base(parent, name) { } 736 | public EzSqlAdoNetCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 737 | public EzSqlAdoNetCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 738 | 739 | public virtual void SetConnectionString(string server, string db) 740 | { 741 | ConnectionString = string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True;Connect Timeout=300;", 742 | server, db); 743 | } 744 | } 745 | 746 | [ConnMgrID("ADO.NET:ORACLE")] 747 | public class EzOracleAdoNetCM : EzAdoNetCM 748 | { 749 | public EzOracleAdoNetCM(EzPackage parent) : base(parent) { } 750 | public EzOracleAdoNetCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 751 | public EzOracleAdoNetCM(EzPackage parent, string name) : base(parent, name) { } 752 | public EzOracleAdoNetCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { } 753 | public EzOracleAdoNetCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { } 754 | 755 | public virtual void SetConnectionString(string server, string user, string pwd, bool unicode) 756 | { 757 | ConnectionString = string.Format("Data Source={0};User ID = {1}; Password = {2}; Unicode = {3};", 758 | server, user, pwd, unicode); 759 | } 760 | } 761 | 762 | public class CacheColumn 763 | { 764 | internal RunWrap.IDTSConnectionManagerCacheColumn100 m_col; 765 | internal CacheColumn(RunWrap.IDTSConnectionManagerCacheColumn100 c) { m_col = c; } 766 | public string Name { get { return ((RunWrap.IDTSName100)m_col).Name; } set { ((RunWrap.IDTSName100)m_col).Name = value; } } 767 | public int Length { get { return m_col.Length; } set { m_col.Length = value; } } 768 | public int Precision { get { return m_col.Precision; } set { m_col.Precision = value; } } 769 | public int Scale { get { return m_col.Scale; } set { m_col.Scale = value; } } 770 | public RunWrap.DataType DataType { get { return m_col.DataType; } set { m_col.DataType = value; } } 771 | public int IndexPosition { get { return m_col.IndexPosition; } set { m_col.IndexPosition = value; } } 772 | public int CodePage { get { return m_col.CodePage; } set { m_col.CodePage = value; } } 773 | } 774 | 775 | sealed public class CacheCols : ICollection 776 | { 777 | private RunWrap.IDTSConnectionManagerCacheColumns100 m_cols; 778 | internal CacheCols(RunWrap.IDTSConnectionManagerCacheColumns100 cols) { m_cols = cols; } 779 | 780 | public IEnumerator GetEnumerator() 781 | { 782 | return new CacheColEnumerator(m_cols.GetEnumerator()); 783 | } 784 | 785 | public CacheColumn this[object index] 786 | { 787 | get 788 | { 789 | RunWrap.IDTSConnectionManagerCacheColumn100 col = m_cols[index]; 790 | if (col == null) 791 | return null; 792 | return new CacheColumn(col); 793 | } 794 | } 795 | 796 | public CacheColumn Add() 797 | { 798 | return new CacheColumn(m_cols.Add()); 799 | } 800 | 801 | public void Remove(CacheColumn index) 802 | { 803 | if (index == null) 804 | throw new ArgumentNullException("index"); 805 | m_cols.Remove(index.m_col); 806 | } 807 | 808 | public void CopyTo(System.Array array, int index) 809 | { 810 | if (array == null) 811 | throw new ArgumentNullException("array"); 812 | int i = index; 813 | foreach (object o in this) 814 | array.SetValue(o, i++); 815 | } 816 | 817 | public void CopyTo(CacheColumn[] array, int index) 818 | { 819 | ((ICollection)this).CopyTo(array, index); 820 | } 821 | 822 | public int Count { get { return m_cols.Count; } } 823 | public bool IsSynchronized { get { return false; } } 824 | public object SyncRoot { get { return null; } } 825 | } 826 | 827 | sealed public class CacheColEnumerator : IEnumerator 828 | { 829 | IEnumerator m_enumerator; 830 | internal CacheColEnumerator(IEnumerator enumerator) { m_enumerator = enumerator; } 831 | 832 | public bool MoveNext() 833 | { 834 | return m_enumerator.MoveNext(); 835 | } 836 | 837 | public object Current { get { return new CacheColumn(m_enumerator.Current as RunWrap.IDTSConnectionManagerCacheColumn100); } } 838 | 839 | public void Reset() 840 | { 841 | m_enumerator.Reset(); 842 | } 843 | 844 | } 845 | 846 | [ConnMgrID("CACHE")] 847 | public class EzCacheCM : EzConnectionManager 848 | { 849 | public EzCacheCM(EzPackage parent) : base(parent) { m_cmcache = (RunWrap.IDTSConnectionManagerCache100)m_conn.InnerObject; } 850 | public EzCacheCM(EzPackage parent, ConnectionManager c) : base(parent, c) { m_cmcache = (RunWrap.IDTSConnectionManagerCache100)m_conn.InnerObject; } 851 | public EzCacheCM(EzPackage parent, string name) : base(parent, name) { m_cmcache = (RunWrap.IDTSConnectionManagerCache100)m_conn.InnerObject; } 852 | public EzCacheCM(EzProject parentProject, string streamName) : base(parentProject, streamName) { m_cmcache = (RunWrap.IDTSConnectionManagerCache100)m_conn.InnerObject; } 853 | public EzCacheCM(EzProject parentProject, string streamName, string name) : base(parentProject, streamName, name) { m_cmcache = (RunWrap.IDTSConnectionManagerCache100)m_conn.InnerObject; } 854 | 855 | private RunWrap.IDTSConnectionManagerCache100 m_cmcache; 856 | private CacheCols m_cols; 857 | 858 | public bool RetainData 859 | { 860 | get { return m_cmcache.RetainData; } 861 | set { m_cmcache.RetainData = value; } 862 | } 863 | 864 | public bool UseFile 865 | { 866 | get { return m_cmcache.UseFile; } 867 | set { m_cmcache.UseFile = value; } 868 | } 869 | 870 | public bool UseEncryption 871 | { 872 | get { return m_cmcache.UseEncryption; } 873 | set { m_cmcache.UseEncryption = value; } 874 | } 875 | 876 | public string DataSourceID 877 | { 878 | get { return (string)m_conn.Properties["DataSourceID"].GetValue(m_conn); } 879 | set { m_conn.Properties["DataSourceID"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 880 | } 881 | 882 | public CacheCols CacheCols 883 | { 884 | get 885 | { 886 | if (m_cols == null) 887 | m_cols = new CacheCols(m_cmcache.Columns); 888 | return m_cols; 889 | } 890 | } 891 | 892 | public void RefreshCacheCols() 893 | { 894 | if (!UseFile || string.IsNullOrEmpty(ConnectionString)) 895 | return; 896 | foreach (RunWrap.IDTSConnectionManagerCacheColumn100 col in m_cmcache.Columns) 897 | m_cmcache.Columns.Remove(col); 898 | RunWrap.IDTSConnectionManagerCacheColumns100 cacheCols = m_cmcache.GetFileColumns(ConnectionString); 899 | for (int i = 0; i < cacheCols.Count; i++) 900 | { 901 | RunWrap.IDTSConnectionManagerCacheColumn100 col = m_cmcache.Columns.Add(); 902 | col.Length = cacheCols[i].Length; 903 | col.Precision = cacheCols[i].Precision; 904 | col.Scale = cacheCols[i].Scale; 905 | col.DataType = cacheCols[i].DataType; 906 | col.CodePage = cacheCols[i].CodePage; 907 | col.IndexPosition = cacheCols[i].IndexPosition; 908 | ((RunWrap.IDTSName100)col).Name = ((RunWrap.IDTSName100)cacheCols[i]).Name; 909 | } 910 | } 911 | 912 | public void SetIndexCols(params string[] cols) 913 | { 914 | if (cols == null) 915 | return; 916 | for (int i = 0; i < cols.Length; i++) 917 | CacheCols[cols[i]].IndexPosition = i + 1; 918 | } 919 | } 920 | 921 | [ConnMgrID("SMOServer")] 922 | public class EzSMOServerCM : EzConnectionManager 923 | { 924 | public EzSMOServerCM(EzPackage parent) : base(parent) { } 925 | public EzSMOServerCM(EzPackage parent, string name) : base(parent, name) { } 926 | public EzSMOServerCM(EzPackage parent, ConnectionManager c) : base(parent, c) { } 927 | 928 | public string SqlServerName 929 | { 930 | get { return (string)m_conn.Properties["SqlServerName"].GetValue(m_conn); } 931 | set { m_conn.Properties["SqlServerName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 932 | } 933 | 934 | public string UserName 935 | { 936 | get { return (string)m_conn.Properties["UserName"].GetValue(m_conn); } 937 | set { m_conn.Properties["UserName"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 938 | } 939 | 940 | public string Password 941 | { 942 | get { return (string)m_conn.Properties["Password"].GetValue(m_conn); } 943 | set { m_conn.Properties["Password"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 944 | } 945 | 946 | public string DataSourceID 947 | { 948 | get { return (string)m_conn.Properties["DataSourceID"].GetValue(m_conn); } 949 | set { m_conn.Properties["DataSourceID"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 950 | } 951 | 952 | public bool UseWindowsAuthentication 953 | { 954 | get { return (bool)m_conn.Properties["UseWindowsAuthentication"].GetValue(m_conn); } 955 | set { m_conn.Properties["UseWindowsAuthentication"].SetValue(m_conn, value); Parent.ReinitializeMetaData(); } 956 | } 957 | } 958 | } 959 | -------------------------------------------------------------------------------- /EzExecutables.cs: -------------------------------------------------------------------------------- 1 | // Copyright � Microsoft Corporation. All Rights Reserved. 2 | // This code released under the terms of the 3 | // Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) 4 | 5 | 6 | using Microsoft.SqlServer.Dts.Pipeline.Wrapper; 7 | using Microsoft.SqlServer.Dts.Runtime; 8 | using Microsoft.SqlServer.Dts.Tasks.ExecutePackageTask; 9 | using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask; 10 | using Microsoft.SqlServer.Dts.Tasks.FileSystemTask; 11 | using Microsoft.SqlServer.Dts.Tasks.TransferDatabaseTask; 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Collections.ObjectModel; 15 | using System.Diagnostics; 16 | using System.Globalization; 17 | using System.IO; 18 | using System.Reflection; 19 | using System.Runtime.Serialization; 20 | using SMO = Microsoft.SqlServer.Management.Smo; 21 | 22 | namespace Microsoft.SqlServer.SSIS.EzAPI 23 | { 24 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 25 | public sealed class ExecIDAttribute : Attribute 26 | { 27 | private string m_id; 28 | public ExecIDAttribute(string id) 29 | { 30 | m_id = id; 31 | } 32 | public string ID { get { return m_id; } } 33 | } 34 | 35 | [Serializable] 36 | public class IncorrectAssignException : Exception 37 | { 38 | public IncorrectAssignException() : base() { } 39 | public IncorrectAssignException(string message) : base(message) { } 40 | protected IncorrectAssignException(SerializationInfo info, StreamingContext context) : base(info, context) { } 41 | public IncorrectAssignException(string message, Exception innerException) : base(message, innerException) { } 42 | } 43 | 44 | [Serializable] 45 | public class ExecutableException : Exception 46 | { 47 | public ExecutableException() : base() { } 48 | public ExecutableException(string message) : base(message) { } 49 | protected ExecutableException(SerializationInfo info, StreamingContext context) : base(info, context) { } 50 | public ExecutableException(string message, Exception innerException) : base(message, innerException) { } 51 | } 52 | 53 | public class EzExecutable 54 | { 55 | protected EzPackage m_pkg; 56 | protected Executable m_exec; 57 | protected EzContainer m_parent; 58 | public EzContainer Parent { get {return m_parent; } } 59 | public EzPackage Package { get { return m_pkg; } } 60 | 61 | public string GetExecID() 62 | { 63 | object[] execids = GetType().GetCustomAttributes(typeof(ExecIDAttribute), true); 64 | if (execids.Length == 0) 65 | return null; 66 | return (execids[0] as ExecIDAttribute).ID; 67 | } 68 | 69 | public static string GetEzDescription(string desc) 70 | { 71 | if (string.IsNullOrEmpty(desc) || !desc.Contains("")) 72 | return desc; 73 | return desc.Substring(desc.IndexOf("", StringComparison.Ordinal) + 9); 74 | } 75 | 76 | protected static bool CompareEzDescription(string ezdesc, string ezname) 77 | { 78 | if (ezdesc == null || !ezdesc.Contains("")) 79 | return false; 80 | int start = ezdesc.IndexOf("", StringComparison.Ordinal) + 8; 81 | int end = ezdesc.IndexOf("", StringComparison.Ordinal); 82 | if (end < 0) 83 | end = ezdesc.Length; 84 | return ezdesc.Substring(start, end - start) == ezname; 85 | } 86 | 87 | public virtual EzExecutable Assign(EzContainer parent, Executable e) 88 | { 89 | if (e == null) 90 | throw new IncorrectAssignException(string.Format("Null cannot be assigned to {0} object.", GetType().Name)); 91 | EzPackage test = this as EzPackage; 92 | if (parent == null && test == null) 93 | throw new IncorrectAssignException("Cannot assign executable as parent is not specified."); 94 | if (parent != null && test != null) 95 | throw new IncorrectAssignException("Cannot set parent for EzPackage object."); 96 | m_pkg = parent == null ? test : parent.Package; 97 | m_exec = e; 98 | m_parent = parent; 99 | TaskHost th = m_exec as TaskHost; 100 | if (th != null) 101 | { 102 | if (!th.CreationName.ToUpper(CultureInfo.InvariantCulture).Contains(GetExecID().ToUpper(CultureInfo.InvariantCulture))) 103 | throw new IncorrectAssignException(string.Format("Cannot assign task with creation name {0}. Expected {1}.", th.CreationName, GetExecID())); 104 | } 105 | else 106 | { 107 | DtsContainer dc = m_exec as DtsContainer; 108 | if (dc != null && !(m_exec is Package)) 109 | if (!dc.CreationName.ToUpper(CultureInfo.InvariantCulture).Contains(GetExecID().ToUpper(CultureInfo.InvariantCulture))) 110 | throw new IncorrectAssignException(string.Format("Cannot assign task with creation name {0}. Expected {1}.", dc.CreationName, GetExecID())); 111 | } 112 | return this; 113 | } 114 | 115 | private string GetEzName(EzContainer p) 116 | { 117 | FieldInfo[] m = p.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 118 | foreach (FieldInfo mi in m) 119 | { 120 | EzExecutable cur = mi.GetValue(p) as EzExecutable; 121 | if (cur == null) 122 | continue; 123 | EzTask t = cur as EzTask; 124 | string curID = t != null ? t.ID : (cur as EzContainer).ID; 125 | t = this as EzTask; 126 | string thisID = t != null ? t.ID : (this as EzContainer).ID; 127 | if (curID == thisID) 128 | return mi.Name; 129 | } 130 | return null; 131 | } 132 | 133 | public string EzName 134 | { 135 | get 136 | { 137 | EzContainer p = Parent; 138 | while (p != null) 139 | { 140 | string res = GetEzName(p); 141 | if (!string.IsNullOrEmpty(res)) 142 | return res; 143 | p = p.Parent; 144 | } 145 | return null; 146 | } 147 | } 148 | 149 | public static implicit operator Executable(EzExecutable e) 150 | { 151 | if (e == null) 152 | return null; 153 | return e.m_exec; 154 | } 155 | 156 | public EzExecutable(EzContainer parent, Executable e) 157 | { 158 | Assign(parent, e); 159 | if (parent != null) 160 | parent.m_ezexecs.Add(this); 161 | } 162 | 163 | public EzExecutable(EzContainer parent) 164 | { 165 | EzPackage cur = this as EzPackage; 166 | if (parent == null && cur == null) 167 | throw new IncorrectAssignException("Cannot assign executable as parent is not specified."); 168 | if (parent != null && cur != null) 169 | throw new ExecutableException("Cannot set parent for EzPackage object."); 170 | m_parent = parent; 171 | m_pkg = cur != null ? cur : parent.Package; 172 | m_exec = CreateExecutable(); 173 | if (parent != null) 174 | parent.m_ezexecs.Add(this); 175 | } 176 | 177 | public string ID 178 | { 179 | get 180 | { 181 | TaskHost th = m_exec as TaskHost; 182 | if (th != null) 183 | return th.ID; 184 | else 185 | { 186 | DtsContainer c = m_exec as DtsContainer; 187 | if (c != null) 188 | return c.ID; 189 | else 190 | return null; 191 | } 192 | } 193 | } 194 | 195 | protected virtual Executable CreateExecutable() 196 | { 197 | return Parent.Executables.Add(GetExecID()); 198 | } 199 | 200 | public void AttachTo(EzExecutable e) 201 | { 202 | Parent.PrecedenceConstraints.Add(e, this); 203 | } 204 | 205 | public void Detatch() 206 | { 207 | foreach (PrecedenceConstraint p in Parent.PrecedenceConstraints) 208 | { 209 | string curid; 210 | if (p.ConstrainedExecutable is TaskHost) 211 | curid = (p.ConstrainedExecutable as TaskHost).ID; 212 | else 213 | curid = (p.ConstrainedExecutable as DtsContainer).ID; 214 | if (curid == ID) 215 | Parent.PrecedenceConstraints.Remove(p); 216 | } 217 | } 218 | } 219 | 220 | public class EzContainer: EzExecutable 221 | { 222 | protected Executables m_execs; 223 | protected DtsContainer host { get { return (DtsContainer)m_exec; } } 224 | 225 | public PrecedenceConstraints PrecedenceConstraints { get { return ((IDTSSequence)m_exec).PrecedenceConstraints; } } 226 | 227 | protected void RecreateExecutables() 228 | { 229 | IDTSSequence s = ((DtsContainer)this) as IDTSSequence; 230 | if (s == null) 231 | throw new ExecutableException("Containers that do not implement IDTSSequence are not supported."); 232 | m_execs = s.Executables; 233 | } 234 | 235 | public override EzExecutable Assign(EzContainer parent, Executable e) 236 | { 237 | base.Assign(parent, e); 238 | RecreateExecutables(); 239 | if (parent == null && (e is Package)) 240 | parent = this; 241 | while (parent != null) 242 | { 243 | InternalAssign(parent); 244 | parent = parent.Parent; 245 | } 246 | CheckAllMembersAssigned(this); 247 | return this; 248 | } 249 | 250 | private void InternalAssign(EzContainer c) 251 | { 252 | FieldInfo[] m = c.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 253 | foreach (FieldInfo mi in m) 254 | { 255 | object cur = mi.GetValue(c); 256 | if (mi.FieldType.IsSubclassOf(typeof(EzExecutable))) 257 | { 258 | foreach (Executable e in Executables) 259 | { 260 | if (((e is TaskHost) && CompareEzDescription((e as TaskHost).Description, mi.Name)) || 261 | ((e is DtsContainer) && CompareEzDescription((e as DtsContainer).Description, mi.Name))) 262 | { 263 | if (cur == null) 264 | { 265 | cur = Activator.CreateInstance(mi.FieldType, new object[] { c, e }); 266 | mi.SetValue(c, cur); 267 | } 268 | else 269 | (cur as EzExecutable).Assign(c, e); 270 | break; 271 | } 272 | } 273 | } 274 | else if (mi.FieldType.IsSubclassOf(typeof(EzConnectionManager))) 275 | { 276 | foreach (ConnectionManager cm in c.Package.Connections) 277 | { 278 | if (CompareEzDescription(cm.Description, mi.Name)) 279 | { 280 | if (cur == null) 281 | { 282 | cur = Activator.CreateInstance(mi.FieldType, new object[] { c.Package, cm }); 283 | mi.SetValue(c, cur); 284 | } 285 | else 286 | (cur as EzConnectionManager).Assign(c.Package, cm); 287 | break; 288 | } 289 | } 290 | } 291 | } 292 | } 293 | 294 | public static void CheckAllMembersAssigned(EzContainer c) 295 | { 296 | if (c == null) 297 | throw new ArgumentNullException("c"); 298 | FieldInfo[] m = c.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 299 | foreach (FieldInfo mi in m) 300 | { 301 | object cur = mi.GetValue(c); 302 | if (mi.FieldType.IsSubclassOf(typeof(EzExecutable)) && mi.FieldType != typeof(EzPackage) && !mi.FieldType.IsSubclassOf(typeof(EzPackage))) 303 | { 304 | if (cur == null || (cur as EzExecutable).Parent.ID != c.ID) 305 | throw new IncorrectAssignException(string.Format("Cannot assign package. Member {0} cannot be assigned", mi.Name)); 306 | } 307 | else if (mi.FieldType.IsSubclassOf(typeof(EzConnectionManager))) 308 | { 309 | if (cur == null || (cur as EzConnectionManager).Parent.ID != c.Package.ID) 310 | throw new IncorrectAssignException(string.Format("Cannot assign package. Member {0} cannot be assigned", mi.Name)); 311 | } 312 | else if (mi.FieldType.IsSubclassOf(typeof(EzComponent))) 313 | { 314 | if (cur == null || (cur as EzComponent).Parent.Package.ID != c.Package.ID) 315 | throw new IncorrectAssignException(string.Format("Cannot assign package. Member {0} cannot be assigned", mi.Name)); 316 | } 317 | } 318 | } 319 | 320 | public EzContainer(EzContainer parent, DtsContainer c) : base(parent, (Executable)c) { } 321 | public EzContainer(EzContainer parent) : base(parent) { RecreateExecutables(); } 322 | 323 | public static implicit operator DtsContainer(EzContainer c) 324 | { 325 | if (c == null) 326 | return null; 327 | return (DtsContainer)c.m_exec; 328 | } 329 | 330 | public string Description { 331 | get { return GetEzDescription(host.Description); } 332 | set { host.Description = string.Format("{0}{1}", EzName, value); } 333 | } 334 | 335 | public string Name { get { return host.Name; } set { host.Name = value; } } 336 | public DTSExecResult ExecutionResult { get { return host.ExecutionResult; } } 337 | public string CreationName { get { return host.CreationName; } } 338 | public DTSExecStatus ExecutionStatus { get { return host.ExecutionStatus; } } 339 | public int ExecutionDuration { get { return host.ExecutionDuration; } } 340 | public bool FailPackageOnFailure { get { return host.FailPackageOnFailure; } } 341 | public DTSForcedExecResult ForceExecutionResult { get { return host.ForceExecutionResult; } set { host.ForceExecutionResult = value; } } 342 | public bool ForceExecutionValue { get { return host.ForceExecutionValue; } set { host.ForceExecutionValue = value; } } 343 | public object ForcedExecutionValue { get { return host.ForcedExecutionValue; } set { host.ForcedExecutionValue = value; } } 344 | public bool IsDefaultLocaleID { get { return host.IsDefaultLocaleID; } } 345 | public int LocaleID { get { return host.LocaleID; } set { host.LocaleID = value; } } 346 | public DTSLoggingMode LoggingMode { get { return host.LoggingMode; } set { host.LoggingMode = value; } } 347 | public LoggingOptions LoggingOptions { get { return host.LoggingOptions; } } 348 | public int MaxErrorCount { get { return host.MaximumErrorCount; } set { host.MaximumErrorCount = value; } } 349 | public LogEntryInfos LogEntryInfos { get { return host.LogEntryInfos; } } 350 | public Executables Executables { get { return m_execs; } } 351 | public Variables Variables { get { return host.Variables; } } 352 | public bool Disable { get { return host.Disable; } set { host.Disable = value; } } 353 | 354 | public bool DelayValidation 355 | { 356 | get { return host.DelayValidation; } 357 | set { host.DelayValidation = value; } 358 | } 359 | 360 | public void ReinitializeMetaData() 361 | { 362 | foreach (EzExecutable e in EzExecs) 363 | { 364 | EzDataFlow df = e as EzDataFlow; 365 | if (df != null) 366 | { 367 | df.ReinitializeMetaData(); 368 | continue; 369 | } 370 | EzContainer c = e as EzContainer; 371 | if (c != null) 372 | c.ReinitializeMetaData(); 373 | } 374 | } 375 | 376 | internal List m_ezexecs = new List(); 377 | public ReadOnlyCollection EzExecs { get { return new ReadOnlyCollection(m_ezexecs); } } 378 | } 379 | 380 | [ExecID("STOCK:FORLOOP")] 381 | public class EzForLoop : EzContainer 382 | { 383 | public EzForLoop(EzContainer parent, DtsContainer c) : base(parent, c) { } 384 | public EzForLoop(EzContainer parent) : base(parent) { RecreateExecutables(); } 385 | 386 | public string AssignExpression 387 | { 388 | get { return (m_exec as ForLoop).AssignExpression; } 389 | set { (m_exec as ForLoop).AssignExpression = value; } 390 | } 391 | 392 | public string EvalExpression 393 | { 394 | get { return (m_exec as ForLoop).EvalExpression; } 395 | set { (m_exec as ForLoop).EvalExpression = value; } 396 | } 397 | 398 | public string InitExpression 399 | { 400 | get { return (m_exec as ForLoop).InitExpression; } 401 | set { (m_exec as ForLoop).InitExpression = value; } 402 | } 403 | } 404 | 405 | [ExecID("STOCK:SEQUENCE")] 406 | public class EzSequence : EzContainer 407 | { 408 | public EzSequence(EzContainer parent, DtsContainer c) : base(parent, c) { } 409 | public EzSequence(EzContainer parent) : base(parent) { RecreateExecutables(); } 410 | 411 | private DtsProperties props 412 | { 413 | get { return (m_exec as Sequence).Properties; } 414 | } 415 | 416 | public void SetExpression(string property, string expression) 417 | { 418 | props[property].SetExpression(m_exec,expression); 419 | } 420 | } 421 | 422 | // Represents the seven different types of For Each enumerators 423 | public enum ForEachEnumeratorType 424 | { 425 | ForEachFileEnumerator = 0, 426 | ForEachItemEnumerator = 1, 427 | ForEachADOEnumerator = 2, 428 | ForEachADONETSchemaRowsetEnumerator = 3, 429 | ForEachFromVariableEnumerator = 4, 430 | ForEachNodeListEnumerator = 5, 431 | ForEachSMOEnumerator = 6 432 | } 433 | 434 | /// 435 | /// Enumeration of OLE-DB types, used when mapping OLE-DB parameters. 436 | /// Adapted from: 437 | /// http://www.sqlis.com/sqlis/post/Execute-SQL-Task-in-Code.aspx 438 | /// 439 | public enum OleDBDataTypes 440 | { 441 | BYTE = 17, 442 | CURRENCY = 6, 443 | DATE = 7, 444 | DBDATE = 133, 445 | DBTIME = 134, 446 | DBTIMESTAMP = 135, 447 | DB_VARNUMERIC = 139, 448 | DECIMAL = 14, 449 | DOUBLE = 5, 450 | FILETIME = 64, 451 | FLOAT = 4, 452 | GUID = 72, 453 | LARGE_INTEGER = 20, 454 | LONG = 3, 455 | NULL = 1, 456 | NUMERIC = 131, 457 | NVARCHAR = 130, 458 | SHORT = 2, 459 | SIGNEDCHAR = 16, 460 | ULARGE_INTEGER = 21, 461 | ULONG = 19, 462 | USHORT = 18, 463 | VARCHAR = 129, 464 | VARIANT_BOOL = 11 465 | } 466 | 467 | [ExecID("STOCK:FOREACHLOOP")] 468 | public class EzForEachLoop : EzContainer 469 | { 470 | public EzForEachLoop(EzContainer parent, DtsContainer c) : base(parent, c) { } 471 | public EzForEachLoop(EzContainer parent) : base(parent) { RecreateExecutables(); } 472 | 473 | public ForEachEnumeratorHost ForEachEnumerator 474 | { 475 | get { return (m_exec as ForEachLoop).ForEachEnumerator; } 476 | set { (m_exec as ForEachLoop).ForEachEnumerator = value; } 477 | } 478 | 479 | /* 480 | * Expose variables: http://stackoverflow.com/a/15617882 481 | */ 482 | public ForEachVariableMappings VariableMappings 483 | { 484 | get { return (m_exec as ForEachLoop).VariableMappings; } 485 | 486 | } 487 | 488 | /* 489 | * Returns the string representation of the given type of For Each enumerator 490 | */ 491 | private string GetEnumerator(ForEachEnumeratorType enumeratorType) 492 | { 493 | string enumString = string.Empty; 494 | switch (enumeratorType) 495 | { 496 | case ForEachEnumeratorType.ForEachFileEnumerator: 497 | enumString = "Foreach File Enumerator"; 498 | break; 499 | case ForEachEnumeratorType.ForEachItemEnumerator: 500 | enumString = "Foreach Item Enumerator"; 501 | break; 502 | case ForEachEnumeratorType.ForEachADOEnumerator: 503 | enumString = "Foreach ADO Enumerator"; 504 | break; 505 | case ForEachEnumeratorType.ForEachADONETSchemaRowsetEnumerator: 506 | enumString = "Foreach ADO.NET Schema Rowset Enumerator"; 507 | break; 508 | case ForEachEnumeratorType.ForEachFromVariableEnumerator: 509 | enumString = "Foreach From Variable Enumerator"; 510 | break; 511 | case ForEachEnumeratorType.ForEachNodeListEnumerator: 512 | enumString = "Foreach NodeList Enumerator"; 513 | break; 514 | case ForEachEnumeratorType.ForEachSMOEnumerator: 515 | enumString = "Foreach SMO Enumerator"; 516 | break; 517 | default: 518 | enumString = "Foreach File Enumerator"; 519 | break; 520 | } 521 | return enumString; 522 | } 523 | 524 | /* 525 | * Based on the argument enumeratorType, initializes the ForEachEnumerator property 526 | * and sets a value to the enumerator's CollectionEnumerator property. 527 | */ 528 | public void Initialize(ForEachEnumeratorType enumeratorType) 529 | { 530 | ForEachEnumerator = (new Application()).ForEachEnumeratorInfos[GetEnumerator(enumeratorType)].CreateNew(); 531 | ForEachEnumerator.CollectionEnumerator = enumeratorType == ForEachEnumeratorType.ForEachItemEnumerator 532 | || enumeratorType == ForEachEnumeratorType.ForEachADOEnumerator 533 | || enumeratorType == ForEachEnumeratorType.ForEachNodeListEnumerator; 534 | RecreateExecutables(); 535 | } 536 | 537 | public void Initialize() 538 | { 539 | Initialize(ForEachEnumeratorType.ForEachFileEnumerator); 540 | } 541 | } 542 | 543 | /// 544 | ///This is a base package class to use when dynamically constructing packages 545 | /// 546 | public class EzPackage: EzContainer 547 | { 548 | public EzPackage() : base((EzContainer)null) { } 549 | public EzPackage(Package p) : base(null, (DtsContainer)p) { } 550 | 551 | protected void SetEzNames() 552 | { 553 | FieldInfo[] m = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 554 | foreach (FieldInfo mi in m) 555 | { 556 | object cur = mi.GetValue(this); 557 | if (cur == null) 558 | continue; 559 | EzTask curTask = cur as EzTask; 560 | EzConnectionManager curCM = cur as EzConnectionManager; 561 | EzComponent curComp = cur as EzComponent; 562 | EzDataFlow curDF = cur as EzDataFlow; 563 | EzContainer curCont = cur as EzContainer; 564 | if (curTask != null) 565 | { 566 | curTask.Description = curTask.Description; // This will set EzNames 567 | if (curDF != null) 568 | curDF.SetEzNames(); 569 | } 570 | else if (curCont != null) 571 | curCont.Description = curCont.Description; // This will set EzNames 572 | else if (curCM != null) 573 | curCM.Description = curCM.Description; // This will set EzNames 574 | } 575 | } 576 | 577 | protected override Executable CreateExecutable() 578 | { 579 | return new Package(); 580 | } 581 | 582 | public static implicit operator Package(EzPackage p) 583 | { 584 | if (p == null) 585 | return null; 586 | p.SetEzNames(); 587 | return (Package)p.m_exec; 588 | } 589 | 590 | public static implicit operator EzPackage(Package p) 591 | { 592 | if (p == null) 593 | return null; 594 | return new EzPackage(p); 595 | } 596 | 597 | public Connections Connections { get { return (m_exec as Package).Connections; } } 598 | //public PrecedenceConstraints PrecedenceConstraints { get { return (m_exec as Package).PrecedenceConstraints; } } 599 | 600 | public bool ConnectionExists(string name) 601 | { 602 | foreach (ConnectionManager cm in ((Package)m_exec).Connections) 603 | if (cm.Name == name) 604 | return true; 605 | return false; 606 | } 607 | 608 | public DTSExecResult Execute() { return (m_exec as Package).Execute(); } 609 | public DTSExecResult Execute(IDTSEvents events) { return (m_exec as Package).Execute(null, null, events, null, null); } 610 | public DTSExecResult Execute(Connections connections, Variables variables, IDTSEvents events, IDTSLogging log, object transaction) 611 | { 612 | return (m_exec as Package).Execute(connections, variables, events, log, transaction); 613 | } 614 | 615 | public void SaveToFile(string fileName) 616 | { 617 | SaveToFile(fileName, null); 618 | } 619 | 620 | public void SaveToFile(string fileName, IDTSEvents events) 621 | { 622 | File.WriteAllText(fileName, SaveToXML(events)); 623 | } 624 | 625 | public string SaveToXML() 626 | { 627 | return SaveToXML(null); 628 | } 629 | 630 | public string SaveToXML(IDTSEvents events) 631 | { 632 | SetEzNames(); 633 | string xml; 634 | (m_exec as Package).SaveToXML(out xml, events); 635 | return xml; 636 | } 637 | 638 | public void LoadFromXML(string xml) 639 | { 640 | LoadFromXML(xml, null); 641 | } 642 | 643 | public void LoadFromXML(string xml, IDTSEvents events) 644 | { 645 | Package p = new Package(); 646 | p.LoadFromXML(xml, events); 647 | Assign(null, p); 648 | } 649 | 650 | public void LoadFromFile(string fileName) 651 | { 652 | LoadFromFile(fileName, null); 653 | } 654 | 655 | public void LoadFromFile(string fileName, IDTSEvents events) 656 | { 657 | LoadFromXML(File.ReadAllText(fileName), events); 658 | } 659 | 660 | public DtsErrors Errors { get { return (m_exec as Package).Errors; } } 661 | 662 | //Paul Rizza - https://blogs.msdn.microsoft.com/paulrizza/2014/07/14/ssis-2012-ezapi-basic-intro/ 663 | public Microsoft.SqlServer.Dts.Runtime.Configurations Configurations 664 | { 665 | get { return (m_exec as Package).Configurations; } 666 | } 667 | 668 | public bool EnableConfigurations 669 | { 670 | get { return (m_exec as Package).EnableConfigurations; } 671 | set { (m_exec as Package).EnableConfigurations = value; } 672 | } 673 | 674 | public DtsEventHandlers EventHandlers 675 | { 676 | get { return (m_exec as Package).EventHandlers; } 677 | } 678 | } 679 | 680 | public class EzExpressionIndexer 681 | { 682 | private EzTask m_eztask; 683 | public EzExpressionIndexer(EzTask atask) { m_eztask = atask; } 684 | public string this[string propname] 685 | { 686 | get { return ((TaskHost)m_eztask).GetExpression(propname); } 687 | set { ((TaskHost)m_eztask).SetExpression(propname, value); } 688 | } 689 | } 690 | 691 | public class EzTask: EzExecutable 692 | { 693 | private EzExpressionIndexer m_exprIndexer; 694 | protected TaskHost host { get {return (TaskHost)m_exec; } } 695 | 696 | public static implicit operator TaskHost(EzTask t) 697 | { 698 | if (t == null) 699 | return null; 700 | return (TaskHost)t.m_exec; 701 | } 702 | 703 | public EzTask(EzContainer parent) : base(parent) { } 704 | public EzTask(EzContainer parent, TaskHost t) : base(parent, (Executable)t) { } 705 | 706 | public string Description 707 | { 708 | get { return GetEzDescription(host.Description); } 709 | set { host.Description = string.Format("{0}{1}", EzName, value); } 710 | } 711 | 712 | public string Name { get { return host.Name; } set {host.Name = value; } } 713 | public DTSExecResult ExecutionResult { get { return host.ExecutionResult; } } 714 | public string CreationName { get { return host.CreationName; } } 715 | public DTSExecStatus ExecutionStatus { get { return host.ExecutionStatus; } } 716 | public int ExecutionDuration { get { return host.ExecutionDuration; } } 717 | public object ExecutionValue { get { return host.ExecutionValue; } } 718 | public bool FailPackageOnFailure { get { return host.FailPackageOnFailure; } } 719 | public DTSForcedExecResult ForceExecutionResult { get {return host.ForceExecutionResult; } set { host.ForceExecutionResult = value; } } 720 | public bool ForceExecutionValue { get { return host.ForceExecutionValue; } set { host.ForceExecutionValue = value; } } 721 | public object ForcedExecutionValue { get { return host.ForcedExecutionValue; } set { host.ForcedExecutionValue = value; } } 722 | public bool IsDefaultLocaleID { get { return host.IsDefaultLocaleID; } } 723 | public int LocaleID { get {return host.LocaleID; } set { host.LocaleID = value; } } 724 | public string PackagePath { get { return host.GetPackagePath(); } } 725 | public DTSLoggingMode LoggingMode { get { return host.LoggingMode; } set {host.LoggingMode = value; } } 726 | public LoggingOptions LoggingOptions { get { return host.LoggingOptions; } } 727 | public int MaxErrorCount { get { return host.MaximumErrorCount; } set { host.MaximumErrorCount = value; } } 728 | public LogEntryInfos LogEntryInfos {get { return host.LogEntryInfos; } } 729 | public Variables Variables { get { return host.Variables; } } 730 | public bool Disable { get { return host.Disable; } set { host.Disable = value; } } 731 | public void SetExpression(string property, string expression) 732 | { 733 | host.Properties[property].SetExpression(host, expression); 734 | } 735 | 736 | public bool DelayValidation 737 | { 738 | get { return host.DelayValidation; } 739 | set { host.DelayValidation = value; } 740 | } 741 | 742 | public DTSTransactionOption TransactionOption 743 | { 744 | get { return host.TransactionOption; } 745 | set { host.TransactionOption = value; } 746 | } 747 | 748 | public EzExpressionIndexer Expression 749 | { 750 | get 751 | { 752 | if (m_exprIndexer == null) 753 | m_exprIndexer = new EzExpressionIndexer(this); 754 | return m_exprIndexer; 755 | } 756 | } 757 | } 758 | 759 | [ExecID("Microsoft.ExpressionTask")] 760 | public class EzExpressionTask : EzTask 761 | { 762 | public EzExpressionTask(EzContainer parent) : base(parent) { } 763 | 764 | public EzExpressionTask(EzContainer parent, TaskHost task) : base(parent, task) { } 765 | 766 | public void SetExpression(string expression) 767 | { 768 | host.Properties["Expression"].SetValue(host, expression); 769 | } 770 | } 771 | 772 | 773 | [ExecID("Microsoft.ExecutePackageTask")] 774 | public class EzExecPackage : EzTask 775 | { 776 | public EzExecPackage(EzContainer parent) : base(parent) { } 777 | public EzExecPackage(EzContainer parent, TaskHost task) : base(parent, task) { } 778 | 779 | public bool ExecOutOfProcess 780 | { 781 | get { return (bool)host.Properties["ExecuteOutOfProcess"].GetValue(host); } 782 | set { host.Properties["ExecuteOutOfProcess"].SetValue(host, value); } 783 | } 784 | 785 | public bool UseProjectReference 786 | { 787 | get { return (bool)host.Properties["UseProjectReference"].GetValue(host); } 788 | set { host.Properties["UseProjectReference"].SetValue(host, value); } 789 | } 790 | 791 | public string PackageName 792 | { 793 | get { return (string)host.Properties["PackageName"].GetValue(host); } 794 | set { host.Properties["PackageName"].SetValue(host, value); } 795 | } 796 | 797 | public string PackagePassword 798 | { 799 | get { return (string)host.Properties["PackagePassword"].GetValue(host); } 800 | set { host.Properties["PackagePassword"].SetValue(host, value); } 801 | } 802 | 803 | public string PackageID 804 | { 805 | get { return (string)host.Properties["PackageID"].GetValue(host); } 806 | set { host.Properties["PackageID"].SetValue(host, value); } 807 | } 808 | 809 | public string VersionID 810 | { 811 | get { return (string)host.Properties["VersionID"].GetValue(host); } 812 | set { host.Properties["VersionID"].SetValue(host, value); } 813 | } 814 | 815 | protected EzConnectionManager m_connection; 816 | public EzConnectionManager Connection 817 | { 818 | get { return m_connection; } 819 | set 820 | { 821 | if (value == null) 822 | throw new ArgumentNullException("value"); 823 | if (value.CM.CreationName != "FILE" && value.CM.CreationName != "OLEDB") 824 | throw new IncorrectAssignException(string.Format("Cannot assign {0} connection to EzExecPackage task", value.CM.CreationName)); 825 | (host.InnerObject as IDTSExecutePackage100).Connection = value.Name; 826 | m_connection = value; 827 | } 828 | } 829 | 830 | public IDTSParameterAssignments ParameterAssignments 831 | { 832 | get { return (host.InnerObject as IDTSExecutePackage100).ParameterAssignments; } 833 | } 834 | } 835 | 836 | 837 | [ExecID("Microsoft.ExecuteSQLTask")] 838 | public class EzExecSqlTask : EzTask 839 | { 840 | public EzExecSqlTask(EzContainer parent) : base(parent) { InitializeTask(); } 841 | public EzExecSqlTask(EzContainer parent, TaskHost task) : base(parent, task) { InitializeTask(); } 842 | 843 | /* 844 | * Provides the component with the initial values assigned in the BIDS environment. 845 | */ 846 | private void InitializeTask() 847 | { 848 | TimeOut = 0; 849 | CodePage = 1252; 850 | ResultSetType = ResultSetType.ResultSetType_None; 851 | SqlStatementSourceType = SqlStatementSourceType.DirectInput; 852 | SqlStatementSource = string.Empty; 853 | BypassPrepare = true; 854 | } 855 | 856 | public uint TimeOut 857 | { 858 | get { return (uint)host.Properties["TimeOut"].GetValue(host); } 859 | set { host.Properties["TimeOut"].SetValue(host, value); } 860 | } 861 | 862 | public uint CodePage 863 | { 864 | get { return (uint)host.Properties["CodePage"].GetValue(host); } 865 | set { host.Properties["CodePage"].SetValue(host, value); } 866 | } 867 | 868 | 869 | public ResultSetType ResultSetType 870 | { 871 | get { return (ResultSetType)host.Properties["ResultSetType"].GetValue(host); } 872 | set { host.Properties["ResultSetType"].SetValue(host, value); } 873 | } 874 | 875 | protected EzConnectionManager m_connection; 876 | public EzConnectionManager Connection 877 | { 878 | get { return m_connection; } 879 | set 880 | { 881 | if (value == null) 882 | { 883 | throw new ArgumentNullException("Connection value"); 884 | } 885 | //if (value.CM.CreationName != "OLEDB") 886 | //{ 887 | // throw new IncorrectAssignException(string.Format("Cannot assign {0} connection to EzExecSqlTask", value.CM.CreationName)); 888 | //} 889 | //(host.InnerObject as ExecuteSQLTask).Connection = value.Name; 890 | host.Properties["Connection"].SetValue(host, value.Name); 891 | m_connection = value; 892 | } 893 | } 894 | 895 | public SqlStatementSourceType SqlStatementSourceType 896 | { 897 | get { return (SqlStatementSourceType)host.Properties["SqlStatementSourceType"].GetValue(host); } 898 | set { host.Properties["SqlStatementSourceType"].SetValue(host, value); } 899 | } 900 | 901 | //Different names between property and gui 902 | public bool IsQueryStoredProcedure 903 | { 904 | get { return (bool)host.Properties["IsStoredProcedure"].GetValue(host); } 905 | set { host.Properties["IsStoredProcedure"].SetValue(host, value); } 906 | } 907 | 908 | public string SqlStatementSource 909 | { 910 | get { return (string)host.Properties["SqlStatementSource"].GetValue(host); } 911 | set { host.Properties["SqlStatementSource"].SetValue(host, value); } 912 | } 913 | 914 | 915 | public bool BypassPrepare 916 | { 917 | get { return (bool)host.Properties["BypassPrepare"].GetValue(host); } 918 | set { host.Properties["BypassPrepare"].SetValue(host, value); } 919 | } 920 | 921 | public IDTSParameterBindings ParameterBindings 922 | { 923 | get { return (host.InnerObject as ExecuteSQLTask).ParameterBindings; } 924 | } 925 | 926 | public IDTSResultBindings ResultBindings 927 | { 928 | get { return (host.InnerObject as ExecuteSQLTask).ResultSetBindings; } 929 | } 930 | } 931 | 932 | [ExecID("Microsoft.Pipeline")] 933 | public class EzDataFlow : EzTask 934 | { 935 | internal List m_components = new List(); 936 | public ReadOnlyCollection Components { get { return new ReadOnlyCollection(m_components); } } 937 | 938 | public EzDataFlow(EzContainer parent) : base(parent) { } 939 | public EzDataFlow(EzContainer parent, TaskHost pipe) : base(parent, pipe) { } 940 | 941 | public MainPipe DataFlow { get { return (MainPipe)host.InnerObject; } } 942 | 943 | public bool AutoAdjustBufferSize 944 | { 945 | get { return ((IDTSPipeline130)DataFlow).AutoAdjustBufferSize; } 946 | set { ((IDTSPipeline130)DataFlow).AutoAdjustBufferSize = value; } 947 | } 948 | 949 | public void DeleteComponent(int ID) 950 | { 951 | for (int i = 0; i < Components.Count; i++) 952 | if (Components[i].ID == ID) 953 | { 954 | m_components.RemoveAt(i); 955 | break; 956 | } 957 | DataFlow.ComponentMetaDataCollection.RemoveObjectByID(ID); 958 | } 959 | 960 | public void SetEzNames() 961 | { 962 | foreach (EzComponent c in Components) 963 | c.Description = c.Description; 964 | } 965 | 966 | private void AssignExecutable(EzExecutable ex) 967 | { 968 | FieldInfo[] m = ex.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 969 | foreach (FieldInfo mi in m) 970 | { 971 | if (mi.FieldType.IsSubclassOf(typeof(EzComponent))) 972 | { 973 | object cur = mi.GetValue(ex); 974 | foreach (IDTSComponentMetaData100 c in DataFlow.ComponentMetaDataCollection) 975 | { 976 | if (CompareEzDescription(c.Description, mi.Name)) 977 | { 978 | if (cur == null) 979 | { 980 | cur = Activator.CreateInstance(mi.FieldType, new object[] { this, c }); 981 | mi.SetValue(ex, cur); 982 | } 983 | else 984 | (cur as EzComponent).Assign(this, c); 985 | break; 986 | } 987 | } 988 | } 989 | } 990 | } 991 | 992 | private void AssignConnectionManagers() 993 | { 994 | FieldInfo[] m = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 995 | foreach (FieldInfo mi in m) 996 | { 997 | if (mi.FieldType.IsSubclassOf(typeof(EzConnectionManager))) 998 | { 999 | object cur = mi.GetValue(this); 1000 | foreach (ConnectionManager c in Package.Connections) 1001 | { 1002 | if (CompareEzDescription(c.Description, mi.Name)) 1003 | { 1004 | if (cur == null) 1005 | { 1006 | cur = Activator.CreateInstance(mi.FieldType, new object[] { this, c }); 1007 | mi.SetValue(this, cur); 1008 | } 1009 | else 1010 | (cur as EzConnectionManager).Assign(Package, c); 1011 | break; 1012 | } 1013 | } 1014 | } 1015 | } 1016 | } 1017 | 1018 | public override EzExecutable Assign(EzContainer parent, Executable e) 1019 | { 1020 | base.Assign(parent, e); 1021 | EzContainer p = parent; 1022 | while (p != null) 1023 | { 1024 | AssignExecutable(p); 1025 | p = p.Parent; 1026 | } 1027 | AssignExecutable(this); 1028 | AssignConnectionManagers(); 1029 | return this; 1030 | } 1031 | 1032 | public void CheckAllMembersAssigned() 1033 | { 1034 | FieldInfo[] m = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); 1035 | foreach (FieldInfo mi in m) 1036 | { 1037 | object cur = mi.GetValue(this); 1038 | if (mi.FieldType.IsSubclassOf(typeof(EzComponent))) 1039 | { 1040 | if (cur == null || (cur as EzComponent).Parent.ID != ID) 1041 | throw new IncorrectAssignException(string.Format("Cannot assign dataflow. Member {0} cannot be assigned", mi.Name)); 1042 | } 1043 | } 1044 | } 1045 | 1046 | public void ReinitializeMetaData() 1047 | { 1048 | foreach (EzComponent c in Components) 1049 | if (c.Meta.InputCollection.Count == 0) 1050 | ReinitializeMetaData(c); 1051 | } 1052 | 1053 | public void ReinitializeMetaData(EzComponent c) 1054 | { 1055 | c.ReinitializeMetaDataNoCast(); 1056 | foreach (IDTSPath100 p in DataFlow.PathCollection) 1057 | { 1058 | if (p.StartPoint.Component.ID != c.Meta.ID) 1059 | continue; 1060 | foreach (EzComponent e in Components) 1061 | if (e.Meta.ID == p.EndPoint.Component.ID) 1062 | ReinitializeMetaData(e); 1063 | } 1064 | } 1065 | 1066 | public IDTSComponentMetaData100 ComponentByClassID(string classid, int number) 1067 | { 1068 | if (number < 0) 1069 | number = 0; 1070 | int cur = 0; 1071 | foreach (IDTSComponentMetaData100 m in DataFlow.ComponentMetaDataCollection) 1072 | { 1073 | if (string.Compare(m.ComponentClassID, classid, StringComparison.OrdinalIgnoreCase) == 0) 1074 | cur++; 1075 | if (cur - 1 == number) 1076 | return m; 1077 | } 1078 | return null; 1079 | } 1080 | } 1081 | 1082 | public class DBFile 1083 | { 1084 | protected EzTransferDBTask m_obj; 1085 | protected string m_file; 1086 | protected string m_folder; 1087 | protected string m_networkFileShare; 1088 | 1089 | public DBFile(EzTransferDBTask obj, string file, string folder, string netShare) 1090 | { 1091 | m_obj = obj; 1092 | m_file = (file == null)? "" : file; 1093 | m_folder = (folder == null)? "" : folder; 1094 | m_networkFileShare = (netShare == null)? "": netShare; 1095 | } 1096 | 1097 | public string File { get { return m_file; } } 1098 | public string Folder { get { return m_folder; } } 1099 | 1100 | public virtual string NetworkFileShare 1101 | { 1102 | get 1103 | { 1104 | return m_networkFileShare; 1105 | } 1106 | set 1107 | { 1108 | m_networkFileShare = value; 1109 | m_obj.UpdateDbFileListProperty(true); 1110 | } 1111 | } 1112 | } 1113 | 1114 | 1115 | public class DestDBFile : DBFile 1116 | { 1117 | //TODO: need to test the virtul propeties 1118 | internal DestDBFile(EzTransferDBTask obj, string destFile, string destFolder, string netShare) : base(obj, destFile, destFolder, netShare) { } 1119 | public new string File { get { return base.File; } set { m_file = value; m_obj.UpdateDbFileListProperty(false); } } 1120 | public new string Folder { get { return base.Folder; } set { m_folder = value; m_obj.UpdateDbFileListProperty(false); } } 1121 | public override string NetworkFileShare 1122 | { 1123 | get 1124 | { 1125 | return base.NetworkFileShare; 1126 | } 1127 | set 1128 | { 1129 | m_networkFileShare = value; 1130 | m_obj.UpdateDbFileListProperty(false); 1131 | } 1132 | } 1133 | } 1134 | 1135 | public class DestFileCollection : ReadOnlyCollection 1136 | { 1137 | private EzTransferDBTask m_obj; 1138 | 1139 | public DestFileCollection(IList list, EzTransferDBTask obj) : base(list) { m_obj = obj; } 1140 | public void Add(string fileName, string path, string share) 1141 | { 1142 | m_obj.m_DestDatabaseFiles.Add(new DestDBFile(m_obj, fileName, path, share)); 1143 | m_obj.UpdateDbFileListProperty(false); 1144 | } 1145 | } 1146 | 1147 | [ExecID("Microsoft.SqlServer.Dts.Tasks.TransferDatabaseTask.TransferDatabaseTask, Microsoft.SqlServer.TransferDatabasesTask, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")] 1148 | public class EzTransferDBTask : EzTask 1149 | { 1150 | public EzTransferDBTask(EzContainer parent) : base(parent) { } 1151 | public EzTransferDBTask(EzContainer parent, TaskHost task) : base(parent, task) { } 1152 | 1153 | public string DestinationDatabaseName 1154 | { 1155 | get { return (string)host.Properties["DestinationDatabaseName"].GetValue(host); } 1156 | set { host.Properties["DestinationDatabaseName"].SetValue(host, value); } 1157 | } 1158 | 1159 | internal List m_DestDatabaseFiles = new List(); 1160 | public DestFileCollection DestinationDatabaseFiles 1161 | { 1162 | get { return new DestFileCollection(m_DestDatabaseFiles, this); } 1163 | //set 1164 | //{ 1165 | // m_DestDatabaseFiles = new List(value); 1166 | // string propValue = GetStringValueOfDbFilesProperty(m_DestDatabaseFiles); 1167 | // host.Properties["DestinationDatabaseFiles"].SetValue(host, propValue); 1168 | //} 1169 | } 1170 | 1171 | public bool DestinationOverwrite 1172 | { 1173 | get { return (bool)host.Properties["DestinationOverwrite"].GetValue(host); } 1174 | set { host.Properties["DestinationOverwrite"].SetValue(host, value); } 1175 | } 1176 | 1177 | public bool ReattachSourceDatabase 1178 | { 1179 | get { return (bool)host.Properties["ReattachSourceDatabase"].GetValue(host); } 1180 | set { host.Properties["ReattachSourceDatabase"].SetValue(host, value); } 1181 | } 1182 | 1183 | 1184 | protected EzSMOServerCM m_srcconnection; 1185 | public EzSMOServerCM SrcConnection 1186 | { 1187 | get { return m_srcconnection; } 1188 | set 1189 | { 1190 | if (value == null) 1191 | throw new ArgumentNullException("value"); 1192 | (host.InnerObject as TransferDatabaseTask).SourceConnection = value.Name; 1193 | m_srcconnection = value; 1194 | } 1195 | } 1196 | 1197 | protected EzSMOServerCM m_destconnection; 1198 | public EzSMOServerCM DestConnection 1199 | { 1200 | get { return m_destconnection; } 1201 | set 1202 | { 1203 | if (value == null) 1204 | throw new ArgumentNullException("value"); 1205 | (host.InnerObject as TransferDatabaseTask).DestinationConnection = value.Name; 1206 | m_destconnection = value; 1207 | } 1208 | 1209 | } 1210 | 1211 | public TransferAction SrcDBAction 1212 | { 1213 | get { return (TransferAction)host.Properties["Action"].GetValue(host); } 1214 | set { host.Properties["Action"].SetValue(host, value); } 1215 | } 1216 | 1217 | public TransferMethod SrcDBMethod 1218 | { 1219 | get { return (TransferMethod)host.Properties["Method"].GetValue(host); } 1220 | set { host.Properties["Method"].SetValue(host, value); } 1221 | } 1222 | 1223 | public string SourceDatabaseName 1224 | { 1225 | get { return (string)host.Properties["SourceDatabaseName"].GetValue(host); } 1226 | set { host.Properties["SourceDatabaseName"].SetValue(host, value); ReinitializeSrcDbFileList(); } 1227 | } 1228 | 1229 | 1230 | 1231 | List m_sourceDatabaseFiles = new List(); 1232 | public ReadOnlyCollection SourceDatabaseFiles 1233 | { 1234 | get { return new ReadOnlyCollection(m_sourceDatabaseFiles); } 1235 | } 1236 | 1237 | private void ReinitializeSrcDbFileList() 1238 | { 1239 | if (m_sourceDatabaseFiles.Count != 0) 1240 | m_sourceDatabaseFiles.Clear(); 1241 | FillOutSourceDBFiles(); 1242 | UpdateDbFileListProperty(true); 1243 | } 1244 | 1245 | internal void UpdateDbFileListProperty(bool IsSource) 1246 | { 1247 | if (IsSource) 1248 | { 1249 | string value = GetStringValueOfDbFilesProperty(m_sourceDatabaseFiles); 1250 | host.Properties["SourceDatabaseFiles"].SetValue(host, value); 1251 | } 1252 | else 1253 | { 1254 | string value = GetStringValueOfDbFilesProperty(m_DestDatabaseFiles); 1255 | host.Properties["DestinationDatabaseFiles"].SetValue(host, value); 1256 | } 1257 | 1258 | } 1259 | 1260 | internal string GetStringValueOfDbFilesProperty (List collection) where T: DBFile 1261 | { 1262 | string value = ""; 1263 | foreach (DBFile dbFile in collection) 1264 | { 1265 | if (SrcDBMethod == TransferMethod.DatabaseOffline) 1266 | value += String.Format("\"{0}\",\"{1}\",\"{2}\";", dbFile.File, dbFile.Folder, dbFile.NetworkFileShare); 1267 | else 1268 | value += String.Format("\"{0}\",\"{1}\",\"\";", dbFile.File, dbFile.Folder); 1269 | } 1270 | 1271 | return value; 1272 | } 1273 | 1274 | 1275 | private void FillOutSourceDBFiles() 1276 | { 1277 | SMO.Server smoServer = null; 1278 | 1279 | if ((ConnectionManager)m_srcconnection == null) 1280 | { 1281 | throw new ExecutableException("The source connection is not specified"); 1282 | } 1283 | //if database name was not specified we throw 1284 | else if (string.IsNullOrEmpty(SourceDatabaseName)) 1285 | { 1286 | throw new ExecutableException("The source database name is not specified"); ; 1287 | } 1288 | else 1289 | { 1290 | try 1291 | { 1292 | 1293 | smoServer = ((ConnectionManager)m_srcconnection).AcquireConnection(null) as SMO.Server; 1294 | SMO.Database database = smoServer.Databases[SourceDatabaseName]; 1295 | if (database == null) 1296 | { 1297 | throw new ExecutableException("The specified database doesnot exist"); 1298 | } 1299 | 1300 | foreach (SMO.FileGroup fileGroup in database.FileGroups) 1301 | { 1302 | foreach (SMO.DataFile dataFile in fileGroup.Files) 1303 | { 1304 | AddRow(dataFile.FileName); 1305 | } 1306 | } 1307 | //let's do all the log files 1308 | foreach (SMO.LogFile logFile in database.LogFiles) 1309 | { 1310 | AddRow(logFile.FileName); 1311 | } 1312 | } 1313 | catch (Exception) { throw; } 1314 | 1315 | finally 1316 | { 1317 | //if the connection is opened let's close it 1318 | if (smoServer != null && smoServer.ConnectionContext.IsOpen) 1319 | { 1320 | smoServer.ConnectionContext.Disconnect(); 1321 | } 1322 | 1323 | //let's call ReleaseConnection on the connection mananger 1324 | if ((ConnectionManager)m_srcconnection != null) 1325 | { 1326 | ((ConnectionManager)m_srcconnection).ReleaseConnection(smoServer); 1327 | } 1328 | } 1329 | } 1330 | 1331 | } 1332 | 1333 | 1334 | /// 1335 | /// creates and add a row to the grid for the specified fileName 1336 | /// 1337 | private void AddRow(string fullFileName) 1338 | { 1339 | DBFile dbFile = new DBFile(this, Path.GetFileName(fullFileName), Path.GetDirectoryName(fullFileName), ""); 1340 | m_sourceDatabaseFiles.Add(dbFile); 1341 | } 1342 | } 1343 | 1344 | 1345 | [ExecID("Microsoft.SqlServer.Dts.Tasks.ExecuteProcess.ExecuteProcess, Microsoft.SqlServer.ExecProcTask,Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")] 1346 | public class EzExecProcessTask : EzTask 1347 | { 1348 | public EzExecProcessTask(EzContainer parent) : base(parent) { } 1349 | public EzExecProcessTask(EzContainer parent, TaskHost task) : base(parent, task) { } 1350 | 1351 | 1352 | public bool RequiredFullFileName 1353 | { 1354 | get { return (bool)host.Properties["RequireFullFileName"].GetValue(host); } 1355 | set { host.Properties["RequireFullFileName"].SetValue(host, value); } 1356 | } 1357 | 1358 | public string Executable 1359 | { 1360 | get { return (string)host.Properties["Executable"].GetValue(host); } 1361 | set { host.Properties["Executable"].SetValue(host, value); } 1362 | } 1363 | 1364 | public string Arguments 1365 | { 1366 | get { return (string)host.Properties["Arguments"].GetValue(host); } 1367 | set { host.Properties["Arguments"].SetValue(host, value); } 1368 | } 1369 | 1370 | public string WorkingDirectory 1371 | { 1372 | get { return (string)host.Properties["WorkingDirectory"].GetValue(host); } 1373 | set { host.Properties["WorkingDirectory"].SetValue(host, value); } 1374 | } 1375 | 1376 | public string StandarInputVariable 1377 | { 1378 | get { return (string)host.Properties["StandarInputVariable"].GetValue(host); } 1379 | set 1380 | { 1381 | if (host.Variables.Contains((string)value)) 1382 | host.Properties["StandarInputVariable"].SetValue(host, value); 1383 | else 1384 | throw new ExecutableException(string.Format("The specified variable {0} does not exist!", (string)value)); 1385 | } 1386 | } 1387 | 1388 | public string StandarOutputVariable 1389 | { 1390 | get { return (string)host.Properties["StandarOutputVariable"].GetValue(host); } 1391 | set 1392 | { 1393 | if (!host.Variables.Contains((string)value)) 1394 | throw new ExecutableException(string.Format("The specified variable {0} does not exist!", (string)value)); 1395 | host.Properties["StandarOutputVariable"].SetValue(host, value); 1396 | } 1397 | } 1398 | 1399 | public string StandarErrorVariable 1400 | { 1401 | get { return (string)host.Properties["StandarErrorVariable"].GetValue(host); } 1402 | set 1403 | { 1404 | if (!host.Variables.Contains((string)value)) 1405 | throw new ExecutableException(string.Format("The specified variable {0} does not exist!", (string)value)); 1406 | host.Properties["StandarErrorVariable"].SetValue(host, value); 1407 | } 1408 | } 1409 | 1410 | public bool FailTaskIfReturnCodeIsNotSuccessValue 1411 | { 1412 | get { return (bool)host.Properties["FailTaskIfReturnCodeIsNotSuccessValue"].GetValue(host); } 1413 | set { host.Properties["FailTaskIfReturnCodeIsNotSuccessValue"].SetValue(host, value); } 1414 | } 1415 | 1416 | public int SuccessValue 1417 | { 1418 | get { return (int)host.Properties["SuccessValue"].GetValue(host); } 1419 | set { host.Properties["SuccessValue"].SetValue(host, value); } 1420 | } 1421 | 1422 | public int TimeOut 1423 | { 1424 | get { return (int)host.Properties["TimeOut"].GetValue(host); } 1425 | set { host.Properties["TimeOut"].SetValue(host, value); } 1426 | } 1427 | 1428 | public bool TerminateProcessAfterTimeOut 1429 | { 1430 | get { return (bool)host.Properties["TerminateProcessAfterTimeOut"].GetValue(host); } 1431 | set 1432 | { 1433 | if (TimeOut != 0) 1434 | host.Properties["TerminateProcessAfterTimeOut"].SetValue(host, value); 1435 | } 1436 | } 1437 | 1438 | public ProcessWindowStyle WindowsStyle 1439 | { 1440 | get { return (ProcessWindowStyle)host.Properties["WindowsStyle"].GetValue(host); } 1441 | set { host.Properties["WindowsStyle"].SetValue(host, value); } 1442 | } 1443 | 1444 | } 1445 | 1446 | 1447 | [ExecID("Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask, Microsoft.SqlServer.FileSystemTask, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")] 1448 | public class EzFileSystemTask : EzTask 1449 | { 1450 | public EzFileSystemTask(EzContainer parent) : base(parent) { } 1451 | public EzFileSystemTask(EzContainer parent, TaskHost task) : base(parent, task) { } 1452 | 1453 | 1454 | public bool OverwriteDestination 1455 | { 1456 | get { return (bool)host.Properties["OverwriteDestination"].GetValue(host); } 1457 | set { host.Properties["OverwriteDestination"].SetValue(host, value); } 1458 | } 1459 | 1460 | public DTSFileSystemOperation Operation 1461 | { 1462 | get { return (DTSFileSystemOperation)host.Properties["Operation"].GetValue(host); } 1463 | set { host.Properties["Operation"].SetValue(host, value); } 1464 | } 1465 | 1466 | public bool IsDestinationPathVariable 1467 | { 1468 | get { return (bool)host.Properties["IsDestinationPathVariable"].GetValue(host); } 1469 | set { host.Properties["IsDestinationPathVariable"].SetValue(host, value); } 1470 | } 1471 | 1472 | public bool IsSourcePathVariable 1473 | { 1474 | get { return (bool)host.Properties["IsSourcePathVariable"].GetValue(host); } 1475 | set { host.Properties["IsSourcePathVariable"].SetValue(host, value); } 1476 | } 1477 | 1478 | protected EzFileCM m_destconnection; 1479 | public EzFileCM DestConnection 1480 | { 1481 | get { return m_destconnection; } 1482 | set 1483 | { 1484 | if (IsDestinationPathVariable) 1485 | throw new ExecutableException("The property \"IsDestinationPathVariable\" is set to True. Please specify a variable for the DestinationVariable"); 1486 | if (value == null) 1487 | throw new ArgumentNullException("value"); 1488 | (host.InnerObject as FileSystemTask).Destination = value.Name; 1489 | m_destconnection = value; 1490 | 1491 | } 1492 | 1493 | } 1494 | 1495 | protected EzFileCM m_srcconnection; 1496 | public EzFileCM SrcConnection 1497 | { 1498 | get { return m_srcconnection; } 1499 | set 1500 | { 1501 | if (IsDestinationPathVariable) 1502 | throw new ExecutableException("The property \"IsSourcePathVariable\" is set to True. Please specify a variable for the SourceVariable"); 1503 | if (value == null) 1504 | throw new ArgumentNullException("value"); 1505 | (host.InnerObject as FileSystemTask).Source = value.Name; 1506 | m_destconnection = value; 1507 | } 1508 | 1509 | } 1510 | 1511 | public string DestinationVariable 1512 | { 1513 | get { return (string)host.Properties["DestinationVariable"].GetValue(host); } 1514 | set 1515 | { 1516 | if (!IsDestinationPathVariable) 1517 | throw new ExecutableException("The property \"IsDestinationPathVariable\" is set to false. Please specify a file connection manager for the DestinationConnection"); 1518 | if (!host.Variables.Contains((string)value)) 1519 | throw new ExecutableException(string.Format("The specified variable {0} does not exist!", (string)value)); 1520 | host.Properties["Destination"].SetValue(host, value); 1521 | } 1522 | } 1523 | 1524 | public string SourceVariable 1525 | { 1526 | get { return (string)host.Properties["SourceVariable"].GetValue(host); } 1527 | set 1528 | { 1529 | if (!IsSourcePathVariable) 1530 | throw new ExecutableException("The property \"IsSourcePathVariable\" is set to false. Please specify a file connection manager for the SourceConnection"); 1531 | if (!host.Variables.Contains((string)value)) 1532 | throw new ExecutableException(string.Format("The specified variable {0} does not exist!", (string)value)); 1533 | host.Properties["Source"].SetValue(host, value); 1534 | } 1535 | } 1536 | 1537 | } 1538 | 1539 | } 1540 | -------------------------------------------------------------------------------- /EzHelpers.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.SqlServer.Dts.Runtime; 2 | using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask; 3 | 4 | namespace Microsoft.SqlServer.SSIS.EzAPI 5 | { 6 | public static class EzHelpers 7 | { 8 | /// 9 | /// Extension method that adds Microsoft.SqlServer.Dts.Runtime.Variable with expression to the Microsoft.SqlServer.Dts.Runtime.Variables 10 | // collection. 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// Variable 18 | public static Variable Add(this Variables vars, string name, string nameSpace, string expression) 19 | { 20 | Variable x = vars.Add(name, false, nameSpace, string.Empty); 21 | x.Expression = expression; 22 | x.EvaluateAsExpression = true; 23 | x.Name = name; 24 | x.Namespace = nameSpace; 25 | 26 | return x; 27 | } 28 | 29 | /// 30 | /// Extension method to easily add parameters bindings to ExecSQLTask 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | public static void Add(this IDTSParameterBindings binds, string parameterName, string dtsVariableName, OleDBDataTypes dataType) 37 | { 38 | IDTSParameterBinding x = binds.Add(); 39 | x.ParameterName = parameterName; 40 | x.DtsVariableName = dtsVariableName; 41 | x.DataType = (int)dataType; 42 | } 43 | 44 | /// 45 | /// Extension method to easily add parameters bindings with direction to ExecSQLTask 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// 51 | public static void Add(this IDTSParameterBindings binds, ParameterDirections direction, string parameterName, string dtsVariableName, OleDBDataTypes dataType) 52 | { 53 | IDTSParameterBinding x = binds.Add(); 54 | x.ParameterName = parameterName; 55 | x.DtsVariableName = dtsVariableName; 56 | x.ParameterDirection = direction; 57 | x.DataType = (int)dataType; 58 | } 59 | 60 | /// 61 | /// Extension method to easily add result bindings to ExecSQLTask 62 | /// 63 | /// 64 | /// 65 | /// 66 | public static void Add(this IDTSResultBindings binds, string resultName, string dtsVariableName) 67 | { 68 | IDTSResultBinding x = binds.Add(); 69 | x.ResultName = resultName; 70 | x.DtsVariableName = dtsVariableName; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /EzProject.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.SqlServer.Dts.Runtime; 2 | using System; 3 | using System.Diagnostics; 4 | using System.IO; 5 | 6 | namespace Microsoft.SqlServer.SSIS.EzAPI 7 | { 8 | /// 9 | /// EzProject is a base class which will be inherited by other types project. 10 | /// EzProject provides a set of wrapper methods to create project, add packages, 11 | /// and set the project properties. 12 | /// 13 | public class EzProject 14 | { 15 | #region members & properties 16 | private Project m_project; 17 | 18 | /// 19 | /// Get Project instance 20 | /// 21 | public Project Project 22 | { 23 | get 24 | { 25 | if (null == m_project) 26 | { 27 | m_project = Project.CreateProject(); 28 | } 29 | 30 | return m_project; 31 | } 32 | } 33 | 34 | /// 35 | /// Get packages in the project 36 | /// 37 | public PackageItems PackageItems 38 | { 39 | get 40 | { 41 | return Project.PackageItems; 42 | } 43 | } 44 | 45 | /// 46 | /// Get ConnectionManagerItems in the Project 47 | /// 48 | public ConnectionManagerItems ConnectionManagerItems 49 | { 50 | get 51 | { 52 | return Project.ConnectionManagerItems; 53 | } 54 | } 55 | 56 | /// 57 | /// Get parameters in the project 58 | /// 59 | public Parameters Parameters 60 | { 61 | get 62 | { 63 | return Project.Parameters; 64 | } 65 | } 66 | 67 | /// 68 | /// Set password of project 69 | /// 70 | public string Password 71 | { 72 | set 73 | { 74 | Project.Password = value; 75 | } 76 | } 77 | 78 | /// 79 | /// Get, set creation date of project 80 | /// 81 | public DateTimeOffset CreationDate 82 | { 83 | get { return Project.CreationDate; } 84 | set { Project.CreationDate = value; } 85 | } 86 | 87 | /// 88 | /// Get, set creator name of project 89 | /// 90 | public string CreatorName 91 | { 92 | get { return Project.CreatorName; } 93 | set { Project.CreatorName = value; } 94 | } 95 | 96 | /// 97 | /// Get description of project 98 | /// 99 | public string Description 100 | { 101 | get { return Project.Description; } 102 | set { Project.Description = value; } 103 | } 104 | 105 | /// 106 | /// Get ID of project 107 | /// 108 | public string ID 109 | { 110 | get { return Project.ID; } 111 | } 112 | 113 | /// 114 | /// Get, set name of project 115 | /// 116 | public string Name 117 | { 118 | get { return Project.Name; } 119 | set { Project.Name = value; } 120 | } 121 | 122 | /// 123 | /// Get, set protection level of project 124 | /// 125 | public DTSProtectionLevel ProtectionLevel 126 | { 127 | get { return Project.ProtectionLevel; } 128 | set { Project.ProtectionLevel = value; } 129 | } 130 | 131 | /// 132 | /// Get, set version build of project 133 | /// 134 | public int VersionBuild 135 | { 136 | get { return Project.VersionBuild; } 137 | set { Project.VersionBuild = value; } 138 | } 139 | 140 | /// 141 | /// Get, set version comments of project 142 | /// 143 | public string VersionComments 144 | { 145 | get { return Project.VersionComments; } 146 | set { Project.VersionComments = value; } 147 | } 148 | 149 | /// 150 | /// Get, set version major of project 151 | /// 152 | public int VersionMajor 153 | { 154 | get { return Project.VersionMajor; } 155 | set { Project.VersionMajor = value; } 156 | } 157 | 158 | /// 159 | /// Get, set verion minor of project 160 | /// 161 | public int VersionMinor 162 | { 163 | get { return Project.VersionMinor; } 164 | set { Project.VersionMinor = value; } 165 | } 166 | 167 | #endregion 168 | 169 | #region constructor & operator override 170 | public EzProject() 171 | { 172 | m_project = Project.CreateProject(); 173 | } 174 | 175 | public EzProject(string projectfile) 176 | { 177 | m_project = Project.CreateProject(projectfile); 178 | } 179 | 180 | /// 181 | /// Construct an EzProject from a Project Object 182 | /// 183 | /// 184 | public EzProject(Project project) 185 | { 186 | if (null == project) 187 | { 188 | m_project = Project.CreateProject(); 189 | } 190 | else 191 | { 192 | m_project = project; 193 | } 194 | } 195 | 196 | /// 197 | /// override operator, in order to return a Project object from an EzProject 198 | /// 199 | /// operand of EzProject object 200 | /// Return a Project object 201 | public static implicit operator Project(EzProject project) 202 | { 203 | if (project == null) 204 | { 205 | return null; 206 | } 207 | 208 | return (Project)project.Project; 209 | } 210 | 211 | /// 212 | /// override operator, in order to return an EzProject object from a Project 213 | /// 214 | /// oeprand of Project object 215 | /// Return an EzProject object 216 | public static implicit operator EzProject(Project project) 217 | { 218 | if (project == null) 219 | { 220 | return null; 221 | } 222 | 223 | return new EzProject(project); 224 | } 225 | #endregion 226 | 227 | #region Methods 228 | /// 229 | /// Add an EzPackage to project 230 | /// 231 | /// EzPackage constraint 232 | /// EzPackage object 233 | /// package stream name 234 | public string AddPackage(T package) where T : EzPackage 235 | { 236 | Debug.Assert(null != package, @"The package should not be nullable."); 237 | string packageStreamName = package.Name + ".dtsx"; 238 | Project.PackageItems.Add((Package)package, packageStreamName); 239 | return packageStreamName; 240 | } 241 | 242 | /// 243 | /// Add a Package to project 244 | /// 245 | /// 246 | /// package stream name 247 | public string AddPackage(Package package) 248 | { 249 | Debug.Assert(null != package, @"The package should not be nullable."); 250 | Project.PackageItems.Add(package, package.Name + ".dtsx"); 251 | return package.Name; 252 | } 253 | 254 | /// 255 | /// Add a package to project with a specified stream name 256 | /// 257 | /// 258 | /// 259 | /// package stream name 260 | public string AddPackage(Package package, string streamname) 261 | { 262 | Debug.Assert(null != package, @"The package should not be nullable."); 263 | Debug.Assert(!string.IsNullOrEmpty(streamname), @"The stream name should not be nullable."); 264 | 265 | Project.PackageItems.Add(package, streamname); 266 | return streamname; 267 | } 268 | 269 | /// 270 | /// Insert a package at a specified position 271 | /// 272 | /// the index to specify the package in the project 273 | /// the package object 274 | /// package stream name 275 | public string InsertPackage(int index, Package package) 276 | { 277 | Debug.Assert(index > -1, @"The package index must be greater than or equal to 0."); 278 | Debug.Assert(null != package, @"The package should not be nullable."); 279 | 280 | try 281 | { 282 | Project.PackageItems.Insert(index, package, package.Name); 283 | return package.Name; 284 | } 285 | catch (Exception) 286 | { 287 | return null; 288 | } 289 | } 290 | 291 | /// 292 | /// Remove a package at specified index position 293 | /// 294 | /// the index to specify the package in project 295 | public void RemovePackageAt(int index) 296 | { 297 | Debug.Assert(index > -1, @"The package index must be greater than or equal to 0."); 298 | 299 | Project.PackageItems.RemoveAt(index); 300 | } 301 | 302 | /// 303 | /// Remove a package by specifiying stream name 304 | /// 305 | /// package stream name 306 | public void RemovePackage(string packagename) 307 | { 308 | Debug.Assert(!string.IsNullOrEmpty(packagename), @"The stream name should not be nullable."); 309 | 310 | Project.PackageItems.Remove(packagename); 311 | } 312 | 313 | /// 314 | /// Add an EzConnectionManager to Project 315 | /// 316 | /// 317 | /// 318 | /// 319 | public ConnectionManager AddConnectionManager(T connection) where T : EzConnectionManager 320 | { 321 | Debug.Assert(null != connection, @"The package should not be nullable."); 322 | string connectionStreamName = connection.Name + ".conmgr"; 323 | ConnectionManagerItem cmi = Project.ConnectionManagerItems.Add(connection.GetConnMgrID(), connectionStreamName); 324 | return cmi.ConnectionManager; 325 | } 326 | 327 | /// 328 | /// Add a connection to Project 329 | /// 330 | /// 331 | /// 332 | public ConnectionManager AddConnectionManager(ConnectionManager connection) 333 | { 334 | Debug.Assert(null != connection, @"The connection should not be nullable."); 335 | string connectionStreamName = connection.Name + ".conmgr"; 336 | ConnectionManagerItem cmi = Project.ConnectionManagerItems.Add(connection.CreationName, connectionStreamName); 337 | return cmi.ConnectionManager; 338 | } 339 | 340 | /// 341 | /// Add a connection to project with a specified stream name 342 | /// 343 | /// 344 | /// 345 | /// connection stream name 346 | public ConnectionManager AddConnectionManager(ConnectionManager connection, string streamname) 347 | { 348 | Debug.Assert(null != connection, @"The connection should not be nullable."); 349 | Debug.Assert(!string.IsNullOrEmpty(streamname), @"The stream name should not be nullable."); 350 | 351 | ConnectionManagerItem cmi = Project.ConnectionManagerItems.Add(connection.CreationName, streamname); 352 | return cmi.ConnectionManager; 353 | } 354 | 355 | 356 | 357 | /// 358 | /// Remove a connection at specified index position 359 | /// 360 | /// the index to specify the connection in project 361 | public void RemoveConnectionManagerAt(int index) 362 | { 363 | Debug.Assert(index > -1, @"The connection index must be greater than or equal to 0."); 364 | 365 | Project.ConnectionManagerItems.RemoveAt(index); 366 | } 367 | 368 | /// 369 | /// Remove a connection by specifiying stream name 370 | /// 371 | /// connection stream name 372 | public void RemoveConnectionManager(string connectionname) 373 | { 374 | Debug.Assert(!string.IsNullOrEmpty(connectionname), @"The connection name should not be nullable."); 375 | 376 | Project.ConnectionManagerItems.Remove(connectionname); 377 | } 378 | 379 | /// 380 | /// Add a parameter for a project. 381 | /// 382 | /// parameter name 383 | /// parameter type 384 | public Parameter AddProjectParameter(string name, TypeCode type) 385 | { 386 | Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable."); 387 | 388 | return Parameters.Add(name, type); 389 | } 390 | 391 | /// 392 | /// Add parameter for a project 393 | /// 394 | /// parameter's name 395 | /// parameter's type 396 | /// parameter is required 397 | /// parameter is sensitive 398 | /// parameter's default value 399 | /// parameter's value 400 | /// parameter object 401 | public Parameter AddProjectParameter(string name, TypeCode type, bool required, bool sensitive, object value) 402 | { 403 | Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable."); 404 | 405 | Parameter param = Parameters.Add(name, type); 406 | param.Required = required; 407 | param.Sensitive = sensitive; 408 | param.Value = value; 409 | return param; 410 | } 411 | 412 | /// 413 | /// Add package parameter for a project 414 | /// 415 | /// parameter's name 416 | /// parameter's type 417 | /// package stream name 418 | /// parameter object 419 | public Parameter AddPackageParameter(string name, TypeCode type, string pkgStreamName) 420 | { 421 | Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable."); 422 | Debug.Assert(!string.IsNullOrEmpty(pkgStreamName), @"The package stream name should not be nullable."); 423 | 424 | //if pacakge exists, add the parameter, else throw exception 425 | if (PackageItems.IndexOf(pkgStreamName) > -1) 426 | { 427 | Parameter param = PackageItems[pkgStreamName].Package.Parameters.Add(name, type); 428 | return param; 429 | } 430 | else 431 | { 432 | throw new ApplicationException("The specified package doesn't exist in the project"); 433 | } 434 | } 435 | 436 | /// 437 | /// Add pacakge parameter for a project 438 | /// 439 | /// parameter's name 440 | /// parameter's type 441 | /// parameter is required 442 | /// parameter is sensitive 443 | /// parameter's default value 444 | /// parameter's value 445 | /// 446 | /// parameter object 447 | public Parameter AddPackageParameter(string name, TypeCode type, bool required, bool sensitive, object value, string pkgStreamName) 448 | { 449 | Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable."); 450 | Debug.Assert(!string.IsNullOrEmpty(pkgStreamName), @"The package stream name should not be nullable."); 451 | 452 | //if pacakge exists, add the parameter, else throw exception 453 | if (PackageItems.IndexOf(pkgStreamName) > -1) 454 | { 455 | Parameter param = PackageItems[pkgStreamName].Package.Parameters.Add(name, type); 456 | param.Required = required; 457 | param.Sensitive = sensitive; 458 | param.Value = value; 459 | return param; 460 | } 461 | else 462 | { 463 | throw new ApplicationException("The specified package doesn't exist in the project"); 464 | } 465 | } 466 | 467 | /// 468 | /// Remove a parameter from project 469 | /// 470 | /// parameter name 471 | public void RemoveParameter(string name) 472 | { 473 | Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable."); 474 | 475 | Parameters.Remove(name); 476 | } 477 | 478 | /// 479 | /// Remove a parameter from project by index 480 | /// 481 | /// parameter index 482 | public void RemoveParameter(int index) 483 | { 484 | Debug.Assert(index > -1, @"The parameter index must be greater than or equal to 0."); 485 | 486 | Parameters.RemoveAt(index); 487 | } 488 | 489 | /// 490 | /// Open project by specifying a file path 491 | /// 492 | /// the project file path 493 | public void OpenProject(string filename) 494 | { 495 | Debug.Assert(File.Exists(filename), @"The specified file path does not exist."); 496 | 497 | m_project = Project.OpenProject(filename); 498 | } 499 | 500 | /// 501 | /// Release all resource used by current instance of project 502 | /// 503 | public void CloseProject() 504 | { 505 | m_project.Dispose(); 506 | } 507 | 508 | /// 509 | /// Open project by specifying stream 510 | /// 511 | /// project stream 512 | public void OpenProject(Stream stream) 513 | { 514 | Debug.Assert(Stream.Null != stream, @"The specified stream should not be nullable."); 515 | 516 | m_project = Project.OpenProject(stream); 517 | } 518 | 519 | /// 520 | /// Save a project to a file. 521 | /// 522 | /// target file path 523 | public void SaveTo(string filename) 524 | { 525 | Debug.Assert(!string.IsNullOrEmpty(filename), @"The specified file path should not be nullable."); 526 | Project.SaveTo(filename); 527 | } 528 | 529 | /// 530 | /// Save a project to a stream. 531 | /// 532 | /// target stream 533 | public void SaveTo(Stream stream) 534 | { 535 | Debug.Assert(Stream.Null != stream, @"The specified stream should not be nullable."); 536 | 537 | Project.SaveTo(stream); 538 | } 539 | 540 | /// 541 | /// Save a project as a file. 542 | /// 543 | /// target file path 544 | public void SaveAs(string filename) 545 | { 546 | Debug.Assert(!string.IsNullOrEmpty(filename), @"The specified file path should not be nullable."); 547 | 548 | Project.SaveAs(filename); 549 | } 550 | 551 | /// 552 | /// Save a project as a stream. 553 | /// 554 | /// target stream 555 | public void SaveAs(Stream stream) 556 | { 557 | Debug.Assert(Stream.Null != stream, @"The specified stream should not be nullable."); 558 | 559 | Project.SaveAs(stream); 560 | } 561 | 562 | /// 563 | /// Save the project 564 | /// 565 | public void Save() 566 | { 567 | Project.Save(); 568 | } 569 | #endregion 570 | } 571 | 572 | /// 573 | /// EzSourceDestinationProject is a project which contains a data flow package. 574 | /// In the data flow package, the data flow only contains source and destination. 575 | /// It will be inherited by specific project containing a data flow package. 576 | /// 577 | public class EzSourceDestinationProject : EzProject 578 | { 579 | #region Constructors & operator override 580 | public EzSourceDestinationProject() 581 | : base() 582 | { } 583 | 584 | public EzSourceDestinationProject(string projectfile) 585 | : base(projectfile) 586 | { } 587 | 588 | public EzSourceDestinationProject(Project project) 589 | : base(project) 590 | { } 591 | 592 | /// 593 | /// Override operator, in order to return an EzSourceDestinationProject from an project 594 | /// 595 | /// operand of Project object 596 | /// Return a EzSourceDestinationProject object 597 | public static implicit operator EzSourceDestinationProject(Project project) 598 | { 599 | return new EzSourceDestinationProject(project); 600 | } 601 | 602 | /// 603 | /// Override operator, in order to return a Project from an EzSourceDestinationProject 604 | /// 605 | /// operand of EzSourceDestinationProject object 606 | /// Return a Project object 607 | public static implicit operator Project(EzSourceDestinationProject project) 608 | { 609 | return project.Project; 610 | } 611 | #endregion 612 | 613 | /// 614 | /// Add an source destionation package in project 615 | /// 616 | /// Source Adapter Type 617 | /// Source Connection Manager Type 618 | /// Tranform Component Type 619 | /// Destination Adapter Type 620 | /// Destination Connection Manager Type 621 | /// source adapter 622 | /// source connection manager 623 | /// destination adapter 624 | /// destination connection manager 625 | /// package stream name 626 | public string AddPackage 627 | (SourceType source, 628 | SourceConnectionType srcconn, 629 | DestinationType destination, 630 | DestinationConnectionType destconn) 631 | where SourceType : EzAdapter 632 | where SourceConnectionType : EzConnectionManager 633 | where DestinationType : EzAdapter 634 | where DestinationConnectionType : EzConnectionManager 635 | { 636 | Debug.Assert(null != source, @"The source component could not be nullable."); 637 | Debug.Assert(null != srcconn, @"The source connection could not be nullable."); 638 | Debug.Assert(null != destination, @"The destination component could not be nullable."); 639 | Debug.Assert(null != destconn, @"The destination connection could not be nullable."); 640 | 641 | //construct a srouce destionation package 642 | EzSrcDestPackage package = 643 | new EzSrcDestPackage(); 644 | package.Source = source; 645 | package.SrcConn = srcconn; 646 | package.Dest = destination; 647 | package.DestConn = destconn; 648 | 649 | //Add this package in project 650 | return AddPackage(package); 651 | } 652 | 653 | /// 654 | /// Add an Ado.Net package in project 655 | /// 656 | /// Transform Component Type 657 | /// source/destination server name 658 | /// source/destination database name 659 | /// source sql command statement 660 | /// destination table name 661 | /// package stream name 662 | public string AddAdoNetPackage(string server, string database, string srcsql, string desttable) 663 | { 664 | Debug.Assert(!string.IsNullOrEmpty(server), @"The server should not be nullable."); 665 | Debug.Assert(!string.IsNullOrEmpty(database), @"The database should not be nullable."); 666 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement should not be nullable."); 667 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table should not be nullable."); 668 | 669 | return AddAdoNetPackage(server, database, srcsql, server, database, desttable); 670 | } 671 | 672 | /// 673 | /// Add an Ado.Net package in project 674 | /// 675 | /// Transform Component Type 676 | /// source server name 677 | /// source database name 678 | /// source sql command statment 679 | /// destination server name 680 | /// destination database name 681 | /// destination table name 682 | /// package stream name 683 | public string AddAdoNetPackage(string srcserver, string srcdb, string srcsql, 684 | string destserver, string destdb, string desttable) 685 | { 686 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 687 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 688 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 689 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 690 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 691 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 692 | 693 | //construct a package 694 | EzSrcDestPackage package = 695 | new EzSrcDestPackage(); 696 | package.SrcConn.SetConnectionString(srcserver, srcdb); 697 | package.Source.SqlCommand = srcsql; 698 | package.DestConn.SetConnectionString(destserver, destdb); 699 | package.Dest.Table = desttable; 700 | 701 | //add this package in project 702 | return AddPackage(package); 703 | } 704 | 705 | /// 706 | /// Add an Oledb source and destination package in project 707 | /// 708 | /// Transform Component Type 709 | /// source/destination server name 710 | /// source/destination database name 711 | /// source sql command statement 712 | /// tranform component 713 | /// destination table name 714 | /// package stream name 715 | public string AddOleDbPackage(string server, string database, string srcsql, string desttable) 716 | where TransformType : EzComponent 717 | { 718 | Debug.Assert(!string.IsNullOrEmpty(server), @"The server should not be nullable."); 719 | Debug.Assert(!string.IsNullOrEmpty(database), @"The database should not be nullable."); 720 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement should not be nullable."); 721 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table should not be nullable."); 722 | 723 | return AddOleDbPackage(server, database, srcsql, server, database, desttable); 724 | } 725 | 726 | /// 727 | /// Add an Oledb Source and destiantion package in project 728 | /// 729 | /// Transform Component Type 730 | /// source server name 731 | /// source database name 732 | /// source sql command statment 733 | /// destination server name 734 | /// destination database name 735 | /// destination table name 736 | /// package stream name 737 | public string AddOleDbPackage(string srcserver, string srcdb, string srcsql, 738 | string destserver, string destdb, string desttable) 739 | { 740 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 741 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 742 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 743 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 744 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 745 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 746 | 747 | //construct a transform package 748 | EzSrcDestPackage package = 749 | new EzSrcDestPackage(); 750 | package.SrcConn.SetConnectionString(srcserver, srcdb); 751 | package.Source.SqlCommand = srcsql; 752 | package.DestConn.SetConnectionString(destserver, destdb); 753 | package.Dest.Table = desttable; 754 | 755 | //add this package in project 756 | return AddPackage(package); 757 | } 758 | 759 | /// 760 | /// Add an oledb source and flat file destination package in project 761 | /// 762 | /// source server name 763 | /// source database name 764 | /// source sql command statment 765 | /// destination flat file 766 | /// package stream name 767 | public string AddOleDbToFilePackage(string srcserver, string srcdb, string srcsql, string destfile) 768 | { 769 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 770 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 771 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 772 | Debug.Assert(!string.IsNullOrEmpty(destfile), @"The destination file could not be nullable."); 773 | 774 | EzSrcDestPackage package = 775 | new EzSrcDestPackage(); 776 | package.SrcConn.SetConnectionString(srcserver, srcdb); 777 | package.Source.SqlCommand = srcsql; 778 | package.DestConn.ConnectionString = destfile; 779 | package.Dest.Overwrite = true; 780 | package.Dest.DefineColumnsInCM(); 781 | 782 | return AddPackage(package); 783 | } 784 | 785 | /// 786 | /// Add a flat file source and oledb destination package in project 787 | /// 788 | /// source flat file 789 | /// destination server name 790 | /// destination database name 791 | /// destination table name 792 | /// package stream name 793 | public string AddFlatFileToOleDbPackage(string srcfile, string destserver, string destdb, string desttable) 794 | { 795 | Debug.Assert(!string.IsNullOrEmpty(srcfile), @"The source file could not be nullable."); 796 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 797 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 798 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 799 | 800 | EzSrcDestPackage package = 801 | new EzSrcDestPackage(); 802 | package.SrcConn.ConnectionString = srcfile; 803 | package.DestConn.SetConnectionString(destserver, destdb); 804 | package.Dest.Table = desttable; 805 | 806 | return AddPackage(package); 807 | } 808 | } 809 | 810 | /// 811 | /// EzTransformProject is a project type which contains a transform package, 812 | /// it provides the overrided methods to add transform pacakges. 813 | /// 814 | public class EzTransformProject : EzProject 815 | { 816 | #region constructor & operator override 817 | public EzTransformProject() 818 | : base() 819 | { } 820 | 821 | public EzTransformProject(string projectfile) 822 | : base(projectfile) 823 | { } 824 | 825 | public EzTransformProject(Project project) : base(project) { } 826 | 827 | /// 828 | /// Override operator, in order to return an EzTransformProject from an project 829 | /// 830 | /// operand of Project object 831 | /// Return a EzTransformProject object 832 | public static implicit operator EzTransformProject(Project project) 833 | { 834 | return new EzTransformProject(project); 835 | } 836 | 837 | /// 838 | /// Override operator, in order to return a Project from an EzTransformProject 839 | /// 840 | /// operand of EzTransformProject object 841 | /// Return a Project object 842 | public static implicit operator Project(EzTransformProject project) 843 | { 844 | return project.Project; 845 | } 846 | #endregion 847 | 848 | /// 849 | /// Add an tranform package in project 850 | /// 851 | /// Source Adapter Type 852 | /// Source Connection Manager Type 853 | /// Tranform Component Type 854 | /// Destination Adapter Type 855 | /// Destination Connection Manager Type 856 | /// source adapter 857 | /// source connection manager 858 | /// tranform component 859 | /// destination adapter 860 | /// destination connection manager 861 | /// package stream name 862 | public string AddPackage 863 | (SourceType source, 864 | SourceConnectionType srcconn, 865 | TranformType transform, 866 | DestinationType destination, 867 | DestinationConnectionType destconn) 868 | where SourceType : EzAdapter 869 | where SourceConnectionType : EzConnectionManager 870 | where TranformType : EzComponent 871 | where DestinationType : EzAdapter 872 | where DestinationConnectionType : EzConnectionManager 873 | { 874 | Debug.Assert(null != source, @"The source component could not be nullable."); 875 | Debug.Assert(null != srcconn, @"The source connection could not be nullable."); 876 | Debug.Assert(null != transform, @"The transform component could not be nullable."); 877 | Debug.Assert(null != destination, @"The destination component could not be nullable."); 878 | Debug.Assert(null != destconn, @"The destination connection could not be nullable."); 879 | 880 | //construct a transform package 881 | EzTransformPackage package = 882 | new EzTransformPackage(); 883 | package.Source = source; 884 | package.SrcConn = srcconn; 885 | package.Transform = transform; 886 | package.Dest = destination; 887 | package.DestConn = destconn; 888 | 889 | //Add this package in project 890 | return AddPackage(package); 891 | } 892 | 893 | /// 894 | /// Add an Ado.Net package in project 895 | /// 896 | /// Transform Component Type 897 | /// source/destination server name 898 | /// source/destination database name 899 | /// source sql command statement 900 | /// tranform component 901 | /// destination table name 902 | /// package stream name 903 | public string AddAdoNetPackage(string server, string database, string srcsql, 904 | TransformType transform, string desttable) 905 | where TransformType : EzComponent 906 | { 907 | Debug.Assert(!string.IsNullOrEmpty(server), @"The server should not be nullable."); 908 | Debug.Assert(!string.IsNullOrEmpty(database), @"The database should not be nullable."); 909 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement should not be nullable."); 910 | Debug.Assert(null != transform, @"The transform component should not be nullable."); 911 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table should not be nullable."); 912 | 913 | return AddAdoNetPackage(server, database, srcsql, transform, server, database, desttable); 914 | } 915 | 916 | /// 917 | /// Add an Ado.Net package in project 918 | /// 919 | /// Transform Component Type 920 | /// source server name 921 | /// source database name 922 | /// source sql command statment 923 | /// transform component 924 | /// destination server name 925 | /// destination database name 926 | /// destination table name 927 | /// package stream name 928 | public string AddAdoNetPackage(string srcserver, string srcdb, string srcsql, 929 | TransformType transform, string destserver, string destdb, string desttable) 930 | where TransformType : EzComponent 931 | { 932 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 933 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 934 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 935 | Debug.Assert(null != transform, @"The transform component could not be nullable."); 936 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 937 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 938 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 939 | 940 | //construct a transform package 941 | EzTransformPackage package = 942 | new EzTransformPackage(); 943 | package.SrcConn.SetConnectionString(srcserver, srcdb); 944 | package.Source.SqlCommand = srcsql; 945 | package.Transform = transform; 946 | package.DestConn.SetConnectionString(destserver, destdb); 947 | package.Dest.Table = desttable; 948 | 949 | //add this package in project 950 | return AddPackage(package); 951 | } 952 | 953 | /// 954 | /// Add an Oledb source and destination package with transform in project 955 | /// 956 | /// Transform Component Type 957 | /// source/destination server name 958 | /// source/destination database name 959 | /// source sql command statement 960 | /// tranform component 961 | /// destination table name 962 | /// package stream name 963 | public string AddOleDbPackage(string server, string database, string srcsql, 964 | TransformType transform, string desttable) 965 | where TransformType : EzComponent 966 | { 967 | Debug.Assert(!string.IsNullOrEmpty(server), @"The server should not be nullable."); 968 | Debug.Assert(!string.IsNullOrEmpty(database), @"The database should not be nullable."); 969 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement should not be nullable."); 970 | Debug.Assert(null != transform, @"The transform component should not be nullable."); 971 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table should not be nullable."); 972 | 973 | return AddOleDbPackage(server, database, srcsql, transform, server, database, desttable); 974 | } 975 | 976 | /// 977 | /// Add an Oledb Source and destiantion package with transform in project 978 | /// 979 | /// Transform Component Type 980 | /// source server name 981 | /// source database name 982 | /// source sql command statment 983 | /// transform component 984 | /// destination server name 985 | /// destination database name 986 | /// destination table name 987 | /// package stream name 988 | public string AddOleDbPackage(string srcserver, string srcdb, string srcsql, 989 | TransformType transform, string destserver, string destdb, string desttable) 990 | where TransformType : EzComponent 991 | { 992 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 993 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 994 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 995 | Debug.Assert(null != transform, @"The transform component could not be nullable."); 996 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 997 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 998 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 999 | 1000 | //construct a transform package 1001 | EzTransformPackage package = 1002 | new EzTransformPackage(); 1003 | package.SrcConn.SetConnectionString(srcserver, srcdb); 1004 | package.Source.SqlCommand = srcsql; 1005 | package.Transform = transform; 1006 | package.DestConn.SetConnectionString(destserver, destdb); 1007 | package.Dest.Table = desttable; 1008 | 1009 | //add this package in project 1010 | return AddPackage(package); 1011 | } 1012 | 1013 | /// 1014 | /// Add an oledb source and flat file destination package with transform in project 1015 | /// 1016 | /// Transform Component Type 1017 | /// source server name 1018 | /// source database name 1019 | /// source sql command statment 1020 | /// transform component 1021 | /// destination flat file 1022 | /// package stream name 1023 | public string AddOleDbToFilePackage(string srcserver, string srcdb, string srcsql, 1024 | TransformType transform, string destfile) 1025 | where TransformType : EzComponent 1026 | { 1027 | Debug.Assert(!string.IsNullOrEmpty(srcserver), @"The source server could not be nullable."); 1028 | Debug.Assert(!string.IsNullOrEmpty(srcdb), @"The source database could not be nullable."); 1029 | Debug.Assert(!string.IsNullOrEmpty(srcsql), @"The source sql command statement could not be nullable."); 1030 | Debug.Assert(null != transform, @"The transform component could not be nullable."); 1031 | Debug.Assert(!string.IsNullOrEmpty(destfile), @"The destination file could not be nullable."); 1032 | 1033 | //construct a transform pacakge 1034 | EzTransformPackage package = 1035 | new EzTransformPackage(); 1036 | package.SrcConn.SetConnectionString(srcserver, srcdb); 1037 | package.Source.SqlCommand = srcsql; 1038 | package.Transform = transform; 1039 | package.DestConn.ConnectionString = destfile; 1040 | package.Dest.Overwrite = true; 1041 | package.Dest.DefineColumnsInCM(); 1042 | 1043 | return AddPackage(package); 1044 | } 1045 | 1046 | /// 1047 | /// Add a flat file source and oledb destination package with tranform in project 1048 | /// 1049 | /// Transform Component Type 1050 | /// source flat file 1051 | /// transform component 1052 | /// destination server name 1053 | /// destination database name 1054 | /// destination table name 1055 | /// package stream name 1056 | public string AddFlatFileToOleDbPackage(string srcfile, TransformType transform, 1057 | string destserver, string destdb, string desttable) 1058 | where TransformType : EzComponent 1059 | { 1060 | Debug.Assert(!string.IsNullOrEmpty(srcfile), @"The source file could not be nullable."); 1061 | Debug.Assert(null != transform, @"The transform component could not be nullable."); 1062 | Debug.Assert(!string.IsNullOrEmpty(destserver), @"The destination server could not be nullable."); 1063 | Debug.Assert(!string.IsNullOrEmpty(destdb), @"The destination database could not be nullable."); 1064 | Debug.Assert(!string.IsNullOrEmpty(desttable), @"The destination table could not be nullable."); 1065 | 1066 | //construct a transform pacakge 1067 | EzTransformPackage package = 1068 | new EzTransformPackage(); 1069 | package.SrcConn.ConnectionString = srcfile; 1070 | package.Transform = transform; 1071 | package.DestConn.SetConnectionString(destserver, destdb); 1072 | package.Dest.Table = desttable; 1073 | 1074 | return AddPackage(package); 1075 | } 1076 | } 1077 | 1078 | /// 1079 | /// EzEPTProject is a project which contains EPT packages, 1080 | /// it provides the overrided methods to add EPT packages. 1081 | /// 1082 | public class EzEPTProject : EzProject 1083 | { 1084 | #region Constructors & operator override 1085 | public EzEPTProject() 1086 | : base() 1087 | { } 1088 | 1089 | public EzEPTProject(string projectfile) 1090 | : base(projectfile) 1091 | { } 1092 | 1093 | public EzEPTProject(Project project) 1094 | : base(project) 1095 | { } 1096 | 1097 | /// 1098 | /// Override operator, in order to return an EzEPTProject from an project 1099 | /// 1100 | /// operand of Project object 1101 | /// Return a EzEPTProject object 1102 | public static implicit operator EzEPTProject(Project project) 1103 | { 1104 | return new EzEPTProject(project); 1105 | } 1106 | 1107 | /// 1108 | /// Override operator, in order to return a Project from an EzEPTProject 1109 | /// 1110 | /// operand of EzEPTProject object 1111 | /// Return a Project object 1112 | public static implicit operator Project(EzEPTProject project) 1113 | { 1114 | return project.Project; 1115 | } 1116 | 1117 | /// 1118 | /// Add EPT package in project. 1119 | /// 1120 | /// child package file path 1121 | /// execute the package out of process 1122 | /// package stream name 1123 | public string AddEPTPackage(string childPackagePath, bool execOutOfProc) 1124 | { 1125 | EzExecPackage package = new EzExecPackage(new EzPackage() as EzContainer); 1126 | EzFileCM pkgCM = new EzFileCM(package.Package); 1127 | pkgCM.ConnectionString = childPackagePath; 1128 | package.Connection = pkgCM; 1129 | package.ExecOutOfProcess = execOutOfProc; 1130 | 1131 | return AddPackage(package.Package); 1132 | } 1133 | #endregion 1134 | } 1135 | } -------------------------------------------------------------------------------- /License/License.md: -------------------------------------------------------------------------------- 1 | ## Microsoft Public License (MS-PL) 2 | 3 | This license governs use of the accompanying software. If you use the 4 | software, you accept this license. If you do not accept the license, 5 | do not use the software. 1. Definitions The terms "reproduce," 6 | "reproduction," "derivative works," and "distribution" have the same 7 | meaning here as under U.S. copyright law. A "contribution" is the 8 | original software, or any additions or changes to the software. A 9 | "contributor" is any person that distributes its contribution under 10 | this license. "Licensed patents" are a contributor's patent claims 11 | that read directly on its contribution. 2. Grant of Rights (A) 12 | Copyright Grant- Subject to the terms of this license, including the 13 | license conditions and limitations in section 3, each contributor 14 | grants you a non-exclusive, worldwide, royalty-free copyright license 15 | to reproduce its contribution, prepare derivative works of its 16 | contribution, and distribute its contribution or any derivative works 17 | that you create. (B) Patent Grant- Subject to the terms of this 18 | license, including the license conditions and limitations in section 19 | 3, each contributor grants you a non-exclusive, worldwide, 20 | royalty-free license under its licensed patents to make, have made, 21 | use, sell, offer for sale, import, and/or otherwise dispose of its 22 | contribution in the software or derivative works of the contribution 23 | in the software. 3. Conditions and Limitations (A) No Trademark 24 | License- This license does not grant you rights to use any 25 | contributors' name, logo, or trademarks. (B) If you bring a patent 26 | claim against any contributor over patents that you claim are 27 | infringed by the software, your patent license from such contributor 28 | to the software ends automatically. (C) If you distribute any portion 29 | of the software, you must retain all copyright, patent, trademark, and 30 | attribution notices that are present in the software. (D) If you 31 | distribute any portion of the software in source code form, you may do 32 | so only under this license by including a complete copy of this 33 | license with your distribution. If you distribute any portion of the 34 | software in compiled or object code form, you may only do so under a 35 | license that complies with this license. (E) The software is licensed 36 | "as-is." You bear the risk of using it. The contributors give no 37 | express warranties, guarantees or conditions. You may have additional 38 | consumer rights under your local laws which this license cannot 39 | change. To the extent permitted under your local laws, the 40 | contributors exclude the implied warranties of merchantability, 41 | fitness for a particular purpose and non-infringement. 42 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("EzApi")] 8 | [assembly: AssemblyDescription("Fork of EzApi http://sqlsrvintegrationsrv.codeplex.com/releases/view/21238 adapted for SQL Server 2016")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("EzApi")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft Corporation. All Rights Reserved.")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("1e4d7f98-490d-450b-887a-690918d9e57c")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | //[assembly: AssemblyVersion("0.8.*")] 32 | //[assembly: AssemblyFileVersion("0.8.*")] 33 | [assembly: AssemblyInformationalVersion(informationalVersion: "0.8.93.0")] 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EzApi2016 2 | 3 | Fork of [EzApi](http://sqlsrvintegrationsrv.codeplex.com/releases/view/21238) adapted for SQL Server 2016 4 | 5 | ## Installation and usage 6 | 7 | The preferred way is to [Nuget](https://www.nuget.org/packages/EzApi/) 8 | 9 | `PM> Install-Package EzApi` via [Package Manager Console](https://docs.nuget.org/docs/start-here/using-the-package-manager-console) 10 | 11 | Alternatively you can compile include the output `EzApi.dll` on your project, or include this project directly in your solution. 12 | 13 | ## Website 14 | 15 | - [http://fpvmorais.github.io/EzApi2016](http://fpvmorais.github.io/EzApi2016) 16 | - [Stackoverflow Related QA](https://stackoverflow.com/questions/tagged/ezapi) 17 | 18 | ## Contributing 19 | 20 | 1. Fork it! 21 | 2. Create your feature branch: `git checkout -b my-new-feature` 22 | 3. Commit your changes: `git commit -am 'Add some feature'` 23 | 4. Push to the branch: `git push origin my-new-feature` 24 | 5. Submit a pull request :D 25 | 26 | ## Credits 27 | 28 | Credits are for Microsoft =) 29 | 30 | ## License 31 | 32 | The project inherits the Microsoft license: 33 | 34 | Copyright © Microsoft Corporation. All Rights Reserved. 35 | 36 | This code released under the terms of the 37 | 38 | Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) 39 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate 2 | encoding: UTF-8 3 | -------------------------------------------------------------------------------- /app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | --------------------------------------------------------------------------------