-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
anle
committed
Aug 7, 2018
1 parent
85bddea
commit 9b5d8a2
Showing
144 changed files
with
7,809 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27428.2005 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ETLBox", "ETLBox\ETLBox.csproj", "{0C7548BA-A597-488A-8ADD-2F628BE691D6}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ETLBoxTest", "ETLBoxTest\ETLBoxTest.csproj", "{E18C5029-9FA4-4846-828C-1B42D5D18C3C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0C7548BA-A597-488A-8ADD-2F628BE691D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0C7548BA-A597-488A-8ADD-2F628BE691D6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0C7548BA-A597-488A-8ADD-2F628BE691D6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0C7548BA-A597-488A-8ADD-2F628BE691D6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E18C5029-9FA4-4846-828C-1B42D5D18C3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E18C5029-9FA4-4846-828C-1B42D5D18C3C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E18C5029-9FA4-4846-828C-1B42D5D18C3C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E18C5029-9FA4-4846-828C-1B42D5D18C3C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A83E1CF2-2A7A-4315-8474-C060C51E118C} | ||
EndGlobalSection | ||
EndGlobal |
93 changes: 93 additions & 0 deletions
93
ETLBox/Definitions/ConnectionManager/DbConnectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Data; | ||
using System.Threading.Tasks; | ||
|
||
namespace ALE.ETLBox { | ||
public abstract class DbConnectionManager<Connection, Command> : IDisposable, IDbConnectionManager | ||
where Connection : class, IDbConnection, new() | ||
where Command : class, IDbCommand, new() { | ||
public int MaxLoginAttempts { get; set; } = 20; | ||
|
||
public ConnectionString ConnectionString { get; set; } | ||
|
||
internal Connection DbConnection { get; set; } | ||
|
||
internal bool IsConnectionOpen => DbConnection?.State == ConnectionState.Open; | ||
|
||
public DbConnectionManager() { } | ||
|
||
public DbConnectionManager(ConnectionString connectionString) : this() { | ||
this.ConnectionString = connectionString; | ||
} | ||
|
||
public void Open() { | ||
DbConnection = new Connection(); | ||
if (!IsConnectionOpen) { | ||
DbConnection.ConnectionString = ConnectionString.Value; | ||
bool successfullyConnected = false; | ||
Exception lastException = null; | ||
for (int i = 1; i <= MaxLoginAttempts; i++) { | ||
try { | ||
DbConnection.Open(); | ||
successfullyConnected = true; | ||
} catch (Exception e) { | ||
successfullyConnected = false; | ||
lastException = e; | ||
Task.Delay(500 * i).Wait(); | ||
} | ||
if (successfullyConnected) break; | ||
} | ||
if (!successfullyConnected) | ||
throw lastException ?? new Exception("Could not connect to database!"); | ||
} | ||
} | ||
|
||
//public void CloseConnection() => Close(); | ||
|
||
public Command CreateCommand(string commandText) { | ||
var cmd = DbConnection.CreateCommand(); | ||
cmd.CommandTimeout = 0; | ||
cmd.CommandText = commandText; | ||
return cmd as Command; | ||
} | ||
|
||
public int ExecuteNonQuery(string commandText) { | ||
Command sqlcmd = CreateCommand(commandText); | ||
return sqlcmd.ExecuteNonQuery(); | ||
} | ||
|
||
public object ExecuteScalar(string commandText) { | ||
Command cmd = CreateCommand(commandText); | ||
return cmd.ExecuteScalar(); | ||
} | ||
|
||
public IDataReader ExecuteReader(string commandText) { | ||
Command cmd = CreateCommand(commandText); | ||
return cmd.ExecuteReader(); | ||
|
||
} | ||
|
||
public abstract void BulkInsert(IDataReader data, IColumnMappingCollection columnMapping, string tableName); | ||
|
||
#region IDisposable Support | ||
private bool disposedValue = false; // To detect redundant calls | ||
|
||
protected void Dispose(bool disposing) { | ||
if (!disposedValue) { | ||
if (disposing) { | ||
if (DbConnection != null) | ||
DbConnection.Close(); | ||
DbConnection = null; | ||
} | ||
disposedValue = true; | ||
} | ||
} | ||
|
||
public void Dispose() => Dispose(true); | ||
public void Close() => Dispose(); | ||
|
||
public abstract IDbConnectionManager Clone(); | ||
#endregion | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
ETLBox/Definitions/ConnectionManager/IConnectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace ALE.ETLBox { | ||
public interface IConnectionManager : IDisposable { | ||
ConnectionString ConnectionString { get; } | ||
void Open(); | ||
void Close(); | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
ETLBox/Definitions/ConnectionManager/ICubeConnectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ALE.ETLBox { | ||
public interface ICubeConnectionManager : IConnectionManager { | ||
void Process(); | ||
void DropIfExists(); | ||
ICubeConnectionManager Clone(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ETLBox/Definitions/ConnectionManager/IDbConnectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Data; | ||
|
||
namespace ALE.ETLBox { | ||
public interface IDbConnectionManager : IConnectionManager { | ||
int ExecuteNonQuery(string command); | ||
object ExecuteScalar(string command); | ||
IDataReader ExecuteReader(string command); | ||
void BulkInsert(IDataReader data, IColumnMappingCollection columnMapping, string tableName); | ||
IDbConnectionManager Clone(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace ALE.ETLBox { | ||
public interface IDataFlowDestination<TInput> : IDataFlowLinkTarget<TInput> { | ||
void Wait(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System.Threading.Tasks.Dataflow; | ||
|
||
namespace ALE.ETLBox { | ||
public interface IDataFlowLinkSource<TOutput> { | ||
ISourceBlock<TOutput> SourceBlock { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System.Threading.Tasks.Dataflow; | ||
|
||
namespace ALE.ETLBox { | ||
public interface IDataFlowLinkTarget<TInput> { | ||
ITargetBlock<TInput> TargetBlock { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ALE.ETLBox { | ||
public interface IDataFlowSource<TOutput> : IDataFlowLinkSource<TOutput> { | ||
void ExecuteAsync(); | ||
void LinkTo(IDataFlowLinkTarget<TOutput> target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace ALE.ETLBox { | ||
public interface IDataFlowTransformation<TInput,TOutput> : IDataFlowLinkSource<TOutput>, IDataFlowLinkTarget<TInput> { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace ALE.ETLBox { | ||
public class TypeInfo { | ||
public PropertyInfo[] PropertyInfos { get; set; } | ||
public int PropertyLength { get; set; } | ||
public bool IsArray { get; set; } = true; | ||
|
||
public TypeInfo() { | ||
|
||
} | ||
|
||
public TypeInfo(Type typ) { | ||
GatherTypeInfos(typ); | ||
} | ||
private void GatherTypeInfos(Type typ) { | ||
IsArray = typ.IsArray; | ||
if (!typ.IsArray) { | ||
PropertyInfos = typ.GetProperties(); | ||
PropertyLength = PropertyInfos.Length; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace ALE.ETLBox { | ||
public interface ITableColumn { | ||
string Name { get; } | ||
string DataType { get; } | ||
bool AllowNulls { get; } | ||
bool IsIdentity { get; } | ||
int? IdentitySeed { get; } | ||
int? IdentityIncrement { get; } | ||
bool IsPrimaryKey { get; } | ||
string DefaultValue { get; } | ||
string DefaultConstraintName { get; } | ||
string Collation { get; } | ||
string ComputedColumn { get; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ALE.ETLBox { | ||
public class ProcedureDefinition { | ||
public string Name { get; set; } | ||
public string Definition { get; set; } | ||
|
||
public List<ProcedureParameter> Parameter { get; set; } | ||
|
||
public ProcedureDefinition() { | ||
Parameter = new List<ProcedureParameter>(); | ||
} | ||
|
||
public ProcedureDefinition(string name, string definition) : this() { | ||
Name = name; | ||
Definition = definition; | ||
} | ||
|
||
public ProcedureDefinition(string name, string definition, List<ProcedureParameter> parameter) : this(name, definition) { | ||
Parameter = parameter; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
|
||
namespace ALE.ETLBox { | ||
public class ProcedureParameter { | ||
public string Name { get; set; } | ||
public string DataType { get; set; } | ||
public string DefaultValue { get; set; } | ||
public bool HasDefaultValue => !String.IsNullOrWhiteSpace(DefaultValue); | ||
public bool ReadOnly { get; set; } | ||
public bool Out { get; set; } | ||
public string Sql { | ||
get { | ||
string sql = $@"@{Name} {DataType}"; | ||
if (HasDefaultValue) | ||
sql += $" = {DefaultValue}"; | ||
if (Out) | ||
sql += " OUT"; | ||
if (ReadOnly) | ||
sql += " READONLY"; | ||
return sql; | ||
} | ||
} | ||
|
||
public ProcedureParameter() { | ||
} | ||
|
||
public ProcedureParameter(string name, string dataType) : this() { | ||
Name = name; | ||
DataType = dataType; | ||
} | ||
|
||
public ProcedureParameter(string name, string dataType, string defaultValue) : this(name, dataType) { | ||
DefaultValue = defaultValue; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Data; | ||
|
||
namespace ALE.ETLBox { | ||
public class TableColumn : ITableColumn, IColumnMapping { | ||
private string _dataSetColumn; | ||
private string _sourceColumn; | ||
|
||
public string Name { get; set; } | ||
public string DataType { get; set; } | ||
public bool AllowNulls { get; set; } | ||
public bool IsIdentity { get; set; } | ||
public int? IdentitySeed { get; set; } | ||
public int? IdentityIncrement { get; set; } | ||
public bool IsPrimaryKey { get; set; } | ||
public string DefaultValue { get; set; } | ||
public string DefaultConstraintName { get; set; } | ||
public string Collation { get; set; } | ||
public string ComputedColumn { get; set; } | ||
public System.Type NETDataType => Type.GetType(DataTypeConverter.GetObjectTypeString(DataType)); | ||
|
||
|
||
public string DataSetColumn { | ||
get { return String.IsNullOrWhiteSpace(_dataSetColumn) ? Name : _dataSetColumn; } | ||
set { | ||
_dataSetColumn = value; | ||
} | ||
} | ||
public string SourceColumn { | ||
get { return String.IsNullOrWhiteSpace(_sourceColumn) ? Name : _sourceColumn; } | ||
set { | ||
_sourceColumn = value; | ||
} | ||
} | ||
|
||
public TableColumn() { } | ||
public TableColumn(string name, string dataType) : this() { | ||
Name = name; | ||
DataType = dataType; | ||
} | ||
|
||
public TableColumn(string name, string dataType, bool allowNulls) : this(name, dataType) { | ||
AllowNulls = allowNulls; | ||
} | ||
|
||
public TableColumn(string name, string dataType, bool allowNulls, bool isPrimaryKey) : this(name, dataType, allowNulls) { | ||
IsPrimaryKey = isPrimaryKey; | ||
} | ||
|
||
public TableColumn(string name, string dataType, bool allowNulls, bool isPrimaryKey, bool isIdentity) : this(name, dataType, allowNulls, isPrimaryKey) { | ||
IsIdentity = isIdentity; | ||
} | ||
} | ||
} |
Oops, something went wrong.