chore: 初始化合力差速器MES采集程序
This commit is contained in:
BIN
Common/99DataBaseAccess2/Common/dll/DataBaseAccess.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/DataBaseAccess.dll
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/DataBaseAccess.pdb
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/DataBaseAccess.pdb
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/DoWhatPlc.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/DoWhatPlc.dll
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/DoWhatPlc.pdb
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/DoWhatPlc.pdb
Normal file
Binary file not shown.
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/MQTTnet.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/MQTTnet.dll
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/MesWorkMqtt.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/MesWorkMqtt.dll
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/MesWorkMqtt.pdb
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/MesWorkMqtt.pdb
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/Newtonsoft.Json.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/Newtonsoft.Json.dll
Normal file
Binary file not shown.
BIN
Common/99DataBaseAccess2/Common/dll/WebApiCall.dll
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/WebApiCall.dll
Normal file
Binary file not shown.
11
Common/99DataBaseAccess2/Common/dll/WebApiCall.dll.config
Normal file
11
Common/99DataBaseAccess2/Common/dll/WebApiCall.dll.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
<appSettings>
|
||||
|
||||
<add key="Url_WebApi" value="http://localhost:41181"/>
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
BIN
Common/99DataBaseAccess2/Common/dll/WebApiCall.pdb
Normal file
BIN
Common/99DataBaseAccess2/Common/dll/WebApiCall.pdb
Normal file
Binary file not shown.
25
Common/99DataBaseAccess2/DataBaseAccess.sln
Normal file
25
Common/99DataBaseAccess2/DataBaseAccess.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32901.82
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04-DataBaseAccess", "DataBaseAccess\04-DataBaseAccess.csproj", "{F434E066-4C59-47C8-AA82-6F48CC84501A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F434E066-4C59-47C8-AA82-6F48CC84501A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F434E066-4C59-47C8-AA82-6F48CC84501A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F434E066-4C59-47C8-AA82-6F48CC84501A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F434E066-4C59-47C8-AA82-6F48CC84501A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CB4AAB51-C433-4A0B-B835-FF7E3CB86238}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5C0C572B-F8F1-41DE-B049-4D40AE29CD21}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataBaseAccess2</RootNamespace>
|
||||
<AssemblyName>99DataBaseAccess2</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\dll\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataAccess.cs" />
|
||||
<Compile Include="JsonHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
611
Common/99DataBaseAccess2/DataBaseAccess/DataAccess.cs
Normal file
611
Common/99DataBaseAccess2/DataBaseAccess/DataAccess.cs
Normal file
@@ -0,0 +1,611 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataLinkMesWork2
|
||||
{
|
||||
public class DataAccess2
|
||||
{
|
||||
public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"];
|
||||
public static bool ExecuteNonQuery(string sql, string connectionString, out string errorMessage)
|
||||
{
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
//ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out string errorMessage)
|
||||
{
|
||||
errorMessage = "";
|
||||
bool result = true;
|
||||
errorMessage = "";
|
||||
ds = new DataSet();
|
||||
|
||||
/// SQLSERVER
|
||||
/// SQLiteDB
|
||||
try
|
||||
{
|
||||
//bool result = false;
|
||||
errorMessage = "";
|
||||
ds = new DataSet();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(sql, conn);
|
||||
dsCommand.Fill(ds);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
//ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 增 删 改
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="sqlParameters"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(procedureName, conn))
|
||||
{
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
if (sqlParameters != null)
|
||||
{
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
cmd.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
}
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + procedureName + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters,out DataTable dt)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
//ds = new DataSet();
|
||||
dt = new DataTable();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
|
||||
dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
|
||||
dsCommand.SelectCommand.CommandTimeout = 0;
|
||||
if (sqlParameters != null)
|
||||
{
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
dsCommand.Fill(dt);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + procedureName + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, out DataSet ds)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
ds = new DataSet();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
|
||||
dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
|
||||
dsCommand.SelectCommand.CommandTimeout = 0;
|
||||
if (sqlParameters != null)
|
||||
{
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
dsCommand.Fill(ds);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + procedureName + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static bool ExecuteDataset(string sql, out DataSet ds)
|
||||
{
|
||||
string errorMessage;
|
||||
string connectionString = ConnectionString_MES;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
ds = new DataSet();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(sql, conn);
|
||||
dsCommand.Fill(ds);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool ExecuteDataTable(string sql, out DataTable dt)
|
||||
{
|
||||
//public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out string errorMessage)
|
||||
string errorMessage;
|
||||
string connectionString = ConnectionString_MES;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
dt = new DataTable();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(sql, conn);
|
||||
dsCommand.Fill(dt);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static DataTable ExecuteSQL(string sql, ref SqlParameter[] sqlParameters)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string err;
|
||||
bool result = false;
|
||||
err = "";
|
||||
DataTable dt = new DataTable();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter(sql, conn))
|
||||
{
|
||||
if (sqlParameters != null)
|
||||
{
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
}
|
||||
dsCommand.Fill(dt);
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
err = e.ToString();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteSelectMesWork\r\n" + sql + "\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static bool ExecuteSQL(string sql)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用)
|
||||
/// </summary>
|
||||
/// <param name="procedureName">存储过程名称</param>
|
||||
/// <param name="sqlParameters">存储过程参数数组</param>
|
||||
/// <param name="dt">增加数据的数据表</param>
|
||||
/// <returns></returns>
|
||||
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters, DataTable dt)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
// if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.InsertCommand = new SqlCommand(procedureName, conn);
|
||||
dsCommand.InsertCommand.CommandType = CommandType.StoredProcedure;
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
if (dt == null) return false;
|
||||
dt.AcceptChanges();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
dt.Rows[i].SetAdded();
|
||||
}
|
||||
dsCommand.Update(dt);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + procedureName + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用)
|
||||
/// </summary>
|
||||
/// <param name="procedureName"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ExecuteStoredProcedure(string procedureName, out DataTable dt)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
dt = new DataTable();
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
|
||||
dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
dsCommand.Fill(dt);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + procedureName + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="sqlParameters"></param>
|
||||
/// <param name="tb"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, DataTable dt)
|
||||
{
|
||||
string connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
|
||||
{
|
||||
dsCommand.InsertCommand = new SqlCommand(sql, conn);
|
||||
|
||||
for (int i = 0; i < sqlParameters.Length; i++)
|
||||
{
|
||||
sqlParameters[i].IsNullable = true;
|
||||
dsCommand.InsertCommand.Parameters.Add(sqlParameters[i]);
|
||||
}
|
||||
if (dt == null) return false;
|
||||
dt.AcceptChanges();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
dt.Rows[i].SetAdded();
|
||||
}
|
||||
dsCommand.Update(dt);
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//ApplicationConfig.ConnectionStringPIS_NEW_Value = "0";
|
||||
//TestConnection();
|
||||
//errorMessage = e.ToString();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteSQL\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool ExecuteNonQuery_newID(string sql, out long newID)
|
||||
{
|
||||
sql += ";select @@identity";
|
||||
string connectionString;
|
||||
connectionString = ConnectionString_MES;
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
newID = Convert.ToInt64(cmd.ExecuteScalar());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
newID = 0;
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\n ExecuteNonQuery_newID\r\n<>洢<EFBFBD><E6B4A2><EFBFBD>̣<EFBFBD>\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExecuteOutNum(string sql, out int count)
|
||||
{
|
||||
string connectionString;
|
||||
connectionString = ConnectionString_MES;
|
||||
string errorMessage;
|
||||
bool result = false;
|
||||
errorMessage = "";
|
||||
using (SqlConnection conn = new SqlConnection(connectionString))
|
||||
{
|
||||
count = 0;
|
||||
try
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
//if (!SqlServerConnectionStatus) return false;
|
||||
conn.Open();
|
||||
count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
|
||||
}
|
||||
//SqlServerConnectionStatus = true;
|
||||
result = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errorMessage = e.ToString();
|
||||
//TestConnection();
|
||||
////ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL<51><4C>䣺\r\n" + sql + "\r\n<><6E><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>\r\n" + connectionString);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (conn.State == ConnectionState.Open)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
336
Common/99DataBaseAccess2/DataBaseAccess/JsonHelper.cs
Normal file
336
Common/99DataBaseAccess2/DataBaseAccess/JsonHelper.cs
Normal file
@@ -0,0 +1,336 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Data;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Web.Script.Serialization;
|
||||
//using System.Runtime.Serialization.Json;
|
||||
|
||||
//using System.Runtime.Serialization.Json;
|
||||
|
||||
public class JsonHelper
|
||||
{
|
||||
#region 序列化和反序列化
|
||||
// 序列化
|
||||
public static string JsonSerializer<T>(T t)
|
||||
{
|
||||
// 使用 DataContractJsonSerializer 将 T 对象序列化为内存流。
|
||||
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T));
|
||||
MemoryStream ms = new MemoryStream();
|
||||
// 使用 WriteObject 方法将 JSON 数据写入到流中。
|
||||
jsonSerializer.WriteObject(ms, t);
|
||||
// 流转字符串
|
||||
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
|
||||
ms.Close();
|
||||
//替换Json的Date字符串
|
||||
string p = @"\\/Date\((\d+)\+\d+\)\\/";
|
||||
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
|
||||
Regex reg = new Regex(p);
|
||||
jsonString = reg.Replace(jsonString, matchEvaluator);
|
||||
return jsonString;
|
||||
}
|
||||
public static T JsonDeserialize<T>(string jsonString)
|
||||
{
|
||||
//将"yyyy-MM-dd HH:mm:ss"格式的字符串转为"\/Date(1294499956278+0800)\/"格式
|
||||
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
|
||||
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
|
||||
Regex reg = new Regex(p);
|
||||
jsonString = reg.Replace(jsonString, matchEvaluator);
|
||||
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(T));
|
||||
// 字符串转流
|
||||
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
|
||||
// 通过使用 DataContractJsonSerializer 的 ReadObject 方法,将 JSON 编码数据反序列化为T
|
||||
T obj = (T)jsonSerializer.ReadObject(ms);
|
||||
return obj;
|
||||
}
|
||||
public static string ConvertJsonDateToDateString(Match match)
|
||||
{
|
||||
string result = string.Empty;
|
||||
DateTime dateTime = new DateTime(1970, 1, 1);
|
||||
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
|
||||
dateTime = dateTime.ToLocalTime();
|
||||
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return result;
|
||||
}
|
||||
private static string ConvertDateStringToJsonDate(Match m)
|
||||
{
|
||||
string result = string.Empty;
|
||||
DateTime dt = DateTime.Parse(m.Groups[0].Value);
|
||||
dt = dt.ToUniversalTime();
|
||||
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
|
||||
result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 对象转换为Json
|
||||
public static string ObjectToJson(object obj)
|
||||
{
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
js.MaxJsonLength = Int32.MaxValue; // 定义JavaScriptSerializer接受字符串的最大长度 hdk 20180524
|
||||
try
|
||||
{
|
||||
return js.Serialize(obj);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
throw new Exception(exception.Message);
|
||||
}
|
||||
}
|
||||
// 数据表转化为集合
|
||||
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
|
||||
{
|
||||
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
|
||||
foreach (DataRow dataRow in dt.Rows)
|
||||
{
|
||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||
|
||||
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
{
|
||||
if (dataRow[dc.ColumnName].GetType() == typeof(DateTime))
|
||||
{
|
||||
string str = Convert.ToDateTime(dataRow[dc.ColumnName]).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
dic.Add(dc.ColumnName, str);
|
||||
}
|
||||
else if
|
||||
(dataRow[dc.ColumnName].GetType() == typeof(byte[]))
|
||||
{
|
||||
string str = Convert.ToBase64String((byte[])dataRow[dc.ColumnName]);
|
||||
dic.Add(dc.ColumnName, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
dic.Add(dc.ColumnName, dataRow[dc.ColumnName]);
|
||||
}
|
||||
|
||||
//Type type1 = dt.Rows[0]["产品图片"].GetType();
|
||||
//Type type2 = typeof(byte[]);
|
||||
|
||||
}
|
||||
list.Add(dic);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 表转换为Json
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static string DataTableToJson(DataTable dt)
|
||||
{
|
||||
return ObjectToJson(DataTableToList(dt));
|
||||
}
|
||||
/// <summary>
|
||||
/// 将DataTable中的数据转换成JSON格式
|
||||
/// </summary>
|
||||
/// <param name="dt">数据源DataTable</param>
|
||||
/// <param name="displayCount">是否输出数据总条数</param>
|
||||
/// <param name="totalcount">JSON中显示的数据总条数</param>
|
||||
/// <returns></returns>
|
||||
public static string CreateJsonParameters(DataTable dt, bool displayCount, int totalcount)
|
||||
{
|
||||
StringBuilder JsonString = new StringBuilder();
|
||||
//Exception Handling
|
||||
|
||||
if (dt != null)
|
||||
{
|
||||
JsonString.Append("{ ");
|
||||
JsonString.Append("\"rows\":[ ");
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
JsonString.Append("{ ");
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
if (j < dt.Columns.Count - 1)
|
||||
{
|
||||
//if (dt.Rows[i][j] == DBNull.Value) continue;
|
||||
if (dt.Columns[j].DataType == typeof(bool))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
dt.Rows[i][j].ToString().ToLower() + ",");
|
||||
}
|
||||
else if (dt.Columns[j].DataType == typeof(string))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
ObjectToJson(dt.Rows[i][j]).ToString() + ",");
|
||||
//JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
|
||||
// dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\",");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\",");
|
||||
}
|
||||
}
|
||||
else if (j == dt.Columns.Count - 1)
|
||||
{
|
||||
//if (dt.Rows[i][j] == DBNull.Value) continue;
|
||||
if (dt.Columns[j].DataType == typeof(bool))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
dt.Rows[i][j].ToString().ToLower());
|
||||
}
|
||||
else if (dt.Columns[j].DataType == typeof(string))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
ObjectToJson(dt.Rows[i][j]).ToString());
|
||||
//JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
|
||||
// dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*end Of String*/
|
||||
if (i == dt.Rows.Count - 1)
|
||||
{
|
||||
JsonString.Append("} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("}, ");
|
||||
}
|
||||
}
|
||||
JsonString.Append("]");
|
||||
|
||||
if (displayCount)
|
||||
{
|
||||
JsonString.Append(",");
|
||||
|
||||
JsonString.Append("\"total\":");
|
||||
JsonString.Append(totalcount);
|
||||
}
|
||||
|
||||
JsonString.Append("}");
|
||||
return JsonString.ToString().Replace("\n", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static string CreateJsonParameters(DataTable dt)
|
||||
{
|
||||
StringBuilder JsonString = new StringBuilder();
|
||||
//Exception Handling
|
||||
|
||||
if (dt != null)
|
||||
{
|
||||
JsonString.Append("{ ");
|
||||
JsonString.Append("\"rows\":[ ");
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
JsonString.Append("{ ");
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
if (j < dt.Columns.Count - 1)
|
||||
{
|
||||
//if (dt.Rows[i][j] == DBNull.Value) continue;
|
||||
if (dt.Columns[j].DataType == typeof(bool))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
dt.Rows[i][j].ToString().ToLower() + ",");
|
||||
}
|
||||
else if (dt.Columns[j].DataType == typeof(string))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
ObjectToJson(dt.Rows[i][j]).ToString() + ",");
|
||||
//JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
|
||||
// dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\",");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\",");
|
||||
}
|
||||
}
|
||||
else if (j == dt.Columns.Count - 1)
|
||||
{
|
||||
//if (dt.Rows[i][j] == DBNull.Value) continue;
|
||||
if (dt.Columns[j].DataType == typeof(bool))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
dt.Rows[i][j].ToString().ToLower());
|
||||
}
|
||||
else if (dt.Columns[j].DataType == typeof(string))
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" +
|
||||
ObjectToJson(dt.Rows[i][j]).ToString());
|
||||
//JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" +
|
||||
// dt.Rows[i][j].ToString().Replace("\"", "\\\"") + "\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("\"" + dt.Columns[j].ColumnName.ToLower() + "\":" + "\"" + dt.Rows[i][j] + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*end Of String*/
|
||||
if (i == dt.Rows.Count - 1)
|
||||
{
|
||||
JsonString.Append("} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("}, ");
|
||||
}
|
||||
}
|
||||
JsonString.Append("]");
|
||||
|
||||
JsonString.Append("}");
|
||||
return JsonString.ToString().Replace("\n", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
/// <summary>
|
||||
/// 根据DataTable生成EasyUI Tree Json树结构
|
||||
/// </summary>
|
||||
/// <param name="tabel">数据源</param>
|
||||
/// <param name="idCol">ID列</param>
|
||||
/// <param name="txtCol">Text列</param>
|
||||
/// <param name="url">节点Url</param>
|
||||
/// <param name="rela">关系字段</param>
|
||||
/// <param name="pId">父ID</param>
|
||||
public string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId)
|
||||
{
|
||||
result.Append(sb.ToString());
|
||||
sb.Clear();
|
||||
if (tabel.Rows.Count > 0)
|
||||
{
|
||||
sb.Append("[");
|
||||
string filer = string.Format("{0}='{1}'", rela, pId);
|
||||
DataRow[] rows = tabel.Select(filer);
|
||||
if (rows.Length > 0)
|
||||
{
|
||||
foreach (DataRow row in rows)
|
||||
{
|
||||
sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\"");
|
||||
if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0)
|
||||
{
|
||||
sb.Append(",\"children\":");
|
||||
GetTreeJsonByTable(tabel, idCol, txtCol, url, rela, row[idCol]);
|
||||
result.Append(sb.ToString());
|
||||
sb.Clear();
|
||||
}
|
||||
result.Append(sb.ToString());
|
||||
sb.Clear();
|
||||
sb.Append("},");
|
||||
}
|
||||
sb = sb.Remove(sb.Length - 1, 1);
|
||||
}
|
||||
sb.Append("]");
|
||||
result.Append(sb.ToString());
|
||||
sb.Clear();
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("DataBaseAccess")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DataBaseAccess")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("f434e066-4c59-47c8-aa82-6f48cc84501a")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user