Commits

Inside Zhou committed 000090b

移除实际上用处不大的SQLPlanException;SQLHelper中UseDistributedTransaction参数未正确初始化。

  • Participants
  • Parent commits 9c6c878

Comments (0)

Files changed (5)

Inside.Util/Inside.Util.csproj

     <Compile Include="Sql\InputPlan.cs" />
     <Compile Include="Sql\QueryPlan.cs" />
     <Compile Include="Sql\SQLHelper.cs" />
-    <Compile Include="Sql\SQLPlanException.cs" />
     <Compile Include="StreamExtension.cs" />
     <Compile Include="StringExtension.cs" />
     <Compile Include="Web\ActionDescriptorAttribute.cs" />

Inside.Util/Properties/AssemblyInfo.cs

  * 第四位数字表示,bugfix,细节优化这一级别。
  * 版本号互不相关,不再重置为0。
  */
-[assembly: AssemblyVersion("1.5.14.16")]
+[assembly: AssemblyVersion("1.6.14.16")]

Inside.Util/Sql/DbCommandExtension.cs

 			var conn = comm.Connection;
 
 			if(null == conn) {
-				throw new SqlPlanException(2);
+				throw new DataException("尚未设置DbCommand使用的DbConnection。");
 			}
 
+			var dump = comm.Dump();
+
 #if DEBUG
-			LogManager.GetLogger("SQLPlan.DbCommandDump").Debug(comm.Dump());
+			LogManager.GetLogger("DbCommandDump").Debug(dump);
 #endif
 
 			dynamic result = null;
 						result = func();
 					}
 					catch(DbException e) {
-						throw new SqlPlanException(1, String.Format("{0}\n{1}", e.Message, comm.Dump()));
+						throw new DataException(dump, e);
 					}
 					break;
 				case ConnectionState.Broken:
 				case ConnectionState.Connecting:
 				case ConnectionState.Executing:
 				case ConnectionState.Fetching:
-					throw new SqlPlanException(3, "数据库连接的状态不正常。".Fmt(conn.State.ToString()));
+					throw new DataException("DbConnection的状态不正常。".Fmt(conn.State.ToString()));
 				default:
 					try {
 						conn.Open();
 						}
 					}
 					catch(DbException e) {
-						throw new SqlPlanException(1, String.Format("{0}\n{1}", e.Message, comm.Dump()));
+						throw new DataException(comm.Dump(), e);
 					}
 					finally {
 						conn.Close();
 					break;
 			}
 
-			_OnDbCommandExcuted(new DbCommandExcutedEventArgs(comm.Dump()));
+			_OnDbCommandExcuted(new DbCommandExcutedEventArgs(dump));
 
 			return result;
 		}

Inside.Util/Sql/SQLHelper.cs

 			this.Conn.ConnectionString = connSettings.ConnectionString;
 
 			this.IsInTransaction = false;
-			this.UseDistributedTransaction = false;
+			this.UseDistributedTransaction = useDistributedTransaction;
 		}
 
 		~SqlHelper() {
 						case ConnectionState.Connecting:
 						case ConnectionState.Executing:
 						case ConnectionState.Fetching:
-							throw new SqlPlanException(3, "数据库连接的状态不正常 : {0}".Fmt(this.Conn.State.ToString()));
+							throw new DataException("DbConnection的状态不正常。".Fmt(this.Conn.State.ToString()));
 						case ConnectionState.Closed:
 						default:
 							this.Conn.Open();

Inside.Util/Sql/SQLPlanException.cs

-using System;
-using System.Data;
-using System.Data.Common;
-
-namespace Inside.Util.Sql {
-	public class SqlPlanException : DataException {
-		public SqlPlanException(int code, string msg = null, Exception innerException = null)
-			: base(msg, innerException) {
-
-			this.Code = code;
-			switch(code) {
-				case 1:
-					this.Message = string.IsNullOrEmpty(msg) ? "查询数据库时发生错误。" : msg;
-					break;
-				case 2:
-					this.Message = string.IsNullOrEmpty(msg) ? "还没有设置该命令使用的数据库链接。" : msg;
-					break;
-				case 3:
-					this.Message = string.IsNullOrEmpty(msg) ? "数据库连接的状态不正常。" : msg;
-					break;
-				case 9:
-					this.Message = string.IsNullOrEmpty(msg) ? "SQLHelper内部发生严重错误,请联系开发者。" : msg;
-					break;
-				default:
-					throw new ArgumentException("code={0},无法识别此错误代码。".Fmt(code));
-			}
-		}
-
-		public int Code { get; private set; }
-		public new string Message { get; private set; }
-
-		public override string ToString() {
-			return "ErrorCode:{0}\nMessage:{1}".Fmt(this.Code, this.Message);
-		}
-	}
-}