Skip to content

Commit

Permalink
373:DBBase处理Oracle下返回的DataBase名称问题。(2016-09-21)
Browse files Browse the repository at this point in the history
374:Oracle的加载方式进行小细节优化(2016-09-22)
375:StaticTool处理ChangeType中对于Guid的转换(2016-09-22)
  • Loading branch information
cyq1162 committed Sep 22, 2016
1 parent ea331c1 commit 303f45c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
3 changes: 2 additions & 1 deletion Action/AppConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ internal static string RunFolderPath
Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
_DLLFullName = ass.FullName;
_RunfolderPath = ass.CodeBase;
_RunfolderPath = System.IO.Path.GetDirectoryName(_RunfolderPath).Replace(AppConst.FilePre, string.Empty)+"\\";
_RunfolderPath = System.IO.Path.GetDirectoryName(_RunfolderPath).Replace(AppConst.FilePre, string.Empty) + "\\";
ass = null;
}
return _RunfolderPath;
}
Expand Down
8 changes: 7 additions & 1 deletion DAL/DbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public virtual string DataBase
{
return _con.Database;
}
else if (dalType == DalType.Oracle)
{
// (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT = 1521)))(CONNECT_DATA =(SID = Aries)))
int i = _con.DataSource.LastIndexOf('=') + 1;
return _con.DataSource.Substring(i).Trim(' ', ')');
}
else
{
return System.IO.Path.GetFileNameWithoutExtension(_con.DataSource);
Expand Down Expand Up @@ -1010,7 +1016,7 @@ private void WriteError(string err)
RollBack();
if (isAllowInterWriteLog)
{
Log.WriteLog(isWriteLog, err + debugInfo);
Log.WriteLog(isWriteLog, err + AppConst.BR + debugInfo);
}
if (OnExceptionEvent != null)
{
Expand Down
27 changes: 13 additions & 14 deletions DAL/OracleDal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected override DbProviderFactory GetFactory(string providerName)
/// <summary>
/// 值-1未初始化;0使用OracleClient;1使用DataAccess;2使用ManagedDataAccess
/// </summary>
internal static int isUseOdpNet = -1;
internal static int clientType = -1;
private static readonly object lockObj = new object();
/// <summary>
/// 是否使用Oracle的ODP.NET组件。
Expand All @@ -182,39 +182,38 @@ private bool IsUseOdpNet
{
get
{
if (isUseOdpNet == -1)
if (clientType == -1)
{
lock (lockObj)
{
if (isUseOdpNet == -1)
if (clientType == -1)
{
if (AppConfig.GetConn(base.conn).IndexOf("host", StringComparison.OrdinalIgnoreCase) == -1)
{
isUseOdpNet = 0;
clientType = 0;
}
else
{
Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
string path = System.IO.Path.GetDirectoryName(ass.CodeBase).Replace(AppConst.FilePre, string.Empty);
ass = null;
if (System.IO.File.Exists(path + "\\Oracle.DataAccess.dll")) ////Oracle 11
string path = AppConst.RunFolderPath;
if (System.IO.File.Exists(path + "Oracle." + ManagedName + "DataAccess.dll"))//Oracle 12
{
ManagedName = "";
isUseOdpNet = 1;
clientType = 2;
}
else if (System.IO.File.Exists(path + "\\Oracle." + ManagedName + "DataAccess.dll"))//Oracle 12
else if (System.IO.File.Exists(path + "Oracle.DataAccess.dll")) ////Oracle 11
{
isUseOdpNet = 2;
ManagedName = "";
clientType = 1;
}
else
{
isUseOdpNet = 0;
clientType = 0;
Log.WriteLog("Can't find Oracle.ManagedDataAccess.dll or Oracle.DataAccess.dll on the path:" + path);
}
}
}
}
}
return isUseOdpNet > 0;
return clientType > 0;
}
}
protected override bool IsExistsDbName(string dbName)
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyTitle("CYQ.Data 数据层(ORM)框架 V5 版本")]
[assembly: AssemblyDescription("论坛:http://www.cyqdata.com/cyqdata")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("秋式软件 (2016-09-20)")]
[assembly: AssemblyCompany("秋式软件 (2016-09-22)")]
[assembly: AssemblyProduct("CYQ.Data 数据层(ORM)框架 V5 版本")]
[assembly: AssemblyCopyright("版权所有 (C) 秋式软件 2010-2020")]
[assembly: AssemblyTrademark("CYQ.Data")]
Expand All @@ -31,5 +31,5 @@
//
// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("5.6.5.5")]
[assembly: AssemblyFileVersion("5.6.5.5")]
[assembly: AssemblyVersion("5.6.5.6")]
[assembly: AssemblyFileVersion("5.6.5.6")]
2 changes: 1 addition & 1 deletion Table/MDataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ internal static MDataTable CreateFrom(DbDataReader sdr)
if (sdr != null && sdr.FieldCount > 0)
{
#region 读表结构
if (OracleDal.isUseOdpNet == 0) //OracleClient 不支持子查询的GetSchemaTable,但ODP.NET是支持的。
if (OracleDal.clientType == 0) //OracleClient 不支持子查询的GetSchemaTable,但ODP.NET是支持的。
{
//从DataReader读取表结构,不管有没有数据。
string hiddenFields = "," + AppConfig.DB.HiddenFields.ToLower() + ",";
Expand Down
2 changes: 1 addition & 1 deletion Table/MDataTableBatchAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ internal bool Insert(bool keepID)
{
return MsSqlBulkCopyInsert(keepID);
}
else if (dalTypeTo == DalType.Oracle && keepID && OracleDal.isUseOdpNet == 1 && _dalHelper == null)
else if (dalTypeTo == DalType.Oracle && keepID && OracleDal.clientType == 1 && _dalHelper == null)
{
return OracleBulkCopyInsert();
}
Expand Down
4 changes: 2 additions & 2 deletions Tool/StaticTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ internal static object ChangeType(object value, Type t)
{
return Activator.CreateInstance(t);
}
else if (t.IsValueType)
else if (t.IsValueType && t.Name != "Guid")
{
return Convert.ChangeType(strValue, t);
}
Expand Down Expand Up @@ -282,6 +282,6 @@ internal static string GetHashKey(string sourceString)
}
}
#endregion

}
}
3 changes: 3 additions & 0 deletions 更新记录.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,6 @@
370��MAction��Insertʱ����Oracle��Mysql�ȷ��ã���ȡ���ֵ������2016-09-20)
371��MAction��Insertʱ��InsertOpĬ��ѡ����Ϊ��ID��ԭ��Ϊ��Fill)��2016-09-20)
372��JsonHelper.ToJson���Ӷ�List<MDataTable>��List<DataTable>��֧�֣�2016-09-20)
373��DBBase����Oracle�·��ص�DataBase�������⡣��2016-09-21)
374��Oracle�ļ��ط�ʽ����Сϸ���Ż���2016-09-22)
375��StaticTool����ChangeType�ж���Guid��ת����2016-09-22)

0 comments on commit 303f45c

Please sign in to comment.