Checking in latest SDALEO changes optimizing Advantage really only.
This commit is contained in:
@@ -1,20 +1,30 @@
|
||||
using System;
|
||||
#if ADVANTAGE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Advantage.Data.Provider;
|
||||
using System.Net;
|
||||
|
||||
namespace Sdaleo.Systems.Advantage
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles SQL CE Credentials, to be
|
||||
/// used by all our SQL CE Functions
|
||||
/// Handles Advantage, to be
|
||||
/// used by all our Advantage Functions
|
||||
/// </summary>
|
||||
public class AdvantageCredential : IComparable, ICloneable, IConnectDb
|
||||
public class AdvantageCredential : IComparable, ICloneable, IConnectDb, IClearConnectionPool
|
||||
{
|
||||
public enum ServerType
|
||||
{
|
||||
REMOTE,
|
||||
LOCAL,
|
||||
REMOTE_LOCAL
|
||||
}
|
||||
|
||||
#region IConnectDb
|
||||
|
||||
/// <summary>
|
||||
/// Let Callers know this is a SQLCE Connection Object
|
||||
/// Let Callers know this is a Advantage Connection Object
|
||||
/// </summary>
|
||||
public DBSystem DBType { get { return DBSystem.ADVANTAGE; } }
|
||||
|
||||
@@ -28,10 +38,8 @@ namespace Sdaleo.Systems.Advantage
|
||||
if (!ValidationConsts.IsValidFileNameNPath(DataSource))
|
||||
return false;
|
||||
|
||||
// For ADS i believe we always want a user and Password
|
||||
|
||||
//if (!String.IsNullOrEmpty(_UDL.Password) && !ValidationConsts.Generic.IsValidPassword(_UDL.Password))
|
||||
// return false;
|
||||
if (!ValidationConsts.Generic.IsValidServerName(User))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -43,32 +51,49 @@ namespace Sdaleo.Systems.Advantage
|
||||
public string ConnectionString { get { return _UDL.ConnectionString; } }
|
||||
|
||||
/// <summary>
|
||||
/// SQL CE uses the File Name and Path as the Datasource
|
||||
/// Advantage the File Name and Path as the Datasource
|
||||
/// </summary>
|
||||
public string DataSource { get { return _UDL.DataSource; } }
|
||||
|
||||
/// <summary>
|
||||
/// SQL CE doesn't use User
|
||||
/// Advantage doesn't use User
|
||||
/// </summary>
|
||||
public string User { get { return _UDL.Username; } }
|
||||
|
||||
/// <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>
|
||||
public bool SupportsDBMS { get { return false; } }
|
||||
|
||||
/// <summary>
|
||||
/// SQL CE doesn't support DBMS like behaviors
|
||||
/// Advantage doesn't support DBMS like behaviors
|
||||
/// </summary>
|
||||
public IamDBMS DBMS { get { return null; } }
|
||||
|
||||
/// <summary>
|
||||
/// SQL CE doesn't support Timeouts
|
||||
/// Advantage * not implemented *
|
||||
/// </summary>
|
||||
public bool SupportsTimeouts { get { return false; } }
|
||||
|
||||
/// <summary>
|
||||
/// SQL CE doesn't support Timeouts
|
||||
/// Advantage * not implemented *
|
||||
/// </summary>
|
||||
public IsupportTimeouts Timeouts { get { return null; } }
|
||||
|
||||
@@ -79,7 +104,7 @@ namespace Sdaleo.Systems.Advantage
|
||||
#region AdvantageCredential Credential Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a SQL CE Connection from an UDL Object
|
||||
/// Create a Advantage Connection from an UDL Object
|
||||
/// </summary>
|
||||
/// <param name="udl"></param>
|
||||
internal AdvantageCredential(UDL udl)
|
||||
@@ -89,19 +114,32 @@ namespace Sdaleo.Systems.Advantage
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an Untrusted SQLCE Credential * No Encryption Used *
|
||||
/// Create a Advantage Connection
|
||||
/// </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>
|
||||
/// Create a Trusted SQLCE Credential * Encryption Used *
|
||||
/// </summary>
|
||||
public AdvantageCredential(string FileNameNPath, string strPassword)
|
||||
{
|
||||
_UDL = new UDL(FileNameNPath, strPassword);
|
||||
_UDL = new UDL(FileNameNPathInclUNCPath, UserID, Password, serverType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -133,5 +171,15 @@ namespace Sdaleo.Systems.Advantage
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IClearConnectionPool Members
|
||||
|
||||
public void ClearConnectionPool(IConnectDb credential)
|
||||
{
|
||||
AdsConnection.FlushConnectionPool(credential.ConnectionString);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if ADVANTAGE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -11,3 +12,4 @@ namespace Sdaleo.Systems.Advantage
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if ADVANTAGE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Advantage
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if ADVANTAGE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Advantage.Internal
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if CTREE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if CTREE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if CTREE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if CTREE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.CTree.Internal
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
145
Systems/ConnStr.cs
Normal file
145
Systems/ConnStr.cs
Normal 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
83
Systems/DataRet.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if MYSQL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if MYSQL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if MYSQL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if MYSQL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.MySql.Internal
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if POSTGRES
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -16,3 +17,4 @@ namespace Sdaleo.Systems.Postgres
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if POSTGRES
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Postgres
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if POSTGRES
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,3 +10,4 @@ namespace Sdaleo.Systems.Postgres
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if POSTGRES
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -164,3 +165,4 @@ namespace Sdaleo.Systems.Postgres.Internal
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -133,3 +134,4 @@ namespace Sdaleo.Systems.SQLCE
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -45,31 +46,31 @@ namespace Sdaleo.Systems.SQLCE
|
||||
public static DBError DatabaseCreate(IConnectDb credential)
|
||||
{
|
||||
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
|
||||
if (dbError.ErrorOccured)
|
||||
return dbError;
|
||||
//if (dbError.ErrorOccured)
|
||||
// return dbError;
|
||||
|
||||
// First Create the Directory if it doesn't exists
|
||||
string path = Path.GetDirectoryName(credential.DataSource);
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
//// First Create the Directory if it doesn't exists
|
||||
//string path = Path.GetDirectoryName(credential.DataSource);
|
||||
//if (!Directory.Exists(path))
|
||||
// Directory.CreateDirectory(path);
|
||||
|
||||
// Now try to create the database if it doesn't exists
|
||||
bool bExists = false;
|
||||
dbError = DatabaseExists(credential, out bExists);
|
||||
if (!bExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
{
|
||||
engine.CreateDatabase();
|
||||
}
|
||||
}
|
||||
catch (SqlCeException e)
|
||||
{
|
||||
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
}
|
||||
}
|
||||
//// Now try to create the database if it doesn't exists
|
||||
//bool bExists = false;
|
||||
//dbError = DatabaseExists(credential, out bExists);
|
||||
//if (!bExists)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
// {
|
||||
// engine.CreateDatabase();
|
||||
// }
|
||||
// }
|
||||
// catch (SqlCeException e)
|
||||
// {
|
||||
// dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
// }
|
||||
//}
|
||||
return dbError;
|
||||
}
|
||||
|
||||
@@ -156,26 +157,26 @@ namespace Sdaleo.Systems.SQLCE
|
||||
public static DBError DatabaseShrink(IConnectDb credential)
|
||||
{
|
||||
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
|
||||
if (dbError.ErrorOccured)
|
||||
return dbError;
|
||||
//if (dbError.ErrorOccured)
|
||||
// return dbError;
|
||||
|
||||
// Now try to shrink the database if it exists
|
||||
bool bExists = false;
|
||||
dbError = DatabaseExists(credential, out bExists);
|
||||
if (bExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
{
|
||||
engine.Shrink();
|
||||
}
|
||||
}
|
||||
catch (SqlCeException e)
|
||||
{
|
||||
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
}
|
||||
}
|
||||
//// Now try to shrink the database if it exists
|
||||
//bool bExists = false;
|
||||
//dbError = DatabaseExists(credential, out bExists);
|
||||
//if (bExists)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
// {
|
||||
// engine.Shrink();
|
||||
// }
|
||||
// }
|
||||
// catch (SqlCeException e)
|
||||
// {
|
||||
// dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
// }
|
||||
//}
|
||||
return dbError;
|
||||
}
|
||||
|
||||
@@ -187,26 +188,26 @@ namespace Sdaleo.Systems.SQLCE
|
||||
public static DBError DatabaseVerify(IConnectDb credential)
|
||||
{
|
||||
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
|
||||
if (dbError.ErrorOccured)
|
||||
return dbError;
|
||||
//if (dbError.ErrorOccured)
|
||||
// return dbError;
|
||||
|
||||
// Now try to repair the database if it exists
|
||||
bool bExists = false;
|
||||
dbError = DatabaseExists(credential, out bExists);
|
||||
if (bExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
{
|
||||
engine.Verify();
|
||||
}
|
||||
}
|
||||
catch (SqlCeException e)
|
||||
{
|
||||
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
}
|
||||
}
|
||||
//// Now try to repair the database if it exists
|
||||
//bool bExists = false;
|
||||
//dbError = DatabaseExists(credential, out bExists);
|
||||
//if (bExists)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
// {
|
||||
// engine.Verify();
|
||||
// }
|
||||
// }
|
||||
// catch (SqlCeException e)
|
||||
// {
|
||||
// dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
// }
|
||||
//}
|
||||
return dbError;
|
||||
}
|
||||
|
||||
@@ -218,30 +219,31 @@ namespace Sdaleo.Systems.SQLCE
|
||||
public static DBError DatabaseRepair(IConnectDb credential)
|
||||
{
|
||||
DBError dbError = ValidationConsts.IsCredentialValid(credential, DBSystem.SQL_CE);
|
||||
if (dbError.ErrorOccured)
|
||||
return dbError;
|
||||
//if (dbError.ErrorOccured)
|
||||
// return dbError;
|
||||
|
||||
// Now try to repair the database if it exists
|
||||
bool bExists = false;
|
||||
dbError = DatabaseExists(credential, out bExists);
|
||||
if (bExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
{
|
||||
// Specify null destination connection string for in-place repair
|
||||
engine.Repair(null, RepairOption.RecoverAllPossibleRows);
|
||||
}
|
||||
}
|
||||
catch (SqlCeException e)
|
||||
{
|
||||
dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
}
|
||||
}
|
||||
//// Now try to repair the database if it exists
|
||||
//bool bExists = false;
|
||||
//dbError = DatabaseExists(credential, out bExists);
|
||||
//if (bExists)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// using (SqlCeEngine engine = new SqlCeEngine(credential.ConnectionString))
|
||||
// {
|
||||
// // Specify null destination connection string for in-place repair
|
||||
// engine.Repair(null, RepairOption.RecoverAllPossibleRows);
|
||||
// }
|
||||
// }
|
||||
// catch (SqlCeException e)
|
||||
// {
|
||||
// dbError = DBMS.CreateErrorDBRetVal(DBSystem.SQL_CE, e);
|
||||
// }
|
||||
//}
|
||||
return dbError;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -39,3 +40,4 @@ namespace Sdaleo.Systems.SQLCE
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -13,3 +14,4 @@ namespace Sdaleo.Systems.SQLCE
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -37,3 +38,4 @@ namespace Sdaleo.Systems.SQLCE
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLCOMPACT
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -93,3 +94,4 @@ namespace Sdaleo.Systems.SQLCE
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Sdaleo.Systems.SQLServer
|
||||
{
|
||||
@@ -9,7 +11,7 @@ namespace Sdaleo.Systems.SQLServer
|
||||
/// Handles SQL Server Credentials, to be
|
||||
/// used by all our SQL Server Functions
|
||||
/// </summary>
|
||||
public class SQLServerCredential : IComparable, ICloneable, IConnectDb, IamDBMS, IsupportTimeouts
|
||||
public class SQLServerCredential : IComparable, ICloneable, IConnectDb, IamDBMS, IsupportTimeouts, IClearConnectionPool
|
||||
{
|
||||
#region IConnectDb
|
||||
|
||||
@@ -31,7 +33,7 @@ namespace Sdaleo.Systems.SQLServer
|
||||
if (!_UDL.TrustedConnection && !ValidationConsts.Generic.IsValidUserCredential(_UDL.Username, _UDL.Password))
|
||||
return false;
|
||||
|
||||
if (!String.IsNullOrEmpty(_UDL.DataBase) && IsDatabaseSet)
|
||||
if (!String.IsNullOrEmpty(_UDL.DataBase) && !IsDatabaseSet)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -274,6 +276,17 @@ namespace Sdaleo.Systems.SQLServer
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IClearConnectionPool Members
|
||||
|
||||
public void ClearConnectionPool(IConnectDb credential)
|
||||
{
|
||||
SqlConnection cn = new SqlConnection(credential.ConnectionString);
|
||||
SqlConnection.ClearPool(cn);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -279,10 +280,10 @@ namespace Sdaleo.Systems.SQLServer
|
||||
|
||||
// Upon DB Creation error, see if we could possibly attach the DB
|
||||
bool bErrorOccuredThatCouldMaybeBeResolvedByAttaching = false;
|
||||
if (retVal.ErrorOccured && !retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_ALREADY_EXISTS) && (
|
||||
retVal.GetAllErrorNumbers.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) ||
|
||||
retVal.GetAllErrorNumbers.Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME)))
|
||||
if (retVal.ErrorOccured && !DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_ALREADY_EXISTS) && (
|
||||
DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_SOME_FILE_NAMES_COULD_NOT_BE_CREATED) ||
|
||||
DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_CAN_NOT_CREATE_FILE_BECAUSE_IT_ALREADY_EXISTS) ||
|
||||
DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME)))
|
||||
{
|
||||
bErrorOccuredThatCouldMaybeBeResolvedByAttaching = true;
|
||||
}
|
||||
@@ -336,8 +337,8 @@ namespace Sdaleo.Systems.SQLServer
|
||||
// If Error Occured try renaming dat files to mdf * legacy code *
|
||||
bool bRetryAttachingErrorOccured = false;
|
||||
if (retVal.ErrorOccured &&
|
||||
(retVal.GetAllErrorNumbers.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_THERE_ALREADY_IS_AN_OBJECT_IN_THE_DB_WITH_THIS_NAME) ||
|
||||
DBMS.GetAllErrorNumbers(DBSystem.SQL_SERVER, retVal).Contains(ErrorConst.ERROR_DB_DEVICE_ACTIVATION_FAILED)))
|
||||
{
|
||||
bRetryAttachingErrorOccured = true;
|
||||
}
|
||||
@@ -570,3 +571,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -480,3 +481,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -17,3 +18,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
public const int ERROR_DB_DEVICE_ACTIVATION_FAILED = 5105;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -187,3 +188,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -73,7 +74,7 @@ namespace Sdaleo.Systems.SQLServer
|
||||
if (values.Length == 2)
|
||||
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);
|
||||
}
|
||||
@@ -98,3 +99,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -776,3 +777,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -316,3 +317,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if SQLSERVER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -101,3 +102,4 @@ namespace Sdaleo.Systems.SQLServer
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -26,12 +26,12 @@ namespace Sdaleo.Systems
|
||||
public const string CharSet_NotAllowedInDirectorPaths = @"/*?<>|" + "\"";
|
||||
|
||||
// Allowed
|
||||
public const string CharSet_AllowedUserNames = CharSet_CharsNum + " -_";
|
||||
public const string CharSet_AllowedPasswords = CharSet_CharsNum + CharSet_CharsSpecialKeyboardAscii;
|
||||
public const string CharSet_AllowedUserNames = CharSet_CharsAlphaNum + " -_";
|
||||
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_AllowedInstanceNames = CharSet_CharsAlphaNum + "$-_";
|
||||
public const string CharSet_AllowedDatabaseNames = CharSet_CharsAlphaNum + CharSet_CharsSpecialKeyboardAscii;
|
||||
public const string CharSet_AllowedTableNames = CharSet_CharsNum + " -_";
|
||||
public const string CharSet_AllowedTableNames = CharSet_CharsAlphaNum + " -_";
|
||||
|
||||
/// <summary>
|
||||
/// Generic Function to use with Allowed Character Sets above
|
||||
|
||||
Reference in New Issue
Block a user