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
|
||||
Reference in New Issue
Block a user