Skip to content

Commit 32f41d7

Browse files
committed
v1.1 新版本发布。
1 parent f562111 commit 32f41d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3654
-1128
lines changed

src/RoadFlow/Business.Platform/Business.Platform.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="LitJSON">
35-
<HintPath>F:\TDDownload\LitJSON\LitJSON.dll</HintPath>
34+
<Reference Include="LitJSON, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
35+
<SpecificVersion>False</SpecificVersion>
36+
<HintPath>..\Source\Web\bin\LitJSON.dll</HintPath>
3637
</Reference>
3738
<Reference Include="System" />
3839
<Reference Include="System.Core" />

src/RoadFlow/Business.Platform/DBConnection.cs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,22 +499,103 @@ public System.Data.IDbConnection GetConnection(Data.Model.DBConnection dbconn)
499499
/// </summary>
500500
/// <param name="linkID"></param>
501501
/// <returns></returns>
502-
public System.Data.IDbDataAdapter GetDataAdapter(Data.Model.DBConnection dbconn, string cmdText, IDbConnection conn)
502+
public System.Data.IDbDataAdapter GetDataAdapter(IDbConnection conn, string connType, string cmdText, IDataParameter[] parArray)
503+
{
504+
IDbDataAdapter dataAdapter = null;
505+
switch (connType)
506+
{
507+
case "SqlServer":
508+
using (SqlCommand cmd = new SqlCommand(cmdText, (SqlConnection)conn))
509+
{
510+
if (parArray != null && parArray.Length > 0)
511+
{
512+
cmd.Parameters.AddRange(parArray);
513+
}
514+
dataAdapter = new SqlDataAdapter(cmd);
515+
}
516+
break;
517+
}
518+
return dataAdapter;
519+
}
520+
521+
/// <summary>
522+
/// 测试一个sql是否合法
523+
/// </summary>
524+
/// <param name="dbconn"></param>
525+
/// <param name="sql"></param>
526+
/// <returns></returns>
527+
public bool TestSql(Data.Model.DBConnection dbconn, string sql)
528+
{
529+
if (dbconn == null)
530+
{
531+
return false;
532+
}
533+
switch (dbconn.Type)
534+
{
535+
case "SqlServer":
536+
using (SqlConnection conn = new SqlConnection(dbconn.ConnectionString))
537+
{
538+
try
539+
{
540+
conn.Open();
541+
}
542+
catch
543+
{
544+
return false;
545+
}
546+
using (SqlCommand cmd = new SqlCommand(sql.ReplaceSelectSql(), (SqlConnection)conn))
547+
{
548+
try
549+
{
550+
cmd.ExecuteNonQuery();
551+
return true;
552+
}
553+
catch
554+
{
555+
return false;
556+
}
557+
}
558+
}
559+
break;
560+
}
561+
return false;
562+
}
563+
564+
/// <summary>
565+
/// 根据连接实体得到数据表
566+
/// </summary>
567+
/// <param name="linkID"></param>
568+
/// <returns></returns>
569+
public System.Data.DataTable GetDataTable(Data.Model.DBConnection dbconn, string sql)
503570
{
504571
if (dbconn == null || dbconn.Type.IsNullOrEmpty() || dbconn.ConnectionString.IsNullOrEmpty())
505572
{
506573
return null;
507574
}
508-
IDbDataAdapter dataAdapter = null;
575+
DataTable dt = new DataTable();
509576
switch (dbconn.Type)
510577
{
511578
case "SqlServer":
512-
dataAdapter = new SqlDataAdapter(cmdText, (SqlConnection)conn);
579+
using (SqlConnection conn = new SqlConnection(dbconn.ConnectionString))
580+
{
581+
try
582+
{
583+
conn.Open();
584+
using (SqlDataAdapter dap = new SqlDataAdapter(sql, conn))
585+
{
586+
dap.Fill(dt);
587+
}
588+
}
589+
catch (SqlException ex)
590+
{
591+
Platform.Log.Add(ex);
592+
}
593+
}
513594
break;
514595

515596
}
516597

517-
return dataAdapter;
598+
return dt;
518599
}
519600

520601
/// <summary>

0 commit comments

Comments
 (0)