Checking in latest SDALEO changes optimizing Advantage really only.

This commit is contained in:
2016-07-25 14:48:03 -04:00
parent 122796eaa3
commit 4a683f3443
114 changed files with 1173 additions and 372 deletions

View File

@@ -9,28 +9,37 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_app</RootNamespace> <RootNamespace>_app</RootNamespace>
<AssemblyName>!app</AssemblyName> <AssemblyName>!app</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -43,6 +52,15 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sdaleo.csproj">
<Project>{c919d6d0-e0ae-4d7a-b13d-350fcb4a22ff}</Project>
<Name>Sdaleo</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -10,17 +10,26 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|Any CPU.Build.0 = Debug|Any CPU {38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|x86.ActiveCfg = Debug|x86
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Debug|x86.Build.0 = Debug|x86
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|Any CPU.ActiveCfg = Release|Any CPU {38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|Any CPU.Build.0 = Release|Any CPU {38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|Any CPU.Build.0 = Release|Any CPU
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|x86.ActiveCfg = Release|Any CPU
{38FF1664-EDE6-4E9F-BD32-AB1BA99F792D}.Release|x86.Build.0 = Release|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Debug|x86.ActiveCfg = Debug|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|Any CPU.Build.0 = Release|Any CPU {C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|Any CPU.Build.0 = Release|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|x86.ActiveCfg = Release|Any CPU
{C919D6D0-E0AE-4D7A-B13D-350FCB4A22FF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Binary file not shown.

View File

@@ -1,4 +1,6 @@
using System; using Sdaleo;
using Sdaleo.Systems.Advantage;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -7,14 +9,23 @@ namespace _app
{ {
class Program class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
//var Running = Yaulw.Win32.COM.GetActiveObjects(""); AdvantageCredential cred = new AdvantageCredential(@"\\medisoft_server\medidata\EMBARK RECOVERY LLC\mwddf.add", "user", "password", AdvantageCredential.ServerType.REMOTE_LOCAL);
//var RunningExcelWorkbooks = Yaulw.Win32.COM.GetRunningObjects();
//int n1 = Running.Count();
//int n2 = RunningExcelWorkbooks.Count();
DB db = DB.Create(cred);
DBRetVal retVal = db.FillDataTable("Select Top 10 FROM MWPAT");
if (!retVal.IsValid)
{
Console.WriteLine(retVal.ErrorMsg);
return;
}
else
{
Console.WriteLine("Fetched successfully");
}
} }
} }
} }

3
!app/app.config Normal file
View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
!app/bin/x86/Debug/!app.exe Normal file

Binary file not shown.

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -8,3 +8,10 @@ C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Debug\!app.exe
C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Debug\!app.pdb C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Debug\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Debug\!app.exe C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Debug\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Debug\!app.pdb C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Debug\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\!app.exe.config
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\Sdaleo.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\Advantage.Data.Provider.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Debug\Sdaleo.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Debug\!app.csprojResolveAssemblyReference.cache

Binary file not shown.

Binary file not shown.

View File

@@ -8,3 +8,16 @@ C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Release\!app.exe
C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Release\!app.pdb C:\Users\DieSonne99\Desktop\Yaulw\!app\obj\Release\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Release\!app.exe C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Release\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Release\!app.pdb C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Release\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\!app.exe.config
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\Sdaleo.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\Advantage.Data.Provider.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\Release\Sdaleo.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\Release\!app.csprojResolveAssemblyReference.cache
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\!app.exe.config
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\Sdaleo.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\Advantage.Data.Provider.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Release\Sdaleo.pdb

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,9 @@
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\!app.exe.config
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\!app.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\Sdaleo.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\Advantage.Data.Provider.dll
C:\Users\DieSonne99\Desktop\Sdaleo\!app\bin\x86\Debug\Sdaleo.pdb
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\x86\Debug\!app.csprojResolveAssemblyReference.cache
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\x86\Debug\!app.exe
C:\Users\DieSonne99\Desktop\Sdaleo\!app\obj\x86\Debug\!app.pdb

BIN
!app/obj/x86/Debug/!app.exe Normal file

Binary file not shown.

BIN
!app/obj/x86/Debug/!app.pdb Normal file

Binary file not shown.

BIN
Components/ADSLOC32.dll Normal file

Binary file not shown.

BIN
Components/Ace32.dll Normal file

Binary file not shown.

BIN
Components/axcws32.dll Normal file

Binary file not shown.

75
DB.cs
View File

@@ -54,12 +54,22 @@ namespace Sdaleo
#region NonQuery #region NonQuery
/// <summary> /// <summary>
/// Use this to Run SQL with the ExecuteNonQuery() Command Object /// Use this to Run SQL with the ExecuteNonQuery() Command Object
/// </summary> /// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param> /// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns> /// <returns>the result of the ExecuteNonQuery() operation</returns>
public DBRetVal ExecuteNonQuery(string SqlCommandText) public DBRetVal ExecuteNonQuery(string SqlCommandText)
{
return ExecuteNonQuery(SqlCommandText, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the ExecuteNonQuery() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns>
public DBRetVal ExecuteNonQuery(string SqlCommandText, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -70,6 +80,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlCommandText; cmd.CommandText = SqlCommandText;
cmd.CommandType = type;
if(_ConnectionStrObj.SupportsTimeouts) if(_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int) _ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int) _ConnectionStrObj.Timeouts.CommandTimeout;
int nRows = cmd.ExecuteNonQuery(); int nRows = cmd.ExecuteNonQuery();
@@ -91,6 +102,17 @@ namespace Sdaleo
/// <param name="parameters">Allows the use of DBMS Independent parameters</param> /// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns> /// <returns>the result of the ExecuteNonQuery() operation</returns>
public DBRetVal ExecuteNonQuery(string SqlCommandText, DBMSIndParameter[] parameters) public DBRetVal ExecuteNonQuery(string SqlCommandText, DBMSIndParameter[] parameters)
{
return ExecuteNonQuery(SqlCommandText, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the ExecuteNonQuery() Command Object
/// </summary>
/// <param name="SqlCommandText">SQL Text/Commands to execute</param>
/// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the ExecuteNonQuery() operation</returns>
public DBRetVal ExecuteNonQuery(string SqlCommandText, DBMSIndParameter[] parameters, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -101,6 +123,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlCommandText; cmd.CommandText = SqlCommandText;
cmd.CommandType = type;
if (_ConnectionStrObj.SupportsTimeouts) if (_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout;
@@ -130,6 +153,16 @@ namespace Sdaleo
/// <param name="SqlText">SQL Text to execute</param> /// <param name="SqlText">SQL Text to execute</param>
/// <returns>the result of the ExecuteScalar() operation</returns> /// <returns>the result of the ExecuteScalar() operation</returns>
public DBRetVal ExecuteScalar(string SqlText) public DBRetVal ExecuteScalar(string SqlText)
{
return ExecuteScalar(SqlText, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the ExecuteScalar() Command Object
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <returns>the result of the ExecuteScalar() operation</returns>
public DBRetVal ExecuteScalar(string SqlText, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -140,6 +173,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlText; cmd.CommandText = SqlText;
cmd.CommandType = type;
if (_ConnectionStrObj.SupportsTimeouts) if (_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout;
object oResult = cmd.ExecuteScalar(); object oResult = cmd.ExecuteScalar();
@@ -161,6 +195,17 @@ namespace Sdaleo
/// <param name="parameters">Allows the use of DBMS Independent parameters</param> /// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the ExecuteScalar() operation</returns> /// <returns>the result of the ExecuteScalar() operation</returns>
public DBRetVal ExecuteScalar(string SqlText, DBMSIndParameter[] parameters) public DBRetVal ExecuteScalar(string SqlText, DBMSIndParameter[] parameters)
{
return ExecuteScalar(SqlText, parameters, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the ExecuteScalar() Command Object
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the ExecuteScalar() operation</returns>
public DBRetVal ExecuteScalar(string SqlText, DBMSIndParameter[] parameters, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -171,6 +216,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlText; cmd.CommandText = SqlText;
cmd.CommandType = type;
if (_ConnectionStrObj.SupportsTimeouts) if (_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout;
@@ -194,12 +240,22 @@ namespace Sdaleo
#region DataTable #region DataTable
/// <summary> /// <summary>
/// Use this to Run SQL with the DataAdapter Fill() /// Use this to Run SQL with the DataAdapter Fill()
/// </summary> /// </summary>
/// <param name="SqlText">SQL Text to execute</param> /// <param name="SqlText">SQL Text to execute</param>
/// <returns>the result of the DataAdapter Fill() operation</returns> /// <returns>the result of the DataAdapter Fill() operation</returns>
public DBRetVal FillDataTable(string SqlText) public DBRetVal FillDataTable(string SqlText)
{
return FillDataTable(SqlText, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the DataAdapter Fill()
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <returns>the result of the DataAdapter Fill() operation</returns>
public DBRetVal FillDataTable(string SqlText, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -210,6 +266,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlText; cmd.CommandText = SqlText;
cmd.CommandType = type;
if (_ConnectionStrObj.SupportsTimeouts) if (_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout;
@@ -229,13 +286,24 @@ namespace Sdaleo
return retVal; return retVal;
} }
/// <summary> /// <summary>
/// Use this to Run SQL with the DataAdapter Fill() /// Use this to Run SQL with the DataAdapter Fill()
/// </summary> /// </summary>
/// <param name="SqlText">SQL Text to execute</param> /// <param name="SqlText">SQL Text to execute</param>
/// <param name="parameters">Allows the use of DBMS Independent parameters</param> /// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the DataAdapter Fill() operation</returns> /// <returns>the result of the DataAdapter Fill() operation</returns>
public DBRetVal FillDataTable(string SqlText, DBMSIndParameter[] parameters) public DBRetVal FillDataTable(string SqlText, DBMSIndParameter[] parameters)
{
return FillDataTable(SqlText, parameters, CommandType.Text);
}
/// <summary>
/// Use this to Run SQL with the DataAdapter Fill()
/// </summary>
/// <param name="SqlText">SQL Text to execute</param>
/// <param name="parameters">Allows the use of DBMS Independent parameters</param>
/// <returns>the result of the DataAdapter Fill() operation</returns>
public DBRetVal FillDataTable(string SqlText, DBMSIndParameter[] parameters, CommandType type)
{ {
DBRetVal retVal = new DBRetVal(); DBRetVal retVal = new DBRetVal();
try try
@@ -246,6 +314,7 @@ namespace Sdaleo
using (DbCommand cmd = conn.CreateCommand()) using (DbCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = SqlText; cmd.CommandText = SqlText;
cmd.CommandType = type;
if (_ConnectionStrObj.SupportsTimeouts) if (_ConnectionStrObj.SupportsTimeouts)
cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout; cmd.CommandTimeout = (int)_ConnectionStrObj.Timeouts.CommandTimeout;

View File

@@ -11,17 +11,47 @@ namespace Sdaleo
/// Our Custom Database Error Class that DB Functions Return to External Callers /// Our Custom Database Error Class that DB Functions Return to External Callers
/// </summary> /// </summary>
public class DBError public class DBError
{ {
/// <summary>
/// Used internally to quickly create a custom error object for
/// default Database Layer Errors
/// </summary>
/// <param name="ErrorMsg">The Error Message to Display</param>
internal const int DATABASE_LAYER_ERROR_NUMBER = 1978;
/// <summary>
/// Error number defaulted to -1
/// </summary>
public int nError { get; set; } public int nError { get; set; }
/// <summary>
/// Error message defaulted to ""
/// </summary>
public string ErrorMsg { get; set; } public string ErrorMsg { get; set; }
/// <summary>
/// List of Error IDs (defaulted to null)
/// </summary>
public ICollection Errors { get; set; } public ICollection Errors { get; set; }
#region Construction
/// <summary>
/// Create a defaulted Error Object
/// </summary>
public DBError() public DBError()
{ {
nError = -1; nError = -1;
ErrorMsg = String.Empty; ErrorMsg = String.Empty;
Errors = null; Errors = null;
} }
/// <summary>
/// Create a custom Error Object
/// </summary>
/// <param name="nError"></param>
/// <param name="ErrorMsg"></param>
/// <param name="Errors"></param>
public DBError(int nError, string ErrorMsg, ICollection Errors) public DBError(int nError, string ErrorMsg, ICollection Errors)
{ {
this.nError = nError; this.nError = nError;
@@ -30,35 +60,40 @@ namespace Sdaleo
} }
/// <summary> /// <summary>
/// Used internally to quickly create a custom error object /// Initialize DBError with SDaleo Default Error Info
/// </summary> /// </summary>
/// <param name="ErrorMsg">The Error Message to Display</param> public DBError(string ErrorMsg)
private const int DATABASE_LAYER_ERROR_NUMBER = 1978; {
this.nError = DATABASE_LAYER_ERROR_NUMBER;
this.ErrorMsg = ErrorMsg;
this.Errors = null;
}
#endregion
#region Internal Static
/// <summary>
/// Create a Default DatabaseLayer Sdaleo Error
/// </summary>
/// <param name="ErrorMsg"></param>
/// <returns></returns>
internal static DBError Create(string ErrorMsg) internal static DBError Create(string ErrorMsg)
{ {
return new DBError(DATABASE_LAYER_ERROR_NUMBER, ErrorMsg, null); return new DBError(DATABASE_LAYER_ERROR_NUMBER, ErrorMsg, null);
} }
public bool ErrorOccured { get { return (nError != -1 && !String.IsNullOrEmpty(ErrorMsg)); } } #endregion
public int GetErrorCount { get { if (Errors != null) { return Errors.Count; } return 0; } }
public List<int> GetAllErrorNumbers
{
get
{
if (Errors != null)
{
List<int> list = new List<int>();
// * DBMS SPECIFIC * /// <summary>
// TO DO /// Did an error occur? nError != -1 and ErrorMsg != ""
foreach (SqlError error in Errors) /// </summary>
list.Add(error.Number); public bool ErrorOccured
// {
get
return list; {
} return (nError != -1 && !String.IsNullOrEmpty(ErrorMsg));
return null; }
} }
}
} }
} }

View File

@@ -42,6 +42,8 @@ namespace Sdaleo
} }
private Mode _Mode = Mode.MODE_INIT; private Mode _Mode = Mode.MODE_INIT;
#region Construction
/// <summary> /// <summary>
/// Initialize DBRetVal /// Initialize DBRetVal
/// </summary> /// </summary>
@@ -68,7 +70,22 @@ namespace Sdaleo
RetVal_int = Int32.MinValue; RetVal_int = Int32.MinValue;
} }
#region Validator /// <summary>
/// Initialize DBRetVal with SDaleo Default Error Info
/// </summary>
public DBRetVal(string ErrorMsg)
: base(ErrorMsg)
{
_Mode = Mode.MODE_INIT;
Result = DBRetValEnum.FAILED;
RetVal_datatable = null;
RetVal_string = String.Empty;
RetVal_int = Int32.MinValue;
}
#endregion
#region Validator
/// <summary> /// <summary>
/// Returns True if the Return value of this object is valid /// Returns True if the Return value of this object is valid
@@ -128,6 +145,22 @@ namespace Sdaleo
} }
} }
/// <summary>
/// Get the First Row of the DataTable Return Value
/// </summary>
/// <returns>valid datatable or throws Exception, if in invalid state</returns>
public DataRow GetDataTableFirstRow()
{
if (_Mode == Mode.MODE_VALUE_DT)
{
return RetVal_datatable.Rows[0];
}
else
{
throw new Exception(String.Format("Invalid State {0}. Can not call GetRetVal() for DataTable right now", _Mode.ToString()));
}
}
/// <summary> /// <summary>
/// Get the Scalar/String Return Value /// Get the Scalar/String Return Value
/// </summary> /// </summary>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Data;
namespace Sdaleo namespace Sdaleo
{ {
@@ -55,4 +56,12 @@ namespace Sdaleo
IConnectDb WithCommandTimeout(uint nCommandTimeout); IConnectDb WithCommandTimeout(uint nCommandTimeout);
IConnectDb WithTimeouts(uint nConnectionTimeout, uint nCommandTimeout); IConnectDb WithTimeouts(uint nConnectionTimeout, uint nCommandTimeout);
} }
/// <summary>
/// Expose Connection Pool Clearing
/// </summary>
public interface IClearConnectionPool
{
void ClearConnectionPool(IConnectDb cn);
}
} }

View File

@@ -2,13 +2,26 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Collections;
using Sdaleo.Systems;
using System.Data.Common; using System.Data.Common;
#if SQLSERVER
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Collections; #endif
#if SQLCOMPACT
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using Sdaleo.Systems; #endif
using Devart.Data.PostgreSql; #if ADVANTAGE
using Advantage.Data.Provider;
#endif
#if CTREE
#endif
#if MYSQL
#endif
#if POSTGRES
//using Devart.Data.PostgreSql;
#endif
namespace Sdaleo namespace Sdaleo
{ {
@@ -17,6 +30,8 @@ namespace Sdaleo
/// </summary> /// </summary>
internal static class DBMS internal static class DBMS
{ {
#region Connection DB Specifics
/// <summary> /// <summary>
/// Creates a Connection Object depending on the type of DBMS we are using /// Creates a Connection Object depending on the type of DBMS we are using
/// </summary> /// </summary>
@@ -30,34 +45,37 @@ namespace Sdaleo
{ {
switch (dbsystem) switch (dbsystem)
{ {
#if SQLSERVER
case DBSystem.SQL_SERVER: case DBSystem.SQL_SERVER:
if(SystemAvailable.Check(dbsystem)) connection = (DbConnection)new SqlConnection(ConnectionStr);
connection = (DbConnection)new SqlConnection(ConnectionStr);
break; break;
#endif
case DBSystem.SQL_CE: #if SQLCOMPACT
if (SystemAvailable.Check(dbsystem)) case DBSystem.SQL_CE:
connection = (DbConnection)new SqlCeConnection(ConnectionStr); connection = (DbConnection)new SqlCeConnection(ConnectionStr);
break; break;
#endif
#if ADVANTAGE
case DBSystem.ADVANTAGE: case DBSystem.ADVANTAGE:
if (SystemAvailable.Check(dbsystem)) connection = (DbConnection)new AdsConnection(ConnectionStr);
connection = (DbConnection)new SqlCeConnection(ConnectionStr);
break; break;
#endif
#if CTREE
case DBSystem.CTREE: case DBSystem.CTREE:
if (SystemAvailable.Check(dbsystem)) connection = null;
connection = (DbConnection)new SqlCeConnection(ConnectionStr);
break; break;
#endif
#if MYSQL
case DBSystem.MYSQL: case DBSystem.MYSQL:
if (SystemAvailable.Check(dbsystem)) connection = null;
connection = (DbConnection)new SqlCeConnection(ConnectionStr);
break; break;
#endif
#if POSTGRES
case DBSystem.POSTGRES: case DBSystem.POSTGRES:
if (SystemAvailable.Check(dbsystem)) connection = null;
connection = (DbConnection)new PgSqlConnection(ConnectionStr); break;
#endif
default:
break; break;
} }
} }
@@ -75,118 +93,41 @@ namespace Sdaleo
DbDataAdapter dbDataAdapter = null; DbDataAdapter dbDataAdapter = null;
switch (dbsystem) switch (dbsystem)
{ {
case DBSystem.SQL_SERVER: #if SQLSERVER
if (SystemAvailable.Check(dbsystem)) case DBSystem.SQL_SERVER:
dbDataAdapter = new SqlDataAdapter((SqlCommand) dbcommand); dbDataAdapter = new SqlDataAdapter((SqlCommand) dbcommand);
break; break;
#endif
#if SQLCOMPACT
case DBSystem.SQL_CE: case DBSystem.SQL_CE:
if (SystemAvailable.Check(dbsystem)) dbDataAdapter = new SqlCeDataAdapter((SqlCeCommand) dbcommand);
dbDataAdapter = new SqlCeDataAdapter((SqlCeCommand) dbcommand);
break; break;
#endif
#if ADVANTAGE
case DBSystem.ADVANTAGE: case DBSystem.ADVANTAGE:
if (SystemAvailable.Check(dbsystem)) dbDataAdapter = new AdsDataAdapter((AdsCommand) dbcommand);
dbDataAdapter = new SqlCeDataAdapter((SqlCeCommand)dbcommand);
break; break;
#endif
#if CTREE
case DBSystem.CTREE: case DBSystem.CTREE:
if (SystemAvailable.Check(dbsystem)) dbDataAdapter = null;
dbDataAdapter = new SqlCeDataAdapter((SqlCeCommand)dbcommand);
break; break;
#endif
#if MYSQL
case DBSystem.MYSQL: case DBSystem.MYSQL:
if (SystemAvailable.Check(dbsystem)) dbDataAdapter = null;
dbDataAdapter = new SqlCeDataAdapter((SqlCeCommand)dbcommand);
break; break;
#endif
case DBSystem.POSTGRES: #if POSTGRES
if (SystemAvailable.Check(dbsystem)) case DBSystem.POSTGRES:
dbDataAdapter = new PgSqlDataAdapter((PgSqlCommand)dbcommand); dbDataAdapter = null;
break;
#endif
default:
break; break;
} }
return dbDataAdapter; return dbDataAdapter;
} }
/// <summary>
/// Creates an Error Object to be returned to the Caller, fills values depending on DBMS
/// </summary>
/// <param name="dbsystem">the DBSystem you want an Error for</param>
/// <param name="e">the exception being thrown by the DBMS</param>
/// <returns>a DBRetVal Object filled with the Error Data, or null if system is not available</returns>
internal static DBRetVal CreateErrorDBRetVal(DBSystem dbsystem, Exception e)
{
DBRetVal retVal = null;
switch (dbsystem)
{
case DBSystem.SQL_SERVER:
{
if (SystemAvailable.Check(dbsystem))
{
SqlException ex = e as SqlException;
if (ex != null)
retVal = new DBRetVal(ex.Number, ex.Message, ex.Errors);
}
}
break;
case DBSystem.SQL_CE:
{
if (SystemAvailable.Check(dbsystem))
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
}
break;
case DBSystem.ADVANTAGE:
{
if (SystemAvailable.Check(dbsystem))
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
}
break;
case DBSystem.CTREE:
{
if (SystemAvailable.Check(dbsystem))
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
}
break;
case DBSystem.MYSQL:
{
if (SystemAvailable.Check(dbsystem))
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
}
break;
case DBSystem.POSTGRES:
{
if (SystemAvailable.Check(dbsystem))
{
PgSqlException ex = e as PgSqlException;
if (ex != null)
retVal = new DBRetVal(0, ex.Message, null);
}
}
break;
}
return retVal;
}
/// <summary> /// <summary>
/// Creates a DBMS Specific Parameter Array from a DMBS Independent Parameter Array /// Creates a DBMS Specific Parameter Array from a DMBS Independent Parameter Array
@@ -203,64 +144,244 @@ namespace Sdaleo
{ {
switch (dbsystem) switch (dbsystem)
{ {
#if SQLSERVER
case DBSystem.SQL_SERVER: case DBSystem.SQL_SERVER:
{ param_s.Add(new SqlParameter(parameter.parameterName, parameter.Value));
if (SystemAvailable.Check(dbsystem))
{
param_s.Add(new SqlParameter(parameter.parameterName, parameter.Value));
}
}
break; break;
#endif
#if SQLCOMPACT
case DBSystem.SQL_CE: case DBSystem.SQL_CE:
{ param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
if (SystemAvailable.Check(dbsystem))
{
param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
}
}
break; break;
#endif
#if ADVANTAGE
case DBSystem.ADVANTAGE: case DBSystem.ADVANTAGE:
{ param_s.Add(new AdsParameter(parameter.parameterName, parameter.Value));
if (SystemAvailable.Check(dbsystem))
{
param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
}
}
break; break;
#endif
#if CTREE
case DBSystem.CTREE: case DBSystem.CTREE:
{ //param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
if (SystemAvailable.Check(dbsystem))
{
param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
}
}
break; break;
#endif
#if MYSQL
case DBSystem.MYSQL: case DBSystem.MYSQL:
{ //param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
if (SystemAvailable.Check(dbsystem))
{
param_s.Add(new SqlCeParameter(parameter.parameterName, parameter.Value));
}
}
break; break;
#endif
case DBSystem.POSTGRES: #if POSTGRES
{ case DBSystem.POSTGRES:
if (SystemAvailable.Check(dbsystem)) //param_s.Add(new PgSqlParameter(parameter.parameterName, parameter.Value));
{ break;
param_s.Add(new PgSqlParameter(parameter.parameterName, parameter.Value)); #endif
} default:
}
break; break;
} }
} }
// Return the Parameter // Return the Parameter
return param_s.ToArray(); return param_s.ToArray();
} }
#endregion
#region Exception DB Specifics
/// <summary>
/// Creates an Error Object to be returned to the Caller, fills values depending on DBMS
/// </summary>
/// <param name="dbsystem">the DBSystem you want an Error for</param>
/// <param name="e">the exception being thrown by the DBMS</param>
/// <returns>a DBRetVal Object filled with the Error Data, or null if system is not available</returns>
internal static DBRetVal CreateErrorDBRetVal(DBSystem dbsystem, Exception e)
{
////
// We want to always make sure in this function that we always return a DBRetVal object
// we should never return null
////
DBRetVal retVal = null;
if(e == null || String.IsNullOrEmpty(e.Message))
{
retVal = new DBRetVal("DB Error Exception object is null or with Empty Message");
return retVal;
}
try
{
switch (dbsystem)
{
#if SQLSERVER
case DBSystem.SQL_SERVER:
{
SqlException ex = e as SqlException;
if (ex != null)
retVal = new DBRetVal(ex.Number, ex.Message, ex.Errors);
}
break;
#endif
#if SQLCOMPACT
case DBSystem.SQL_CE:
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
break;
#endif
#if ADVANTAGE
case DBSystem.ADVANTAGE:
{
AdsException ex = e as AdsException;
if (ex != null)
retVal = new DBRetVal(ex.Number, ex.Message, null);
}
break;
#endif
#if CTREE
case DBSystem.CTREE:
{
//SqlCeException ex = e as SqlCeException;
//if (ex != null)
// retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
break;
#endif
#if MYSQL
case DBSystem.MYSQL:
{
//SqlCeException ex = e as SqlCeException;
//if (ex != null)
// retVal = new DBRetVal(ex.NativeError, ex.Message, ex.Errors);
}
break;
#endif
#if POSTGRES
case DBSystem.POSTGRES:
{
//PgSqlException ex = e as PgSqlException;
//if (ex != null)
// retVal = new DBRetVal(0, ex.Message, null);
}
break;
#endif
default:
break;
}
}
catch (Exception ex)
{
retVal = new DBRetVal(ex.Message);
}
////
// We want to always make sure in this function that we always return a DBRetVal object
// we should never return null
////
if (retVal == null)
retVal = new DBRetVal("DB Error Exception object could not be created");
return retVal;
}
/// <summary>
/// Returns the Error Number for the specified Exception Object for the specified DMBS,
/// or -1 if an error occured
/// </summary>
/// <param name="dbsystem">>the DBSystem you want an Error Number for</param>
/// <param name="e">the exception being thrown by the DBMS</param>
/// <returns>the Error Number (ID) of the Exception thrown or -1 if anything else happened</returns>
internal static int GetErrorNumberForErrorObject(DBSystem dbsystem, Exception e)
{
int nError = -1;
if (e == null || String.IsNullOrEmpty(e.Message))
return nError;
try
{
switch (dbsystem)
{
#if SQLSERVER
case DBSystem.SQL_SERVER:
{
SqlException ex = e as SqlException;
if (ex != null)
nError = ex.Number;
}
break;
#endif
#if SQLCOMPACT
case DBSystem.SQL_CE:
{
SqlCeException ex = e as SqlCeException;
if (ex != null)
nError = ex.NativeError;
}
break;
#endif
#if ADVANTAGE
case DBSystem.ADVANTAGE:
{
AdsException ex = e as AdsException;
if (ex != null)
nError = ex.Number;
}
break;
#endif
#if CTREE
case DBSystem.CTREE:
{
//SqlCeException ex = e as SqlCeException;
//if (ex != null)
// nError = ex.NativeError;
}
break;
#endif
#if MYSQL
case DBSystem.MYSQL:
{
//SqlCeException ex = e as SqlCeException;
//if (ex != null)
// nError = ex.NativeError;
}
break;
#endif
#if POSTGRES
case DBSystem.POSTGRES:
{
//PgSqlException ex = e as PgSqlException;
//if (ex != null)
// nError = ex.NativeError;
}
break;
#endif
default:
break;
}
}
catch (Exception ex) { /* ignore */ }
return nError;
}
/// <summary>
/// Retrieves all Error Numbers that the specified DBError has in it's collection.
/// If it doesn't have a collection it will just return an empty list.
/// </summary>
/// <param name="dbsystem"></param>
/// <param name="error"></param>
/// <returns></returns>
internal static List<int> GetAllErrorNumbers(DBSystem dbsystem, DBError error)
{
List<int> list = new List<int>();
if (error != null && error.Errors != null)
{
foreach (Exception e in error.Errors)
{
int nError = GetErrorNumberForErrorObject(dbsystem, e);
list.Add(nError);
}
}
return list;
}
#endregion
} }
} }

View File

@@ -23,6 +23,19 @@ namespace Sdaleo
return false; return false;
} }
/// <summary>
/// Returns true if passed in object is valid and is empty
/// </summary>
/// <param name="oToValidate">an object to validate</param>
/// <returns>true if valid, false otherwise</returns>
internal static bool IsNotNullAndIsEmpty(object oToValidate)
{
if ((oToValidate != null) && (oToValidate.ToString() == String.Empty))
return true;
else
return false;
}
/// <summary> /// <summary>
/// Convert a string to an Object of Type T /// Convert a string to an Object of Type T
/// </summary> /// </summary>

View File

@@ -75,7 +75,7 @@ namespace Sdaleo
ServerAddress = values[0]; ServerAddress = values[0];
InstanceName = values[1]; InstanceName = values[1];
} }
else if (value.Length > 2) else if (values.Length > 2)
{ {
int nIndx = value.LastIndexOf('\\'); int nIndx = value.LastIndexOf('\\');
ServerAddress = value.Substring(0, nIndx); ServerAddress = value.Substring(0, nIndx);
@@ -120,6 +120,11 @@ namespace Sdaleo
/// </summary> /// </summary>
internal string AttachDBFilename { get; private set; } internal string AttachDBFilename { get; private set; }
/// <summary>
///
/// </summary>
internal string ServerType { get; private set; }
#endregion #endregion
#region ReadOnly Bool Getters #region ReadOnly Bool Getters
@@ -180,6 +185,26 @@ namespace Sdaleo
#endregion #endregion
#region Advantage Constructors
/// <summary>
/// Construction Advantage (Set common UDL Settings for Advantage)
/// </summary>
/// <param name="path"></param>
/// <param name="filename"></param>
/// <param name="Password"></param>
/// <param name="ServerType"></param>
internal UDL(string FileNameNPath, string UserID, string Password, string ServerType)
{
UseConnectionTimeout = false;
this.DataSource = FileNameNPath;
this.Username = UserID;
this.Password = Password;
this.ServerType = ServerType;
}
#endregion
#region SQL Server Constructors #region SQL Server Constructors
/// <summary> /// <summary>
@@ -330,6 +355,14 @@ namespace Sdaleo
strUDL += strAddMore; strUDL += strAddMore;
} }
// Advantage DB
if (!String.IsNullOrEmpty(ServerType))
{
string strAddMore = String.Format("ServerType={0};", ServerType);
strUDL += strAddMore;
strUDL += "TableType=ADT;";
}
// At the end, specifically add the connection timeout * If asked to * // At the end, specifically add the connection timeout * If asked to *
if (UseConnectionTimeout) if (UseConnectionTimeout)
{ {
@@ -367,41 +400,43 @@ namespace Sdaleo
String[] tokens = ConnectionString.Split(';'); String[] tokens = ConnectionString.Split(';');
foreach (string Pair in tokens) foreach (string Pair in tokens)
{ {
string[] KeyValuePair = Pair.Split('='); string[] KeyValuePair = Pair.Split('=');
try try
{ {
string left = KeyValuePair[0];
string right = KeyValuePair[1];
switch (KeyValuePair[0].ToUpper().Trim()) switch (KeyValuePair[0].ToUpper().Trim())
{ {
case "INITIAL CATALOG": case "INITIAL CATALOG":
DataBase = KeyValuePair[1].Trim(); DataBase = right.Trim();
break; break;
case "USER ID": case "USER ID":
Username = KeyValuePair[1].Trim(); Username = right.Trim();
break; break;
case "PASSWORD": case "PASSWORD":
Password = KeyValuePair[1]; Password = right;
break; break;
case "DATA SOURCE": case "DATA SOURCE":
DataSource = KeyValuePair[1].Trim(); DataSource = right.Trim();
break; break;
case "ATTACHDBFILENAME": case "ATTACHDBFILENAME":
AttachDBFilename = KeyValuePair[1].Trim(); AttachDBFilename = right.Trim();
break; break;
case "USER INSTANCE": case "USER INSTANCE":
UserInstance = Boolean.Parse(KeyValuePair[1].Trim()); UserInstance = Boolean.Parse(right.Trim());
break; break;
case "CONNECTION TIMEOUT": case "CONNECTION TIMEOUT":
ConnectionTimeout = UInt32.Parse(KeyValuePair[1].Trim()); ConnectionTimeout = UInt32.Parse(right.Trim());
break; break;
case "TRUSTED_CONNECTION": case "TRUSTED_CONNECTION":
TrustedConnection = Boolean.Parse(KeyValuePair[1].Trim()); TrustedConnection = Boolean.Parse(right.Trim());
break; break;
case "INTEGRATED SECURITY": case "INTEGRATED SECURITY":
@@ -420,9 +455,13 @@ namespace Sdaleo
Encrypt = true; Encrypt = true;
break; break;
case "SERVERTYPE":
ServerType = KeyValuePair[1].Trim();
break;
} }
} }
catch (Exception) { /* ignore and continue iteration */ } catch (Exception e) { string m = e.Message; /* ignore and continue iteration */ }
} }
} }
} }

View File

@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdaleo</RootNamespace> <RootNamespace>Sdaleo</RootNamespace>
<AssemblyName>Sdaleo</AssemblyName> <AssemblyName>Sdaleo</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SccProjectName> <SccProjectName>
</SccProjectName> </SccProjectName>
@@ -26,18 +26,20 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\Target\Debug\</OutputPath> <OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants> <DefineConstants>TRACE;DEBUG;NET35 ADVANTAGE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\Target\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NET35</DefineConstants> <DefineConstants>TRACE;NET35 ADVANTAGE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Advantage.Data.Provider"> <Reference Include="Advantage.Data.Provider">
@@ -51,7 +53,10 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" /> <Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Desktop\System.Data.SqlServerCe.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@@ -109,12 +114,17 @@
<Compile Include="Systems\ValidationConsts.cs" /> <Compile Include="Systems\ValidationConsts.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Components\Advantage.Data.Provider.dll" /> <EmbeddedResource Include="Components\Advantage.Data.Provider.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Components\Devart.Data.dll" /> <EmbeddedResource Include="Components\Devart.Data.dll" />
<EmbeddedResource Include="Components\Devart.Data.PostgreSql.dll" /> <EmbeddedResource Include="Components\Devart.Data.PostgreSql.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Components\Ace32.dll" />
<EmbeddedResource Include="Components\ADSLOC32.dll" />
<EmbeddedResource Include="Components\axcws32.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -1,20 +1,30 @@
using System; #if ADVANTAGE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Advantage.Data.Provider;
using System.Net;
namespace Sdaleo.Systems.Advantage namespace Sdaleo.Systems.Advantage
{ {
/// <summary> /// <summary>
/// Handles SQL CE Credentials, to be /// Handles Advantage, to be
/// used by all our SQL CE Functions /// used by all our Advantage Functions
/// </summary> /// </summary>
public class AdvantageCredential : IComparable, ICloneable, IConnectDb public class AdvantageCredential : IComparable, ICloneable, IConnectDb, IClearConnectionPool
{ {
public enum ServerType
{
REMOTE,
LOCAL,
REMOTE_LOCAL
}
#region IConnectDb #region IConnectDb
/// <summary> /// <summary>
/// Let Callers know this is a SQLCE Connection Object /// Let Callers know this is a Advantage Connection Object
/// </summary> /// </summary>
public DBSystem DBType { get { return DBSystem.ADVANTAGE; } } public DBSystem DBType { get { return DBSystem.ADVANTAGE; } }
@@ -28,10 +38,8 @@ namespace Sdaleo.Systems.Advantage
if (!ValidationConsts.IsValidFileNameNPath(DataSource)) if (!ValidationConsts.IsValidFileNameNPath(DataSource))
return false; return false;
// For ADS i believe we always want a user and Password if (!ValidationConsts.Generic.IsValidServerName(User))
return false;
//if (!String.IsNullOrEmpty(_UDL.Password) && !ValidationConsts.Generic.IsValidPassword(_UDL.Password))
// return false;
return true; return true;
} }
@@ -43,32 +51,49 @@ namespace Sdaleo.Systems.Advantage
public string ConnectionString { get { return _UDL.ConnectionString; } } public string ConnectionString { get { return _UDL.ConnectionString; } }
/// <summary> /// <summary>
/// SQL CE uses the File Name and Path as the Datasource /// Advantage the File Name and Path as the Datasource
/// </summary> /// </summary>
public string DataSource { get { return _UDL.DataSource; } } public string DataSource { get { return _UDL.DataSource; } }
/// <summary> /// <summary>
/// SQL CE doesn't use User /// Advantage doesn't use User
/// </summary> /// </summary>
public string User { get { return _UDL.Username; } } public string User { get { return _UDL.Username; } }
/// <summary> /// <summary>
/// SQL CE doesn't support DBMS like behaviors /// Advantage Server Type
/// </summary>
public ServerType Type
{
get
{
try
{
ServerType type = (ServerType) Enum.Parse(typeof(ServerType), _UDL.ServerType.Replace('|','_'));
return type;
}
catch (Exception) { /* ignore */ }
return ServerType.LOCAL;
}
}
/// <summary>
/// Advantage doesn't really support DBMS like behaviors
/// </summary> /// </summary>
public bool SupportsDBMS { get { return false; } } public bool SupportsDBMS { get { return false; } }
/// <summary> /// <summary>
/// SQL CE doesn't support DBMS like behaviors /// Advantage doesn't support DBMS like behaviors
/// </summary> /// </summary>
public IamDBMS DBMS { get { return null; } } public IamDBMS DBMS { get { return null; } }
/// <summary> /// <summary>
/// SQL CE doesn't support Timeouts /// Advantage * not implemented *
/// </summary> /// </summary>
public bool SupportsTimeouts { get { return false; } } public bool SupportsTimeouts { get { return false; } }
/// <summary> /// <summary>
/// SQL CE doesn't support Timeouts /// Advantage * not implemented *
/// </summary> /// </summary>
public IsupportTimeouts Timeouts { get { return null; } } public IsupportTimeouts Timeouts { get { return null; } }
@@ -79,7 +104,7 @@ namespace Sdaleo.Systems.Advantage
#region AdvantageCredential Credential Constructors #region AdvantageCredential Credential Constructors
/// <summary> /// <summary>
/// Create a SQL CE Connection from an UDL Object /// Create a Advantage Connection from an UDL Object
/// </summary> /// </summary>
/// <param name="udl"></param> /// <param name="udl"></param>
internal AdvantageCredential(UDL udl) internal AdvantageCredential(UDL udl)
@@ -89,19 +114,32 @@ namespace Sdaleo.Systems.Advantage
} }
/// <summary> /// <summary>
/// Create an Untrusted SQLCE Credential * No Encryption Used * /// Create a Advantage Connection
/// </summary> /// </summary>
public AdvantageCredential(string FileNameNPath) public AdvantageCredential(string FileNameNPathInclUNCPath, string UserID, string Password, ServerType type)
{ {
_UDL = new UDL(FileNameNPath, String.Empty); string serverType = type.ToString().ToUpper().Replace('_', '|');
}
if (!String.IsNullOrEmpty(FileNameNPathInclUNCPath) && FileNameNPathInclUNCPath.StartsWith(@"\\"))
{
int n = FileNameNPathInclUNCPath.IndexOf(@"\", @"\\".Length);
if(n != -1)
{
IPAddress ipaddress;
string hostname = FileNameNPathInclUNCPath.Substring(@"\\".Length, n - @"\\".Length);
if(IPAddress.TryParse(hostname, out ipaddress))
{
serverType = ServerType.REMOTE.ToString();
if (!hostname.Contains(":"))
{
// Add Port Number to Ip Address * Required by Advantage * default port is 6262
FileNameNPathInclUNCPath = FileNameNPathInclUNCPath.Replace(hostname, hostname + ":6262");
}
}
}
}
/// <summary> _UDL = new UDL(FileNameNPathInclUNCPath, UserID, Password, serverType);
/// Create a Trusted SQLCE Credential * Encryption Used *
/// </summary>
public AdvantageCredential(string FileNameNPath, string strPassword)
{
_UDL = new UDL(FileNameNPath, strPassword);
} }
#endregion #endregion
@@ -133,5 +171,15 @@ namespace Sdaleo.Systems.Advantage
} }
#endregion #endregion
#region IClearConnectionPool Members
public void ClearConnectionPool(IConnectDb credential)
{
AdsConnection.FlushConnectionPool(credential.ConnectionString);
}
#endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if ADVANTAGE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -11,3 +12,4 @@ namespace Sdaleo.Systems.Advantage
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if ADVANTAGE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Advantage
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if ADVANTAGE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Advantage.Internal
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if CTREE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if CTREE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if CTREE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if CTREE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree.Internal
{ {
} }
} }
#endif

145
Systems/ConnStr.cs Normal file
View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sdaleo.Systems
{
public static class ConnStr
{
/// <summary>
/// Quick Check to see if a connection string is valid * must have DataSource Key and
/// a Value * in order to be considered a valid Connection String
/// </summary>
/// <param name="ConnectionString"></param>
/// <returns></returns>
public static bool IsConnectionString(string ConnectionString)
{
if (!String.IsNullOrEmpty(ConnectionString) &&
ConnectionString.ToUpper().Contains("DATA SOURCE") &&
ConnectionString.Contains("="))
{
String[] tokens = ConnectionString.Split(';');
foreach (string Pair in tokens)
{
string[] KeyValuePair = Pair.Split('=');
try
{
string left = KeyValuePair[0];
string right = KeyValuePair[1];
if (String.Compare(KeyValuePair[0].ToUpper().Trim(), "DATA SOURCE", true) == 0)
return !String.IsNullOrEmpty(right);
}
catch (Exception) { /* ignore and continue iteration */ }
}
return true;
}
return false;
}
/// <summary>
/// Check to see if a Connection String Contains the specified Key
/// </summary>
/// <param name="Key"></param>
/// <param name="ConnectionString"></param>
/// <returns></returns>
public static bool ContainsKey(string Key, string ConnectionString)
{
if (!String.IsNullOrEmpty(Key) && !String.IsNullOrEmpty(ConnectionString))
{
String[] tokens = ConnectionString.Split(';');
foreach (string Pair in tokens)
{
string[] KeyValuePair = Pair.Split('=');
try
{
string left = KeyValuePair[0];
string right = KeyValuePair[1];
if (String.Compare(KeyValuePair[0].ToUpper().Trim(), Key.ToUpper().Trim(), true) == 0)
return true;
}
catch (Exception) { /* ignore and continue iteration */ }
}
}
return false;
}
/// <summary>
/// Retrieve the value of a Key for the specified Connection String
/// </summary>
/// <param name="Key"></param>
/// <param name="ConnectionString"></param>
/// <returns></returns>
public static string RetrieveValue(string Key, string ConnectionString)
{
if (!String.IsNullOrEmpty(Key) && !String.IsNullOrEmpty(ConnectionString))
{
String[] tokens = ConnectionString.Split(';');
foreach (string Pair in tokens)
{
string[] KeyValuePair = Pair.Split('=');
try
{
string left = KeyValuePair[0];
string right = KeyValuePair[1];
string FoundValue = "";
if(String.Compare(KeyValuePair[0].ToUpper().Trim(), Key.ToUpper().Trim(), true) == 0)
{
if (!String.IsNullOrEmpty(right))
{
FoundValue = right.Trim();
return FoundValue;
}
}
}
catch (Exception) { /* ignore and continue iteration */ }
}
}
return String.Empty;
}
/// <summary>
/// Tries to retrieve the DataSource Value from a Connection string.
/// If it can it will return that. If it can't it will return the originial
/// ConnectionString passed in Trimmed().
/// </summary>
/// <param name="ConnectionString"></param>
/// <returns></returns>
public static string GetDataSource(string ConnectionString)
{
if (IsConnectionString(ConnectionString))
{
String[] tokens = ConnectionString.Split(';');
foreach (string Pair in tokens)
{
string[] KeyValuePair = Pair.Split('=');
try
{
string left = KeyValuePair[0];
string right = KeyValuePair[1];
string FoundValue = "";
if (String.Compare(KeyValuePair[0].ToUpper().Trim(), "DATA SOURCE", true) == 0)
{
if (!String.IsNullOrEmpty(right))
{
FoundValue = right.Trim();
return FoundValue;
}
}
}
catch (Exception) { /* ignore and continue iteration */ }
}
}
// Migth still be a data source just not from a Connection string
// so just return the value trimmed
if(!String.IsNullOrEmpty(ConnectionString))
return ConnectionString.Trim();
else
return String.Empty;
}
}
}

83
Systems/DataRet.cs Normal file
View File

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sdaleo.Systems
{
/// <summary>
/// To Deal with Data Return Type validaton / retrieval
/// </summary>
public static class DataRet
{
/// <summary>
/// Quickly retrieve a value for a given type
/// Will use default value of the type if object is null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="oToRetrieve"></param>
/// <returns></returns>
public static T Retrieve<T>(object oToRetrieve)
{
// Create a Default Type T
T retVal = default(T);
if (oToRetrieve != null)
return ObjTool.ConvertStringToObj<T>(oToRetrieve.ToString());
return retVal;
}
/// <summary>
/// Quickly retrieve a value for a given type
/// Will use default value passed in, if object is null
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="oToRetrieve"></param>
/// <returns></returns>
public static T Retrieve<T>(object oToRetrieve, T defaultValue)
{
// Create a Default Type T
T retVal = default(T);
if (ObjTool.IsNotNullAndNotEmpty(oToRetrieve))
return ObjTool.ConvertStringToObj<T>(oToRetrieve.ToString());
else
retVal = defaultValue;
return retVal;
}
/// <summary>
/// Quickly retrieve a string value
/// Will use default value passed in, if string is null
/// </summary>
/// <param name="oToRetrieve"></param>
/// <param name="bTrim">set to true to Trim() the string</param>
/// <returns></returns>
public static string Retrieve(object oToRetrieve, string defaultValue, bool bTrim)
{
string retVal = String.Empty;
if (ObjTool.IsNotNullAndNotEmpty(oToRetrieve))
{
retVal = oToRetrieve.ToString();
if (bTrim)
retVal = retVal.Trim();
return retVal;
}
else
{
retVal = defaultValue;
}
return retVal;
}
/// <summary>
/// Quickly retrieve a string value
/// Will use "", if string is null.
/// Will automatically call Trim().
/// </summary>
/// <returns></returns>
public static string Retrieve(object oToRetrieve)
{
return Retrieve(oToRetrieve, String.Empty, true);
}
}
}

View File

@@ -1,4 +1,5 @@
using System; #if MYSQL
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if MYSQL
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if MYSQL
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if MYSQL
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql.Internal
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if POSTGRES
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -16,3 +17,4 @@ namespace Sdaleo.Systems.Postgres
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if POSTGRES
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Postgres
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if POSTGRES
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Postgres
{ {
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if POSTGRES
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -164,3 +165,4 @@ namespace Sdaleo.Systems.Postgres.Internal
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -133,3 +134,4 @@ namespace Sdaleo.Systems.SQLCE
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -45,31 +46,31 @@ namespace Sdaleo.Systems.SQLCE
public static DBError DatabaseCreate(IConnectDb credential) public static DBError DatabaseCreate(IConnectDb credential)
{ {
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE); DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
if (dbError.ErrorOccured) //if (dbError.ErrorOccured)
return dbError; // return dbError;
// First Create the Directory if it doesn't exists //// First Create the Directory if it doesn't exists
string path = Path.GetDirectoryName(credential.DataSource); //string path = Path.GetDirectoryName(credential.DataSource);
if (!Directory.Exists(path)) //if (!Directory.Exists(path))
Directory.CreateDirectory(path); // Directory.CreateDirectory(path);
// Now try to create the database if it doesn't exists //// Now try to create the database if it doesn't exists
bool bExists = false; //bool bExists = false;
dbError = DatabaseExists(credential, out bExists); //dbError = DatabaseExists(credential, out bExists);
if (!bExists) //if (!bExists)
{ //{
try // try
{ // {
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString)) // using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
{ // {
engine.CreateDatabase(); // engine.CreateDatabase();
} // }
} // }
catch (SqlCeException e) // catch (SqlCeException e)
{ // {
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e); // dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
} // }
} //}
return dbError; return dbError;
} }
@@ -156,26 +157,26 @@ namespace Sdaleo.Systems.SQLCE
public static DBError DatabaseShrink(IConnectDb credential) public static DBError DatabaseShrink(IConnectDb credential)
{ {
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE); DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
if (dbError.ErrorOccured) //if (dbError.ErrorOccured)
return dbError; // return dbError;
// Now try to shrink the database if it exists //// Now try to shrink the database if it exists
bool bExists = false; //bool bExists = false;
dbError = DatabaseExists(credential, out bExists); //dbError = DatabaseExists(credential, out bExists);
if (bExists) //if (bExists)
{ //{
try // try
{ // {
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString)) // using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
{ // {
engine.Shrink(); // engine.Shrink();
} // }
} // }
catch (SqlCeException e) // catch (SqlCeException e)
{ // {
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e); // dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
} // }
} //}
return dbError; return dbError;
} }
@@ -187,26 +188,26 @@ namespace Sdaleo.Systems.SQLCE
public static DBError DatabaseVerify(IConnectDb credential) public static DBError DatabaseVerify(IConnectDb credential)
{ {
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE); DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
if (dbError.ErrorOccured) //if (dbError.ErrorOccured)
return dbError; // return dbError;
// Now try to repair the database if it exists //// Now try to repair the database if it exists
bool bExists = false; //bool bExists = false;
dbError = DatabaseExists(credential, out bExists); //dbError = DatabaseExists(credential, out bExists);
if (bExists) //if (bExists)
{ //{
try // try
{ // {
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString)) // using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
{ // {
engine.Verify(); // engine.Verify();
} // }
} // }
catch (SqlCeException e) // catch (SqlCeException e)
{ // {
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e); // dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
} // }
} //}
return dbError; return dbError;
} }
@@ -218,30 +219,31 @@ namespace Sdaleo.Systems.SQLCE
public static DBError DatabaseRepair(IConnectDb credential) public static DBError DatabaseRepair(IConnectDb credential)
{ {
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE); DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
if (dbError.ErrorOccured) //if (dbError.ErrorOccured)
return dbError; // return dbError;
// Now try to repair the database if it exists //// Now try to repair the database if it exists
bool bExists = false; //bool bExists = false;
dbError = DatabaseExists(credential, out bExists); //dbError = DatabaseExists(credential, out bExists);
if (bExists) //if (bExists)
{ //{
try // try
{ // {
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString)) // using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
{ // {
// Specify null destination connection string for in-place repair // // Specify null destination connection string for in-place repair
engine.Repair(null, RepairOption.RecoverAllPossibleRows); // engine.Repair(null, RepairOption.RecoverAllPossibleRows);
} // }
} // }
catch (SqlCeException e) // catch (SqlCeException e)
{ // {
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e); // dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
} // }
} //}
return dbError; return dbError;
} }
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -39,3 +40,4 @@ namespace Sdaleo.Systems.SQLCE
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -13,3 +14,4 @@ namespace Sdaleo.Systems.SQLCE
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -37,3 +38,4 @@ namespace Sdaleo.Systems.SQLCE
} }
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLCOMPACT
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -93,3 +94,4 @@ namespace Sdaleo.Systems.SQLCE
} }
} }
} }
#endif

View File

@@ -1,7 +1,9 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Data.SqlClient;
namespace Sdaleo.Systems.SQLServer namespace Sdaleo.Systems.SQLServer
{ {
@@ -9,7 +11,7 @@ namespace Sdaleo.Systems.SQLServer
/// Handles SQL Server Credentials, to be /// Handles SQL Server Credentials, to be
/// used by all our SQL Server Functions /// used by all our SQL Server Functions
/// </summary> /// </summary>
public class SQLServerCredential : IComparable, ICloneable, IConnectDb, IamDBMS, IsupportTimeouts public class SQLServerCredential : IComparable, ICloneable, IConnectDb, IamDBMS, IsupportTimeouts, IClearConnectionPool
{ {
#region IConnectDb #region IConnectDb
@@ -31,7 +33,7 @@ namespace Sdaleo.Systems.SQLServer
if (!_UDL.TrustedConnection && !ValidationConsts.Generic.IsValidUserCredential(_UDL.Username, _UDL.Password)) if (!_UDL.TrustedConnection && !ValidationConsts.Generic.IsValidUserCredential(_UDL.Username, _UDL.Password))
return false; return false;
if (!String.IsNullOrEmpty(_UDL.DataBase) && IsDatabaseSet) if (!String.IsNullOrEmpty(_UDL.DataBase) && !IsDatabaseSet)
return false; return false;
return true; return true;
@@ -274,6 +276,17 @@ namespace Sdaleo.Systems.SQLServer
} }
#endregion #endregion
#region IClearConnectionPool Members
public void ClearConnectionPool(IConnectDb credential)
{
SqlConnection cn = new SqlConnection(credential.ConnectionString);
SqlConnection.ClearPool(cn);
}
#endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -279,10 +280,10 @@ namespace Sdaleo.Systems.SQLServer
// Upon DB Creation error, see if we could possibly attach the DB // Upon DB Creation error, see if we could possibly attach the DB
bool bErrorOccuredThatCouldMaybeBeResolvedByAttaching = false; bool bErrorOccuredThatCouldMaybeBeResolvedByAttaching = false;
if (retVal.ErrorOccured && !retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_ALREADY_EXISTS) && ( if (retVal.ErrorOccured && !DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_ALREADY_EXISTS) && (
retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_SOME_FILE_NAMES_COULD_NOT_BE_CREATED) || DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_SOME_FILE_NAMES_COULD_NOT_BE_CREATED) ||
retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_CAN_NOT_CREATE_FILE_BECAUSE_IT_ALREADY_EXISTS) || DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_CAN_NOT_CREATE_FILE_BECAUSE_IT_ALREADY_EXISTS) ||
retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME))) DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME)))
{ {
bErrorOccuredThatCouldMaybeBeResolvedByAttaching = true; bErrorOccuredThatCouldMaybeBeResolvedByAttaching = true;
} }
@@ -336,8 +337,8 @@ namespace Sdaleo.Systems.SQLServer
// If Error Occured try renaming dat files to mdf * legacy code * // If Error Occured try renaming dat files to mdf * legacy code *
bool bRetryAttachingErrorOccured = false; bool bRetryAttachingErrorOccured = false;
if (retVal.ErrorOccured && if (retVal.ErrorOccured &&
(retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME) || (DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME) ||
retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_DEVICE_ACTIVATION_FAILED))) DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_DEVICE_ACTIVATION_FAILED)))
{ {
bRetryAttachingErrorOccured = true; bRetryAttachingErrorOccured = true;
} }
@@ -570,3 +571,4 @@ namespace Sdaleo.Systems.SQLServer
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -480,3 +481,4 @@ namespace Sdaleo.Systems.SQLServer
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -17,3 +18,4 @@ namespace Sdaleo.Systems.SQLServer
public const int ERROR_DB_DEVICE_ACTIVATION_FAILED = 5105; public const int ERROR_DB_DEVICE_ACTIVATION_FAILED = 5105;
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -187,3 +188,4 @@ namespace Sdaleo.Systems.SQLServer
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -73,7 +74,7 @@ namespace Sdaleo.Systems.SQLServer
if (values.Length == 2) if (values.Length == 2)
return ValidationConsts.Generic.IsValidServerName(values[0]) && ValidationConsts.Generic.IsValidInstanceName(values[1]); return ValidationConsts.Generic.IsValidServerName(values[0]) && ValidationConsts.Generic.IsValidInstanceName(values[1]);
} }
else if (!string.IsNullOrEmpty(strDataSource) && (strDataSource.IndexOf('\\') == 0)) else if (!string.IsNullOrEmpty(strDataSource) && (strDataSource.IndexOf('\\') == -1))
{ {
return ValidationConsts.Generic.IsValidServerName(strDataSource); return ValidationConsts.Generic.IsValidServerName(strDataSource);
} }
@@ -98,3 +99,4 @@ namespace Sdaleo.Systems.SQLServer
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -776,3 +777,4 @@ namespace Sdaleo.Systems.SQLServer
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -316,3 +317,4 @@ namespace Sdaleo.Systems.SQLServer
#endregion #endregion
} }
} }
#endif

View File

@@ -1,4 +1,5 @@
using System; #if SQLSERVER
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -101,3 +102,4 @@ namespace Sdaleo.Systems.SQLServer
} }
} }
} }
#endif

View File

@@ -26,12 +26,12 @@ namespace Sdaleo.Systems
public const string CharSet_NotAllowedInDirectorPaths = @"/*?<>|" + "\""; public const string CharSet_NotAllowedInDirectorPaths = @"/*?<>|" + "\"";
// Allowed // Allowed
public const string CharSet_AllowedUserNames = CharSet_CharsNum + " -_"; public const string CharSet_AllowedUserNames = CharSet_CharsAlphaNum + " -_";
public const string CharSet_AllowedPasswords = CharSet_CharsNum + CharSet_CharsSpecialKeyboardAscii; public const string CharSet_AllowedPasswords = CharSet_CharsAlphaNum + CharSet_CharsSpecialKeyboardAscii;
public const string CharSet_AllowedServerNames = CharSet_CharsSambaComputerNames + CharSet_CharsIPAddress; // we allow IP addresses as computer names public const string CharSet_AllowedServerNames = CharSet_CharsSambaComputerNames + CharSet_CharsIPAddress; // we allow IP addresses as computer names
public const string CharSet_AllowedInstanceNames = CharSet_CharsAlphaNum + "$-_"; public const string CharSet_AllowedInstanceNames = CharSet_CharsAlphaNum + "$-_";
public const string CharSet_AllowedDatabaseNames = CharSet_CharsAlphaNum + CharSet_CharsSpecialKeyboardAscii; public const string CharSet_AllowedDatabaseNames = CharSet_CharsAlphaNum + CharSet_CharsSpecialKeyboardAscii;
public const string CharSet_AllowedTableNames = CharSet_CharsNum + " -_"; public const string CharSet_AllowedTableNames = CharSet_CharsAlphaNum + " -_";
/// <summary> /// <summary>
/// Generic Function to use with Allowed Character Sets above /// Generic Function to use with Allowed Character Sets above

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/x86/Debug/Sdaleo.dll Normal file

Binary file not shown.

BIN
bin/x86/Debug/Sdaleo.pdb Normal file

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More