init: 导入项目到 meswork Gitea

This commit is contained in:
XingCheng3
2026-05-29 10:07:05 +08:00
commit ad9a4106fb
3582 changed files with 460312 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
<?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>{97127B87-D43D-457C-9894-5F2244E4D2E7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataLinkMesWork</RootNamespace>
<AssemblyName>DataLinkMesWork</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>..\WebAppDll\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\DataLinkMesWork.xml</DocumentationFile>
</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>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="BasicData, Version=20.20.3.15, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\BasicData.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>..\DLL\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<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="DataLinkMesWork.Bakup.ConnType.cs" />
<Compile Include="DataLinkMesWork.ConnType.Bak.cs" />
<Compile Include="DataLinkMesWork.ConnType.cs" />
<Compile Include="DataLinkMesWork.Bakup.cs" />
<Compile Include="DataLinkMesWork.SqlCmd.ConnType.cs" />
<Compile Include="DataLinkMesWork.SqlCmd.Bakup.cs" />
<Compile Include="DataLinkMesWork.SqlWebCall.Bakup.ConnType.cs" />
<Compile Include="DataLinkMesWork.SqlWebCall.ConnType.cs" />
<Compile Include="DataLinkMesWork.SqlWebCall.Bakup.cs" />
<Compile Include="DataLinkMesWork.SqlWebCall.cs" />
<Compile Include="DataLinkMesWork.SqlCmd.cs" />
<Compile Include="DataLinkMesWork.cs" />
<Compile Include="DbCallType1001\DbCallType1001.cs" />
<Compile Include="DbCallType2\DbCallType2.cs" />
<Compile Include="DbCallType3\DbCallType3.cs" />
<Compile Include="DbCallType4\DbCallType4.cs" />
<Compile Include="DbCallType5\DbCallType5.cs" />
<Compile Include="DbCallType\dbCallType.cs" />
<Compile Include="Json\IJsonWrapper.cs" />
<Compile Include="Json\JsonData.cs" />
<Compile Include="Json\JsonException.cs" />
<Compile Include="Json\JsonMapper.cs" />
<Compile Include="Json\JsonMockWrapper.cs" />
<Compile Include="Json\JsonReader.cs" />
<Compile Include="Json\JsonWriter.cs" />
<Compile Include="Json\Lexer.cs" />
<Compile Include="Json\Netstandard15Polyfill.cs" />
<Compile Include="Json\ParserToken.cs" />
<Compile Include="KeyWord\KeyWordTest.cs" />
<Compile Include="KeyWord\SoftKey.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\Common.OleDb.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\ContentResult.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\DataAccess.Access.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\DataAccess.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\DataAccess.Excel.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\DataAccess.SqlServer.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\DataAccess.TestConnection.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\JsonHelper.cs" />
<Compile Include="P0.MES.Common\bizDataAccess\SQLCommon.cs" />
<Compile Include="P0.MES.Common\Sqlite\DbHelperSQLite.cs" />
<Compile Include="P0.MES.Common\SystemFramework\ApplicationConfig.cs" />
<Compile Include="P0.MES.Common\SystemFramework\Reflection.cs" />
<Compile Include="P0.MES.Common\SystemFramework\UDP.Receive.cs" />
<Compile Include="P0.MES.Common\SystemFramework\UDP.Send.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Reg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Reg.Designer.cs">
<DependentUpon>Reg.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Reg.resx">
<DependentUpon>Reg.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Mes32X32.ico" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,301 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLinkMesWork
{
public partial class DataLink
{
/// <summary>
/// 通过执行SQL语句查询数据库
/// </summary>
/// <param name="sql"></param>
/// <param name="ds"></param>
/// <returns></returns>
public static bool ExecuteDataset_Bakup(string sql, out DataSet ds)
{
string errorMessage;
return SQLCommon.ExecuteDataset(sql, connectionStringBakup, out ds, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteNonQuery_Bakup(string sql)
{
string errorMessage;
return SQLCommon.ExecuteNonQuery( sql, connectionStringBakup, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改。返回后面Select 参数 行数或自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum_Bakup(string sql, out int count)
{
string errorMessage;
return SQLCommon.ExecuteOutNum(sql, connectionStringBakup, out count, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql_Bakup(string sql, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionStringBakup, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql_Bakup(string sql, ref ParamData[] paramData, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, connectionStringBakup, ref thisParms, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql_Bakup(string sql, out DataTable dt, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionStringBakup, out dt, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql_Bakup(string sql, ref ParamData[] paramData,out DataTable dt, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, ref thisParms, connectionStringBakup, out dt,out errorMessage);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="tbname"></param>
/// <param name="fieldkey"></param>
/// <param name="where"></param>
/// <param name="fieldshow"></param>
/// <param name="fieldorder"></param>
/// <param name="fieldgroup"></param>
/// <param name="pagecurrent"></param>
/// <param name="pagesize"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecPageQueryMesWork_Bakup(string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string ErrorMessage;
return DataAccess.ExecPageQueryMesWork(tbname, connectionStringBakup, fieldkey, where, fieldshow, fieldorder, fieldgroup, pagecurrent, pagesize, out pagecount, out itemcount, out dt, out ErrorMessage);
}
/// <summary>
/// INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool Insert_Bakup(string tableName, ParamData[] paramData,out string err)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionStringBakup, out err);
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_Bakup(string procedureName, ref ParamData[] paramData, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms=null;
GetSqlCmd(paramData, out thisParms);
if(SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out errorMessage))
{
for(int i=0;i< thisParms.Length;i++)
{
if(paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 插入数据,可以返回自动编号。存储过程增加 select @@identity
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="index"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_Bakup(string procedureName, ref ParamData[] paramData, out long index,out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out index,out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 用存储过程查询数据
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="dt"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_Bakup(string procedureName, ref ParamData[] paramData, out DataTable dt, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out dt, out errorMessage);
}
public static bool ExecuteStoredProcedure_Bakup(string procedureName, ref ParamData[] paramData, out DataSet ds, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out ds, out errorMessage);
}
// ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
/// <summary>
/// 将数据插入数据库
/// 输入表名
/// 输入字段对应的值
/// 返回自动编号
/// </summary>
/// <param name="tableName">输入表名</param>
/// <param name="paramData">输入字段对应的值</param>
/// <param name="id">返回自动编号</param>
/// <param name="err">返回插入失败的原因</param>
/// <returns></returns>
public static bool Insert_Bakup(string tableName, ParamData[] paramData, out long id,out string err)
{
//INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionStringBakup, out id,out err);
}
public static bool Insert_Bakup(System.Data.DataTable dt, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(dt, out thisParms);
return SQLCommon.ExecuteSqlCmd(sqlCmd, connectionStringBakup, ref thisParms, dt, out err);
}
/// <summary>
/// 根据条件,更新数据库
/// </summary>
/// <param name="tableName">被更新的表</param>
/// <param name="paramSet">更改的字段与值对应表</param>
/// <param name="paramWhere">更改的字段与值对应表的条件</param>
/// <returns></returns>
public static bool UpData_Bakup(string tableName, ParamData[] paramSet, ParamData[] paramWhere, out string err)
{
//UPDATE Test SET [f1] = @f1,[f2] = @f2,[f3] = @f3 WHERE f1=@ff1 and f2=@ff2
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdUpdate( tableName, paramSet, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionStringBakup, out err);
}
/// <summary>
/// DELETE FROM TEST WHERE f1=@f1
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramWhere">WHERE f1=@f1 @f1,value</param>
/// <returns></returns>
public static bool DeleteBakup(string tableName, ParamData[] paramWhere, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdDelete(tableName, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionStringBakup, out err);
}
/// <summary>
/// SELECT f1,f2 from test where f1=@f1 and f1=@f2
/// </summary>
/// <param name="selectCmd"></param>
/// <param name="paramData">ParamData数组赋值(f1,value1),(f2,value2)</param>
/// <param name="dt"></param>
/// <param name="err"></param>
/// <returns></returns>
public static bool Select_Bakup(string selectCmd, ParamData[] paramData, out DataTable dt, out string err)
{
//SELECT f1,f2 from test where f1=@f1 and f1=@f2
SqlParameter[] thisParms;
GetSqlCmdSelect(paramData, out thisParms);
return SQLCommon.ExecuteSelectMesWork(selectCmd, ref thisParms, connectionStringBakup, out dt,out err);
}
/// <summary>
///paramData: @tbname sysname, --要分页显示的表名
/// @fieldkey sysname, --用于定位记录的主键(惟一键)字段,只能是单个字段
/// @fieldshow nvarchar(1000), --以逗号分隔的要显示的字段列表,如果不指定,则显示所有字段
/// @fieldOrder nvarchar(1000), ----以逗号分隔的排序字段列表,可以指定在字段后面指定DESC/ASC --用于指定排序顺序
/// @PageCurrent int=1, --要显示的页码
/// @PageSize int=30, --每页的大小(记录数)
///paramDataWhere: @where nvarchar(1000), --查询条件
///@PageCount int OUTPUT, --总页数
///@ItemCount int output --数据总数
/// </summary>
/// <param name="paramData[6]">tbname,fieldkey,fieldshow,fieldorder,pagecurrent,pagesize</param>
/// <param name="paramDataWhere"></param>
/// <param name="dt"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="err"></param>
public static bool SelectPage_Bakup(string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string err = "";
dt = null;
return DataAccess.ExecPageQueryMesWork(tbname, connectionStringBakup, fieldkey, where, fieldshow, fieldorder, fieldgroup,pagecurrent, pagesize, out pagecount, out itemcount, out dt, out err);
}
}
}

View File

@@ -0,0 +1,355 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLinkMesWork
{
public partial class DataLink
{
/// <summary>
/// 通过执行SQL语句查询数据库
/// </summary>
/// <param name="sql"></param>
/// <param name="ds"></param>
/// <returns></returns>
public static bool ExecuteDataset(string connType, string sql, out DataSet ds)
{
string errorMessage;
return SQLCommon.ExecuteDataset(sql, connectionString, out ds, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteNonQuery(string connType, string sql)
{
string errorMessage;
return SQLCommon.ExecuteNonQuery( sql, connectionString, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改。返回后面Select 参数 行数或自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum(string connType, string sql, out int count)
{
string errorMessage;
return SQLCommon.ExecuteOutNum(sql, connectionString, out count, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string connType, string sql, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionString, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string connType, string sql, ref ParamData[] paramData, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, connectionString, ref thisParms, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string connType, string sql, out DataTable dt, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionString, out dt, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string connType, string sql, ref ParamData[] paramData,out DataTable dt, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, ref thisParms, connectionString, out dt,out errorMessage);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="tbname"></param>
/// <param name="fieldkey"></param>
/// <param name="where"></param>
/// <param name="fieldshow"></param>
/// <param name="fieldorder"></param>
/// <param name="fieldgroup"></param>
/// <param name="pagecurrent"></param>
/// <param name="pagesize"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecPageQueryMesWork(string connType, string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string ErrorMessage;
return DataAccess.ExecPageQueryMesWork(tbname, connectionString, fieldkey, where, fieldshow, fieldorder, fieldgroup, pagecurrent, pagesize, out pagecount, out itemcount, out dt, out ErrorMessage);
}
/// <summary>
/// INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool Insert(string connType, string tableName, ParamData[] paramData,out string err)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString,out err);
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="connString"></param>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string connType, string connString,string procedureName, ref ParamData[] paramData, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, connString, ref thisParms, out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_ConnType(string connType, string procedureName, ref ParamData[] paramData, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms=null;
GetSqlCmd(paramData, out thisParms);
if(SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out errorMessage))
{
for(int i=0;i< thisParms.Length;i++)
{
if(paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string connType, string procedureName, ref SqlParameter[] thisParms, out string errorMessage)
{
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out errorMessage);
}
public static bool ExecuteStoredProcedureWithConnectionString(string connType, string procedureName, ref ParamData[] paramData, out string errorMessage,string conString)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, conString, ref thisParms, out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 插入数据,可以返回自动编号。存储过程增加 select @@identity
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="index"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string connType, string procedureName, ref ParamData[] paramData, out long index,out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out index,out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 用存储过程查询数据
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="dt"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string connType, string procedureName, ref ParamData[] paramData, out DataTable dt, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out dt, out errorMessage);
}
public static bool ExecuteStoredProcedure(string connType, string procedureName, ref ParamData[] paramData, out DataSet ds, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out ds, out errorMessage);
}
// ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
/// <summary>
/// 将数据插入数据库
/// 输入表名
/// 输入字段对应的值
/// 返回自动编号
/// </summary>
/// <param name="tableName">输入表名</param>
/// <param name="paramData">输入字段对应的值</param>
/// <param name="id">返回自动编号</param>
/// <param name="err">返回插入失败的原因</param>
/// <returns></returns>
public static bool Insert(string connType, string tableName, ParamData[] paramData, out long id,out string err)
{
//INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out id,out err);
}
public static bool Insert(string connType, System.Data.DataTable dt, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(dt, out thisParms);
return SQLCommon.ExecuteSqlCmd(sqlCmd, connectionString, ref thisParms, dt, out err);
}
/// <summary>
/// 根据条件,更新数据库
/// </summary>
/// <param name="tableName">被更新的表</param>
/// <param name="paramSet">更改的字段与值对应表</param>
/// <param name="paramWhere">更改的字段与值对应表的条件</param>
/// <returns></returns>
public static bool UpData(string connType, string tableName, ParamData[] paramSet, ParamData[] paramWhere, out string err)
{
//UPDATE Test SET [f1] = @f1,[f2] = @f2,[f3] = @f3 WHERE f1=@ff1 and f2=@ff2
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdUpdate( tableName, paramSet, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out err);
}
/// <summary>
/// DELETE FROM TEST WHERE f1=@f1
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramWhere">WHERE f1=@f1 @f1,value</param>
/// <returns></returns>
public static bool Delete(string connType, string tableName, ParamData[] paramWhere, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdDelete(tableName, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out err);
}
/// <summary>
/// SELECT f1,f2 from test where f1=@f1 and f1=@f2
/// </summary>
/// <param name="selectCmd"></param>
/// <param name="paramData">ParamData数组赋值(f1,value1),(f2,value2)</param>
/// <param name="dt"></param>
/// <param name="err"></param>
/// <returns></returns>
public static bool Select(string connType, string selectCmd, ParamData[] paramData, out DataTable dt, out string err)
{
//SELECT f1,f2 from test where f1=@f1 and f1=@f2
SqlParameter[] thisParms;
GetSqlCmdSelect(paramData, out thisParms);
return SQLCommon.ExecuteSelectMesWork(selectCmd, ref thisParms, connectionString, out dt,out err);
}
/// <summary>
///paramData: @tbname sysname, --要分页显示的表名
/// @fieldkey sysname, --用于定位记录的主键(惟一键)字段,只能是单个字段
/// @fieldshow nvarchar(1000), --以逗号分隔的要显示的字段列表,如果不指定,则显示所有字段
/// @fieldOrder nvarchar(1000), ----以逗号分隔的排序字段列表,可以指定在字段后面指定DESC/ASC --用于指定排序顺序
/// @PageCurrent int=1, --要显示的页码
/// @PageSize int=30, --每页的大小(记录数)
///paramDataWhere: @where nvarchar(1000), --查询条件
///@PageCount int OUTPUT, --总页数
///@ItemCount int output --数据总数
/// </summary>
/// <param name="paramData[6]">tbname,fieldkey,fieldshow,fieldorder,pagecurrent,pagesize</param>
/// <param name="paramDataWhere"></param>
/// <param name="dt"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="err"></param>
public static bool SelectPage(string connType, string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string err = "";
dt = null;
return DataAccess.ExecPageQueryMesWork(tbname, connectionString, fieldkey, where, fieldshow, fieldorder, fieldgroup,pagecurrent, pagesize, out pagecount, out itemcount, out dt, out err);
}
}
}

View File

@@ -0,0 +1,744 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLinkMesWork
{
public partial class DataLink
{
/// <summary>
/// 通过执行SQL语句查询数据库
/// </summary>
/// <param name="sql"></param>
/// <param name="ds"></param>
/// <returns></returns>
public static bool ExecuteDataset(string sql, out DataSet ds)
{
string errorMessage;
return SQLCommon.ExecuteDataset(sql, connectionString, out ds, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteNonQuery(string sql)
{
string errorMessage;
return SQLCommon.ExecuteNonQuery( sql, connectionString, out errorMessage);
}
/// <summary>
/// 通过执行SQL语句实现对表的增、删、改。返回后面Select 参数 行数或自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum(string sql, out int count)
{
string errorMessage;
return SQLCommon.ExecuteOutNum(sql, connectionString, out count, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string sql, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionString, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string sql, ref ParamData[] paramData, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, connectionString, ref thisParms, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string sql, out DataTable dt, out string errorMessage)
{
return SQLCommon.ExecuteSql(sql, connectionString, out dt, out errorMessage);
}
/// <summary>
/// 执行带参数的SQL语句完成增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool ExecuteSql(string sql, ref ParamData[] paramData,out DataTable dt, out string errorMessage)
{
SqlParameter[] thisParms;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteSql(sql, ref thisParms, connectionString, out dt,out errorMessage);
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="tbname"></param>
/// <param name="fieldkey"></param>
/// <param name="where"></param>
/// <param name="fieldshow"></param>
/// <param name="fieldorder"></param>
/// <param name="fieldgroup"></param>
/// <param name="pagecurrent"></param>
/// <param name="pagesize"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecPageQueryMesWork(string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string ErrorMessage;
return DataAccess.ExecPageQueryMesWork(tbname, connectionString, fieldkey, where, fieldshow, fieldorder, fieldgroup, pagecurrent, pagesize, out pagecount, out itemcount, out dt, out ErrorMessage);
}
/// <summary>
/// INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramData"></param>
/// <returns></returns>
public static bool Insert(string tableName, ParamData[] paramData,out string err)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString,out err);
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="connString"></param>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string connString,string procedureName, ref ParamData[] paramData, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, connString, ref thisParms, out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string procedureName, ref ParamData[] paramData, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms=null;
GetSqlCmd(paramData, out thisParms);
if(SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out errorMessage))
{
for(int i=0;i< thisParms.Length;i++)
{
if(paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] thisParms, out string errorMessage)
{
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out errorMessage);
}
public static bool ExecuteStoredProcedureWithConnectionString(string procedureName, ref ParamData[] paramData, out string errorMessage,string conString)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, conString, ref thisParms, out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 插入数据,可以返回自动编号。存储过程增加 select @@identity
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="index"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string procedureName, ref ParamData[] paramData, out long index,out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
if (SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out index,out errorMessage))
{
for (int i = 0; i < thisParms.Length; i++)
{
if (paramData[i].isOutPut)
{
paramData[i].value = thisParms[i].Value.ToString();
}
}
return true;
}
return false;
}
/// <summary>
/// 用存储过程查询数据
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="dt"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string procedureName, ref ParamData[] paramData, out DataTable dt, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out dt, out errorMessage);
}
public static bool ExecuteStoredProcedure(string procedureName, ref ParamData[] paramData, out DataSet ds, out string errorMessage)
{
//INSERT INTO [Test](f1,f2) VALUES(@f1,@f2)
SqlParameter[] thisParms = null;
GetSqlCmd(paramData, out thisParms);
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionString, ref thisParms, out ds, out errorMessage);
}
// ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
/// <summary>
/// 将数据插入数据库
/// 输入表名
/// 输入字段对应的值
/// 返回自动编号
/// </summary>
/// <param name="tableName">输入表名</param>
/// <param name="paramData">输入字段对应的值</param>
/// <param name="id">返回自动编号</param>
/// <param name="err">返回插入失败的原因</param>
/// <returns></returns>
public static bool Insert(string tableName, ParamData[] paramData, out long id,out string err)
{
//INSERT INTO [Test]([f1],f2) VALUES(@f1,@f2)
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(tableName, paramData, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out id,out err);
}
public static bool Insert(System.Data.DataTable dt, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmd(dt, out thisParms);
return SQLCommon.ExecuteSqlCmd(sqlCmd, connectionString, ref thisParms, dt, out err);
}
/// <summary>
/// 根据条件,更新数据库
/// </summary>
/// <param name="tableName">被更新的表</param>
/// <param name="paramSet">更改的字段与值对应表</param>
/// <param name="paramWhere">更改的字段与值对应表的条件</param>
/// <returns></returns>
public static bool UpData(string tableName, ParamData[] paramSet, ParamData[] paramWhere, out string err)
{
//UPDATE Test SET [f1] = @f1,[f2] = @f2,[f3] = @f3 WHERE f1=@ff1 and f2=@ff2
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdUpdate( tableName, paramSet, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out err);
}
/// <summary>
/// DELETE FROM TEST WHERE f1=@f1
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramWhere">WHERE f1=@f1 @f1,value</param>
/// <returns></returns>
public static bool Delete(string tableName, ParamData[] paramWhere, out string err)
{
SqlParameter[] thisParms;
string sqlCmd;
sqlCmd = GetSqlCmdDelete(tableName, paramWhere, out thisParms);
return SQLCommon.ExecuteInsertMesWork(sqlCmd, ref thisParms, connectionString, out err);
}
/// <summary>
/// SELECT f1,f2 from test where f1=@f1 and f1=@f2
/// </summary>
/// <param name="selectCmd"></param>
/// <param name="paramData">ParamData数组赋值(f1,value1),(f2,value2)</param>
/// <param name="dt"></param>
/// <param name="err"></param>
/// <returns></returns>
public static bool Select(string selectCmd, ParamData[] paramData, out DataTable dt, out string err)
{
//SELECT f1,f2 from test where f1=@f1 and f1=@f2
SqlParameter[] thisParms;
GetSqlCmdSelect(paramData, out thisParms);
return SQLCommon.ExecuteSelectMesWork(selectCmd, ref thisParms, connectionString, out dt,out err);
}
/// <summary>
///paramData: @tbname sysname, --要分页显示的表名
/// @fieldkey sysname, --用于定位记录的主键(惟一键)字段,只能是单个字段
/// @fieldshow nvarchar(1000), --以逗号分隔的要显示的字段列表,如果不指定,则显示所有字段
/// @fieldOrder nvarchar(1000), ----以逗号分隔的排序字段列表,可以指定在字段后面指定DESC/ASC --用于指定排序顺序
/// @PageCurrent int=1, --要显示的页码
/// @PageSize int=30, --每页的大小(记录数)
///paramDataWhere: @where nvarchar(1000), --查询条件
///@PageCount int OUTPUT, --总页数
///@ItemCount int output --数据总数
/// </summary>
/// <param name="paramData[6]">tbname,fieldkey,fieldshow,fieldorder,pagecurrent,pagesize</param>
/// <param name="paramDataWhere"></param>
/// <param name="dt"></param>
/// <param name="pagecount"></param>
/// <param name="itemcount"></param>
/// <param name="err"></param>
public static bool SelectPage(string tbname, string fieldkey, string where, string fieldshow, string fieldorder, string fieldgroup, int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt)
{
string err = "";
dt = null;
return DataAccess.ExecPageQueryMesWork(tbname, connectionString, fieldkey, where, fieldshow, fieldorder, fieldgroup,pagecurrent, pagesize, out pagecount, out itemcount, out dt, out err);
}
static private string SelectPageGetLogicalOperator(string logicaloperator)
{
string logicalOperator = "=";
if (logicaloperator != null)
{
if (logicaloperator.Length > 0)
{
logicalOperator = logicaloperator;
}
}
return logicalOperator;
}
static private string SelectPageGetValue(string type,string value)
{
string itemValue="";
switch (type)
{
case "string":
itemValue = "'"+value+"'";
break;
case "int":
case "float":
itemValue = value;
break;
case "bool":
if(value=="true")
{
value = "1";
}
if (value == "false")
{
value = "0";
}
itemValue = value;
break;
case "datetime":
itemValue = "'"+value+"'";
break;
default:
itemValue = "'" + value + "'";
break;
}
return itemValue;
}
/// <summary>
/// UPDATE Test SET [f1] = @f1,[f2] = @f2,[f3] = @f3 WHERE f1=@ff1 and f2=@ff2
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramSet"></param>
/// <param name="paramWhere"></param>
/// <param name="thisParms"></param>
/// <returns></returns>
private static string GetSqlCmdUpdate(string tableName, ParamData[] paramSet, ParamData[] paramWhere, out SqlParameter[] thisParms)
{
string sqlStr = "";
string sqlStrSet = "";
string sqlStrWhere = "";
//string sqlStrParam = "";
string sqlCmd;
thisParms = null;
object itemValue;
sqlStr = "UPDATE " + tableName+" SET ";
if (paramWhere != null)
{
if (paramWhere.Length > 0)
{
thisParms = new SqlParameter[paramWhere.Length + paramSet.Length];
for (int i = 0; i < paramWhere.Length; i++)
{
sqlStrWhere = sqlStrWhere + " (" + paramWhere[i].name + "=" + "@" + paramWhere[i].name + ") and";
//itemValue = GetInputStringValue(paramWhere[i].datatype, paramWhere[i].value);
thisParms[i] = new SqlParameter("@" + paramWhere[i].name, paramWhere[i].value);
}
//去掉 "and"
char[] TrimChar = { 'a', 'n', 'd' }; //此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠
sqlStrWhere = " WHERE " + sqlStrWhere.Trim(TrimChar);
}
else
{
thisParms = new SqlParameter[paramSet.Length];
}
}
else
{
thisParms = new SqlParameter[paramSet.Length];
}
//UPDATE Test SET [f1] = @f1,[f2] = @f2,[f3] = @f3 WHERE f1=@ff1 and f2=@ff2
if (paramSet!=null)
{
if(paramSet.Length>0)
{
for(int i =0; i< paramSet.Length; i++)
{
sqlStrSet = sqlStrSet + paramSet[i].name + "=" + "@" + paramSet[i].name + ",";
//itemValue = GetInputStringValue(paramSet[i].datatype, paramSet[i].value);
thisParms[i+ paramWhere.Length] = new SqlParameter("@" + paramSet[i].name, paramSet[i].value);
}
sqlStrSet = sqlStrSet.Trim(',');
}
}
sqlCmd = sqlStr + sqlStrSet + sqlStrWhere;// + sqlStrParam;
return sqlCmd;
}
/// <summary>
///
/// </summary>
/// <param name="tableName"></param>
/// <param name="paramData"></param>
/// <param name="thisParms"></param>
/// <returns></returns>
private static string GetSqlCmdDelete(string tableName, ParamData[] paramData, out SqlParameter[] thisParms)
{
string sqlStr = "";
string sqlStrWhere = "";
string sqlCmd;
thisParms = null;
object itemValue;
sqlStr = "DELETE FROM " + tableName ;
if(paramData!=null)
{
if(paramData.Length>0)
{
thisParms = new SqlParameter[paramData.Length];
for (int i = 0; i < paramData.Length; i++)
{
sqlStrWhere = sqlStrWhere + "(" + paramData[i].name + "=" + "@" + paramData[i].name + ") and";
//itemValue = GetInputStringValue(paramData[i].datatype, paramData[i].value);
thisParms[i] = new SqlParameter("@" + paramData[i].name, paramData[i].value);
}
//去掉 "and"
char[] TrimChar = { 'a', 'n', 'd' }; //此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠
sqlStrWhere = " WHERE "+sqlStrWhere.Trim(TrimChar);
}
}
sqlCmd = sqlStr + sqlStrWhere;
return sqlCmd;
}
private static string GetSqlCmd(string tableName, ParamData[] paramData, out SqlParameter[] thisParms)
{
string sqlStr = "";
string sqlStrField = "";
string sqlStrParam = "";
string sqlCmd;
thisParms = new SqlParameter[paramData.Length];
object itemValue;
sqlStr = sqlStr + "INSERT INTO " + tableName + "(";
for (int i = 0; i < paramData.Length; i++)
{
sqlStrField = sqlStrField + paramData[i].name + ",";
sqlStrParam = sqlStrParam + "@" + paramData[i].name + ",";
//itemValue = GetInputStringValue(paramData[i].datatype, paramData[i].value);
thisParms[i] = new SqlParameter("@" + paramData[i].name, paramData[i].value);
}
sqlStrField = sqlStrField.Trim(',') + ")";
sqlStrParam = " VALUES(" + sqlStrParam.Trim(',') + ")";
sqlCmd = sqlStr + sqlStrField + sqlStrParam;
return sqlCmd;
}
private static void GetSqlCmd( ParamData[] paramData, out SqlParameter[] thisParms)
{
if(paramData == null)
{
thisParms = null;
return;
}
thisParms = new SqlParameter[paramData.Length];
//object itemValue;
for (int i = 0; i < paramData.Length; i++)
{
//itemValue = GetInputStringValue(paramData[i].datatype, paramData[i].value);
thisParms[i] = new SqlParameter("@" + paramData[i].name, paramData[i].value);
if(paramData[i].isOutPut)
{
thisParms[i].Direction = ParameterDirection.Output;
}
}
}
private static string GetSqlCmd(DataTable dt, out SqlParameter[] thisParms)
{
string sqlStr = "";
string sqlStrField = "";
string sqlStrParam = "";
string sqlCmd;
string tableName = dt.TableName;
thisParms = new SqlParameter[dt.Columns.Count];
sqlStr = sqlStr + "INSERT INTO " + tableName + "(";
for (int i = 0; i < dt.Columns.Count; i++)
{
sqlStrField = sqlStrField + dt.Columns[i].ColumnName + ",";
sqlStrParam = sqlStrParam + "@" + dt.Columns[i].ColumnName + ",";
SqlDbType sqlType;
sqlType = SqlTypeString2SqlType(dt.Columns[i].DataType.Name);
//itemValue = GetInputStringValue(paramData[i].datatype, paramData[i].value);
thisParms[i] = new SqlParameter("@" + dt.Columns[i].ColumnName, sqlType);
thisParms[i].SourceColumn = dt.Columns[i].ColumnName;
thisParms[i].IsNullable = true;
}
sqlStrField = sqlStrField.Trim(',') + ")";
sqlStrParam = " VALUES(" + sqlStrParam.Trim(',') + ")";
sqlCmd = sqlStr + sqlStrField + sqlStrParam;
return sqlCmd;
}
// sql server数据类型varchar
// 转换为SqlDbType类型
public static SqlDbType SqlTypeString2SqlType(string sqlTypeString)
{
SqlDbType dbType = SqlDbType.Variant;//默认为Object
switch (sqlTypeString)
{
case "Int32":
dbType = SqlDbType.Int;
break;
case "varchar":
dbType = SqlDbType.VarChar;
break;
case "bit":
dbType = SqlDbType.Bit;
break;
case "DateTime":
dbType = SqlDbType.DateTime;
break;
case "decimal":
dbType = SqlDbType.Decimal;
break;
case "float":
dbType = SqlDbType.Float;
break;
case "image":
dbType = SqlDbType.Image;
break;
case "money":
dbType = SqlDbType.Money;
break;
case "ntext":
dbType = SqlDbType.NText;
break;
case "String":
dbType = SqlDbType.NVarChar;
break;
case "smalldatetime":
dbType = SqlDbType.SmallDateTime;
break;
case "smallint":
dbType = SqlDbType.SmallInt;
break;
case "text":
dbType = SqlDbType.Text;
break;
case "bigint":
dbType = SqlDbType.BigInt;
break;
case "binary":
dbType = SqlDbType.Binary;
break;
case "char":
dbType = SqlDbType.Char;
break;
case "nchar":
dbType = SqlDbType.NChar;
break;
case "numeric":
dbType = SqlDbType.Decimal;
break;
case "real":
dbType = SqlDbType.Real;
break;
case "smallmoney":
dbType = SqlDbType.SmallMoney;
break;
case "sql_variant":
dbType = SqlDbType.Variant;
break;
case "timestamp":
dbType = SqlDbType.Timestamp;
break;
case "tinyint":
dbType = SqlDbType.TinyInt;
break;
case "uniqueidentifier":
dbType = SqlDbType.UniqueIdentifier;
break;
case "varbinary":
dbType = SqlDbType.VarBinary;
break;
case "xml":
dbType = SqlDbType.Xml;
break;
}
return dbType;
}
// SqlDbType转换为C#数据类型
public static Type SqlType2CsharpType(SqlDbType sqlType)
{
switch (sqlType)
{
case SqlDbType.BigInt:
return typeof(Int64);
case SqlDbType.Binary:
return typeof(Object);
case SqlDbType.Bit:
return typeof(Boolean);
case SqlDbType.Char:
return typeof(String);
case SqlDbType.DateTime:
return typeof(DateTime);
case SqlDbType.Decimal:
return typeof(Decimal);
case SqlDbType.Float:
return typeof(Double);
case SqlDbType.Image:
return typeof(Object);
case SqlDbType.Int:
return typeof(Int32);
case SqlDbType.Money:
return typeof(Decimal);
case SqlDbType.NChar:
return typeof(String);
case SqlDbType.NText:
return typeof(String);
case SqlDbType.NVarChar:
return typeof(String);
case SqlDbType.Real:
return typeof(Single);
case SqlDbType.SmallDateTime:
return typeof(DateTime);
case SqlDbType.SmallInt:
return typeof(Int16);
case SqlDbType.SmallMoney:
return typeof(Decimal);
case SqlDbType.Text:
return typeof(String);
case SqlDbType.Timestamp:
return typeof(Object);
case SqlDbType.TinyInt:
return typeof(Byte);
case SqlDbType.Udt://自定义的数据类型
return typeof(Object);
case SqlDbType.UniqueIdentifier:
return typeof(Object);
case SqlDbType.VarBinary:
return typeof(Object);
case SqlDbType.VarChar:
return typeof(String);
case SqlDbType.Variant:
return typeof(Object);
case SqlDbType.Xml:
return typeof(Object);
default:
return null;
}
}
//Dictionary<Type, SqlDbType> GetSQLTypeConversionMap()
//{
// var result = new Dictionary<Type, SqlDbType>();
// result.Add(typeof(string), SqlDbType.VarChar);
// result.Add(typeof(Int16), SqlDbType.Int);
// result.Add(typeof(Int32), SqlDbType.Int);
// result.Add(typeof(DateTime), SqlDbType.DateTime2);
// return result;
//}
private static void GetSqlCmdSelect(ParamData[] paramData, out SqlParameter[] thisParms)
{
thisParms = null;
if (paramData == null) return;
thisParms = new SqlParameter[paramData.Length];
object itemValue;
for (int i = 0; i < paramData.Length; i++)
{
//itemValue = GetInputStringValue(paramData[i].datatype, paramData[i].value);
thisParms[i] = new SqlParameter("@" + paramData[i].name, paramData[i].value);
}
}
}
}

View File

@@ -0,0 +1,101 @@
//using BasicData;
//using BizDataAccess;
//using LitJson;
using BasicData;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public partial class DataLink
{
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_Bakup(string connType, string procedureName, ref SqlParameter[] thisParms, out string errorMessage)
{
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out errorMessage);
}
/// <summary>
/// 调数据库数据,并返回结果
/// </summary>
/// <param name="type"></param>
/// <param name="jsonData"></param>
/// <param name="dataobj"></param>
/// <returns></returns>
public static string SqlWebCall_Bakup(string connType, int type, JsonData jsonData, jsonobj dataobj)
{
string result = "";
string resultReg = "";
if (!InitSystemReg(out resultReg))
{
return resultReg;
}
switch (type)
{
case 1001:
result = ExecuteInsertMesWork_Bakup(jsonData);
break;
case 1002:
result = ExecuteSelectMesWork_Bakup(jsonData);
break;
case 1:
result = ExePROCEDURE_Type1_Bakup(dataobj);
break;
case 2:
result = ExePROCEDURE_Type2_Bakup(dataobj);
break;
case 3:
result = ExePROCEDURE_Type3_Bakup(dataobj);
break;
case 4:
result = ExePROCEDURE_Type4_Bakup(dataobj);
break;
case 5:
result = ExePROCEDURE_Type5_Bakup(dataobj);
break;
case 6:
break;
case 7:
result = ExePROCEDURE_Type7_Bakup(jsonData);
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
result = ExePROCEDURE_Type11_Bakup(jsonData);
break;
case 12:
result = ExePROCEDURE_Type12_Bakup(jsonData);
break;
case 13://返回dataset json
result = ExePROCEDURE_Type13_Bakup(jsonData);
break;
}
return result;
}
}
}

View File

@@ -0,0 +1,101 @@
//using BasicData;
//using BizDataAccess;
//using LitJson;
using BasicData;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public partial class DataLink
{
/// <summary>
/// 执行增、删、改存储过程
/// </summary>
/// <param name="procedureName"></param>
/// <param name="paramData"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure_Bakup(string procedureName, ref SqlParameter[] thisParms, out string errorMessage)
{
return SQLCommon.ExecuteStoredProcedure(procedureName, connectionStringBakup, ref thisParms, out errorMessage);
}
/// <summary>
/// 调数据库数据,并返回结果
/// </summary>
/// <param name="type"></param>
/// <param name="jsonData"></param>
/// <param name="dataobj"></param>
/// <returns></returns>
public static string SqlWebCall_Bakup(int type, JsonData jsonData, jsonobj dataobj)
{
string result = "";
string resultReg = "";
if (!InitSystemReg(out resultReg))
{
return resultReg;
}
switch (type)
{
case 1001:
result = ExecuteInsertMesWork_Bakup(jsonData);
break;
case 1002:
result = ExecuteSelectMesWork_Bakup(jsonData);
break;
case 1:
result = ExePROCEDURE_Type1_Bakup(dataobj);
break;
case 2:
result = ExePROCEDURE_Type2_Bakup(dataobj);
break;
case 3:
result = ExePROCEDURE_Type3_Bakup(dataobj);
break;
case 4:
result = ExePROCEDURE_Type4_Bakup(dataobj);
break;
case 5:
result = ExePROCEDURE_Type5_Bakup(dataobj);
break;
case 6:
break;
case 7:
result = ExePROCEDURE_Type7_Bakup(jsonData);
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
result = ExePROCEDURE_Type11_Bakup(jsonData);
break;
case 12:
result = ExePROCEDURE_Type12_Bakup(jsonData);
break;
case 13://返回dataset json
result = ExePROCEDURE_Type13_Bakup(jsonData);
break;
}
return result;
}
}
}

View File

@@ -0,0 +1,209 @@
//using BasicData;
//using BizDataAccess;
//using LitJson;
using BasicData;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public partial class DataLink
{
private static bool InitSystemReg(string connType,out string resultReg)
{
resultReg = "[{ \"result\":\"" + "请注册系统,注册号:" + "\"}]";
if (!initSystemIsOk)
{
string SerialNumberStr;
if (InitSystem(out SerialNumberStr))
{
connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
connectionStringBakup = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringBakup"];
isBakup = System.Configuration.ConfigurationManager.AppSettings["IsBakup"];
initSystemIsOk = true;
return true;
}
else
{
resultReg = "[{ \"result\":\"" + "请注册系统,注册号:" + SerialNumberStr + "\"}]";
return false;
}
}else
{
return true;
}
}
///// <summary>
///// 调数据库数据,并返回结果
///// </summary>
///// <param name="type"></param>
///// <param name="jsonData"></param>
///// <param name="dataobj"></param>
///// <returns></returns>
//public static string SqlWebCall(string connType, int type, JsonData jsonData, jsonobj dataobj)
//{
// string result = "";
// string resultReg = "";
// if (!InitSystemReg(out resultReg))
// {
// return resultReg;
// }
// switch (type)
// {
// case 1001:
// result = ExecuteInsertMesWork(connType, jsonData);
// break;
// case 1002:
// result = ExecuteSelectMesWork(connType, jsonData);
// break;
// case 1:
// result = ExePROCEDURE_Type1(connType, dataobj);
// break;
// case 2:
// result = ExePROCEDURE_Type2(connType, dataobj);
// break;
// case 3:
// result = ExePROCEDURE_Type3(connType, dataobj);
// break;
// case 4:
// result = ExePROCEDURE_Type4(connType, dataobj);
// break;
// case 5:
// result = ExePROCEDURE_Type5(connType, dataobj);
// break;
// case 6:
// break;
// case 7:
// result = ExePROCEDURE_Type7(connType, jsonData);
// break;
// case 8:
// break;
// case 9:
// break;
// case 10:
// break;
// case 11:
// result = ExePROCEDURE_Type11(connType, jsonData);
// break;
// case 12:
// result = ExePROCEDURE_Type12(connType, jsonData);
// break;
// case 13://返回dataset json
// result = ExePROCEDURE_Type13(connType, jsonData);
// break;
// }
// return result;
//}
/// <summary>
/// "UserID": $("#UserID").val(),
/// "Type": $("#TYPE").val(),
/// "ModularID": $("#ModularID").val(),
/// "Name": $("#NAME").val(),
/// "Param": $("#PARAM1value").val(),
/// "Pagination": $("#Pagination").val(),
/// HasReturn: $("#HASRETURN").get(0).checked
/// </summary>
/// <param name="json"></param>
public static void LogJsonData(string connType, JsonData json)
{
string type=null;
string name = null;
string param = null;
string userID = null;
string pagination = null;
bool hasReturn = false;
string modularID = "";
GetString_JsonData( json, out type, out name, out param, out userID,out pagination,out hasReturn,out modularID);
LogInsert(type, name, param, userID, modularID);
}
/// <summary>
/// ALTER PROCEDURE [_日志_增加]
///@UserID nvarchar(50)=null,
///@子组件 nvarchar(50)=null,--vue 变量 ModularID
///@TypeID nvarchar(50)=null,
///@名称 nvarchar(200)=null,
///@参数 nvarchar(max)=null
/// </summary>
/// <param name="type">TypeID</param>
/// <param name="name">名称</param>
/// <param name="param">参数</param>
/// <param name="userID">UserID</param>
/// <param name="modularID">子组件</param>
public static void LogInsert(string connType, string type,string name,string param,string userID,string modularID)
{
string errorMessage;
string procedureName;
ParamData[] paramData;
paramData = new ParamData[5];
procedureName = "_日志_增加";
paramData[0].name = "UserID";
paramData[0].value = userID;
paramData[1].name = "TypeID";
paramData[1].value = type;
paramData[2].name = "名称";
paramData[2].value = name;
paramData[3].name = "参数";
paramData[3].value = param;
paramData[4].name = "子组件";
paramData[4].value = modularID;
string connString = GetConnectionStringByConnType(connType);
if (InitSystem())
{
ExecuteStoredProcedure(connString,procedureName, ref paramData, out errorMessage);
}
else
{
LogInsertErr(connType,type, name, param, userID, modularID);
}
}
private static void LogInsertErr(string connType, string type, string name, string param, string userID, string modularID)
{
string errorMessage;
string procedureName;
ParamData[] paramData;
paramData = new ParamData[5];
procedureName = "_日志_增加";
paramData[0].name = "UserID";
paramData[0].value = userID;
paramData[1].name = "TypeID";
paramData[1].value = type;
paramData[2].name = "名称";
paramData[2].value = name;
paramData[3].name = "参数";
paramData[3].value = param+"----登录失败";
paramData[4].name = "子组件";
paramData[4].value = modularID;
string connString = GetConnectionStringByConnType(connType);
ExecuteStoredProcedureWithConnectionString(procedureName, ref paramData, out errorMessage, connString);
}
}
}

View File

@@ -0,0 +1,553 @@
//using BasicData;
//using BizDataAccess;
//using LitJson;
using BasicData;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public partial class DataLink
{
private static bool InitSystemReg(out string resultReg)
{
resultReg = "[{ \"result\":\"" + "请注册系统,注册号:" + "\"}]";
if (!initSystemIsOk)
{
string SerialNumberStr;
if (InitSystem(out SerialNumberStr))
{
connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
connectionStringBakup = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringBakup"];
isBakup = System.Configuration.ConfigurationManager.AppSettings["IsBakup"];
initSystemIsOk = true;
return true;
}
else
{
resultReg = "[{ \"result\":\"" + "请注册系统,注册号:" + SerialNumberStr + "\"}]";
return false;
}
}else
{
return true;
}
}
/// <summary>
/// 调数据库数据,并返回结果
/// </summary>
/// <param name="type"></param>
/// <param name="jsonData"></param>
/// <param name="dataobj"></param>
/// <returns></returns>
public static string SqlWebCall(int type, JsonData jsonData, jsonobj dataobj)
{
string result = "";
string resultReg = "";
if (!InitSystemReg(out resultReg))
{
return resultReg;
}
switch (type)
{
case 1001:
result = ExecuteInsertMesWork(jsonData);
break;
case 1002:
result = ExecuteSelectMesWork(jsonData);
break;
case 1:
result = ExePROCEDURE_Type1(dataobj);
break;
case 2:
result = ExePROCEDURE_Type2(dataobj);
break;
case 3:
result = ExePROCEDURE_Type3(dataobj);
break;
case 4:
result = ExePROCEDURE_Type4(dataobj);
break;
case 5:
result = ExePROCEDURE_Type5(dataobj);
break;
case 6:
break;
case 7:
result = ExePROCEDURE_Type7(jsonData);
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
result = ExePROCEDURE_Type11(jsonData);
break;
case 12:
result = ExePROCEDURE_Type12(jsonData);
break;
case 13://返回dataset json
result = ExePROCEDURE_Type13(jsonData);
break;
}
return result;
}
public static string SqlWebCall(string connType,int type, JsonData jsonData, jsonobj dataobj)
{
string result = "";
string resultReg = "";
if (!InitSystemReg(out resultReg))
{
return resultReg;
}
switch (type)
{
case 1001:
result = ExecuteInsertMesWork(connType,jsonData);
break;
case 1002:
result = ExecuteSelectMesWork(connType,jsonData);
break;
case 1:
result = ExePROCEDURE_Type1(connType,dataobj);
break;
case 2:
result = ExePROCEDURE_Type2(connType,dataobj);
break;
case 3:
result = ExePROCEDURE_Type3(connType,dataobj);
break;
case 4:
result = ExePROCEDURE_Type4(connType,dataobj);
break;
case 5:
result = ExePROCEDURE_Type5(connType,dataobj);
break;
case 6:
break;
case 7:
result = ExePROCEDURE_Type7(connType,jsonData);
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
result = ExePROCEDURE_Type11(connType,jsonData);
break;
case 12:
result = ExePROCEDURE_Type12(connType,jsonData);
break;
case 13://返回dataset json
result = ExePROCEDURE_Type13(connType,jsonData);
break;
}
return result;
}
/// <summary>
/// "UserID": $("#UserID").val(),
/// "Type": $("#TYPE").val(),
/// "ModularID": $("#ModularID").val(),
/// "Name": $("#NAME").val(),
/// "Param": $("#PARAM1value").val(),
/// "Pagination": $("#Pagination").val(),
/// HasReturn: $("#HASRETURN").get(0).checked
/// </summary>
/// <param name="json"></param>
public static void LogJsonData(JsonData json)
{
string type=null;
string name = null;
string param = null;
string userID = null;
string pagination = null;
bool hasReturn = false;
string modularID = "";
GetString_JsonData( json, out type, out name, out param, out userID,out pagination,out hasReturn,out modularID);
LogInsert(type, name, param, userID, modularID);
}
/// <summary>
/// "UserID": $("#UserID").val(),
/// "ModularID": $("#ModularID").val(), 子组件
/// "Type": $("#TYPE").val(),
/// "Name": $("#NAME").val(),
/// "Param": $("#PARAM1value").val(),
/// "Pagination": $("#Pagination").val(),
/// HasReturn: $("#HASRETURN").get(0).checked
/// </summary>
/// <param name="json"></param>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="param"></param>
/// <param name="userID"></param>
/// <param name="pagination"></param>
/// <param name="hasReturn"></param>
/// <param name="modularID">子组件</param>
public static void GetString_JsonData(JsonData json, out string type,out string name,out string param,out string userID,out string pagination,out bool hasReturn,out string modularID)
{
type = null;
name = null;
param = "";
userID = null;
pagination=null;
hasReturn=false;
modularID = "";
if (json == null) return;
if (json.Keys.Contains("Type"))
{
if (json["Type"] != null)
type = json["Type"].ToString();
}
else if (json.Keys.Contains("type"))
{
if (json["type"] != null)
type = json["type"].ToString();
}
if (json.Keys.Contains("Name"))
{
if (json["Name"] != null)
name = json["Name"].ToString();
}
else if (json.Keys.Contains("name"))
{
if (json["name"] != null)
name = json["name"].ToString();
}
if (json.Keys.Contains("Param"))
{
if (json["Param"] != null)
param = json["Param"].ToString();
}
else if (json.Keys.Contains("param"))
{
if (json["param"] != null)
param = json["param"].ToString();
}
if (json.Keys.Contains("UserID"))
{
if (json["UserID"] != null)
userID = json["UserID"].ToString();
}
else if (json.Keys.Contains("userID"))
{
if (json["userID"] != null)
userID = json["userID"].ToString();
}
if (json.Keys.Contains("Pagination"))
{
if (json["Pagination"] != null)
pagination = json["Pagination"].ToString();
}
else if (json.Keys.Contains("pagination"))
{
if (json["pagination"] != null)
pagination = json["pagination"].ToString();
}
if (json.Keys.Contains("HasReturn"))
{
try
{
if (json["HasReturn"] != null)
hasReturn = Convert.ToBoolean(json["HasReturn"].ToString());
}
catch
{
}
}
else if (json.Keys.Contains("hasReturn"))
{
try
{
if (json["hasReturn"] != null)
hasReturn = Convert.ToBoolean(json["hasReturn"].ToString());
}
catch
{
}
}
if (json.Keys.Contains("ModularID"))
{
try
{
if (json["ModularID"] != null)
modularID = json["ModularID"].ToString();
}
catch
{
}
}
else if (json.Keys.Contains("modularID"))
{
try
{
if (json["modularID"] != null)
modularID = json["modularID"].ToString();
}
catch
{
}
}
//ModularID
}
/// <summary>
/// "UserID": $("#UserID").val(),
/// "ModularID": $("#ModularID").val(), 子组件
/// "Type": $("#TYPE").val(),
/// "Name": $("#NAME").val(),
/// "Param": $("#PARAM1value").val(),
/// "Pagination": $("#Pagination").val(),
/// HasReturn: $("#HASRETURN").get(0).checked
/// </summary>
/// <param name="json"></param>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="param"></param>
/// <param name="userID"></param>
/// <param name="pagination"></param>
/// <param name="hasReturn"></param>
/// <param name="modularID">子组件</param>
public static void GetString_JsonData_Type7(JsonData json, out string type, out string name, out JsonData param, out string userID, out string pagination, out bool hasReturn, out string modularID)
{
type = null;
name = null;
param = null;
userID = null;
pagination = null;
hasReturn = false;
modularID = "";
if (json.Keys.Contains("Type"))
{
if (json["Type"] != null)
type = json["Type"].ToString();
}
else if (json.Keys.Contains("type"))
{
if (json["type"] != null)
type = json["type"].ToString();
}
if (json.Keys.Contains("Name"))
{
if (json["Name"] != null)
name = json["Name"].ToString();
}
else if (json.Keys.Contains("name"))
{
if (json["name"] != null)
name = json["name"].ToString();
}
if (json.Keys.Contains("Param"))
{
if (json["Param"] != null)
param = json["Param"];
}
else if (json.Keys.Contains("param"))
{
if (json["param"] != null)
param = json["param"];
}
if (json.Keys.Contains("UserID"))
{
if (json["UserID"] != null)
userID = json["UserID"].ToString();
}
else if (json.Keys.Contains("userID"))
{
if (json["userID"] != null)
userID = json["userID"].ToString();
}
if (json.Keys.Contains("Pagination"))
{
if (json["Pagination"] != null)
pagination = json["Pagination"].ToString();
}
else if (json.Keys.Contains("pagination"))
{
if (json["pagination"] != null)
pagination = json["pagination"].ToString();
}
if (json.Keys.Contains("HasReturn"))
{
try
{
if (json["HasReturn"] != null)
hasReturn = Convert.ToBoolean(json["HasReturn"].ToString());
}
catch
{
}
}
else if (json.Keys.Contains("hasReturn"))
{
try
{
if (json["hasReturn"] != null)
hasReturn = Convert.ToBoolean(json["hasReturn"].ToString());
}
catch
{
}
}
if (json.Keys.Contains("ModularID"))
{
try
{
if (json["ModularID"] != null)
modularID = json["ModularID"].ToString();
}
catch
{
}
}
else if (json.Keys.Contains("modularID"))
{
try
{
if (json["modularID"] != null)
modularID = json["modularID"].ToString();
}
catch
{
}
}
//ModularID
}
/// <summary>
/// ALTER PROCEDURE [_日志_增加]
///@UserID nvarchar(50)=null,
///@子组件 nvarchar(50)=null,--vue 变量 ModularID
///@TypeID nvarchar(50)=null,
///@名称 nvarchar(200)=null,
///@参数 nvarchar(max)=null
/// </summary>
/// <param name="type">TypeID</param>
/// <param name="name">名称</param>
/// <param name="param">参数</param>
/// <param name="userID">UserID</param>
/// <param name="modularID">子组件</param>
public static void LogInsert(string type,string name,string param,string userID,string modularID)
{
string errorMessage;
string procedureName;
ParamData[] paramData;
paramData = new ParamData[5];
procedureName = "_日志_增加";
paramData[0].name = "UserID";
paramData[0].value = userID;
paramData[1].name = "TypeID";
paramData[1].value = type;
paramData[2].name = "名称";
paramData[2].value = name;
paramData[3].name = "参数";
paramData[3].value = param;
paramData[4].name = "子组件";
paramData[4].value = modularID;
if (InitSystem())
{
ExecuteStoredProcedure(procedureName, ref paramData, out errorMessage);
}
else
{
LogInsertErr(type, name, param, userID, modularID);
}
}
private static void LogInsertErr(string type, string name, string param, string userID, string modularID)
{
string errorMessage;
string procedureName;
ParamData[] paramData;
paramData = new ParamData[5];
procedureName = "_日志_增加";
paramData[0].name = "UserID";
paramData[0].value = userID;
paramData[1].name = "TypeID";
paramData[1].value = type;
paramData[2].name = "名称";
paramData[2].value = name;
paramData[3].name = "参数";
paramData[3].value = param+"----登录失败";
paramData[4].name = "子组件";
paramData[4].value = modularID;
string connectionStringTemp = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
ExecuteStoredProcedureWithConnectionString(procedureName, ref paramData, out errorMessage, connectionStringTemp);
//procedureName = "_日志_增加";
//paramData[0].name = "UserID";
//paramData[0].value = userID;
//paramData[1].name = "TypeID";
//paramData[1].value = type;
//paramData[2].name = "名称";
//paramData[2].value = name;
//paramData[3].name = "参数";
//paramData[3].value = param + "--登录失败";
//ExecuteStoredProcedureWithConnectionString(procedureName, ref paramData, out errorMessage, connectionStringTemp);
}
public static bool InitSystem()
{
if (!InitSystemIsOk)
{
string linkMessage;
InitSystem(out linkMessage);
}
return InitSystemIsOk;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02DataLinkMesWork", "02DataLinkMesWork.csproj", "{97127B87-D43D-457C-9894-5F2244E4D2E7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97127B87-D43D-457C-9894-5F2244E4D2E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97127B87-D43D-457C-9894-5F2244E4D2E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97127B87-D43D-457C-9894-5F2244E4D2E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97127B87-D43D-457C-9894-5F2244E4D2E7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {427C3D16-DB8E-45FB-8F05-86090BD7DCB6}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLinkMesWork
{
public class DbComType
{
public static string DbCallType(DataTable dt, string dbCallType,string name)
{
string responseText = "";
switch (dbCallType)
{
// 执行存储过程
case "1001":
responseText = DbCallType1001.DbCallType(dt, name);
//responseText = DbCallType1.ExePROCEDURE(dataobj);
break; // 执行存储过程
}
return responseText;
}
}
}

View File

@@ -0,0 +1,115 @@
using System;
using System.Data;
using BizDataAccess;
using System.Data.SqlClient;
using BasicData;
namespace DataLinkMesWork
{
/// <summary>
/// 1、执行存储过程存储过程返回查询结果表表以JSON字符串返回给页面。
///输入参数参数名称1&参数&参数类型|参数名称1&参数&参数类型
/// </summary>
public class DbCallType1
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
/// <summary>
/// 1、执行存储过程存储过程返回查询结果表表以JSON字符串返回给页面。
/// 输入参数参数名称1&参数&参数类型|参数名称1&参数&参数类型
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public static string ExePROCEDURE(jsonobj json)
{
string[] parmas;
string[] names;
SqlParameter[] thisParms = null;
string result = "";
bool isOK;
bool isOutput = false;
DataSet ds = null;
DataTable dt1 = null;
try
{
names = json.Name.Split('&');
string name;
name = names[0];
if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
{
isOK = SQLCommon.ExecuteStoredProcedure(name, connectionString, ref thisParms, out ds, out result);
}
else//执行有参数的存储过程
{
parmas = json.Param.Split('&');
thisParms = new SqlParameter[parmas.Length];
SQLCommon.GetCmdParam(json, ref thisParms, out isOutput);
isOK = SQLCommon.ExecuteStoredProcedure(name, connectionString, ref thisParms, out ds, out result);
}
if (isOK)
{
if(names.Length>=2)
{
string type = names[1].Split('=')[1];
DataTable dt = ds.Tables[0];
result = DbComType.DbCallType(dt, type, json.Name);
}
else
{
if (ds != null && ds.Tables.Count > 0)
{
if (json.Pagination == "" || json.Pagination == null) // 判断是否需要分页
{
// 以下操作为处理模型数据 *********************************************
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // 通过循环拿到单个DIV的模型数据
//{
// string modelData = JsonHelper.ObjectToJson(ds.Tables[0].Rows[i]["模型数据"].ToString()); // 由于转JSON字符有限单个转换
// result += modelData.Substring(1, modelData.Length - 2); // 去除首和尾的字符串引号并拼接
//}
//result = "[{\"模型数据\":\"" + result + "\"}]"; // 拼接成最终字符串
//**********************************************************************
result = JsonHelper.DataTableToJson(ds.Tables[0]);
}
else
{
int pageSize = int.Parse(json.Pagination.Split('&')[0]);
int pageList = int.Parse(json.Pagination.Split('&')[1]);
DataTable dt = ds.Tables[0];
dt1 = dt.Copy(); //复制dt
dt1.Rows.Clear();//清空内容只保留dt结构。
for (int i = (pageSize - 1) * pageList; i < pageSize * pageList; i++)//循环需要显示的行
{
if (i < dt.Rows.Count)
{
dt1.ImportRow(dt.Rows[i]);//这是加入的是第i行
}
}
result = JsonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
}
}
}
string resultOutput = "";
//[{"name1":"value1","name2":"value2"}]
if (isOutput)//存储过程有输出参数
{
resultOutput = SQLCommon.GetOutputValue(thisParms);
string jsonStr;
jsonStr = "{\"result\":" + result + "," + "\"output\":" + resultOutput + "}";
result = jsonStr;
}
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch(Exception e)
{
result = "[{ \"result\":\"0\"}]";
}
return result;
}
}
}

View File

@@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataLinkMesWork
{
public class DbCallType1001
{
public static string DbCallType(DataTable dt,string name)
{
string responseText = "";
int n;
int k;
string []names = name.Split('&');
n = Convert.ToInt32( names[2].Split('=')[1]);
k = Convert.ToInt32(names[3].Split('=')[1]); ;
responseText = DbCallType( dt, n, k);
return responseText;
}
public static string DbCallType(DataTable dt, int n,int k)
{
string responseText = "";
int len = dt.Rows.Count;
double[] str = new double[len];
for (int i = 0; i < len; i++)
{
str[i] = Convert.ToDouble(dt.Rows[i]["测量值"]);
}
double minV = Min(str);
double maxV = Max(str);
double Dv = (maxV - minV) / n;
Dv = RoundInterval(Dv);
minV = Math.Floor(minV / Dv) * Dv;
maxV = Math.Ceiling(maxV / Dv) * Dv;
string textY1 = "";
string textY2 = "";
double acv = 0.0;
object average;
double bottom = minV;
StringBuilder textadd = new StringBuilder();
for (bottom = minV; bottom < maxV; bottom += Dv)
{
int number = 0;
double top = bottom + Dv;
foreach (double p in str)
{
if (top >= maxV)
{
if (p >= bottom && p <= top)
++number;
}
else
{
if (p >= bottom && p < top)
++number;
}
}
acv += Convert.ToDouble(number);
average = ((acv / (n * k)) * 100).ToString("0.00");
textY1 += number;
textY2 += average;
if (top < maxV)
{
textY1 += ",";
textY2 += ",";
}
}
textadd.Append(textY1);
textadd.Append("|");
textadd.Append(textY2);
responseText = Convert.ToString(textadd);
return responseText;
}
/// <summary>
/// 观测值最大值
/// </summary>
/// <param name="Xn">子组观测值</param>
/// <returns></returns>
static private double Max(double[] Xn)
{
double temp;
temp = Xn[0];
for (int i = 0; i < Xn.Length; i++)
{
temp = (Xn[i] > temp) ? Xn[i] : temp;
}
return temp;
}
/// <summary>
/// 观测值最小值
/// </summary>
/// <param name="Xn">子组观测值</param>
/// <returns></returns>
static private double Min(double[] Xn)
{
double temp;
temp = Xn[0];
for (int i = 0; i < Xn.Length; i++)
{
temp = (Xn[i] < temp) ? Xn[i] : temp;
}
return temp;
}
/// <summary>
/// Helper method which rounds specified axsi interval.
/// </summary>
/// <param name="interval">Calculated axis interval.</param>
/// <returns>Rounded axis interval.</returns>
static double RoundInterval(double interval)
{
// If the interval is zero return error
if (interval == 0.0)
{
throw (new ArgumentOutOfRangeException("interval", "Interval can not be zero."));
}
// If the real interval is > 1.0
double step = -1;
double tempValue = interval;
while (tempValue > 1.0)
{
step++;
tempValue = tempValue / 10.0;
if (step > 1000)
{
throw (new InvalidOperationException("Auto interval error due to invalid point values or axis minimum/maximum."));
}
}
// If the real interval is < 1.0
tempValue = interval;
if (tempValue < 1.0)
{
step = 0;
}
while (tempValue < 1.0)
{
step--;
tempValue = tempValue * 10.0;
if (step < -1000)
{
throw (new InvalidOperationException("Auto interval error due to invalid point values or axis minimum/maximum."));
}
}
double tempDiff = interval / Math.Pow(10.0, step);
if (tempDiff < 3.0)
{
tempDiff = 2.0;
}
else if (tempDiff < 7.0)
{
tempDiff = 5.0;
}
else
{
tempDiff = 10.0;
}
// Make a correction of the real interval
return tempDiff * Math.Pow(10.0, step);
}
}
}

View File

@@ -0,0 +1,65 @@
using BasicData;
using System;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using BasicData;
namespace DataLinkMesWork
{
/// <summary>
/// 提供通用的调用存储过程的方法(不需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="errorMessage">错误信息</param>
public class DbCallType2
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string[] parmas;
SqlParameter[] thisParms = null;
string result = "";
bool isOK;
bool isOutput = false;
try
{
if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
{
isOK = SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out result);
}
else//执行有参数的存储过程
{
parmas = json.Param.Split('&');
thisParms = new SqlParameter[parmas.Length];
SQLCommon.GetCmdParam(json, ref thisParms, out isOutput);
isOK = SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out result);
}
if (isOK)
{
result = "[{ \"result\":\"1\"}]";
string resultOutput = "";
//[{"name1":"value1","name2":"value2"}]
if (isOutput)//存储过程有输出参数
{
resultOutput = SQLCommon.GetOutputValue(thisParms);
string jsonStr;
jsonStr = "{\"result\":" + result + "," + "\"output\":" + resultOutput + "}";
result = jsonStr;
}
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch
{
result = "[{ \"result\":\"0\"}]";
}
return result;
}
}
}

View File

@@ -0,0 +1,44 @@
using BasicData;
using System;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using BasicData;
namespace DataLinkMesWork
{
public class DbCallType3
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string result = "[{ \"result\":\"0\"}]";
bool isOK;
if (json.Name != null)
{
DataTable dt = null;
try
{
isOK = SQLCommon.ExecuteDataTable(json.Name, connectionString, out dt, out result);
if (isOK)
{
if (dt != null)
{
result = JsonHelper.DataTableToJson(dt);
}
}
else
{
result = "[{ \"result\":\"0\"}]";
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
}
return result;
}
}
}

View File

@@ -0,0 +1,39 @@
using BasicData;
using System;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using BasicData;
namespace DataLinkMesWork
{
public class DbCallType4
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string result = "[{ \"result\":\"0\"}]"; ;
bool isOK;
if (json.Name != null)
{
try
{
isOK = SQLCommon.ExecuteNonQuery(json.Name, connectionString, out result);
if (isOK)
{
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"0\"}]";
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"0\"}]";
}
}
return result;
}
}
}

View File

@@ -0,0 +1,740 @@
using System;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using BasicData;
using System.Collections;
//using LitJson;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using BasicData;
namespace DataLinkMesWork
{
public class DbCallType5
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string result = "";
DataSet ds = null;
try
{
if (json.Param == "" || json.Param == null)//执行没有参数的存储过程
{
SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, out ds, out result);
}
else//执行有参数的存储过程
{
string[] parmas;
SqlParameter[] thisParms;
try
{
parmas = json.Param.Split('|');
thisParms = new SqlParameter[parmas.Length];
for (int i = 0; i < parmas.Length; i++)
{
string[] pp = parmas[i].Split('&');
object inputValue = null;
if (pp.Length == 3)
{
switch (pp[2])
{
case "Int":
inputValue = Convert.ToInt32(pp[1]);
break;
case "String":
inputValue = pp[2];
break;
case "Boolean":
inputValue = Convert.ToBoolean(pp[1]);
break;
case "DateTime":
inputValue = Convert.ToDateTime(pp[1]);
break;
default:
inputValue = pp[1];
break;
}
thisParms[i] = new SqlParameter(pp[0], inputValue);
}
else if (pp.Length == 2)
{
thisParms[i] = new SqlParameter(pp[0], pp[1]);
}
}
}
catch (Exception)
{
return result = "参数有误,请检查参数的格式是否正确";
}
SQLCommon.ExecuteStoredProcedure(json.Name, connectionString, ref thisParms, out ds, out result);
}
if (ds != null && ds.Tables.Count > 0)
{
result = JsonHelper.DataTableToJson(ds.Tables[0]);
}
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
}
}
public class DbCallType6
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
/// <summary>
/// 1、执行存储过程存储过程返回查询结果表表以JSON字符串返回给页面。
/// 输入参数参数名称1&参数&参数类型|参数名称1&参数&参数类型
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public static string ExePROCEDURE(JsonData json)
{
SqlParameter[] thisParms = null;
string result = "";
bool isOK = false;
JsonData jsonData;
JsonData jsonDataName;//存储过程名称
JsonData jsonDataParam;//存储过程参数
try
{
{
string type1;
string name2;
string param1;
string userID1;
string pagination1;
bool hasReturn1;
string modularID1;
DataLink.GetString_JsonData(json, out type1, out name2, out param1, out userID1, out pagination1, out hasReturn1, out modularID1);
jsonDataName = name2;//存储过程名称
jsonDataParam = param1; //存储过程参数 json格式 [{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]
jsonData = JsonMapper.ToObject(jsonDataParam.ToString()); //转为JSON格式
if (jsonDataParam.ToString() == "" || jsonDataParam.ToString() == null)//执行没有参数的存储过程
{
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out result);
}
else//执行有参数的存储过程
{
thisParms = new SqlParameter[jsonData.Count];
for (int i = 0; i < jsonData.Count; i++)
{
string name1 = jsonData[i]["name"].ToString();// 参数名
string value = jsonData[i]["value"].ToString();// 参数值
//string type = jsonData[i]["type"].ToString();// 参数类型
thisParms[i] = new SqlParameter(name1, value);
}
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out result);
}
}
if (isOK)
{
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch (Exception e)
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
return result;
}
}
public class DbCallType7
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(JsonData json)
{
string[] parmas;
string[] parmasName;
string[] names;
SqlParameter[] thisParms = null;
string result = "";
bool isOK = false;
bool isOutput = false;
DataSet ds = null;
DataTable dt1 = null;
JsonData jsonData;
JsonData jsonDataType;
JsonData jsonDataName;
JsonData jsonDataParam;
JsonData jsonDataParamRow;
JsonData jsonValue;
string name;
string sqlInsert = "";
try
{
{
string type1;
string name1;
string param1;
string userID1;
string pagination1;
bool hasReturn1;
string modularID1;
DataLink.GetString_JsonData(json, out type1, out name1, out param1, out userID1, out pagination1, out hasReturn1, out modularID1);
jsonDataName = name1;//存储过程名称
jsonDataParam = param1; //存储过程参数 json格式 [{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]
name = jsonDataName.ToString();
using (SqlConnection conn = new SqlConnection(connectionString))
{
try
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(name, conn))
{
cmd.CommandTimeout = 0;
cmd.CommandType = CommandType.Text;
#region
string createTableStr_key1 = null;
foreach (KeyValuePair<string, JsonData> jParamData in jsonDataParam[0])
{
createTableStr_key1 = createTableStr_key1 + "[" + jParamData.Key + "]" + " nvarchar(max),";
}
createTableStr_key1 = createTableStr_key1.TrimEnd(',');
//判断表是否存在,存在则删除重建,不存在直接重建
string dropsql = " if exists(select * from sysobjects where id = object_id(N'[" + name + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)" +
" begin "
+ " DROP TABLE " + name
+ " CREATE TABLE " + name
+ "(" + " TableId int identity(1,1), " + createTableStr_key1 + ")"
+ " end "
+ " else "
+ " begin "
+ " CREATE TABLE " + name
+ "(" + " TableId int identity(1,1), " + createTableStr_key1 + ")"
+ " end ";
//DataAccess.ExecuteSQL(dropsql);
cmd.CommandText = dropsql;
cmd.ExecuteNonQuery();
#endregion
#region
for (int i = 0; i < jsonDataParam.Count; i++)
{
jsonDataParamRow = jsonDataParam[i];
string sqlInert;//sql字符串
string createTableStr_key = null;//列
string createTableStr_value = null;//值
sqlInert = "INSERT INTO " + name + "(";
foreach (KeyValuePair<string, JsonData> jParamData in jsonDataParamRow)
{
createTableStr_key = createTableStr_key + "[" + jParamData.Key +"]"+ ",";
createTableStr_value = createTableStr_value + "'" + jParamData.Value.ToString().Replace("'","''") +"'" + ",";
}
createTableStr_key = createTableStr_key.TrimEnd(',');
createTableStr_value = createTableStr_value.TrimEnd(',');
sqlInert += createTableStr_key + ")" + "values" + "(";
sqlInert += createTableStr_value + ")";//最终sql字符串
cmd.CommandText = sqlInert;
cmd.ExecuteNonQuery();
// bool resultsql = DataAccess.ExecuteSQL(sqlInert);
}
#endregion
}
isOK = true;
}
catch (Exception e)
{
// errorMessage = e.ToString();
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
}
if (isOK)
{
result = "[{ \"result\":\"1\"}]";
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch (Exception e)
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
return result;
}
private static void DropTable(string name)
{
}
private static void CreateTable()
{
}
private static void InsertTable()
{
}
private static void InsertTableStr()
{
}
}
/// <summary>
/// 执行查询类SQL语言
/// </summary>
public class DbCallType8
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string result = "[{ \"result\":\"false\"}]";
bool isOK;
if (json.Name != null)
{
DataTable dt = null;
try
{
isOK = SQLCommon.ExecuteDataTable(json.Name, connectionString, out dt, out result);
if (isOK)
{
if (dt != null)
{
result = JsonHelper.DataTableToJson(dt);
}
}
else
{
result = "[{ \"result\":\"false\"}]";
}
}
catch (Exception ex)
{
result = "[{ \"result\":\"false\"}]";
}
}
return result;
}
}
public class DbCallType9
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
string result = "";
bool isOK;
if (json.Name != null)
{
DataTable dt = null;
try
{
isOK = SQLCommon.ExecuteNonQuery(json.Name, connectionString, out result);
if (isOK)
{
result = "[{ \"result\":\"true\"}]";
}
else
{
result = "[{ \"result\":\"false\"}]";
}
}
catch (Exception ex)
{
result = ex.Message;
}
}
return result;
}
}
public class DbCallType0
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(jsonobj json)
{
return "";
}
}
/// <summary>
/// 查询 DbCallType1 的更新版 采用新协议 例:{"type":"11","name":"存储过程","param":"[{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]"}
/// </summary>
public class DbCallType11
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(JsonData json)
{
SqlParameter[] thisParms = null;
string result = "";
bool isOK = false;// 存储过程执行是否成功
bool isOutput = false;
DataSet ds = null;
JsonData jsonData;
JsonData jsonDataName;//存储过程名称
JsonData jsonDataParam;//存储过程参数
try
{
{
string type1;
string name1;
string param1;
string userID1;
string pagination1;
bool hasReturn1;
string modularID1;
DataLink.GetString_JsonData(json, out type1, out name1, out param1, out userID1, out pagination1, out hasReturn1, out modularID1);
jsonDataName = name1;//存储过程名称
jsonDataParam = param1; //存储过程参数 json格式 [{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]
jsonData = JsonMapper.ToObject(jsonDataParam.ToString()); //转格式
if (jsonDataParam.ToString() == "" || jsonDataParam.ToString() == null)//参数为空,执行没有参数的存储过程
{
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out ds, out result);
}
else//执行有参数的存储过程
{
thisParms = new SqlParameter[jsonData.Count];//定义参数个数
for (int i = 0; i < jsonData.Count; i++)
{
string name = jsonData[i]["name"].ToString();// 参数名
//string value = jsonData[i]["value"].ToString();// 参数值
string value = null;
try
{
//判断是否为数组,若为数组转为字符串格式
if (jsonData[i]["value"].IsArray == true)
{
//数组转字符串
value = jsonData[i]["value"].ToJson().ToString().Replace("[", "").Replace("]", "").Replace("\"", "");// 数组参数值转字符串
// unicode解码
value = DeUnicode(value);
}
else//不是数组格式直接转字符串
{
value = jsonData[i]["value"].ToString();// 参数值
}
}
catch (Exception E)//value为null时。Tostring()会报错,需要手动赋值
{
value = null;
}
string output = null;// 参数是否为输出类型
string type = null;// 参数类型
thisParms[i] = new SqlParameter(name, value);
if (jsonData[i].ContainsKey("output"))
{
output = jsonData[i]["output"].ToString();// 参数是否为输出类型
}
if (jsonData[i].ContainsKey("type"))
{
type = jsonData[i]["type"].ToString();// 参数类型
}
if (output == "1")
{
object inputValue = null; ;
inputValue = GetInputValue(type,output);
thisParms[i] = new SqlParameter(name, inputValue);
thisParms[i].Direction = ParameterDirection.Output;
isOutput = true;// 存在输出参数
}
}
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out ds, out result);
}
}
if (isOK)
{
if (ds != null && ds.Tables.Count > 0)
{
//DataTable dt = ds.Tables[0];
//result = JsonHelper.CreateJsonParameters(dt, true, dt.Rows.Count);
//result = "[{ \"result\":\"" + "0" + "\"}]";
if (json.ContainsKey("pageSize") && json.ContainsKey("pageList")) // 判断是否需要分页
{
int pageSize = int.Parse(json["pageSize"].ToString());
int pageList = int.Parse(json["pageList"].ToString());
DataTable dt = ds.Tables[0];
DataTable dt1 = dt.Copy(); //复制dt
dt1.Rows.Clear();//清空内容只保留dt结构。
for (int i = (pageList - 1) * pageSize; i < pageList * pageSize; i++)//循环需要显示的行
{
if (i < dt.Rows.Count)
{
dt1.ImportRow(dt.Rows[i]);//这是加入的是第i行
}
}
result = JsonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
}
else
{
result = JsonHelper.DataTableToJson(ds.Tables[0]);
}
}
string resultOutput = "";
//[{"name1":"value1","name2":"value2"}]
if (isOutput)//存储过程有输出参数
{
resultOutput = SQLCommon.GetOutputValue(thisParms);
string jsonStr;
jsonStr = "{\"result\":" + result + "," + "\"output\":" + resultOutput + "}";
result = jsonStr;
}
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch (Exception e)
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
return result;
}
/// <summary>
/// Unicode解码
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string DeUnicode(string str)
{
//最直接的方法Regex.Unescape(str);
Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
return reg.Replace(str, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
}
/// <summary>
/// 返回输出参数类型
/// </summary>
/// <param name="type"></param>
/// <param name="output"></param>
/// <returns></returns>
static object GetInputValue(object type, object output)
{
object inputValue = null;
switch (type.ToString())
{
case "int":
inputValue = Convert.ToInt32(output);
break;
case "string":
inputValue = output;
break;
case "boolean":
case "bool":
if (output.ToString() == "1" || output.ToString() == "true")
{
inputValue = true;
}
else
{
inputValue = false;
}
break;
case "datetime":
inputValue = Convert.ToDateTime(output);
break;
default:
inputValue = output.ToString();
break;
}
return inputValue;
}
}
/// <summary>
/// 增删改 DbCallType2 的更新版 采用新协议 {"type":"12","name":"存储过程","param":"[{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]"}
/// </summary>
public class DbCallType12
{
private static string connectionString = System.Configuration.ConfigurationManager.AppSettings.GetValues("ConnectionString")[0].ToString();
public static string ExePROCEDURE(JsonData json)
{
SqlParameter[] thisParms = null;
string result = "";
bool isOK = false;
bool isOutput = false;
JsonData jsonData;
JsonData jsonDataName;//存储过程名称
JsonData jsonDataParam;//存储过程参数
try
{
{
string type1;
string name1;
string param1;
string userID1;
string pagination1;
bool hasReturn1;
string modularID1;
DataLink.GetString_JsonData(json, out type1, out name1, out param1, out userID1, out pagination1, out hasReturn1, out modularID1);
jsonDataName = name1;//存储过程名称
jsonDataParam = param1; //存储过程参数 json格式 [{\"name\":\"name1\",\"value\":\"value1\"},{\"name\":\"name2\",\"value\":\"value1\"}]
jsonData = JsonMapper.ToObject(jsonDataParam.ToString()); //转为JSON格式
if (jsonDataParam.ToString() == "" || jsonDataParam.ToString() == null)//执行没有参数的存储过程
{
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out result);
}
else//执行有参数的存储过程
{
thisParms = new SqlParameter[jsonData.Count];
for (int i = 0; i < jsonData.Count; i++)
{
string name = jsonData[i]["name"].ToString();// 参数名
string value = null;
try
{
//判断是否为数组,若为数组转为字符串格式
if (jsonData[i]["value"].IsArray == true)
{
//数组转字符串
value = jsonData[i]["value"].ToJson().ToString().Replace("[","").Replace("]","").Replace("\"","");// 数组参数值转字符串
// unicode解码
value = DeUnicode(value);
}
else//不是数组格式直接转字符串
{
value = jsonData[i]["value"].ToString();// 参数值
}
}
catch (Exception E)//value为null时。Tostring()会报错,需要手动赋值
{
value = null;
}
string output = null;// 参数是否为输出类型
string type = null;// 参数类型
thisParms[i] = new SqlParameter(name, value);
if (jsonData[i].ContainsKey("output"))
{
output = jsonData[i]["output"].ToString();// 参数是否为输出类型
}
if (jsonData[i].ContainsKey("type"))
{
type = jsonData[i]["type"].ToString();// 参数类型
}
if (output == "1")
{
object inputValue = null; ;
inputValue = GetInputValue(type, output);
thisParms[i] = new SqlParameter(name, inputValue);
thisParms[i].Direction = ParameterDirection.Output;
isOutput = true;// 存在输出参数
}
}
isOK = SQLCommon.ExecuteStoredProcedure(jsonDataName.ToString(), connectionString, ref thisParms, out result);
}
}
if (isOK)
{
result = "[{ \"result\":\"1\"}]";
string resultOutput = "";
if (isOutput)//存储过程有输出参数
{
resultOutput = SQLCommon.GetOutputValue(thisParms);
string jsonStr;
jsonStr = "{\"result\":" + result + "," + "\"output\":" + resultOutput + "}";
result = jsonStr;
}
}
else
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
}
catch (Exception e)
{
result = "[{ \"result\":\"" + "0" + "\"}]";
}
return result;
}
/// <summary>
/// Unicode解码
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string DeUnicode(string str)
{
//最直接的方法Regex.Unescape(str);
Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
return reg.Replace(str, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); });
}
/// <summary>
/// 返回输出参数类型
/// </summary>
/// <param name="type"></param>
/// <param name="output"></param>
/// <returns></returns>
static object GetInputValue(object type, object output)
{
object inputValue = null;
switch (type.ToString())
{
case "int":
inputValue = Convert.ToInt32(output);
break;
case "string":
inputValue = output;
break;
case "boolean":
case "bool":
if (output.ToString() == "1" || output.ToString() == "true")
{
inputValue = true;
}
else
{
inputValue = false;
}
break;
case "datetime":
inputValue = Convert.ToDateTime(output);
break;
default:
inputValue = output.ToString();
break;
}
return inputValue;
}
}
}

View File

@@ -0,0 +1,60 @@
#region Header
/**
* IJsonWrapper.cs
* Interface that represents a type capable of handling all kinds of JSON
* data. This is mainly used when mapping objects through JsonMapper, and
* it's implemented by JsonData.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System.Collections;
using System.Collections.Specialized;
namespace DataLinkMesWork
{
public enum JsonType
{
None,
Object,
Array,
String,
Int,
Long,
Double,
Boolean
}
public interface IJsonWrapper : IList, IOrderedDictionary
{
bool IsArray { get; }
bool IsBoolean { get; }
bool IsDouble { get; }
bool IsInt { get; }
bool IsLong { get; }
bool IsObject { get; }
bool IsString { get; }
bool GetBoolean ();
double GetDouble ();
int GetInt ();
JsonType GetJsonType ();
long GetLong ();
string GetString ();
void SetBoolean (bool val);
void SetDouble (double val);
void SetInt (int val);
void SetJsonType (JsonType type);
void SetLong (long val);
void SetString (string val);
string ToJson ();
void ToJson (JsonWriter writer);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,65 @@
#region Header
/**
* JsonException.cs
* Base class throwed by LitJSON when a parsing error occurs.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
namespace DataLinkMesWork
{
public class JsonException :
#if NETSTANDARD1_5
Exception
#else
ApplicationException
#endif
{
public JsonException () : base ()
{
}
internal JsonException (ParserToken token) :
base (String.Format (
"Invalid token '{0}' in input string", token))
{
}
internal JsonException (ParserToken token,
Exception inner_exception) :
base (String.Format (
"Invalid token '{0}' in input string", token),
inner_exception)
{
}
internal JsonException (int c) :
base (String.Format (
"Invalid character '{0}' in input string", (char) c))
{
}
internal JsonException (int c, Exception inner_exception) :
base (String.Format (
"Invalid character '{0}' in input string", (char) c),
inner_exception)
{
}
public JsonException (string message) : base (message)
{
}
public JsonException (string message, Exception inner_exception) :
base (message, inner_exception)
{
}
}
}

View File

@@ -0,0 +1,956 @@
#region Header
/**
* JsonMapper.cs
* JSON to .Net object and object to JSON conversions.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
namespace DataLinkMesWork
{
internal struct PropertyMetadata
{
public MemberInfo Info;
public bool IsField;
public Type Type;
}
internal struct ArrayMetadata
{
private Type element_type;
private bool is_array;
private bool is_list;
public Type ElementType {
get {
if (element_type == null)
return typeof (JsonData);
return element_type;
}
set { element_type = value; }
}
public bool IsArray {
get { return is_array; }
set { is_array = value; }
}
public bool IsList {
get { return is_list; }
set { is_list = value; }
}
}
internal struct ObjectMetadata
{
private Type element_type;
private bool is_dictionary;
private IDictionary<string, PropertyMetadata> properties;
public Type ElementType {
get {
if (element_type == null)
return typeof (JsonData);
return element_type;
}
set { element_type = value; }
}
public bool IsDictionary {
get { return is_dictionary; }
set { is_dictionary = value; }
}
public IDictionary<string, PropertyMetadata> Properties {
get { return properties; }
set { properties = value; }
}
}
internal delegate void ExporterFunc (object obj, JsonWriter writer);
public delegate void ExporterFunc<T> (T obj, JsonWriter writer);
internal delegate object ImporterFunc (object input);
public delegate TValue ImporterFunc<TJson, TValue> (TJson input);
public delegate IJsonWrapper WrapperFactory ();
public class JsonMapper
{
#region Fields
private static readonly int max_nesting_depth;
private static readonly IFormatProvider datetime_format;
private static readonly IDictionary<Type, ExporterFunc> base_exporters_table;
private static readonly IDictionary<Type, ExporterFunc> custom_exporters_table;
private static readonly IDictionary<Type,
IDictionary<Type, ImporterFunc>> base_importers_table;
private static readonly IDictionary<Type,
IDictionary<Type, ImporterFunc>> custom_importers_table;
private static readonly IDictionary<Type, ArrayMetadata> array_metadata;
private static readonly object array_metadata_lock = new Object ();
private static readonly IDictionary<Type,
IDictionary<Type, MethodInfo>> conv_ops;
private static readonly object conv_ops_lock = new Object ();
private static readonly IDictionary<Type, ObjectMetadata> object_metadata;
private static readonly object object_metadata_lock = new Object ();
private static readonly IDictionary<Type,
IList<PropertyMetadata>> type_properties;
private static readonly object type_properties_lock = new Object ();
private static readonly JsonWriter static_writer;
private static readonly object static_writer_lock = new Object ();
#endregion
#region Constructors
static JsonMapper ()
{
max_nesting_depth = 100;
array_metadata = new Dictionary<Type, ArrayMetadata> ();
conv_ops = new Dictionary<Type, IDictionary<Type, MethodInfo>> ();
object_metadata = new Dictionary<Type, ObjectMetadata> ();
type_properties = new Dictionary<Type,
IList<PropertyMetadata>> ();
static_writer = new JsonWriter ();
datetime_format = DateTimeFormatInfo.InvariantInfo;
base_exporters_table = new Dictionary<Type, ExporterFunc> ();
custom_exporters_table = new Dictionary<Type, ExporterFunc> ();
base_importers_table = new Dictionary<Type,
IDictionary<Type, ImporterFunc>> ();
custom_importers_table = new Dictionary<Type,
IDictionary<Type, ImporterFunc>> ();
RegisterBaseExporters ();
RegisterBaseImporters ();
}
#endregion
#region Private Methods
private static void AddArrayMetadata (Type type)
{
if (array_metadata.ContainsKey (type))
return;
ArrayMetadata data = new ArrayMetadata ();
data.IsArray = type.IsArray;
if (type.GetInterface ("System.Collections.IList") != null)
data.IsList = true;
foreach (PropertyInfo p_info in type.GetProperties ()) {
if (p_info.Name != "Item")
continue;
ParameterInfo[] parameters = p_info.GetIndexParameters ();
if (parameters.Length != 1)
continue;
if (parameters[0].ParameterType == typeof (int))
data.ElementType = p_info.PropertyType;
}
lock (array_metadata_lock) {
try {
array_metadata.Add (type, data);
} catch (ArgumentException) {
return;
}
}
}
private static void AddObjectMetadata (Type type)
{
if (object_metadata.ContainsKey (type))
return;
ObjectMetadata data = new ObjectMetadata ();
if (type.GetInterface ("System.Collections.IDictionary") != null)
data.IsDictionary = true;
data.Properties = new Dictionary<string, PropertyMetadata> ();
foreach (PropertyInfo p_info in type.GetProperties ()) {
if (p_info.Name == "Item") {
ParameterInfo[] parameters = p_info.GetIndexParameters ();
if (parameters.Length != 1)
continue;
if (parameters[0].ParameterType == typeof (string))
data.ElementType = p_info.PropertyType;
continue;
}
PropertyMetadata p_data = new PropertyMetadata ();
p_data.Info = p_info;
p_data.Type = p_info.PropertyType;
data.Properties.Add (p_info.Name, p_data);
}
foreach (FieldInfo f_info in type.GetFields ()) {
PropertyMetadata p_data = new PropertyMetadata ();
p_data.Info = f_info;
p_data.IsField = true;
p_data.Type = f_info.FieldType;
data.Properties.Add (f_info.Name, p_data);
}
lock (object_metadata_lock) {
try {
object_metadata.Add (type, data);
} catch (ArgumentException) {
return;
}
}
}
private static void AddTypeProperties (Type type)
{
if (type_properties.ContainsKey (type))
return;
IList<PropertyMetadata> props = new List<PropertyMetadata> ();
foreach (PropertyInfo p_info in type.GetProperties ()) {
if (p_info.Name == "Item")
continue;
PropertyMetadata p_data = new PropertyMetadata ();
p_data.Info = p_info;
p_data.IsField = false;
props.Add (p_data);
}
foreach (FieldInfo f_info in type.GetFields ()) {
PropertyMetadata p_data = new PropertyMetadata ();
p_data.Info = f_info;
p_data.IsField = true;
props.Add (p_data);
}
lock (type_properties_lock) {
try {
type_properties.Add (type, props);
} catch (ArgumentException) {
return;
}
}
}
private static MethodInfo GetConvOp (Type t1, Type t2)
{
lock (conv_ops_lock) {
if (! conv_ops.ContainsKey (t1))
conv_ops.Add (t1, new Dictionary<Type, MethodInfo> ());
}
if (conv_ops[t1].ContainsKey (t2))
return conv_ops[t1][t2];
MethodInfo op = t1.GetMethod (
"op_Implicit", new Type[] { t2 });
lock (conv_ops_lock) {
try {
conv_ops[t1].Add (t2, op);
} catch (ArgumentException) {
return conv_ops[t1][t2];
}
}
return op;
}
private static object ReadValue (Type inst_type, JsonReader reader)
{
reader.Read ();
if (reader.Token == JsonToken.ArrayEnd)
return null;
Type underlying_type = Nullable.GetUnderlyingType(inst_type);
Type value_type = underlying_type ?? inst_type;
if (reader.Token == JsonToken.Null) {
#if NETSTANDARD1_5
if (inst_type.IsClass() || underlying_type != null) {
return null;
}
#else
if (inst_type.IsClass || underlying_type != null) {
return null;
}
#endif
throw new JsonException (String.Format (
"Can't assign null to an instance of type {0}",
inst_type));
}
if (reader.Token == JsonToken.Double ||
reader.Token == JsonToken.Int ||
reader.Token == JsonToken.Long ||
reader.Token == JsonToken.String ||
reader.Token == JsonToken.Boolean) {
Type json_type = reader.Value.GetType ();
if (value_type.IsAssignableFrom (json_type))
return reader.Value;
// If there's a custom importer that fits, use it
if (custom_importers_table.ContainsKey (json_type) &&
custom_importers_table[json_type].ContainsKey (
value_type)) {
ImporterFunc importer =
custom_importers_table[json_type][value_type];
return importer (reader.Value);
}
// Maybe there's a base importer that works
if (base_importers_table.ContainsKey (json_type) &&
base_importers_table[json_type].ContainsKey (
value_type)) {
ImporterFunc importer =
base_importers_table[json_type][value_type];
return importer (reader.Value);
}
// Maybe it's an enum
#if NETSTANDARD1_5
if (value_type.IsEnum())
return Enum.ToObject (value_type, reader.Value);
#else
if (value_type.IsEnum)
return Enum.ToObject (value_type, reader.Value);
#endif
// Try using an implicit conversion operator
MethodInfo conv_op = GetConvOp (value_type, json_type);
if (conv_op != null)
return conv_op.Invoke (null,
new object[] { reader.Value });
// No luck
throw new JsonException (String.Format (
"Can't assign value '{0}' (type {1}) to type {2}",
reader.Value, json_type, inst_type));
}
object instance = null;
if (reader.Token == JsonToken.ArrayStart) {
AddArrayMetadata (inst_type);
ArrayMetadata t_data = array_metadata[inst_type];
if (! t_data.IsArray && ! t_data.IsList)
throw new JsonException (String.Format (
"Type {0} can't act as an array",
inst_type));
IList list;
Type elem_type;
if (! t_data.IsArray) {
list = (IList) Activator.CreateInstance (inst_type);
elem_type = t_data.ElementType;
} else {
list = new ArrayList ();
elem_type = inst_type.GetElementType ();
}
while (true) {
object item = ReadValue (elem_type, reader);
if (item == null && reader.Token == JsonToken.ArrayEnd)
break;
list.Add (item);
}
if (t_data.IsArray) {
int n = list.Count;
instance = Array.CreateInstance (elem_type, n);
for (int i = 0; i < n; i++)
((Array) instance).SetValue (list[i], i);
} else
instance = list;
} else if (reader.Token == JsonToken.ObjectStart) {
AddObjectMetadata (value_type);
ObjectMetadata t_data = object_metadata[value_type];
instance = Activator.CreateInstance (value_type);
while (true) {
reader.Read ();
if (reader.Token == JsonToken.ObjectEnd)
break;
string property = (string) reader.Value;
if (t_data.Properties.ContainsKey (property)) {
PropertyMetadata prop_data =
t_data.Properties[property];
if (prop_data.IsField) {
((FieldInfo) prop_data.Info).SetValue (
instance, ReadValue (prop_data.Type, reader));
} else {
PropertyInfo p_info =
(PropertyInfo) prop_data.Info;
if (p_info.CanWrite)
p_info.SetValue (
instance,
ReadValue (prop_data.Type, reader),
null);
else
ReadValue (prop_data.Type, reader);
}
} else {
if (! t_data.IsDictionary) {
if (! reader.SkipNonMembers) {
throw new JsonException (String.Format (
"The type {0} doesn't have the " +
"property '{1}'",
inst_type, property));
} else {
ReadSkip (reader);
continue;
}
}
((IDictionary) instance).Add (
property, ReadValue (
t_data.ElementType, reader));
}
}
}
return instance;
}
private static IJsonWrapper ReadValue (WrapperFactory factory,
JsonReader reader)
{
reader.Read ();
if (reader.Token == JsonToken.ArrayEnd ||
reader.Token == JsonToken.Null)
return null;
IJsonWrapper instance = factory ();
if (reader.Token == JsonToken.String) {
instance.SetString ((string) reader.Value);
return instance;
}
if (reader.Token == JsonToken.Double) {
instance.SetDouble ((double) reader.Value);
return instance;
}
if (reader.Token == JsonToken.Int) {
instance.SetInt ((int) reader.Value);
return instance;
}
if (reader.Token == JsonToken.Long) {
instance.SetLong ((long) reader.Value);
return instance;
}
if (reader.Token == JsonToken.Boolean) {
instance.SetBoolean ((bool) reader.Value);
return instance;
}
if (reader.Token == JsonToken.ArrayStart) {
instance.SetJsonType (JsonType.Array);
while (true) {
IJsonWrapper item = ReadValue (factory, reader);
if (item == null && reader.Token == JsonToken.ArrayEnd)
break;
((IList) instance).Add (item);
}
}
else if (reader.Token == JsonToken.ObjectStart) {
instance.SetJsonType (JsonType.Object);
while (true) {
reader.Read ();
if (reader.Token == JsonToken.ObjectEnd)
break;
string property = (string) reader.Value;
((IDictionary) instance)[property] = ReadValue (
factory, reader);
}
}
return instance;
}
private static void ReadSkip (JsonReader reader)
{
ToWrapper (
delegate { return new JsonMockWrapper (); }, reader);
}
private static void RegisterBaseExporters ()
{
base_exporters_table[typeof (byte)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToInt32 ((byte) obj));
};
base_exporters_table[typeof (char)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToString ((char) obj));
};
base_exporters_table[typeof (DateTime)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToString ((DateTime) obj,
datetime_format));
};
base_exporters_table[typeof (decimal)] =
delegate (object obj, JsonWriter writer) {
writer.Write ((decimal) obj);
};
base_exporters_table[typeof (sbyte)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToInt32 ((sbyte) obj));
};
base_exporters_table[typeof (short)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToInt32 ((short) obj));
};
base_exporters_table[typeof (ushort)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToInt32 ((ushort) obj));
};
base_exporters_table[typeof (uint)] =
delegate (object obj, JsonWriter writer) {
writer.Write (Convert.ToUInt64 ((uint) obj));
};
base_exporters_table[typeof (ulong)] =
delegate (object obj, JsonWriter writer) {
writer.Write ((ulong) obj);
};
}
private static void RegisterBaseImporters ()
{
ImporterFunc importer;
importer = delegate (object input) {
return Convert.ToByte ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (byte), importer);
importer = delegate (object input) {
return Convert.ToUInt64 ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (ulong), importer);
importer = delegate (object input) {
return Convert.ToInt64((int)input);
};
RegisterImporter(base_importers_table, typeof(int),
typeof(long), importer);
importer = delegate (object input) {
return Convert.ToSByte ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (sbyte), importer);
importer = delegate (object input) {
return Convert.ToInt16 ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (short), importer);
importer = delegate (object input) {
return Convert.ToUInt16 ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (ushort), importer);
importer = delegate (object input) {
return Convert.ToUInt32 ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (uint), importer);
importer = delegate (object input) {
return Convert.ToSingle ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (float), importer);
importer = delegate (object input) {
return Convert.ToDouble ((int) input);
};
RegisterImporter (base_importers_table, typeof (int),
typeof (double), importer);
importer = delegate (object input) {
return Convert.ToDecimal ((double) input);
};
RegisterImporter (base_importers_table, typeof (double),
typeof (decimal), importer);
importer = delegate (object input) {
return Convert.ToUInt32 ((long) input);
};
RegisterImporter (base_importers_table, typeof (long),
typeof (uint), importer);
importer = delegate (object input) {
return Convert.ToChar ((string) input);
};
RegisterImporter (base_importers_table, typeof (string),
typeof (char), importer);
importer = delegate (object input) {
return Convert.ToDateTime ((string) input, datetime_format);
};
RegisterImporter (base_importers_table, typeof (string),
typeof (DateTime), importer);
importer = delegate (object input) {
return DateTimeOffset.Parse((string)input, datetime_format);
};
RegisterImporter(base_importers_table, typeof(string),
typeof(DateTimeOffset), importer);
}
private static void RegisterImporter (
IDictionary<Type, IDictionary<Type, ImporterFunc>> table,
Type json_type, Type value_type, ImporterFunc importer)
{
if (! table.ContainsKey (json_type))
table.Add (json_type, new Dictionary<Type, ImporterFunc> ());
table[json_type][value_type] = importer;
}
private static void WriteValue (object obj, JsonWriter writer,
bool writer_is_private,
int depth)
{
if (depth > max_nesting_depth)
throw new JsonException (
String.Format ("Max allowed object depth reached while " +
"trying to export from type {0}",
obj.GetType ()));
if (obj == null) {
writer.Write (null);
return;
}
if (obj is IJsonWrapper) {
if (writer_is_private)
writer.TextWriter.Write (((IJsonWrapper) obj).ToJson ());
else
((IJsonWrapper) obj).ToJson (writer);
return;
}
if (obj is String) {
writer.Write ((string) obj);
return;
}
if (obj is Double) {
writer.Write ((double) obj);
return;
}
if (obj is Int32) {
writer.Write ((int) obj);
return;
}
if (obj is Boolean) {
writer.Write ((bool) obj);
return;
}
if (obj is Int64) {
writer.Write ((long) obj);
return;
}
if (obj is Array) {
writer.WriteArrayStart ();
foreach (object elem in (Array) obj)
WriteValue (elem, writer, writer_is_private, depth + 1);
writer.WriteArrayEnd ();
return;
}
if (obj is IList) {
writer.WriteArrayStart ();
foreach (object elem in (IList) obj)
WriteValue (elem, writer, writer_is_private, depth + 1);
writer.WriteArrayEnd ();
return;
}
if (obj is IDictionary) {
writer.WriteObjectStart ();
foreach (DictionaryEntry entry in (IDictionary) obj) {
writer.WritePropertyName ((string) entry.Key);
WriteValue (entry.Value, writer, writer_is_private,
depth + 1);
}
writer.WriteObjectEnd ();
return;
}
Type obj_type = obj.GetType ();
// See if there's a custom exporter for the object
if (custom_exporters_table.ContainsKey (obj_type)) {
ExporterFunc exporter = custom_exporters_table[obj_type];
exporter (obj, writer);
return;
}
// If not, maybe there's a base exporter
if (base_exporters_table.ContainsKey (obj_type)) {
ExporterFunc exporter = base_exporters_table[obj_type];
exporter (obj, writer);
return;
}
// Last option, let's see if it's an enum
if (obj is Enum) {
Type e_type = Enum.GetUnderlyingType (obj_type);
if (e_type == typeof (long)
|| e_type == typeof (uint)
|| e_type == typeof (ulong))
writer.Write ((ulong) obj);
else
writer.Write ((int) obj);
return;
}
// Okay, so it looks like the input should be exported as an
// object
AddTypeProperties (obj_type);
IList<PropertyMetadata> props = type_properties[obj_type];
writer.WriteObjectStart ();
foreach (PropertyMetadata p_data in props) {
if (p_data.IsField) {
writer.WritePropertyName (p_data.Info.Name);
WriteValue (((FieldInfo) p_data.Info).GetValue (obj),
writer, writer_is_private, depth + 1);
}
else {
PropertyInfo p_info = (PropertyInfo) p_data.Info;
if (p_info.CanRead) {
writer.WritePropertyName (p_data.Info.Name);
WriteValue (p_info.GetValue (obj, null),
writer, writer_is_private, depth + 1);
}
}
}
writer.WriteObjectEnd ();
}
#endregion
public static string ToJson (object obj)
{
lock (static_writer_lock) {
static_writer.Reset ();
WriteValue (obj, static_writer, true, 0);
return static_writer.ToString ();
}
}
public static void ToJson (object obj, JsonWriter writer)
{
WriteValue (obj, writer, false, 0);
}
public static JsonData ToObject (JsonReader reader)
{
return (JsonData) ToWrapper (
delegate { return new JsonData (); }, reader);
}
public static JsonData ToObject (TextReader reader)
{
JsonReader json_reader = new JsonReader (reader);
return (JsonData) ToWrapper (
delegate { return new JsonData (); }, json_reader);
}
public static JsonData ToObject (string json)
{
return (JsonData) ToWrapper (
delegate { return new JsonData (); }, json);
}
public static T ToObject<T> (JsonReader reader)
{
return (T) ReadValue (typeof (T), reader);
}
public static T ToObject<T> (TextReader reader)
{
JsonReader json_reader = new JsonReader (reader);
return (T) ReadValue (typeof (T), json_reader);
}
public static T ToObject<T> (string json)
{
JsonReader reader = new JsonReader (json);
return (T) ReadValue (typeof (T), reader);
}
public static object ToObject(string json, Type ConvertType )
{
JsonReader reader = new JsonReader(json);
return ReadValue(ConvertType, reader);
}
public static IJsonWrapper ToWrapper (WrapperFactory factory,
JsonReader reader)
{
return ReadValue (factory, reader);
}
public static IJsonWrapper ToWrapper (WrapperFactory factory,
string json)
{
JsonReader reader = new JsonReader (json);
return ReadValue (factory, reader);
}
public static void RegisterExporter<T> (ExporterFunc<T> exporter)
{
ExporterFunc exporter_wrapper =
delegate (object obj, JsonWriter writer) {
exporter ((T) obj, writer);
};
custom_exporters_table[typeof (T)] = exporter_wrapper;
}
public static void RegisterImporter<TJson, TValue> (
ImporterFunc<TJson, TValue> importer)
{
ImporterFunc importer_wrapper =
delegate (object input) {
return importer ((TJson) input);
};
RegisterImporter (custom_importers_table, typeof (TJson),
typeof (TValue), importer_wrapper);
}
public static void UnregisterExporters ()
{
custom_exporters_table.Clear ();
}
public static void UnregisterImporters ()
{
custom_importers_table.Clear ();
}
}
}

View File

@@ -0,0 +1,105 @@
#region Header
/**
* JsonMockWrapper.cs
* Mock object implementing IJsonWrapper, to facilitate actions like
* skipping data more efficiently.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
using System.Collections;
using System.Collections.Specialized;
namespace DataLinkMesWork
{
public class JsonMockWrapper : IJsonWrapper
{
public bool IsArray { get { return false; } }
public bool IsBoolean { get { return false; } }
public bool IsDouble { get { return false; } }
public bool IsInt { get { return false; } }
public bool IsLong { get { return false; } }
public bool IsObject { get { return false; } }
public bool IsString { get { return false; } }
public bool GetBoolean () { return false; }
public double GetDouble () { return 0.0; }
public int GetInt () { return 0; }
public JsonType GetJsonType () { return JsonType.None; }
public long GetLong () { return 0L; }
public string GetString () { return ""; }
public void SetBoolean (bool val) {}
public void SetDouble (double val) {}
public void SetInt (int val) {}
public void SetJsonType (JsonType type) {}
public void SetLong (long val) {}
public void SetString (string val) {}
public string ToJson () { return ""; }
public void ToJson (JsonWriter writer) {}
bool IList.IsFixedSize { get { return true; } }
bool IList.IsReadOnly { get { return true; } }
object IList.this[int index] {
get { return null; }
set {}
}
int IList.Add (object value) { return 0; }
void IList.Clear () {}
bool IList.Contains (object value) { return false; }
int IList.IndexOf (object value) { return -1; }
void IList.Insert (int i, object v) {}
void IList.Remove (object value) {}
void IList.RemoveAt (int index) {}
int ICollection.Count { get { return 0; } }
bool ICollection.IsSynchronized { get { return false; } }
object ICollection.SyncRoot { get { return null; } }
void ICollection.CopyTo (Array array, int index) {}
IEnumerator IEnumerable.GetEnumerator () { return null; }
bool IDictionary.IsFixedSize { get { return true; } }
bool IDictionary.IsReadOnly { get { return true; } }
ICollection IDictionary.Keys { get { return null; } }
ICollection IDictionary.Values { get { return null; } }
object IDictionary.this[object key] {
get { return null; }
set {}
}
void IDictionary.Add (object k, object v) {}
void IDictionary.Clear () {}
bool IDictionary.Contains (object key) { return false; }
void IDictionary.Remove (object key) {}
IDictionaryEnumerator IDictionary.GetEnumerator () { return null; }
object IOrderedDictionary.this[int idx] {
get { return null; }
set {}
}
IDictionaryEnumerator IOrderedDictionary.GetEnumerator () {
return null;
}
void IOrderedDictionary.Insert (int i, object k, object v) {}
void IOrderedDictionary.RemoveAt (int i) {}
}
}

View File

@@ -0,0 +1,478 @@
#region Header
/**
* JsonReader.cs
* Stream-like access to JSON text.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace DataLinkMesWork
{
public enum JsonToken
{
None,
ObjectStart,
PropertyName,
ObjectEnd,
ArrayStart,
ArrayEnd,
Int,
Long,
Double,
String,
Boolean,
Null
}
public class JsonReader
{
#region Fields
private static readonly IDictionary<int, IDictionary<int, int[]>> parse_table;
private Stack<int> automaton_stack;
private int current_input;
private int current_symbol;
private bool end_of_json;
private bool end_of_input;
private Lexer lexer;
private bool parser_in_string;
private bool parser_return;
private bool read_started;
private TextReader reader;
private bool reader_is_owned;
private bool skip_non_members;
private object token_value;
private JsonToken token;
#endregion
#region Public Properties
public bool AllowComments {
get { return lexer.AllowComments; }
set { lexer.AllowComments = value; }
}
public bool AllowSingleQuotedStrings {
get { return lexer.AllowSingleQuotedStrings; }
set { lexer.AllowSingleQuotedStrings = value; }
}
public bool SkipNonMembers {
get { return skip_non_members; }
set { skip_non_members = value; }
}
public bool EndOfInput {
get { return end_of_input; }
}
public bool EndOfJson {
get { return end_of_json; }
}
public JsonToken Token {
get { return token; }
}
public object Value {
get { return token_value; }
}
#endregion
#region Constructors
static JsonReader ()
{
parse_table = PopulateParseTable ();
}
public JsonReader (string json_text) :
this (new StringReader (json_text), true)
{
}
public JsonReader (TextReader reader) :
this (reader, false)
{
}
private JsonReader (TextReader reader, bool owned)
{
if (reader == null)
throw new ArgumentNullException ("reader");
parser_in_string = false;
parser_return = false;
read_started = false;
automaton_stack = new Stack<int> ();
automaton_stack.Push ((int) ParserToken.End);
automaton_stack.Push ((int) ParserToken.Text);
lexer = new Lexer (reader);
end_of_input = false;
end_of_json = false;
skip_non_members = true;
this.reader = reader;
reader_is_owned = owned;
}
#endregion
#region Static Methods
private static IDictionary<int, IDictionary<int, int[]>> PopulateParseTable ()
{
// See section A.2. of the manual for details
IDictionary<int, IDictionary<int, int[]>> parse_table = new Dictionary<int, IDictionary<int, int[]>> ();
TableAddRow (parse_table, ParserToken.Array);
TableAddCol (parse_table, ParserToken.Array, '[',
'[',
(int) ParserToken.ArrayPrime);
TableAddRow (parse_table, ParserToken.ArrayPrime);
TableAddCol (parse_table, ParserToken.ArrayPrime, '"',
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, '[',
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, ']',
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, '{',
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Number,
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.True,
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.False,
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Null,
(int) ParserToken.Value,
(int) ParserToken.ValueRest,
']');
TableAddRow (parse_table, ParserToken.Object);
TableAddCol (parse_table, ParserToken.Object, '{',
'{',
(int) ParserToken.ObjectPrime);
TableAddRow (parse_table, ParserToken.ObjectPrime);
TableAddCol (parse_table, ParserToken.ObjectPrime, '"',
(int) ParserToken.Pair,
(int) ParserToken.PairRest,
'}');
TableAddCol (parse_table, ParserToken.ObjectPrime, '}',
'}');
TableAddRow (parse_table, ParserToken.Pair);
TableAddCol (parse_table, ParserToken.Pair, '"',
(int) ParserToken.String,
':',
(int) ParserToken.Value);
TableAddRow (parse_table, ParserToken.PairRest);
TableAddCol (parse_table, ParserToken.PairRest, ',',
',',
(int) ParserToken.Pair,
(int) ParserToken.PairRest);
TableAddCol (parse_table, ParserToken.PairRest, '}',
(int) ParserToken.Epsilon);
TableAddRow (parse_table, ParserToken.String);
TableAddCol (parse_table, ParserToken.String, '"',
'"',
(int) ParserToken.CharSeq,
'"');
TableAddRow (parse_table, ParserToken.Text);
TableAddCol (parse_table, ParserToken.Text, '[',
(int) ParserToken.Array);
TableAddCol (parse_table, ParserToken.Text, '{',
(int) ParserToken.Object);
TableAddRow (parse_table, ParserToken.Value);
TableAddCol (parse_table, ParserToken.Value, '"',
(int) ParserToken.String);
TableAddCol (parse_table, ParserToken.Value, '[',
(int) ParserToken.Array);
TableAddCol (parse_table, ParserToken.Value, '{',
(int) ParserToken.Object);
TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Number,
(int) ParserToken.Number);
TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.True,
(int) ParserToken.True);
TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.False,
(int) ParserToken.False);
TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Null,
(int) ParserToken.Null);
TableAddRow (parse_table, ParserToken.ValueRest);
TableAddCol (parse_table, ParserToken.ValueRest, ',',
',',
(int) ParserToken.Value,
(int) ParserToken.ValueRest);
TableAddCol (parse_table, ParserToken.ValueRest, ']',
(int) ParserToken.Epsilon);
return parse_table;
}
private static void TableAddCol (IDictionary<int, IDictionary<int, int[]>> parse_table, ParserToken row, int col,
params int[] symbols)
{
parse_table[(int) row].Add (col, symbols);
}
private static void TableAddRow (IDictionary<int, IDictionary<int, int[]>> parse_table, ParserToken rule)
{
parse_table.Add ((int) rule, new Dictionary<int, int[]> ());
}
#endregion
#region Private Methods
private void ProcessNumber (string number)
{
if (number.IndexOf ('.') != -1 ||
number.IndexOf ('e') != -1 ||
number.IndexOf ('E') != -1) {
double n_double;
if (double.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out n_double)) {
token = JsonToken.Double;
token_value = n_double;
return;
}
}
int n_int32;
if (int.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int32)) {
token = JsonToken.Int;
token_value = n_int32;
return;
}
long n_int64;
if (long.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int64)) {
token = JsonToken.Long;
token_value = n_int64;
return;
}
ulong n_uint64;
if (ulong.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_uint64))
{
token = JsonToken.Long;
token_value = n_uint64;
return;
}
// Shouldn't happen, but just in case, return something
token = JsonToken.Int;
token_value = 0;
}
private void ProcessSymbol ()
{
if (current_symbol == '[') {
token = JsonToken.ArrayStart;
parser_return = true;
} else if (current_symbol == ']') {
token = JsonToken.ArrayEnd;
parser_return = true;
} else if (current_symbol == '{') {
token = JsonToken.ObjectStart;
parser_return = true;
} else if (current_symbol == '}') {
token = JsonToken.ObjectEnd;
parser_return = true;
} else if (current_symbol == '"') {
if (parser_in_string) {
parser_in_string = false;
parser_return = true;
} else {
if (token == JsonToken.None)
token = JsonToken.String;
parser_in_string = true;
}
} else if (current_symbol == (int) ParserToken.CharSeq) {
token_value = lexer.StringValue;
} else if (current_symbol == (int) ParserToken.False) {
token = JsonToken.Boolean;
token_value = false;
parser_return = true;
} else if (current_symbol == (int) ParserToken.Null) {
token = JsonToken.Null;
parser_return = true;
} else if (current_symbol == (int) ParserToken.Number) {
ProcessNumber (lexer.StringValue);
parser_return = true;
} else if (current_symbol == (int) ParserToken.Pair) {
token = JsonToken.PropertyName;
} else if (current_symbol == (int) ParserToken.True) {
token = JsonToken.Boolean;
token_value = true;
parser_return = true;
}
}
private bool ReadToken ()
{
if (end_of_input)
return false;
lexer.NextToken ();
if (lexer.EndOfInput) {
Close ();
return false;
}
current_input = lexer.Token;
return true;
}
#endregion
public void Close ()
{
if (end_of_input)
return;
end_of_input = true;
end_of_json = true;
if (reader_is_owned)
{
using(reader){}
}
reader = null;
}
public bool Read ()
{
if (end_of_input)
return false;
if (end_of_json) {
end_of_json = false;
automaton_stack.Clear ();
automaton_stack.Push ((int) ParserToken.End);
automaton_stack.Push ((int) ParserToken.Text);
}
parser_in_string = false;
parser_return = false;
token = JsonToken.None;
token_value = null;
if (! read_started) {
read_started = true;
if (! ReadToken ())
return false;
}
int[] entry_symbols;
while (true) {
if (parser_return) {
if (automaton_stack.Peek () == (int) ParserToken.End)
end_of_json = true;
return true;
}
current_symbol = automaton_stack.Pop ();
ProcessSymbol ();
if (current_symbol == current_input) {
if (! ReadToken ()) {
if (automaton_stack.Peek () != (int) ParserToken.End)
throw new JsonException (
"Input doesn't evaluate to proper JSON text");
if (parser_return)
return true;
return false;
}
continue;
}
try {
entry_symbols =
parse_table[current_symbol][current_input];
} catch (KeyNotFoundException e) {
throw new JsonException ((ParserToken) current_input, e);
}
if (entry_symbols[0] == (int) ParserToken.Epsilon)
continue;
for (int i = entry_symbols.Length - 1; i >= 0; i--)
automaton_stack.Push (entry_symbols[i]);
}
}
}
}

View File

@@ -0,0 +1,473 @@
#region Header
/**
* JsonWriter.cs
* Stream-like facility to output JSON text.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace DataLinkMesWork
{
internal enum Condition
{
InArray,
InObject,
NotAProperty,
Property,
Value
}
internal class WriterContext
{
public int Count;
public bool InArray;
public bool InObject;
public bool ExpectingValue;
public int Padding;
}
public class JsonWriter
{
#region Fields
private static readonly NumberFormatInfo number_format;
private WriterContext context;
private Stack<WriterContext> ctx_stack;
private bool has_reached_end;
private char[] hex_seq;
private int indentation;
private int indent_value;
private StringBuilder inst_string_builder;
private bool pretty_print;
private bool validate;
private bool lower_case_properties;
private TextWriter writer;
#endregion
#region Properties
public int IndentValue {
get { return indent_value; }
set {
indentation = (indentation / indent_value) * value;
indent_value = value;
}
}
public bool PrettyPrint {
get { return pretty_print; }
set { pretty_print = value; }
}
public TextWriter TextWriter {
get { return writer; }
}
public bool Validate {
get { return validate; }
set { validate = value; }
}
public bool LowerCaseProperties {
get { return lower_case_properties; }
set { lower_case_properties = value; }
}
#endregion
#region Constructors
static JsonWriter ()
{
number_format = NumberFormatInfo.InvariantInfo;
}
public JsonWriter ()
{
inst_string_builder = new StringBuilder ();
writer = new StringWriter (inst_string_builder);
Init ();
}
public JsonWriter (StringBuilder sb) :
this (new StringWriter (sb))
{
}
public JsonWriter (TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException ("writer");
this.writer = writer;
Init ();
}
#endregion
#region Private Methods
private void DoValidation (Condition cond)
{
if (! context.ExpectingValue)
context.Count++;
if (! validate)
return;
if (has_reached_end)
throw new JsonException (
"A complete JSON symbol has already been written");
switch (cond) {
case Condition.InArray:
if (! context.InArray)
throw new JsonException (
"Can't close an array here");
break;
case Condition.InObject:
if (! context.InObject || context.ExpectingValue)
throw new JsonException (
"Can't close an object here");
break;
case Condition.NotAProperty:
if (context.InObject && ! context.ExpectingValue)
throw new JsonException (
"Expected a property");
break;
case Condition.Property:
if (! context.InObject || context.ExpectingValue)
throw new JsonException (
"Can't add a property here");
break;
case Condition.Value:
if (! context.InArray &&
(! context.InObject || ! context.ExpectingValue))
throw new JsonException (
"Can't add a value here");
break;
}
}
private void Init ()
{
has_reached_end = false;
hex_seq = new char[4];
indentation = 0;
indent_value = 4;
pretty_print = false;
validate = true;
lower_case_properties = false;
ctx_stack = new Stack<WriterContext> ();
context = new WriterContext ();
ctx_stack.Push (context);
}
private static void IntToHex (int n, char[] hex)
{
int num;
for (int i = 0; i < 4; i++) {
num = n % 16;
if (num < 10)
hex[3 - i] = (char) ('0' + num);
else
hex[3 - i] = (char) ('A' + (num - 10));
n >>= 4;
}
}
private void Indent ()
{
if (pretty_print)
indentation += indent_value;
}
private void Put (string str)
{
if (pretty_print && ! context.ExpectingValue)
for (int i = 0; i < indentation; i++)
writer.Write (' ');
writer.Write (str);
}
private void PutNewline ()
{
PutNewline (true);
}
private void PutNewline (bool add_comma)
{
if (add_comma && ! context.ExpectingValue &&
context.Count > 1)
writer.Write (',');
if (pretty_print && ! context.ExpectingValue)
writer.Write (Environment.NewLine);
}
private void PutString (string str)
{
Put (String.Empty);
writer.Write ('"');
int n = str.Length;
for (int i = 0; i < n; i++) {
switch (str[i]) {
case '\n':
writer.Write ("\\n");
continue;
case '\r':
writer.Write ("\\r");
continue;
case '\t':
writer.Write ("\\t");
continue;
case '"':
case '\\':
writer.Write ('\\');
writer.Write (str[i]);
continue;
case '\f':
writer.Write ("\\f");
continue;
case '\b':
writer.Write ("\\b");
continue;
}
if ((int) str[i] >= 32 && (int) str[i] <= 126) {
writer.Write (str[i]);
continue;
}
// Default, turn into a \uXXXX sequence
IntToHex ((int) str[i], hex_seq);
writer.Write ("\\u");
writer.Write (hex_seq);
}
writer.Write ('"');
}
private void Unindent ()
{
if (pretty_print)
indentation -= indent_value;
}
#endregion
public override string ToString ()
{
if (inst_string_builder == null)
return String.Empty;
return inst_string_builder.ToString ();
}
public void Reset ()
{
has_reached_end = false;
ctx_stack.Clear ();
context = new WriterContext ();
ctx_stack.Push (context);
if (inst_string_builder != null)
inst_string_builder.Remove (0, inst_string_builder.Length);
}
public void Write (bool boolean)
{
DoValidation (Condition.Value);
PutNewline ();
Put (boolean ? "true" : "false");
context.ExpectingValue = false;
}
public void Write (decimal number)
{
DoValidation (Condition.Value);
PutNewline ();
Put (Convert.ToString (number, number_format));
context.ExpectingValue = false;
}
public void Write (double number)
{
DoValidation (Condition.Value);
PutNewline ();
string str = Convert.ToString (number, number_format);
Put (str);
if (str.IndexOf ('.') == -1 &&
str.IndexOf ('E') == -1)
writer.Write (".0");
context.ExpectingValue = false;
}
public void Write (int number)
{
DoValidation (Condition.Value);
PutNewline ();
Put (Convert.ToString (number, number_format));
context.ExpectingValue = false;
}
public void Write (long number)
{
DoValidation (Condition.Value);
PutNewline ();
Put (Convert.ToString (number, number_format));
context.ExpectingValue = false;
}
public void Write (string str)
{
DoValidation (Condition.Value);
PutNewline ();
if (str == null)
Put ("null");
else
PutString (str);
context.ExpectingValue = false;
}
[CLSCompliant(false)]
public void Write (ulong number)
{
DoValidation (Condition.Value);
PutNewline ();
Put (Convert.ToString (number, number_format));
context.ExpectingValue = false;
}
public void WriteArrayEnd ()
{
DoValidation (Condition.InArray);
PutNewline (false);
ctx_stack.Pop ();
if (ctx_stack.Count == 1)
has_reached_end = true;
else {
context = ctx_stack.Peek ();
context.ExpectingValue = false;
}
Unindent ();
Put ("]");
}
public void WriteArrayStart ()
{
DoValidation (Condition.NotAProperty);
PutNewline ();
Put ("[");
context = new WriterContext ();
context.InArray = true;
ctx_stack.Push (context);
Indent ();
}
public void WriteObjectEnd ()
{
DoValidation (Condition.InObject);
PutNewline (false);
ctx_stack.Pop ();
if (ctx_stack.Count == 1)
has_reached_end = true;
else {
context = ctx_stack.Peek ();
context.ExpectingValue = false;
}
Unindent ();
Put ("}");
}
public void WriteObjectStart ()
{
DoValidation (Condition.NotAProperty);
PutNewline ();
Put ("{");
context = new WriterContext ();
context.InObject = true;
ctx_stack.Push (context);
Indent ();
}
public void WritePropertyName (string property_name)
{
DoValidation (Condition.Property);
PutNewline ();
string propertyName = (property_name == null || !lower_case_properties)
? property_name
: property_name.ToLowerInvariant();
PutString (propertyName);
if (pretty_print) {
if (propertyName.Length > context.Padding)
context.Padding = propertyName.Length;
for (int i = context.Padding - propertyName.Length;
i >= 0; i--)
writer.Write (' ');
writer.Write (": ");
} else
writer.Write (':');
context.ExpectingValue = true;
}
}
}

View File

@@ -0,0 +1,913 @@
#region Header
/**
* Lexer.cs
* JSON lexer implementation based on a finite state machine.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
//namespace LitJson
namespace DataLinkMesWork
{
internal class FsmContext
{
public bool Return;
public int NextState;
public Lexer L;
public int StateStack;
}
internal class Lexer
{
#region Fields
private delegate bool StateHandler (FsmContext ctx);
private static readonly int[] fsm_return_table;
private static readonly StateHandler[] fsm_handler_table;
private bool allow_comments;
private bool allow_single_quoted_strings;
private bool end_of_input;
private FsmContext fsm_context;
private int input_buffer;
private int input_char;
private TextReader reader;
private int state;
private StringBuilder string_buffer;
private string string_value;
private int token;
private int unichar;
#endregion
#region Properties
public bool AllowComments {
get { return allow_comments; }
set { allow_comments = value; }
}
public bool AllowSingleQuotedStrings {
get { return allow_single_quoted_strings; }
set { allow_single_quoted_strings = value; }
}
public bool EndOfInput {
get { return end_of_input; }
}
public int Token {
get { return token; }
}
public string StringValue {
get { return string_value; }
}
#endregion
#region Constructors
static Lexer ()
{
PopulateFsmTables (out fsm_handler_table, out fsm_return_table);
}
public Lexer (TextReader reader)
{
allow_comments = true;
allow_single_quoted_strings = true;
input_buffer = 0;
string_buffer = new StringBuilder (128);
state = 1;
end_of_input = false;
this.reader = reader;
fsm_context = new FsmContext ();
fsm_context.L = this;
}
#endregion
#region Static Methods
private static int HexValue (int digit)
{
switch (digit) {
case 'a':
case 'A':
return 10;
case 'b':
case 'B':
return 11;
case 'c':
case 'C':
return 12;
case 'd':
case 'D':
return 13;
case 'e':
case 'E':
return 14;
case 'f':
case 'F':
return 15;
default:
return digit - '0';
}
}
private static void PopulateFsmTables (out StateHandler[] fsm_handler_table, out int[] fsm_return_table)
{
// See section A.1. of the manual for details of the finite
// state machine.
fsm_handler_table = new StateHandler[28] {
State1,
State2,
State3,
State4,
State5,
State6,
State7,
State8,
State9,
State10,
State11,
State12,
State13,
State14,
State15,
State16,
State17,
State18,
State19,
State20,
State21,
State22,
State23,
State24,
State25,
State26,
State27,
State28
};
fsm_return_table = new int[28] {
(int) ParserToken.Char,
0,
(int) ParserToken.Number,
(int) ParserToken.Number,
0,
(int) ParserToken.Number,
0,
(int) ParserToken.Number,
0,
0,
(int) ParserToken.True,
0,
0,
0,
(int) ParserToken.False,
0,
0,
(int) ParserToken.Null,
(int) ParserToken.CharSeq,
(int) ParserToken.Char,
0,
0,
(int) ParserToken.CharSeq,
(int) ParserToken.Char,
0,
0,
0,
0
};
}
private static char ProcessEscChar (int esc_char)
{
switch (esc_char) {
case '"':
case '\'':
case '\\':
case '/':
return Convert.ToChar (esc_char);
case 'n':
return '\n';
case 't':
return '\t';
case 'r':
return '\r';
case 'b':
return '\b';
case 'f':
return '\f';
default:
// Unreachable
return '?';
}
}
private static bool State1 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char == ' ' ||
ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r')
continue;
if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 3;
return true;
}
switch (ctx.L.input_char) {
case '"':
ctx.NextState = 19;
ctx.Return = true;
return true;
case ',':
case ':':
case '[':
case ']':
case '{':
case '}':
ctx.NextState = 1;
ctx.Return = true;
return true;
case '-':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 2;
return true;
case '0':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 4;
return true;
case 'f':
ctx.NextState = 12;
return true;
case 'n':
ctx.NextState = 16;
return true;
case 't':
ctx.NextState = 9;
return true;
case '\'':
if (! ctx.L.allow_single_quoted_strings)
return false;
ctx.L.input_char = '"';
ctx.NextState = 23;
ctx.Return = true;
return true;
case '/':
if (! ctx.L.allow_comments)
return false;
ctx.NextState = 25;
return true;
default:
return false;
}
}
return true;
}
private static bool State2 (FsmContext ctx)
{
ctx.L.GetChar ();
if (ctx.L.input_char >= '1' && ctx.L.input_char<= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 3;
return true;
}
switch (ctx.L.input_char) {
case '0':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 4;
return true;
default:
return false;
}
}
private static bool State3 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
continue;
}
if (ctx.L.input_char == ' ' ||
ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') {
ctx.Return = true;
ctx.NextState = 1;
return true;
}
switch (ctx.L.input_char) {
case ',':
case ']':
case '}':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 1;
return true;
case '.':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 5;
return true;
case 'e':
case 'E':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 7;
return true;
default:
return false;
}
}
return true;
}
private static bool State4 (FsmContext ctx)
{
ctx.L.GetChar ();
if (ctx.L.input_char == ' ' ||
ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') {
ctx.Return = true;
ctx.NextState = 1;
return true;
}
switch (ctx.L.input_char) {
case ',':
case ']':
case '}':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 1;
return true;
case '.':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 5;
return true;
case 'e':
case 'E':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 7;
return true;
default:
return false;
}
}
private static bool State5 (FsmContext ctx)
{
ctx.L.GetChar ();
if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 6;
return true;
}
return false;
}
private static bool State6 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
continue;
}
if (ctx.L.input_char == ' ' ||
ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') {
ctx.Return = true;
ctx.NextState = 1;
return true;
}
switch (ctx.L.input_char) {
case ',':
case ']':
case '}':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 1;
return true;
case 'e':
case 'E':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 7;
return true;
default:
return false;
}
}
return true;
}
private static bool State7 (FsmContext ctx)
{
ctx.L.GetChar ();
if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 8;
return true;
}
switch (ctx.L.input_char) {
case '+':
case '-':
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
ctx.NextState = 8;
return true;
default:
return false;
}
}
private static bool State8 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') {
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
continue;
}
if (ctx.L.input_char == ' ' ||
ctx.L.input_char >= '\t' && ctx.L.input_char<= '\r') {
ctx.Return = true;
ctx.NextState = 1;
return true;
}
switch (ctx.L.input_char) {
case ',':
case ']':
case '}':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
return true;
}
private static bool State9 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'r':
ctx.NextState = 10;
return true;
default:
return false;
}
}
private static bool State10 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'u':
ctx.NextState = 11;
return true;
default:
return false;
}
}
private static bool State11 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'e':
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
private static bool State12 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'a':
ctx.NextState = 13;
return true;
default:
return false;
}
}
private static bool State13 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'l':
ctx.NextState = 14;
return true;
default:
return false;
}
}
private static bool State14 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 's':
ctx.NextState = 15;
return true;
default:
return false;
}
}
private static bool State15 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'e':
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
private static bool State16 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'u':
ctx.NextState = 17;
return true;
default:
return false;
}
}
private static bool State17 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'l':
ctx.NextState = 18;
return true;
default:
return false;
}
}
private static bool State18 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'l':
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
private static bool State19 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
switch (ctx.L.input_char) {
case '"':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 20;
return true;
case '\\':
ctx.StateStack = 19;
ctx.NextState = 21;
return true;
default:
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
continue;
}
}
return true;
}
private static bool State20 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case '"':
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
private static bool State21 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case 'u':
ctx.NextState = 22;
return true;
case '"':
case '\'':
case '/':
case '\\':
case 'b':
case 'f':
case 'n':
case 'r':
case 't':
ctx.L.string_buffer.Append (
ProcessEscChar (ctx.L.input_char));
ctx.NextState = ctx.StateStack;
return true;
default:
return false;
}
}
private static bool State22 (FsmContext ctx)
{
int counter = 0;
int mult = 4096;
ctx.L.unichar = 0;
while (ctx.L.GetChar ()) {
if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9' ||
ctx.L.input_char >= 'A' && ctx.L.input_char <= 'F' ||
ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') {
ctx.L.unichar += HexValue (ctx.L.input_char) * mult;
counter++;
mult /= 16;
if (counter == 4) {
ctx.L.string_buffer.Append (
Convert.ToChar (ctx.L.unichar));
ctx.NextState = ctx.StateStack;
return true;
}
continue;
}
return false;
}
return true;
}
private static bool State23 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
switch (ctx.L.input_char) {
case '\'':
ctx.L.UngetChar ();
ctx.Return = true;
ctx.NextState = 24;
return true;
case '\\':
ctx.StateStack = 23;
ctx.NextState = 21;
return true;
default:
ctx.L.string_buffer.Append ((char) ctx.L.input_char);
continue;
}
}
return true;
}
private static bool State24 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case '\'':
ctx.L.input_char = '"';
ctx.Return = true;
ctx.NextState = 1;
return true;
default:
return false;
}
}
private static bool State25 (FsmContext ctx)
{
ctx.L.GetChar ();
switch (ctx.L.input_char) {
case '*':
ctx.NextState = 27;
return true;
case '/':
ctx.NextState = 26;
return true;
default:
return false;
}
}
private static bool State26 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char == '\n') {
ctx.NextState = 1;
return true;
}
}
return true;
}
private static bool State27 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char == '*') {
ctx.NextState = 28;
return true;
}
}
return true;
}
private static bool State28 (FsmContext ctx)
{
while (ctx.L.GetChar ()) {
if (ctx.L.input_char == '*')
continue;
if (ctx.L.input_char == '/') {
ctx.NextState = 1;
return true;
}
ctx.NextState = 27;
return true;
}
return true;
}
#endregion
private bool GetChar ()
{
if ((input_char = NextChar ()) != -1)
return true;
end_of_input = true;
return false;
}
private int NextChar ()
{
if (input_buffer != 0) {
int tmp = input_buffer;
input_buffer = 0;
return tmp;
}
return reader.Read ();
}
public bool NextToken ()
{
StateHandler handler;
fsm_context.Return = false;
while (true) {
handler = fsm_handler_table[state - 1];
if (! handler (fsm_context))
throw new JsonException (input_char);
if (end_of_input)
return false;
if (fsm_context.Return) {
string_value = string_buffer.ToString ();
string_buffer.Remove (0, string_buffer.Length);
token = fsm_return_table[state - 1];
if (token == (int) ParserToken.Char)
token = input_char;
state = fsm_context.NextState;
return true;
}
state = fsm_context.NextState;
}
}
private void UngetChar ()
{
input_buffer = input_char;
}
}
}

View File

@@ -0,0 +1,24 @@
#if NETSTANDARD1_5
using System;
using System.Reflection;
namespace DataLinkMesWork
{
internal static class Netstandard15Polyfill
{
internal static Type GetInterface(this Type type, string name)
{
return type.GetTypeInfo().GetInterface(name);
}
internal static bool IsClass(this Type type)
{
return type.GetTypeInfo().IsClass;
}
internal static bool IsEnum(this Type type)
{
return type.GetTypeInfo().IsEnum;
}
}
}
#endif

View File

@@ -0,0 +1,44 @@
#region Header
/**
* ParserToken.cs
* Internal representation of the tokens used by the lexer and the parser.
*
* The authors disclaim copyright to this source code. For more details, see
* the COPYING file included with this distribution.
**/
#endregion
namespace DataLinkMesWork
{
internal enum ParserToken
{
// Lexer tokens (see section A.1.1. of the manual)
None = System.Char.MaxValue + 1,
Number,
True,
False,
Null,
CharSeq,
// Single char
Char,
// Parser Rules (see section A.2.1 of the manual)
Text,
Object,
ObjectPrime,
Pair,
PairRest,
Array,
ArrayPrime,
Value,
ValueRest,
String,
// End of input
End,
// The empty rule
Epsilon
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,349 @@
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Collections;
using System.IO;
namespace DataLinkMesWork
{
public class MyMD5
{
private static UInt32 A;
private static UInt32 B;
private static UInt32 C;
private static UInt32 D;
private const int S11 = 7;
private const int S12 = 12;
private const int S13 = 17;
private const int S14 = 22;
private const int S21 = 5;
private const int S22 = 9;
private const int S23 = 14;
private const int S24 = 20;
private const int S31 = 4;
private const int S32 = 11;
private const int S33 = 16;
private const int S34 = 23;
private const int S41 = 6;
private const int S42 = 10;
private const int S43 = 15;
private const int S44 = 21;
// F, G, H and I are basic MD5 functions.
// F(X,Y,Z) =(X&Y)|((~X)&Z)
// G(X,Y,Z) =(X&Z)|(Y&(~Z))
// H(X,Y,Z) =X^Y^Z
// I(X,Y,Z)=Y^(X|(~Z))
// (& AND| OR~NOT^XOR)
private static UInt32 F(UInt32 x, UInt32 y, UInt32 z)
{
return (x & y) | ((~x) & z);
}
private static UInt32 G(UInt32 x, UInt32 y, UInt32 z)
{
return (x & z) | (y & (~z));
}
private static UInt32 H(UInt32 x, UInt32 y, UInt32 z)
{
return x ^ y ^ z;
}
private static UInt32 I(UInt32 x, UInt32 y, UInt32 z)
{
return y ^ (x | (~z));
}
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
private static void FF(ref UInt32 a, UInt32 b, UInt32 c, UInt32 d, UInt32 mj, int s, UInt32 ti)
{
a = a + F(b, c, d) + mj + ti;
a = a << s | a >> (32 - s);
a += b;
}
private static void GG(ref UInt32 a, UInt32 b, UInt32 c, UInt32 d, UInt32 mj, int s, UInt32 ti)
{
a = a + G(b, c, d) + mj + ti;
a = a << s | a >> (32 - s);
a += b;
}
private static void HH(ref UInt32 a, UInt32 b, UInt32 c, UInt32 d, UInt32 mj, int s, UInt32 ti)
{
a = a + H(b, c, d) + mj + ti;
a = a << s | a >> (32 - s);
a += b;
}
private static void II(ref UInt32 a, UInt32 b, UInt32 c, UInt32 d, UInt32 mj, int s, UInt32 ti)
{
a = a + I(b, c, d) + mj + ti;
a = a << s | a >> (32 - s);
a += b;
}
private static void MD5_Init()
{
//A = 0x67452301; //in memory, this is 0x01234567
//B = 0xefcdab89; //in memory, this is 0x89abcdef
//C = 0x98badcfe; //in memory, this is 0xfedcba98
//D = 0x10325476; //in memory, this is 0x76543210
A = 0x12345678; //in memory, this is 0x01234567
B = 0xabcdef21; //in memory, this is 0x89abcdef
C = 0x1a1b1c1d; //in memory, this is 0xfedcba98
D = 0x2a3b3c3d; //in memory, this is 0x76543210
}
private static UInt32[] MD5_Append(byte[] input)
{
int zeros = 0;
int ones = 1;
int size = 0;
int n = input.Length;
int m = n % 64;
if (m < 56)
{
zeros = 55 - m;
size = n - m + 64;
}
else if (m == 56)
{
zeros = 63;
ones = 1;
size = n + 8 + 64;
}
else
{
zeros = 63 - m + 56;
size = n + 64 - m + 64;
}
ArrayList bs = new ArrayList(input);
if (ones == 1)
{
bs.Add((byte)0x80); // 0x80 = 10000000
}
for (int i = 0; i < zeros; i++)
{
bs.Add((byte)0);
}
UInt64 N = (UInt64)n * 8;
byte h1 = (byte)(N & 0xFF);
byte h2 = (byte)((N >> 8) & 0xFF);
byte h3 = (byte)((N >> 16) & 0xFF);
byte h4 = (byte)((N >> 24) & 0xFF);
byte h5 = (byte)((N >> 32) & 0xFF);
byte h6 = (byte)((N >> 40) & 0xFF);
byte h7 = (byte)((N >> 48) & 0xFF);
byte h8 = (byte)(N >> 56);
bs.Add(h1);
bs.Add(h2);
bs.Add(h3);
bs.Add(h4);
bs.Add(h5);
bs.Add(h6);
bs.Add(h7);
bs.Add(h8);
byte[] ts = (byte[])bs.ToArray(typeof(byte));
// Decodes input (byte[]) into output (UInt32[]). Assumes len is
// a multiple of 4.
UInt32[] output = new UInt32[size / 4];
for (Int64 i = 0, j = 0; i < size; j++, i += 4)
{
output[j] = (UInt32)(ts[i] | ts[i + 1] << 8 | ts[i + 2] << 16 | ts[i + 3] << 24);
}
return output;
}
private static UInt32[] MD5_Trasform(UInt32[] x)
{
UInt32 a, b, c, d;
for (int k = 0; k < x.Length; k += 16)
{
a = A;
b = B;
c = C;
d = D;
//Round 1
FF(ref a, b, c, d, x[k + 0], S11, 0xd76aa478); // 1
FF(ref d, a, b, c, x[k + 1], S12, 0xe8c7b756); // 2
FF(ref c, d, a, b, x[k + 2], S13, 0x242070db); // 3
FF(ref b, c, d, a, x[k + 3], S14, 0xc1bdceee); // 4
FF(ref a, b, c, d, x[k + 4], S11, 0xf57c0faf); // 5
FF(ref d, a, b, c, x[k + 5], S12, 0x4787c62a); // 6
FF(ref c, d, a, b, x[k + 6], S13, 0xa8304613); // 7
FF(ref b, c, d, a, x[k + 7], S14, 0xfd469501); // 8
FF(ref a, b, c, d, x[k + 8], S11, 0x698098d8); // 9
FF(ref d, a, b, c, x[k + 9], S12, 0x8b44f7af); // 10
FF(ref c, d, a, b, x[k + 10], S13, 0xffff5bb1); // 11
FF(ref b, c, d, a, x[k + 11], S14, 0x895cd7be); // 12
FF(ref a, b, c, d, x[k + 12], S11, 0x6b901122); // 13
FF(ref d, a, b, c, x[k + 13], S12, 0xfd987193); // 14
FF(ref c, d, a, b, x[k + 14], S13, 0xa679438e); // 15
FF(ref b, c, d, a, x[k + 15], S14, 0x49b40821); // 16
// Round 2
GG(ref a, b, c, d, x[k + 1], S21, 0xf61e2562); // 17
GG(ref d, a, b, c, x[k + 6], S22, 0xc040b340); // 18
GG(ref c, d, a, b, x[k + 11], S23, 0x265e5a51); // 19
GG(ref b, c, d, a, x[k + 0], S24, 0xe9b6c7aa); // 20
GG(ref a, b, c, d, x[k + 5], S21, 0xd62f105d); // 21
GG(ref d, a, b, c, x[k + 10], S22, 0x2441453); // 22
GG(ref c, d, a, b, x[k + 15], S23, 0xd8a1e681); // 23
GG(ref b, c, d, a, x[k + 4], S24, 0xe7d3fbc8); // 24
GG(ref a, b, c, d, x[k + 9], S21, 0x21e1cde6); // 25
GG(ref d, a, b, c, x[k + 14], S22, 0xc33707d6); // 26
GG(ref c, d, a, b, x[k + 3], S23, 0xf4d50d87); // 27
GG(ref b, c, d, a, x[k + 8], S24, 0x455a14ed); // 28
GG(ref a, b, c, d, x[k + 13], S21, 0xa9e3e905); // 29
GG(ref d, a, b, c, x[k + 2], S22, 0xfcefa3f8); // 30
GG(ref c, d, a, b, x[k + 7], S23, 0x676f02d9); // 31
GG(ref b, c, d, a, x[k + 12], S24, 0x8d2a4c8a); // 32
// Round 3
HH(ref a, b, c, d, x[k + 5], S31, 0xfffa3942); // 33
HH(ref d, a, b, c, x[k + 8], S32, 0x8771f681); // 34
HH(ref c, d, a, b, x[k + 11], S33, 0x6d9d6122); // 35
HH(ref b, c, d, a, x[k + 14], S34, 0xfde5380c); // 36
HH(ref a, b, c, d, x[k + 1], S31, 0xa4beea44); // 37
HH(ref d, a, b, c, x[k + 4], S32, 0x4bdecfa9); // 38
HH(ref c, d, a, b, x[k + 7], S33, 0xf6bb4b60); // 39
HH(ref b, c, d, a, x[k + 10], S34, 0xbebfbc70); // 40
HH(ref a, b, c, d, x[k + 13], S31, 0x289b7ec6); // 41
HH(ref d, a, b, c, x[k + 0], S32, 0xeaa127fa); // 42
HH(ref c, d, a, b, x[k + 3], S33, 0xd4ef3085); // 43
HH(ref b, c, d, a, x[k + 6], S34, 0x4881d05); // 44
HH(ref a, b, c, d, x[k + 9], S31, 0xd9d4d039); // 45
HH(ref d, a, b, c, x[k + 12], S32, 0xe6db99e5); // 46
HH(ref c, d, a, b, x[k + 15], S33, 0x1fa27cf8); // 47
HH(ref b, c, d, a, x[k + 2], S34, 0xc4ac5665); // 48
// Round 4
II(ref a, b, c, d, x[k + 0], S41, 0xf4292244); // 49
II(ref d, a, b, c, x[k + 7], S42, 0x432aff97); // 50
II(ref c, d, a, b, x[k + 14], S43, 0xab9423a7); // 51
II(ref b, c, d, a, x[k + 5], S44, 0xfc93a039); // 52
II(ref a, b, c, d, x[k + 12], S41, 0x655b59c3); // 53
II(ref d, a, b, c, x[k + 3], S42, 0x8f0ccc92); // 54
II(ref c, d, a, b, x[k + 10], S43, 0xffeff47d); // 55
II(ref b, c, d, a, x[k + 1], S44, 0x85845dd1); // 56
II(ref a, b, c, d, x[k + 8], S41, 0x6fa87e4f); // 57
II(ref d, a, b, c, x[k + 15], S42, 0xfe2ce6e0); // 58
II(ref c, d, a, b, x[k + 6], S43, 0xa3014314); // 59
II(ref b, c, d, a, x[k + 13], S44, 0x4e0811a1); // 60
II(ref a, b, c, d, x[k + 4], S41, 0xf7537e82); // 61
II(ref d, a, b, c, x[k + 11], S42, 0xbd3af235); // 62
II(ref c, d, a, b, x[k + 2], S43, 0x2ad7d2bb); // 63
II(ref b, c, d, a, x[k + 9], S44, 0xeb86d391); // 64
A += a;
B += b;
C += c;
D += d;
}
return new UInt32[] { A, B, C, D };
}
public static byte[] MyMD5Array(byte[] input)
{
MD5_Init();
UInt32[] block = MD5_Append(input);
UInt32[] bits = MD5_Trasform(block);
// Encodes bits (UInt32[]) into output (byte[]). Assumes len is
// a multiple of 4.
byte[] output = new byte[bits.Length * 4];
for (int i = 0, j = 0; i < bits.Length; i++, j += 4)
{
output[j] = (byte)(bits[i] & 0xff);
output[j + 1] = (byte)((bits[i] >> 8) & 0xff);
output[j + 2] = (byte)((bits[i] >> 16) & 0xff);
output[j + 3] = (byte)((bits[i] >> 24) & 0xff);
}
return output;
}
public static string ArrayToHexString(byte[] array, bool uppercase)
{
string hexString = "";
string format = "x2";
if (uppercase)
{
format = "X2";
}
foreach (byte b in array)
{
hexString += b.ToString(format);
}
return hexString;
}
public static string MyMD5String(string message)
{
char[] c = message.ToCharArray();
byte[] b = new byte[c.Length];
for (int i = 0; i < c.Length; i++)
{
b[i] = (byte)c[i];
}
byte[] digest = MyMD5Array(b);
return ArrayToHexString(digest, true).ToLower().Substring(0,8);
}
public static string MyMD5File(string fileName)
{
byte[] array = null;
FileStream fs = null;
try
{
fs = File.Open(fileName, FileMode.Open, FileAccess.Read);
array = new byte[fs.Length];
fs.Read(array, 0, (int)fs.Length);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
byte[] digest = MyMD5Array(array);
fs.Close();
return ArrayToHexString(digest, true);
}
#region UnitTest
public static string Test(string message)
{
return MyMD5.MyMD5String(message);
}
public static string MD5String(string message)
{
return MyMD5.MyMD5String(message).Substring(0,8);
}
public static string TestSuite()
{
string s = "";
s += Test("");
s += Test("a");
s += Test("abc");
s += Test("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
s += Test("message digest");
s += Test("abcdefghijklmnopqrstuvwxyz");
s += Test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
s += Test("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
return s;
}
//public static void Main()
//{
// Console.WriteLine(TestSuite());
// Console.ReadLine();
//}
#endregion
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,468 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace SQLiteDBUtility
{
/// <summary>
/// 数据访问基础类(基于SQLite)
/// 可以用户可以修改满足自己项目的需要。
/// </summary>
public abstract class DbHelperSQLite
{
//数据库连接字符串(web.config来配置)可以动态更改connectionString支持多数据库.
public static string connectionString = CreateConnectionString();
public DbHelperSQLite()
{
}
private static string CreateConnectionString()
{
//string dbName = ConfigurationManager.AppSettings["SQLiteDB"];
string sqlLitePath = "data source=" + System.Environment.CurrentDirectory+ "\\db\\MW_DataFactory_App.db" + ";version=3;";
return sqlLitePath;
}
#region
public static int GetMaxID(string FieldName, string TableName)
{
string strsql = "select max(" + FieldName + ")+1 from " + TableName;
object obj = GetSingle(strsql);
if (obj == null)
{
return 1;
}
else
{
return int.Parse(obj.ToString());
}
}
public static bool Exists(string strSql)
{
object obj = GetSingle(strSql);
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
else
{
return true;
}
}
public static bool Exists(string strSql, params SQLiteParameter[] cmdParms)
{
object obj = GetSingle(strSql, cmdParms);
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
else
{
return true;
}
}
#endregion
#region SQL语句
/// <summary>
/// 执行SQL语句返回影响的记录数
/// </summary>
/// <param name="SQLString">SQL语句</param>
/// <returns>影响的记录数</returns>
public static int ExecuteSql(string SQLString)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
{
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SQLite.SQLiteException E)
{
connection.Close();
throw new Exception(E.Message);
}
}
}
}
/// <summary>
/// 执行多条SQL语句实现数据库事务。
/// </summary>
/// <param name="SQLStringList">多条SQL语句</param>
public static void ExecuteSqlTran(ArrayList SQLStringList)
{
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
conn.Open();
SQLiteCommand cmd = new SQLiteCommand();
cmd.Connection = conn;
SQLiteTransaction tx = conn.BeginTransaction();
cmd.Transaction = tx;
try
{
for (int n = 0; n < SQLStringList.Count; n++)
{
string strsql = SQLStringList[n].ToString();
if (strsql.Trim().Length > 1)
{
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
}
tx.Commit();
}
catch (System.Data.SQLite.SQLiteException E)
{
tx.Rollback();
throw new Exception(E.Message);
}
}
}
/// <summary>
/// 执行带一个存储过程参数的的SQL语句。
/// </summary>
/// <param name="SQLString">SQL语句</param>
/// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
/// <returns>影响的记录数</returns>
public static int ExecuteSql(string SQLString, string content)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
SQLiteCommand cmd = new SQLiteCommand(SQLString, connection);
SQLiteParameter myParameter = new SQLiteParameter("@content", DbType.String);
myParameter.Value = content;
cmd.Parameters.Add(myParameter);
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SQLite.SQLiteException E)
{
throw new Exception(E.Message);
}
finally
{
cmd.Dispose();
connection.Close();
}
}
}
/// <summary>
/// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
/// </summary>
/// <param name="strSQL">SQL语句</param>
/// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
/// <returns>影响的记录数</returns>
public static int ExecuteSqlInsertImg(string strSQL, byte[] fs)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
SQLiteParameter myParameter = new SQLiteParameter("@fs", DbType.Binary);
myParameter.Value = fs;
cmd.Parameters.Add(myParameter);
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SQLite.SQLiteException E)
{
throw new Exception(E.Message);
}
finally
{
cmd.Dispose();
connection.Close();
}
}
}
/// <summary>
/// 执行一条计算查询结果语句返回查询结果object
/// </summary>
/// <param name="SQLString">计算查询结果语句</param>
/// <returns>查询结果object</returns>
public static object GetSingle(string SQLString)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
{
try
{
connection.Open();
object obj = cmd.ExecuteScalar();
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
return null;
}
else
{
return obj;
}
}
catch (System.Data.SQLite.SQLiteException e)
{
connection.Close();
throw new Exception(e.Message);
}
}
}
}
/// <summary>
/// 执行查询语句返回SQLiteDataReader
/// </summary>
/// <param name="strSQL">查询语句</param>
/// <returns>SQLiteDataReader</returns>
public static SQLiteDataReader ExecuteReader(string strSQL)
{
SQLiteConnection connection = new SQLiteConnection(connectionString);
SQLiteCommand cmd = new SQLiteCommand(strSQL, connection);
try
{
connection.Open();
SQLiteDataReader myReader = cmd.ExecuteReader();
return myReader;
}
catch (System.Data.SQLite.SQLiteException e)
{
throw new Exception(e.Message);
}
}
/// <summary>
/// 执行查询语句返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.SQLite.SQLiteException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
#endregion
#region SQL语句
/// <summary>
/// 执行SQL语句返回影响的记录数
/// </summary>
/// <param name="SQLString">SQL语句</param>
/// <returns>影响的记录数</returns>
public static int ExecuteSql(string SQLString, params SQLiteParameter[] cmdParms)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
try
{
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
int rows = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return rows;
}
catch (System.Data.SQLite.SQLiteException E)
{
throw new Exception(E.Message);
}
}
}
}
/// <summary>
/// 执行多条SQL语句实现数据库事务。
/// </summary>
/// <param name="SQLStringList">SQL语句的哈希表key为sql语句value是该语句的SQLiteParameter[]</param>
public static void ExecuteSqlTran(Hashtable SQLStringList)
{
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
conn.Open();
using (SQLiteTransaction trans = conn.BeginTransaction())
{
SQLiteCommand cmd = new SQLiteCommand();
try
{
//循环
foreach (DictionaryEntry myDE in SQLStringList)
{
string cmdText = myDE.Key.ToString();
SQLiteParameter[] cmdParms = (SQLiteParameter[])myDE.Value;
PrepareCommand(cmd, conn, trans, cmdText, cmdParms);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
trans.Commit();
}
}
catch
{
trans.Rollback();
throw;
}
}
}
}
/// <summary>
/// 执行一条计算查询结果语句返回查询结果object
/// </summary>
/// <param name="SQLString">计算查询结果语句</param>
/// <returns>查询结果object</returns>
public static object GetSingle(string SQLString, params SQLiteParameter[] cmdParms)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
try
{
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
object obj = cmd.ExecuteScalar();
cmd.Parameters.Clear();
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
return null;
}
else
{
return obj;
}
}
catch (System.Data.SQLite.SQLiteException e)
{
throw new Exception(e.Message);
}
}
}
}
/// <summary>
/// 执行查询语句返回SQLiteDataReader
/// </summary>
/// <param name="strSQL">查询语句</param>
/// <returns>SQLiteDataReader</returns>
public static SQLiteDataReader ExecuteReader(string SQLString, params SQLiteParameter[] cmdParms)
{
SQLiteConnection connection = new SQLiteConnection(connectionString);
SQLiteCommand cmd = new SQLiteCommand();
try
{
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
SQLiteDataReader myReader = cmd.ExecuteReader();
cmd.Parameters.Clear();
return myReader;
}
catch (System.Data.SQLite.SQLiteException e)
{
throw new Exception(e.Message);
}
}
/// <summary>
/// 执行查询语句返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString, params SQLiteParameter[] cmdParms)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
SQLiteCommand cmd = new SQLiteCommand();
PrepareCommand(cmd, connection, null, SQLString, cmdParms);
using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd))
{
DataSet ds = new DataSet();
try
{
da.Fill(ds, "ds");
cmd.Parameters.Clear();
}
catch (System.Data.SQLite.SQLiteException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
}
private static void PrepareCommand(SQLiteCommand cmd, SQLiteConnection conn, SQLiteTransaction trans, string cmdText, SQLiteParameter[] cmdParms)
{
if (conn.State != ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandText = cmdText;
if (trans != null)
cmd.Transaction = trans;
cmd.CommandType = CommandType.Text;//cmdType;
if (cmdParms != null)
{
foreach (SQLiteParameter parm in cmdParms)
cmd.Parameters.Add(parm);
}
}
#endregion
}
}

View File

@@ -0,0 +1,265 @@
//----------------------------------------------------------------
// Copyright (C) 2000-2001 Microsoft Corporation
// All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation. See these other
// materials for detailed information regarding Microsoft code samples.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//----------------------------------------------------------------
namespace SystemFramework
{
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
/// <summary>
/// A class to help with error checking and automatic logging
/// of asserts and conditional checks.
/// <remarks>
/// This class works with displays system assert dialogs
/// as well as writing to the application log with the
/// ApplicationLog class. There is no instance data associated
/// with this class.
/// </remarks>
/// </summary>
public class ApplicationAssert
{
// #if !DEBUG
/// <value>
/// A LineNumber constant to be used when not in a debug build
/// so that ApplicationAssert. LineNumber is always a valid expression.
/// <remarks>
/// This allows us to pass ApplicationAssert.LineNumber with good debug
/// functionality and minimal runtime overhead.
/// </remarks>
/// </value>
// public const int LineNumber = 0;
// #else
static string currentTrace;
/// <value>Property LineNumber is used to get the current line number in the calling function.</value>
/// <remarks>
/// This should be called in a parameter list to get accurate
/// information about the line number before the Check* functions
/// are called. If we wait until the Check* functions themselves
/// to retrieve this information, then the stack trace indicates
/// the next executable line, which is only marginally useful
/// information. This function is compiled out in debug builds in
/// favor of the LineNumber constant.
/// Returns LineNumber, or 0 on failure.
/// </remarks>
public static int LineNumber
{
get
{
try
{
//
// Get the trace information with file information by skipping
// this function and then reading the top stack frame.
//
return (new StackTrace(1, true)).GetFrame(0).GetFileLineNumber();
}
catch
{
}
return 0;
}
}
//#endif
/// <summary>
/// Check the given condition and show an assert dialog when the
/// desktop is interactive.
/// <remarks>
/// Log the assertion at a warning level in case the desktop is not
/// interactive. The text will always contain full stack trace
/// information and will show the location of the error condition if
/// the source code is available.
/// </remarks>
/// <param name="condition">An expression to be tested for True</param>
/// <param name="errorText">The message to display</param>
/// <param name="lineNumber">
/// The line of the current error in the function. See
/// GenerateStackTrace for more information.
/// </param>
/// </summary>
//[ConditionalAttribute("DEBUG")]
public static void Check(bool condition, String errorText, int lineNumber)
{
if ( !condition )
{
String detailMessage = String.Empty;
StringBuilder strBuilder;
GenerateStackTrace(lineNumber);
detailMessage = currentTrace;
strBuilder = new StringBuilder();
strBuilder.Append("Assert: ").Append("\r\n").Append(errorText).Append("\r\n").Append(detailMessage);
ApplicationLog.WriteLog(strBuilder.ToString());
System.Diagnostics.Debug.Fail(errorText, detailMessage);
}
}
/// <summary>
///
/// </summary>
/// <param name="errorText"></param>
/// <param name="lineNumber"></param>
/// <returns></returns>
public static string GetDetailMessage(String errorText, int lineNumber)
{
String detailMessage = String.Empty;
StringBuilder strBuilder;
GenerateStackTrace(lineNumber);
detailMessage = currentTrace;
strBuilder = new StringBuilder();
strBuilder.Append("Assert: ").Append("\r\n").Append(errorText).Append("\r\n").Append(detailMessage);
return strBuilder.ToString();
}
/// <summary>
/// Verify that a required condition holds.
/// <remarks>
/// Show an assert dialog in a DEBUG build before throwing an
/// ApplicationException. It is assumed that the exception will be
/// handled or logged, so this does not log a warning for the assertion
/// like the Check function, which does not actually throw.
/// </remarks>
/// <param name="condition">An expression to be tested for True</param>
/// <param name="errorText">The message to display</param>
/// <param name="lineNumber">
/// The line of the current error in the function. See
/// GenerateStackTrace for more information.
/// </param>
/// <exception class="System.ApplicationException">
/// The checked condition failed.
/// </exception>
/// </summary>
public static void CheckCondition(bool condition, String errorText, int lineNumber)
{
//Test the condition
if ( !condition )
{
//Assert and throw if the condition is not met
String detailMessage;
GenerateStackTrace(lineNumber);
detailMessage = currentTrace;
Debug.Fail(errorText, detailMessage);
throw new ApplicationException(errorText);
}
}
/// <summary>
/// Generate a stack trace to display/log with the assertion text.
/// <remarks>
/// The trace information includes file and line number information
/// if its available, as well as a copy of the line of text if
/// the source code is available. This function is only included in
/// DEBUG builds of the application.
/// </remarks>
/// <param name="lineNumber">
/// The line of the current error in the function. This
/// value should be retrieved by call Application.LineNumber
/// in the parameter list of any of the Check* functions. If
/// LineNumber is not provided,then the next executable line is used.
/// </param>
/// </summary>
[ConditionalAttribute("DEBUG")]
private static void GenerateStackTrace(int lineNumber)
{
currentTrace = String.Empty;
// #if DEBUG
StringBuilder message; //Used for smart string concatenation
String fileName; //The source file name
int currentLine; //The line to process in the source file
String sourceLine; //The line from the source file
StreamReader fileStream = null; //The reader used to scan the source file
bool openedFile = false;
StackTrace curTrace;
StackFrame curFrame;
message = new StringBuilder();
//New StackTrace should never fail, but Try/Catch to be rock solid.
try
{
//Get a new stack trace with line information. Skip the first function
// and second functions (this one, and the calling Check* function)
curTrace = new StackTrace(2, true);
try
{
//
// Get the first retrieved stack frame and attempt to get
// file information from the trace, then open the file
// and find the specified line. Display as much information
// as possible if this is not supported.
//
curFrame = curTrace.GetFrame(0);
//Retrieve and add File/Line information. Note that we only
//proceed if both of these are available.
if ((String.Empty != (fileName = curFrame.GetFileName())) &&
(0 <= (currentLine = (lineNumber != 0) ? lineNumber : curFrame.GetFileLineNumber())))
{
//Append File name and line number
message.Append(fileName).Append(", Line: ").Append(currentLine);
//Append the actual code if we can find the source file
fileStream = new StreamReader(fileName);
openedFile = true;
do
{
sourceLine = fileStream.ReadLine();
--currentLine;
} while (currentLine != 0);
message.Append("\r\n");
if (lineNumber != 0)
{
message.Append("Current executable line:");
}
else
{
message.Append("\r\n").Append("Next executable line:");
}
message.Append("\r\n").Append(sourceLine.Trim());
}
}
catch
{
//Ignore errors, just show as much as we can
}
finally
{
//Always close the file
if (openedFile) fileStream.Close();
}
//Retrieve the final string
currentTrace = message.ToString();
}
catch
{
//Nothing to do, just get out of here with the default (empty) return value
}
// #endif
}
} // class ApplicationAssert
} // namespace Duwamish7.SystemFramework

View File

@@ -0,0 +1,219 @@
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
namespace SystemFramework
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class ApplicationLog
{
//This object is added as a debug listener.
private static StreamWriter debugWriter;
/// <summary>
///
/// </summary>
/// <param name="ex"></param>
/// <param name="catchInfo"></param>
/// <returns></returns>
public static String FormatException(Exception ex, String catchInfo)
{
StringBuilder strBuilder = new StringBuilder();
strBuilder.Append("Message:"+DateTime.Now.ToString()+"\r\n");
if (catchInfo != String.Empty)
{
strBuilder.Append(catchInfo).Append("\r\n");
}
strBuilder.Append(ex.Message).Append("\r\n").Append(ex.StackTrace).Append("\r\n").Append(ex.Source).Append("\r\n").Append(DateTime.Now.ToString()).Append("\r\n\r\n");
ApplicationAssert.GetDetailMessage(strBuilder.ToString(), ApplicationAssert.LineNumber);
return strBuilder.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="ex"></param>
/// <param name="catchInfo"></param>
public static void WriteLog( Exception ex, String catchInfo)
{
WriteLog(FormatException( ex, catchInfo));
}
/// <summary>
/// Determine where a string needs to be written based on the
/// configuration settings and the error level.
/// <param name="messageText">The string to be logged.</param>
/// </summary>
public static void WriteLog( String messageText)
{
//
// Be very careful by putting a Try/Catch around the entire routine.
// We should never throw an exception while logging.
//
try
{
//
// Write the message to the trace file
//
//Make sure a tracing file is specified.
if (debugWriter != null)
{
lock(debugWriter)
{
//写入Log文件
Debug.WriteLine("Time:"+DateTime.Now.ToString()+"\r\n"+messageText);
debugWriter.Flush();
//显示到屏幕
// Trace.WriteLine(messageText);
// Trace.Flush();
}
}
}
catch {} //Ignore any exceptions.
}
static ApplicationLog()
{
//Protect thread locks with Try/Catch to guarantee that we let go of the lock.
try
{
//See if there is a debug configuration file specified and set up the
// tracing variables.
bool clearSettings = true;
try
{
String tracingFile = System.Configuration.ConfigurationManager.AppSettings.GetValues("TracingTraceFile")[0].ToString();
FileInfo file = new FileInfo(tracingFile);
debugWriter = new StreamWriter(file.Open(FileMode.Append, FileAccess.Write, FileShare.ReadWrite));
Debug.Listeners.Add(new TextWriterTraceListener(debugWriter));
TextWriterTraceListener consoleWriter = new
TextWriterTraceListener(System.Console.Out);
Trace.Listeners.Add(consoleWriter);
clearSettings = false;
}
catch
{
//Ignore the error
}
//Use default (empty) values if something went wrong
if (clearSettings)
{
debugWriter = null;
}
}
finally
{
//Remove the lock from the class object
//Monitor.Exit(myType);
}
}
private static void GenerateStackTrace(int lineNumber, out String currentTrace)
{
currentTrace = String.Empty;
StringBuilder message; //Used for smart string concatenation
String fileName; //The source file name
int currentLine; //The line to process in the source file
String sourceLine; //The line from the source file
StreamReader fileStream = null; //The reader used to scan the source file
bool openedFile = false;
StackTrace curTrace;
StackFrame curFrame;
message = new StringBuilder();
//New StackTrace should never fail, but Try/Catch to be rock solid.
try
{
//Get a new stack trace with line information. Skip the first function
// and second functions (this one, and the calling Check* function)
curTrace = new StackTrace(2, true);
try
{
//
// Get the first retrieved stack frame and attempt to get
// file information from the trace, then open the file
// and find the specified line. Display as much information
// as possible if this is not supported.
//
curFrame = curTrace.GetFrame(0);
//Retrieve and add File/Line information. Note that we only
//proceed if both of these are available.
if ((String.Empty != (fileName = curFrame.GetFileName())) &&
(0 <= (currentLine = (lineNumber != 0) ? lineNumber : curFrame.GetFileLineNumber())))
{
//Append File name and line number
message.Append(fileName).Append(", Line: ").Append(currentLine);
//Append the actual code if we can find the source file
fileStream = new StreamReader(fileName);
openedFile = true;
do
{
sourceLine = fileStream.ReadLine();
--currentLine;
} while (currentLine != 0);
message.Append("\r\n");
if (lineNumber != 0)
{
message.Append("Current executable line:");
}
else
{
message.Append("\r\n").Append("Next executable line:");
}
message.Append("\r\n").Append(sourceLine.Trim());
}
}
catch
{
//Ignore errors, just show as much as we can
}
finally
{
//Always close the file
if (openedFile) fileStream.Close();
}
//Retrieve the final string
currentTrace = message.ToString();
}
catch
{
//Nothing to do, just get out of here with the default (empty) return value
}
}
}
}

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Web;
using System.ComponentModel;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public class Reflection
{
/// <summary>
/// 通过反射调用动态连接库方法
/// </summary>
/// <param name="assembly">程序集(DLL)</param>
/// <param name="Namespace">命名空间名称,如果无命名空间写“”</param>
/// <param name="Classname">类名</param>
/// <param name="Method">方法名</param>
/// <param name="Paramsters">函数参数数组</param>
static public string ReflectionMethod(Assembly assembly, string Namespace, string Classname, string Method, object[] Paramsters)
{
try
{
Type t;
//类
if (Namespace == "")
{
t = assembly.GetType(Classname);
}
else
{
t = assembly.GetType(Namespace + "." + Classname);
}
if (t == null)
{
return "类不存在";
}
////方法
MethodInfo mi = t.GetMethod(Method); //获取方法
if (mi == null)
{
return "方法不存在";
}
ParameterInfo[] paramsInfo = mi.GetParameters();
for (int i = 0; i < paramsInfo.Length; i++)
{
Type tType = paramsInfo[i].ParameterType;
//改变参数类型
Paramsters[i]= SD_ChanageType(Paramsters[i],tType);
}
/// 建一个实例化的类
object instanceObject = Activator.CreateInstance(t);
mi.Invoke(instanceObject, Paramsters);
return "ok";
}
catch(Exception err)
{
return err.ToString();
}
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <param name="convertsionType"></param>
/// <returns></returns>
public static object SD_ChanageType(object value, Type convertsionType)
{
//判断convertsionType类型是否为泛型因为nullable是泛型类,
if (convertsionType.IsGenericType &&
//判断convertsionType是否为nullable泛型类
convertsionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null || value.ToString().Length == 0)
{
return null;
}
//如果convertsionType为nullable类声明一个NullableConverter类该类提供从Nullable类到基础基元类型的转换
NullableConverter nullableConverter = new NullableConverter(convertsionType);
//将convertsionType转换为nullable对的基础基元类型
convertsionType = nullableConverter.UnderlyingType;
}
return Convert.ChangeType(value, convertsionType);
}
}
}

View File

@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.Text;
//添加的命名空间引用
using System.Net;
using System.Net.Sockets;
using System.Threading;
using SystemFramework;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void DelegateClassHandle_UDPServerReceive(object sender, UDPServerReceiveEvetnArgs e);
/// <summary>
///
/// </summary>
public class UDPServerReceiveEvetnArgs : EventArgs
{
object tagKey = 0;
object opName = "";
object tagValue = 0;
object tagQuality = 0;
/// <summary>
///
/// </summary>
public UDPServerReceiveEvetnArgs()
{ }
/// <summary>
///
/// </summary>
public object TagKey
{
get { return this.tagKey; }
set { this.tagKey = value; }
}
/// <summary>
///
/// </summary>
public object TagValue
{
get { return this.tagValue; }
set { this.tagValue = value; }
}
/// <summary>
///
/// </summary>
public object OpName
{
get { return this.opName; }
set { this.opName = value; }
}
/// <summary>
///
/// </summary>
public object TagQuality
{
get { return this.tagQuality; }
set { this.tagQuality = value; }
}
}
/// <summary>
///
/// </summary>
public class TagDataUDPServerReceive
{
private object tagKey;
/// <summary>
///
/// </summary>
public object TagKey
{
get { return tagKey; }
set { tagKey = value; }
}
private object tagValue;
/// <summary>
///
/// </summary>
public object TagValue
{
get { return tagValue; }
set { tagValue = value; }
}
/// <summary>
///
/// </summary>
public event DelegateClassHandle_UDPServerReceive TagDataOnChange;
/// <summary>
///
/// </summary>
/// <param name="e"></param>
public void InvokeTagData(UDPServerReceiveEvetnArgs e)
{
if (TagDataOnChange != null)
{
TagDataOnChange(this, e);
}
}
/// <summary>
///
/// </summary>
/// <param name="tagValue"></param>
public void InvokeTagData(object tagValue)
{
if (TagDataOnChange != null)
{
UDPServerReceiveEvetnArgs e = new UDPServerReceiveEvetnArgs();
e.TagValue = tagValue;
TagDataOnChange(this, e);
}
}
}
/// <summary>
/// 使用的接收端口
/// </summary>
public class UDPServerReceive
{
Thread mythread;
//使用的接收端口
/// <summary>
/// 端口号
/// </summary>
private int port;
/// <summary>
/// udp连接对象
/// </summary>
private UdpClient udpclient;
/// <summary>
///
/// </summary>
public TagDataUDPServerReceive m_TagDataUDPServerReceive;
/// <summary>
///
/// </summary>
/// <param name="port_In"></param>
public UDPServerReceive(int port_In)
{
m_TagDataUDPServerReceive = new TagDataUDPServerReceive();
port = port_In;
//创建一个线程接收接收远程主机发来的信息
mythread = new Thread(new ThreadStart(RecData));
//将线程设为后台运行
mythread.IsBackground = true;
mythread.Start();
}
/// <summary>
/// 开始接受新的端口数据
/// </summary>
/// <param name="port_In"></param>
public void Start(int port_In)
{
port = port_In;
if (mythread != null)
{
try
{
if (udpclient != null)
{
udpclient.Close();
}
mythread.Abort();
}
catch { }
}
//创建一个线程接收接收远程主机发来的信息
mythread = new Thread(new ThreadStart(RecData));
//将线程设为后台运行
mythread.IsBackground = true;
mythread.Start();
}
/// <summary>
/// 开始接受新的端口数据
/// </summary>
/// <param name="port_In"></param>
public void Close(int port_In)
{
port = port_In;
if (mythread != null)
{
try
{
if (udpclient != null)
{
udpclient.Close();
}
//mythread.Abort();
}
catch { }
}
}
/// <summary>
/// 在后台运行的接收线程
/// </summary>
private void RecData()
{
try
{
//本机指定端口接收
udpclient = new UdpClient(port);
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "RecData:new UdpClient(port)=" + port.ToString());
}
IPEndPoint remote = null;
while (true)
{
try
{
//接收从远程主机发送过来的信息
string sendMessage;
//关闭udpclient时此句会产生异常
byte[] bytes = udpclient.Receive(ref remote);
string strSource = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
sendMessage = strSource;
m_TagDataUDPServerReceive.InvokeTagData(sendMessage);
}
catch
{
break;
}
}
}
}
}

View File

@@ -0,0 +1,200 @@
using System;
using System.Collections.Generic;
using System.Text;
//添加的命名空间引用
using System.Net;
using System.Net.Sockets;
using System.Threading;
using SystemFramework;
namespace DataLinkMesWork
{
/// <summary>
/// 利用UDP向端口port发送数据
/// </summary>
public class UDPClientSend
{
/// <summary>
/// 向指定IP发送UDP
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="text"></param>
public static void Send(string ip, int port, string text)
{
UdpClient myUdpclient = new UdpClient();
string sendMessage;
try
{
DateTime m_DateTime = DateTime.Now;
IPEndPoint iep;
if (ip == "")
{
iep = new IPEndPoint(IPAddress.Broadcast, port);
}
else
{
iep = new IPEndPoint(IPAddress.Parse(ip), port);
}
sendMessage = text;
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclient.Send(bytes, bytes.Length, iep);
myUdpclient.Close();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "UDPClientSend Send");
}
finally
{
myUdpclient.Close();
}
}
/// <summary>
/// 利用UDP向端口port发送数据
/// </summary>
/// <param name="port"></param>
/// <param name="opName"></param>
/// <param name="text"></param>
public static void Send(int port, string text)
{
UdpClient myUdpclient = new UdpClient();
string sendMessage;
try
{
DateTime m_DateTime = DateTime.Now;
IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, port);
sendMessage = text;
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclient.Send(bytes, bytes.Length, iep);
myUdpclient.Close();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "UDPClientSend Send");
}
finally
{
myUdpclient.Close();
}
}
/// <summary>
/// 向指定端口发生UDP广播
/// </summary>
/// <param name="port"></param>
/// <param name="text"></param>
public static void Send_ALL(int port, string text)
{
UdpClient myUdpclient = new UdpClient();
string sendMessage;
try
{
DateTime m_DateTime = DateTime.Now;
IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, port);
sendMessage = text;
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclient.Send(bytes, bytes.Length, iep);
myUdpclient.Close();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "UDPClientSend Send");
}
finally
{
myUdpclient.Close();
}
}
/// <summary>
/// 利用UDP向端口port发送数据
/// </summary>
/// <param name="port"></param>
/// <param name="opName"></param>
/// <param name="text"></param>
public static void Send(int port,string opName, string text)
{
UdpClient myUdpclient = new UdpClient();
if (opName == null)
opName = "OpName";
string sendMessage;
try
{
DateTime m_DateTime = DateTime.Now;
IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, port);
sendMessage = text;
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclient.Send(bytes, bytes.Length, iep);
myUdpclient.Close();
if (ApplicationConfig.IsUsingUdpMonitor == 1)
{
if (port != ApplicationConfig.DupPort_Recieve_Monitor)
{
sendMessage = "Send?" + ApplicationConfig.IPAddress + "?" + port.ToString() + "?" + opName+"?" + text + "?" + m_DateTime.ToString("G") + "." + m_DateTime.Millisecond.ToString();
UdpClient myUdpclientMonitor = new UdpClient();
iep = new IPEndPoint(IPAddress.Broadcast, ApplicationConfig.DupPort_Recieve_Monitor);
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclientMonitor.Send(bytes, bytes.Length, iep);
myUdpclientMonitor.Close();
}
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "UDPClientSend Send");
}
finally
{
myUdpclient.Close();
}
}
/// <summary>
/// 利用监控端口41199发送数据
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="opName"></param>
/// <param name="text"></param>
public static void SendToMonitor(string ip,int port, string opName, string text)
{
UdpClient myUdpclient = new UdpClient();
string sendMessage;
try
{
DateTime m_DateTime = DateTime.Now;
IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, ApplicationConfig.DupPort_Recieve_Monitor);
sendMessage = "Receive?" + ip + "?" + port.ToString() + "?" + opName + "?" + text + "?" + m_DateTime.ToString("G") + "." + m_DateTime.Millisecond.ToString();
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes(sendMessage);
myUdpclient.Send(bytes, bytes.Length, iep);
myUdpclient.Close();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, "UDPClientSend Send");
}
finally
{
myUdpclient.Close();
}
}
}
}

View File

@@ -0,0 +1,416 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;
using System.Data.OleDb;
using SystemFramework;
//using SystemFramework;
namespace DataLinkMesWork
{
/// <summary>
/// 数据访问类——提供通用的数据访问方法
/// </summary>
public partial class SQLCommon
{
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="dt">查询结果记录集</param>
/// <param name="oleDbParameter"></param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataTable_OleDb_Insert(string sql, string connectionString, DataTable dt, ref OleDbParameter[] oleDbParameter, out string errorMessage)
{
bool result = false;
errorMessage = "";
try
{
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
using (OleDbDataAdapter dsCommand = new OleDbDataAdapter())
{
dsCommand.InsertCommand = new OleDbCommand(sql, conn);
for (int i = 0; i < oleDbParameter.Length; i++)
{
oleDbParameter[i].IsNullable = true;
dsCommand.InsertCommand.Parameters.Add(oleDbParameter[i]);
}
if (dt == null) return false;
dt.AcceptChanges();
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i].SetAdded();
}
dsCommand.Update(dt);
}
dt.AcceptChanges();
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteDataTable_OleDb\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\n连接字符串\r\n" + connectionString);
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="dt">查询结果记录集</param>
/// <param name="oleDbParameter">参数</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataTable_OleDb_Update(string sql, string connectionString, DataTable dt, ref OleDbParameter[] oleDbParameter, out string errorMessage)
{
bool result = false;
errorMessage = "";
//dt = new DataTable();
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
using (OleDbDataAdapter dsCommand = new OleDbDataAdapter())
{
dsCommand.UpdateCommand = new OleDbCommand(sql, conn);
for (int i = 0; i < oleDbParameter.Length; i++)
{
dsCommand.UpdateCommand.Parameters.Add(oleDbParameter[i]);
}
if (dt == null) return false;
dt.AcceptChanges();
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i].SetModified();//.SetAdded();
}
dsCommand.Update(dt);
}
dt.AcceptChanges();
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteDataTable_OleDb\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql">标准SQL语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteNonQuery_OleDb(string sql, string connectionString, out string errorMessage)
{
bool result = false;
errorMessage = "";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
conn.Open();
cmd.ExecuteNonQuery();
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery_OleDb\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn != null)
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
}
return result;
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL语句集合不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="connectionString"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteNonQuery_OleDb(StringCollection sql, string connectionString, out string errorMessage)
{
bool result = false;
errorMessage = "";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
for (int i = 0; i < sql.Count; i++)
{
using (OleDbCommand cmd = new OleDbCommand(sql[i].ToString(), conn))
{
cmd.ExecuteNonQuery();
}
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery_OleDb\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="ds">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataset_OleDb(string sql, string connectionString, out DataSet ds, out string errorMessage)
{
bool result = false;
errorMessage = "";
ds = new DataSet();
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
using (OleDbDataAdapter dsCommand = new OleDbDataAdapter())
{
dsCommand.SelectCommand = new OleDbCommand(sql, conn);
conn.Open();
dsCommand.Fill(ds);
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteDataset_OleDb(返回DataSet)\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="dt">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataTable_OleDb(string sql, string connectionString, out DataTable dt, out string errorMessage)
{
bool result = false;
errorMessage = "";
dt = new DataTable("TableName");
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
using (OleDbDataAdapter dsCommand = new OleDbDataAdapter())
{
dsCommand.SelectCommand = new OleDbCommand(sql, conn);
dsCommand.Fill(dt);
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteDataTable_OleDb\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn != null)
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="ds">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataTable_OleDb(string sql, string connectionString, out DataSet ds, out string errorMessage)
{
bool result = false;
errorMessage = "";
ds = new DataSet();
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
try
{
conn.Open();
using (OleDbDataAdapter dsCommand = new OleDbDataAdapter())
{
dsCommand.SelectCommand = new OleDbCommand(sql, conn);
dsCommand.Fill(ds);
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteDataTable_OleDb(返回DataSet)\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 返回符合条件的记录行数
/// </summary>
/// <param name="sql"></param>
/// <param name="connectionString"></param>
/// <param name="count"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteOutNum_OleDb(string sql, string connectionString, out int count, out string errorMessage)
{
bool result = false;
errorMessage = "";
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
count = 0;
try
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
object obj = cmd.ExecuteScalar();
if (obj != null)
{
count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
}
else
count = 0;
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteOutNum\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 增加记录,同时返回自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="connectionString"></param>
/// <param name="newID"></param>
/// <returns></returns>
public static bool ExecuteNonQuery_newID_OleDb(string sql, string connectionString, out long newID)
{
string errorMessage;
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
newID = 0;
try
{
conn.Open();
using (OleDbTransaction myTransaction = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
myTransaction.Commit();
cmd.ExecuteNonQuery();
cmd.CommandText = "select @@identity as id";
newID = Convert.ToInt64(cmd.ExecuteScalar());
}
}
return true;
}
catch (Exception e)
{
errorMessage = e.ToString();
ApplicationLog.WriteLog(e, "\r\nExecuteOutNum\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
return false;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
}
}
}

View File

@@ -0,0 +1,5 @@
internal class ContentResult
{
public object Content { get; set; }
public string ContentType { get; set; }
}

View File

@@ -0,0 +1,218 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Data.OleDb;
//using SystemFramework;
namespace DataLinkMesWork
{
/// <summary>
///
/// </summary>
public partial class DataAccess
{
/// <summary>
/// 更新Access数据
/// </summary>
/// <param name="sql"></param>
/// <param name="dt"></param>
/// <param name="oleDbParameter"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Update(string sql,DataTable dt, ref OleDbParameter[] oleDbParameter)
{
string errorMessage;
return SQLCommon.ExecuteDataTable_OleDb_Update(sql, ApplicationConfig.dbConnectionString_Access, dt, ref oleDbParameter, out errorMessage);
}
/// <summary>
/// 增加Access数据
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="dt"></param>
/// <param name="oleDbParameter"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Insert_Access(string sql, string filename, DataTable dt, ref OleDbParameter[] oleDbParameter)
{
string errorMessage;
string connectionString = ConnectString_OleDb_Access(filename);
return SQLCommon.ExecuteDataTable_OleDb_Insert(sql, connectionString, dt, ref oleDbParameter, out errorMessage);
}
/// <summary>
/// 用于 Access
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="filename">Excel Access文件</param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb_Access(string filename, string sql)
{
string ErrorMessage;
string dbConnectionString_Access;
dbConnectionString_Access = ConnectString_OleDb_Access(filename);
return SQLCommon.ExecuteNonQuery_OleDb(sql, dbConnectionString_Access, out ErrorMessage);
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Access(string sql, string filename, out DataTable dt)
{
string ErrorMessage;
string strConnectionstring;
strConnectionstring = ConnectString_OleDb_Access(filename);
ErrorMessage = "";
return SQLCommon.ExecuteDataTable_OleDb(sql, strConnectionstring, out dt, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Access_Connectionstring(string sql, string strConnectionstring, out DataTable dt)
{
string ErrorMessage;
ErrorMessage = "";
return SQLCommon.ExecuteDataTable_OleDb(sql, strConnectionstring, out dt, out ErrorMessage);
} /// <summary>
/// 根据Access文件名称获得Access连接字符串
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static string ConnectString_OleDb_Access(string filename)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename;
return strConn;
}
/// <summary>
/// 用于 Access
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="ConnectionString_Access"></param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb_Access_ConnectionString_Access(string sql, string ConnectionString_Access)
{
string ErrorMessage;
return SQLCommon.ExecuteNonQuery_OleDb(sql, ConnectionString_Access, out ErrorMessage);
}
/// <summary>
/// 用于 Access
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb_Access(string sql)
{
string ErrorMessage;
return SQLCommon.ExecuteNonQuery_OleDb(sql, ApplicationConfig.ConnectionString_Access, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb_Access(StringCollection sql)
{
string ErrorMessage;
return SQLCommon.ExecuteNonQuery_OleDb(sql, ApplicationConfig.ConnectionString_Access, out ErrorMessage);
}
/// <summary>
/// 用于 Access
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Access(string sql, out DataTable dt)
{
string ErrorMessage;
return SQLCommon.ExecuteDataTable_OleDb(sql, ApplicationConfig.ConnectionString_Access, out dt, out ErrorMessage);
}
/// <summary>
/// 返回count
/// </summary>
/// <param name="sql"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum_OleDb_Access(string sql, out int count)
{
string errorMessage;
return SQLCommon.ExecuteOutNum_OleDb(sql, ApplicationConfig.ConnectionString_Access, out count, out errorMessage);
}
/// <summary>
/// 返回count
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum_OleDb_Access(string sql, string filename, out int count)
{
string errorMessage;
string connectionString = ConnectString_OleDb_Access(filename);
return SQLCommon.ExecuteOutNum_OleDb(sql, connectionString, out count, out errorMessage);
}
/// <summary>
/// 增加Access数据
/// </summary>
/// <param name="sql"></param>
/// <param name="dt"></param>
/// <param name="oleDbParameter"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Insert_Access(string sql, DataTable dt, ref OleDbParameter[] oleDbParameter)
{
string errorMessage;
return SQLCommon.ExecuteDataTable_OleDb_Insert(sql, ApplicationConfig.ConnectionString_Access, dt, ref oleDbParameter, out errorMessage);
}
/// <summary>
/// 执行Insert 命令,同时返回自动编号
/// 保存到Access数据库
/// </summary>
/// <param name="sql"></param>
/// <param name="newID"></param>
public static bool ExecuteNonQuery_newID_OleDb(string sql, out long newID)
{
return SQLCommon.ExecuteNonQuery_newID_OleDb(sql, ApplicationConfig.ConnectionString_Access, out newID);
}
/// <summary>
/// 执行Insert 命令,同时返回自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="newID"></param>
public static bool ExecuteNonQuery_newID_OleDb(string sql,string filename, out long newID)
{
string strConnectionstring;
strConnectionstring = ConnectString_OleDb_Access(filename);
return SQLCommon.ExecuteNonQuery_newID_OleDb(sql, strConnectionstring, out newID);
}
}
}

View File

@@ -0,0 +1,111 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Data.OleDb;
//using SystemFramework;
namespace DataLinkMesWork
{
public partial class DataAccess
{
/// <summary>
/// 获得Excel连接
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static string ConnectString_OleDb(string filename)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=\"" + filename + "\""; ;
strConn += ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";
return strConn;
}
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static OleDbConnection getConn_OleDb(string filename)
{
string strConnectionstring = ConnectString_OleDb(filename);
OleDbConnection conn = new OleDbConnection(strConnectionstring);
conn.Open();
return conn;
}
/// <summary>
/// 增加Excel数据
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="dt"></param>
/// <param name="oleDbParameter"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Insert_Excel(string sql, string filename, DataTable dt, ref OleDbParameter[] oleDbParameter)
{
string errorMessage;
string connectionString = ConnectString_OleDb(filename);
return SQLCommon.ExecuteDataTable_OleDb_Insert(sql, connectionString, dt, ref oleDbParameter, out errorMessage);
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql"></param>
/// <param name="filename">Excel Access文件</param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb(string sql, string filename, out string ErrorMessage)
{
string strConnectionstring;
strConnectionstring = ConnectString_OleDb(filename);
ErrorMessage = "";
return SQLCommon.ExecuteNonQuery_OleDb(sql, strConnectionstring, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteSQL_OleDb(StringCollection sql, string filename, out string ErrorMessage)
{
string strConnectionstring;
strConnectionstring = ConnectString_OleDb(filename);
ErrorMessage = "";
return SQLCommon.ExecuteNonQuery_OleDb(sql, strConnectionstring, out ErrorMessage);
}
/// <summary>
/// 用于 Excel Access
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql"></param>
/// <param name="filename"></param>
/// <param name="dt"></param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb(string sql, string filename, out DataTable dt, out string ErrorMessage)
{
string strConnectionstring;
strConnectionstring = ConnectString_OleDb(filename);
ErrorMessage = "";
return SQLCommon.ExecuteDataTable_OleDb(sql, strConnectionstring, out dt, out ErrorMessage);
}
}
}

View File

@@ -0,0 +1,169 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Data.OleDb;
//using SystemFramework;
namespace DataLinkMesWork
{
public partial class DataAccess
{
/// <summary>
/// 增加SqlServer数据
/// </summary>
/// <param name="sql"></param>
/// <param name="dt"></param>
/// <param name="oleDbParameter"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Insert_SqlServer(string sql, DataTable dt, ref OleDbParameter[] oleDbParameter)
{
string errorMessage;
return SQLCommon.ExecuteDataTable_OleDb_Insert(sql, ApplicationConfig.ConnectionString_MES, dt, ref oleDbParameter, out errorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="count"></param>
/// <returns></returns>
public static bool ExecuteOutNum(string sql, out int count)
{
string errorMessage;
return SQLCommon.ExecuteOutNum(sql, ApplicationConfig.ConnectionString_MES, out count, out errorMessage);
}
/// <summary>
/// 提供通用的调用存储过程的方法(更新数据)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="dt">增加数据的数据表</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure_Update(string procedureName, ref SqlParameter[] sqlParameters, DataTable dt)
{
string errorMessage;
return SQLCommon.ExecuteStoredProcedure_Update(procedureName, ApplicationConfig.ConnectionString_MES, ref sqlParameters, dt, out errorMessage);
}
/// <summary>
/// 直接执行制定SQL语句.用于无返回条件的SQL语句执行Insert ,delete update等。
/// </summary>
/// <param name="sql"></param>
/// <returns>成功返回True / 失败返回False</returns>
public static bool ExecuteSQL(string sql)
{
string ErrorMessage;
return SQLCommon.ExecuteNonQuery(sql, ApplicationConfig.ConnectionString_MES, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static bool ExecuteSQL(StringCollection sql)
{
string ErrorMessage;
return SQLCommon.ExecuteNonQuery(sql, ApplicationConfig.ConnectionString_MES, out ErrorMessage);
}
/// <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 tb)
{
string ErrorMessage;
return SQLCommon.ExecuteSQL(sql, ref sqlParameters, ApplicationConfig.ConnectionString_MES, tb, out ErrorMessage);
}
/// <summary>
/// 直接执行制定SQL语句.用于无返回条件的SQL语句执行Insert ,delete update等。
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="ErrorMessage"></param>
/// <returns>成功返回True / 失败返回False</returns>
public static bool ExecuteSQL(string sql, string strConnectionstring, out string ErrorMessage)
{
ErrorMessage = "";
return SQLCommon.ExecuteNonQuery(sql, strConnectionstring, out ErrorMessage);
}
/// <summary>
/// 增加记录后,返回自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="newID"></param>
/// <returns></returns>
public static bool ExecuteNonQuery_newID(string sql, out long newID)
{
return SQLCommon.ExecuteNonQuery_newID(sql, out newID);
}
/// <summary>
/// 执行指定SQL语句用于执行查询后返回记录集
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="ds">返回记录集</param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteDataSet(string sql, string strConnectionstring, out DataSet ds, out string ErrorMessage)
{
ErrorMessage = "";
return SQLCommon.ExecuteDataset(sql, strConnectionstring, out ds, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="dt"></param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteDataTable(string sql, string strConnectionstring, out DataTable dt, out string ErrorMessage)
{
ErrorMessage = "";
return SQLCommon.ExecuteDataTable(sql, strConnectionstring, out dt, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecuteDataTable(string sql, out DataTable dt)
{
string ErrorMessage = "";
return SQLCommon.ExecuteDataTable(sql, ApplicationConfig.ConnectionString_MES, out dt, out ErrorMessage);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="dr"></param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteDataReader(string sql, string strConnectionstring, out SqlDataReader dr, out string ErrorMessage)
{
ErrorMessage = "";
return SQLCommon.ExecuteDataReader(sql, strConnectionstring, out dr, out ErrorMessage);
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Threading;
using System.Data.OleDb;
using SystemFramework;
//using SystemFramework;
namespace DataLinkMesWork
{
public partial class DataAccess
{
/// <summary>
/// 测试与数据的连接线程
/// </summary>
static Thread threadTestConnection;
/// <summary>
/// 测试与数据的连接
/// </summary>
/// <returns></returns>
public static void TestConnection()
{
try
{
if (threadTestConnection == null)
{
threadTestConnection = new Thread(new ThreadStart(SQLCommon.TestConnection));
threadTestConnection.Start();
}
else
{
threadTestConnection.Abort();
threadTestConnection = null;
threadTestConnection = new Thread(new ThreadStart(SQLCommon.TestConnection));
threadTestConnection.Start();
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Source);
}
}
/// <summary>
/// 测试与数据的连接
/// </summary>
/// <returns></returns>
public static void TestConnectionFirst()
{
SQLCommon.TestConnection();
}
}
}

View File

@@ -0,0 +1,439 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Data.OleDb;
//using SystemFramework;
namespace DataLinkMesWork
{
public partial class DataAccess
{
/// <summary>
/// 创建增加数据用表
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public static DataTable GetInsertTable(DataTable dt)
{
DataTable dt1;
DataRow row;
dt1 = dt.Clone();
for (int i = 0; i < dt.Rows.Count; i++)
{
row = dt1.NewRow();
for (int j = 0; j < dt.Columns.Count; j++)
{
row[j] = dt.Rows[i][j];
}
dt1.Rows.Add(row);
}
return dt1;
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="ds"></param>
/// <returns></returns>
public static bool ExecuteDataTable_OleDb_Access1(string sql,out DataSet ds)
{
string ErrorMessage ;
return SQLCommon.ExecuteDataTable_OleDb(sql, ApplicationConfig.dbConnectionString_Access, out ds, out ErrorMessage);
}
/// <summary>
/// 获取EXCEL的表 表名字列
/// </summary>
/// <param name="p_ExcelFile">Excel文件</param>
/// <returns>数据表</returns>
public static DataTable GetExcelTableName(string p_ExcelFile)
{
try
{
if (System.IO.File.Exists(p_ExcelFile))
{
OleDbConnection _ExcelConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=\"Excel 8.0\";Data Source=" + p_ExcelFile);
_ExcelConn.Open();
DataTable _Table = _ExcelConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
_ExcelConn.Close();
return _Table;
}
return null;
}
catch
{
return null;
}
}
/// <summary>
///
/// </summary>
/// <param name="strConnectionstring"></param>
/// <returns></returns>
public static SqlConnection getConn(string strConnectionstring)
{
SqlConnection conn = new SqlConnection(strConnectionstring);
conn.Open();
return conn;
}
/// <summary>
///
/// </summary>
/// <param name="conn"></param>
/// <param name="mTrans"></param>
/// <param name="sql"></param>
public static void TranExecuteNonQuery(SqlConnection conn, SqlTransaction mTrans, string sql)
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Transaction = mTrans;
cmd.ExecuteNonQuery();
}
/// <summary>
/// 执行指定Sql 语句,返回所影响的行数。
/// </summary>
/// <param name="sql">拼接出来的SQL语句。</param>
/// <param name="strConnectionstring"></param>
/// <param name="count">返回所影响的记录条数</param>
/// <param name="ErrorMessage">ErrorMessage</param>
/// <returns>True / False</returns>
public static bool ExecuteSql_count(string sql,string strConnectionstring, out int count,out string ErrorMessage)
{
SqlParameter[] thisParms = new SqlParameter[2];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@sql", sql);
thisParms[0].Direction = ParameterDirection.Input;
thisParms[1] = new System.Data.SqlClient.SqlParameter("@count", SqlDbType.Int, 32);
thisParms[1].Direction = ParameterDirection.Output;
count = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_executesql_count", strConnectionstring, ref thisParms, out ErrorMessage))
{
count = Convert.ToInt32(thisParms[1].Value.ToString());
return true;
}
return false;
}
/// <summary>
/// 执行指定插入 Sql 语句返回当前记录的新ID。
/// </summary>
/// <param name="sql">拼接出来的SQL语句。</param>
/// <param name="strConnectionstring"></param>
/// <param name="tablename"></param>
/// <param name="newID">返回当前记录的新ID</param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteSql_newID(string sql,string strConnectionstring, string tablename, out long newID, out string ErrorMessage)
{
SqlParameter[] thisParms = new SqlParameter[3];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@sql", sql);
thisParms[0].Direction = ParameterDirection.Input;
thisParms[1] = new System.Data.SqlClient.SqlParameter("@newID", SqlDbType.BigInt, 64);
thisParms[1].Direction = ParameterDirection.Output;
thisParms[2] = new System.Data.SqlClient.SqlParameter("@tablename", tablename);
thisParms[2].Direction = ParameterDirection.Input;
newID = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_insertRecord_newID", strConnectionstring, ref thisParms, out ErrorMessage))
{
newID = Convert.ToInt32(thisParms[1].Value.ToString());
return true;
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
/// <param name="strConnectionstring"></param>
/// <param name="tablename"></param>
/// <param name="newID"></param>
/// <param name="ErrorMessage"></param>
/// <returns></returns>
public static bool ExecuteSql_newID(string sql,string strConnectionstring,string tablename, out int newID,out string ErrorMessage)
{
SqlParameter[] thisParms = new SqlParameter[3];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@sql", sql);
thisParms[0].Direction = ParameterDirection.Input;
thisParms[1] = new System.Data.SqlClient.SqlParameter("@newID", SqlDbType.Int, 32);
thisParms[1].Direction = ParameterDirection.Output;
thisParms[2] = new System.Data.SqlClient.SqlParameter("@tablename", tablename);
thisParms[2].Direction = ParameterDirection.Input;
newID = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_insertRecord_newID", strConnectionstring, ref thisParms, out ErrorMessage))
{
newID = Convert.ToInt32(thisParms[1].Value.ToString());
return true;
}
return false;
}
/// <summary>
/// 根据输入参数,对指定表进行分页显示
/// </summary>
/// <param name="tbname">要进行分页的表/视图的名称</param>
/// <param name="strConnectionstring"></param>
/// <param name="fieldkey">表或者视图的主键</param>
/// <param name="where">进行过滤的条件</param>
/// <param name="fieldshow">需要显示的字段名称</param>
/// <param name="fieldorder">排序的条件,直接输入字段名 +desc/asc例如id desc,name asc</param>
/// <param name="pagecurrent">当前页的页码</param>
/// <param name="pagesize">每一页的显示的数据量</param>
/// <param name="pagecount">返回页码总数</param>
/// <param name="itemcount">返回数据总数</param>
/// <param name="ds"></param>
/// <param name="ErrorMessage">返回错误</param>
/// <returns>True / False</returns>
public static bool ExecPageQuery(string tbname,string strConnectionstring, string fieldkey, string where, string fieldshow, string fieldorder, int pagecurrent, int pagesize, out int pagecount, out int itemcount,out DataSet ds, out string ErrorMessage)
{
SqlParameter[] thisParms = new SqlParameter[9];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@tbname", tbname);
thisParms[0].Direction = ParameterDirection.Input;
thisParms[1] = new System.Data.SqlClient.SqlParameter("@fieldkey", fieldkey);
thisParms[1].Direction = ParameterDirection.Input;
thisParms[2] = new System.Data.SqlClient.SqlParameter("@where", where);
thisParms[2].Direction = ParameterDirection.Input;
thisParms[3] = new System.Data.SqlClient.SqlParameter("@fieldshow",fieldshow);
thisParms[3].Direction = ParameterDirection.Input;
thisParms[4] = new System.Data.SqlClient.SqlParameter("@fieldorder", fieldorder);
thisParms[4].Direction = ParameterDirection.Input;
thisParms[5] = new System.Data.SqlClient.SqlParameter("@pagecurrent", pagecurrent);
thisParms[5].Direction = ParameterDirection.Input;
thisParms[6] = new System.Data.SqlClient.SqlParameter("@pagesize", pagesize);
thisParms[6].Direction = ParameterDirection.Input;
thisParms[7] = new System.Data.SqlClient.SqlParameter("@pagecount", SqlDbType.Int,32);
thisParms[7].Direction = ParameterDirection.Output;
thisParms[8] = new System.Data.SqlClient.SqlParameter("@itemcount", SqlDbType.Int,32);
thisParms[8].Direction = ParameterDirection.Output;
pagecount = 0;
itemcount = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_pagesplit", strConnectionstring, ref thisParms, out ds, out ErrorMessage))
{
pagecount = Convert.ToInt32(thisParms[7].Value.ToString());
itemcount = Convert.ToInt32(thisParms[8].Value.ToString());
return true;
}
return false;
}
public static bool ExecPageQueryMesWork(string tbname, string strConnectionstring, string fieldkey, string where, string fieldshow, string fieldorder, string filedgroup,int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataTable dt, out string ErrorMessage)
{
DataSet ds;
dt = new DataTable();
SqlParameter[] thisParms = new SqlParameter[9];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@tbname", tbname);
thisParms[1] = new System.Data.SqlClient.SqlParameter("@fieldkey", fieldkey);
thisParms[2] = new System.Data.SqlClient.SqlParameter("@where", where);
thisParms[3] = new System.Data.SqlClient.SqlParameter("@fieldshow", fieldshow);
thisParms[4] = new System.Data.SqlClient.SqlParameter("@fieldOrder", fieldorder);
thisParms[5] = new System.Data.SqlClient.SqlParameter("@PageCurrent", pagecurrent);
thisParms[6] = new System.Data.SqlClient.SqlParameter("@PageSize", pagesize);
thisParms[7] = new System.Data.SqlClient.SqlParameter("@PageCount", SqlDbType.Int, 32);
thisParms[8] = new System.Data.SqlClient.SqlParameter("@ItemCount", SqlDbType.Int, 32);
thisParms[7].Direction = ParameterDirection.Output;
thisParms[8].Direction = ParameterDirection.Output;
pagecount = 0;
itemcount = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_pagesplit", strConnectionstring, ref thisParms, out ds, out ErrorMessage))
{
dt = ds.Tables[0];
pagecount = Convert.ToInt32(thisParms[7].Value.ToString());
itemcount = Convert.ToInt32(thisParms[8].Value.ToString());
return true;
}
return false;
}
/// <summary>
/// 根据输入参数,对指定表进行分页显示
/// </summary>
/// <param name="tbname">要进行分页的表/视图的名称</param>
/// <param name="strConnectionstring">表或者视图的主键</param>
/// <param name="fieldkey">表或者视图的主键</param>
/// <param name="where">进行过滤的条件</param>
/// <param name="fieldshow">需要显示的字段名称</param>
/// <param name="fieldorder">排序的条件,直接输入字段名 +desc/asc例如id desc,name asc</param>
/// <param name="filedgroup">排序的条件,直接输入字段名 +desc/asc例如id desc,name asc</param>
/// <param name="pagecurrent">当前页的页码</param>
/// <param name="pagesize">每一页的显示的数据量</param>
/// <param name="pagecount">返回页码总数</param>
/// <param name="itemcount">返回数据总数</param>
/// <param name="ds"></param>
/// <param name="ErrorMessage">返回错误</param>
/// <returns>True / False</returns>
public static bool ExecPageQuery_GroupBy(string tbname, string strConnectionstring, string fieldkey, string where, string fieldshow, string fieldorder,string filedgroup ,int pagecurrent, int pagesize, out int pagecount, out int itemcount, out DataSet ds, out string ErrorMessage)
{
SqlParameter[] thisParms = new SqlParameter[10];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@tbname", tbname);
thisParms[0].Direction = ParameterDirection.Input;
thisParms[1] = new System.Data.SqlClient.SqlParameter("@fieldkey", fieldkey);
thisParms[1].Direction = ParameterDirection.Input;
thisParms[2] = new System.Data.SqlClient.SqlParameter("@where", where);
thisParms[2].Direction = ParameterDirection.Input;
thisParms[3] = new System.Data.SqlClient.SqlParameter("@fieldshow", fieldshow);
thisParms[3].Direction = ParameterDirection.Input;
thisParms[4] = new System.Data.SqlClient.SqlParameter("@fieldorder", fieldorder);
thisParms[4].Direction = ParameterDirection.Input;
thisParms[5] = new System.Data.SqlClient.SqlParameter("@filedgroup", filedgroup);
thisParms[5].Direction = ParameterDirection.Input;
thisParms[6] = new System.Data.SqlClient.SqlParameter("@pagecurrent", pagecurrent);
thisParms[6].Direction = ParameterDirection.Input;
thisParms[7] = new System.Data.SqlClient.SqlParameter("@pagesize", pagesize);
thisParms[7].Direction = ParameterDirection.Input;
thisParms[8] = new System.Data.SqlClient.SqlParameter("@pagecount", SqlDbType.Int, 32);
thisParms[8].Direction = ParameterDirection.Output;
thisParms[9] = new System.Data.SqlClient.SqlParameter("@itemcount", SqlDbType.Int, 32);
thisParms[9].Direction = ParameterDirection.Output;
pagecount = 0;
itemcount = 0;
ErrorMessage = "";
if (SQLCommon.ExecuteStoredProcedure("sp_xt_pagesplit_GroupBy", strConnectionstring, ref thisParms, out ds, out ErrorMessage))
{
pagecount = Convert.ToInt32(thisParms[8].Value.ToString());
itemcount = Convert.ToInt32(thisParms[9].Value.ToString());
return true;
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="intGrantee"></param>
/// <param name="intGranteeType"></param>
/// <param name="intObjectId"></param>
/// <param name="intOjbectType"></param>
/// <param name="strConnectionString"></param>
/// <param name="strErrmessage"></param>
/// <returns></returns>
public static bool addGrants(int intGrantee, int intGranteeType, int intObjectId, int intOjbectType,string strConnectionString,out string strErrmessage)
{
string getdate = " '" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "' ";
string sql = "insert into grants (grantee,granteetype,objectid,objecttype,createtime,creator,creatorid) values("
+intGrantee + ","
+intGranteeType + ","
+intObjectId + ","
+ intOjbectType + ",getdate,'SYSTEM',0)";
if (ExecuteSQL(sql, strConnectionString, out strErrmessage))
{
return true;
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="intGrantee"></param>
/// <param name="intGranteeType"></param>
/// <param name="intObjectId"></param>
/// <param name="intOjbectType"></param>
/// <param name="strConnectionString"></param>
/// <param name="strErrmessage"></param>
/// <returns></returns>
public static bool delGrants(int intGrantee, int intGranteeType, int intObjectId, int intOjbectType, string strConnectionString, out string strErrmessage)
{
string sql = "update grants set deleted=1 where grantee=" + intGrantee + " and granteetype=" + intGranteeType + " and objectid=" + intObjectId + " and objecttype=" + intOjbectType;
if (ExecuteSQL(sql, strConnectionString, out strErrmessage))
{
return true;
}
return false;
}
/// <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 errorMessage;
return SQLCommon.ExecuteStoredProcedure( procedureName, ApplicationConfig.ConnectionString_MES, ref sqlParameters, dt, out errorMessage);
}
/// <summary>
/// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, ref SqlParameter[] sqlParameters)
{
string errorMessage;
return SQLCommon.ExecuteStoredProcedure(procedureName, ApplicationConfig.ConnectionString_MES, ref sqlParameters, out errorMessage);
}
/// <summary>
/// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用)
/// </summary>
/// <param name="procedureName"></param>
/// <param name="dt"></param>
/// <returns></returns>
public static bool ExecuteStoredProcedure(string procedureName, out DataTable dt)
{
string errorMessage;
return SQLCommon.ExecuteStoredProcedure(procedureName, ApplicationConfig.ConnectionString_MES, out dt, out errorMessage);
}
/// <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, out DataTable dt)
{
string errorMessage;
DataSet ds;
SQLCommon.ExecuteStoredProcedure(procedureName, ApplicationConfig.ConnectionString_MES, ref sqlParameters,out ds, out errorMessage);
try
{
dt = ds.Tables[0];
return true;
}
catch
{
dt = null;
return false;
}
}
}
}

View File

@@ -0,0 +1,258 @@
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;
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;
}
}
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();
}
}

View File

@@ -0,0 +1,959 @@
using System;
//using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;
//using System.Data.OleDb;
using SystemFramework;
using BasicData;
namespace BizDataAccess
{
/// <summary>
/// 数据访问类——提供通用的数据访问方法
/// </summary>
public partial class SQLCommon
{
/// <summary>
///
/// </summary>
/// <param name="json"></param>
/// <param name="thisParms"></param>
/// <param name="isOutput"></param>
/// <returns></returns>
public static bool GetCmdParam(jsonobj json, ref SqlParameter[] thisParms,out bool isOutput )
{
//SqlParameter[] thisParms=null;
string[] parmas;
isOutput = false;
try
{
parmas = json.Param.Split('&');
// 判断输入字符串是否合法,若不合法,则移除该条件参数
for (int i = parmas.Length-1; i >= 0; i--) {
string a = parmas[i];
string illegal1 = "==";
string illegal2 = "null";
string illegal3 = "undefined";
if (a.IndexOf(illegal1) > -1 || a.IndexOf(illegal2) > -1 || a.IndexOf(illegal3) > -1) {
ArrayList ar = new ArrayList(parmas);
ar.Remove(parmas[i]);
parmas = (string[])ar.ToArray(typeof(string));
}
}
// 移除不合法参数后重新定义thisParms长度
thisParms = new SqlParameter[parmas.Length];
for (int i = 0; i < parmas.Length; i++)
{
string[] pp = parmas[i].Split('=');
object inputValue = null;
if (pp.Length == 4)
{
if(pp[3]=="output")
{
inputValue = GetInputValue(pp);
thisParms[i] = new SqlParameter(pp[0], inputValue);
thisParms[i].Direction = ParameterDirection.Output;
isOutput = true;
}
}
else if (pp.Length == 3)
{
inputValue = GetInputValue(pp);
thisParms[i] = new SqlParameter(pp[0], inputValue);
}
else if (pp.Length == 2)
{
thisParms[i] = new SqlParameter(pp[0], pp[1]);
}
}
}
catch (Exception ex)
{
ex.ToString();
return false;
}
return true;
}
/// <summary>
/// 根据输出参数获得输出变量Json字符串
/// </summary>
/// <param name="thisParms"></param>
/// <returns></returns>
public static string GetOutputValue(SqlParameter[] thisParms)
{
string resultOutput = "";
//[{"name1":"value1","name2":"value2"}]
resultOutput = "";
int outputCount=0;
for (int i = 0; i < thisParms.Length; i++)
{
if (thisParms[i].Direction == ParameterDirection.Output)
{
if (outputCount == 0)
{
resultOutput = resultOutput + "\"" + thisParms[i].ParameterName + "\":" + "\"" + thisParms[i].Value.ToString() + "\"";
}
else
{
resultOutput = resultOutput + "," + "\"" + thisParms[i].ParameterName + "\":" + "\"" + thisParms[i].Value.ToString() + "\"";
}
outputCount++;
}
}
resultOutput = "[{" + resultOutput + "}]";
return resultOutput;
}
/// <summary>
/// 发动机型号代码&1&Int|工位号&ML050&String|PageCurrent&1&Int|PageSize&10&Int|PageCount&0&Int&Output|ItemCount&0&Int&Output
/// </summary>
/// <param name="pp"></param>
/// <returns></returns>
static object GetInputValue(string[] pp)
{
object inputValue = null;
switch (pp[2])
{
case "int":
inputValue = Convert.ToInt32(pp[1]);
break;
case "string":
inputValue = pp[1];
break;
case "boolean":
if(pp[1]=="1")
{
inputValue = true;
}
else
{
inputValue = false;
}
break;
case "datetime":
inputValue = Convert.ToDateTime(pp[1]);
break;
default:
inputValue = pp[1];
break;
}
return inputValue;
}
/// <summary>
/// SqlServer连接状态
/// =true 连接正常
/// =false 连接失败
/// </summary>
static bool sqlServerConnectionStatus=true;
/// <summary>
/// SqlServer连接状态
/// =true 连接正常
/// =false 连接失败
/// </summary>
public static bool SqlServerConnectionStatus
{
get
{
return sqlServerConnectionStatus;
}
set
{
sqlServerConnectionStatus = value;
}
}
/// <summary>
/// 测试与数据的连接
/// SqlServer连接状态
/// =true 连接正常
/// =false 连接失败
/// </summary>
/// <returns></returns>
public static void TestConnection()
{
string sql = "select top 1 uid from sysusers ";
string connectionString = ApplicationConfig.ConnectionString_MES;
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
SqlServerConnectionStatus = true;
return;
}
catch (Exception e)
{
//SqlServerConnectionStatus = false;
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
// SqlServer 与数据通讯状态
return;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
/// <summary>
/// 测试与数据的连接
/// SqlServer连接状态
/// =true 连接正常
/// =false 连接失败
/// </summary>
/// <returns></returns>
public static bool TestConnectionWorkStart()
{
bool isOK = true;
string sql = "select top 1 uid from sysusers ";
string connectionString = ApplicationConfig.ConnectionString_MES;
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
return isOK;
}
catch
{
isOK = false;
return isOK;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
/// <summary>
/// 执行标准SQL语句不要求返回结果适合增、删、改
/// </summary>
/// <param name="sql">标准SQL语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteNonQuery(StringCollection sql, string connectionString, out string errorMessage)
{
bool result = false;
errorMessage = "";
string sqlText="";
//SqlCommand cmd;
// using (SqlConnection connection =
//new SqlConnection(GetConnectionString()))
using (SqlConnection conn = new SqlConnection(connectionString))
{
try
{
if (!SqlServerConnectionStatus) return false;
conn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
for (int i = 0; i < sql.Count; i++)
{
cmd.CommandText = sql[i].ToString();
sqlText = cmd.CommandText;
//SqlCommand cmd = new SqlCommand(sql[i].ToString(), conn);
cmd.ExecuteNonQuery();
}
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sqlText + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
return result;
}
//try
//{
// if (!SqlServerConnectionStatus) return false;
// conn.Open();
// cmd = new SqlCommand();
// cmd.Connection = conn;
// for (int i = 0; i < sql.Count; i++)
// {
// cmd.CommandText = sql[i].ToString();
// sqlText = cmd.CommandText;
// //SqlCommand cmd = new SqlCommand(sql[i].ToString(), conn);
// cmd.ExecuteNonQuery();
// }
// SqlServerConnectionStatus = true;
// result = true;
//}
//catch (Exception e)
//{
// errorMessage = e.ToString();
// TestConnection();
// ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sqlText + "\r\n连接字符串\r\n" + connectionString);
//}
//finally
//{
// if (conn.State == ConnectionState.Open)
// conn.Close();
//}
//return result;
}
/// <summary>
/// 执行SQL命令实现Insert Update Delete 命令
/// </summary>
/// <param name="sql"></param>
/// <param name="connectionString"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
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语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 执行SQL后返回第一行第一列的结果
/// </summary>
/// <param name="sql"></param>
/// <param name="connectionString"></param>
/// <param name="count"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteOutNum(string sql, string connectionString, out int count, out 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语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="ds">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out 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(sql, conn);
dsCommand.Fill(ds);
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="dt">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out 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(sql, conn);
dsCommand.Fill(dt);
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 执行标准SQL查询语句返回记录集
/// </summary>
/// <param name="sql">标准SQL查询语句</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="dr">查询结果记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteDataReader(string sql, string connectionString, out SqlDataReader dr, out string errorMessage)
{
bool result = false;
errorMessage = "";
dr = null;
using (SqlConnection conn = new SqlConnection(connectionString))
{
try
{
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sql;
if (!SqlServerConnectionStatus) return false;
conn.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteNonQuery\r\nSQL语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="ds">存储过程里面返回的记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataSet ds, out 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存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="startRecord">从其开始的从零开始的记录号</param>
/// <param name="maxRecords">要检索的最大记录数</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="ds">存储过程里面返回的记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, int startRecord, int maxRecords, ref SqlParameter[] sqlParameters, out DataSet ds, out 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;
if(sqlParameters!=null)
{
for (int i = 0; i < sqlParameters.Length; i++)
{
dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
}
}
dsCommand.Fill(ds, startRecord, maxRecords, "srcTable");
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(不需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out 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();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
///
/// <param name="ds">存储过程里面返回的记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, out DataSet ds, out 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.Fill(ds);
}
SqlServerConnectionStatus = true;
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(需要返回查询的记录集的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
///
/// <param name="dt">存储过程里面返回的记录集</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, out DataTable dt, out 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存储过程\r\n" + procedureName + "\r\n连接字符串\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="connectionString"></param>
/// <param name="dt"></param>
/// <param name="errorMessage"></param>
/// <returns></returns>
public static bool ExecuteSQL(string sql, ref SqlParameter[] sqlParameters, string connectionString, DataTable dt, out 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语句\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(增加数据的数据表的到数据库的调用)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="dt">增加数据的数据表</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, DataTable dt, out 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存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 提供通用的调用存储过程的方法(更新数据)
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="connectionString">连库字符串</param>
/// <param name="sqlParameters">存储过程参数数组</param>
/// <param name="dt">增加数据的数据表</param>
/// <param name="errorMessage">错误信息</param>
/// <returns>布尔值true表示该执行成功false表示执行失败</returns>
public static bool ExecuteStoredProcedure_Update(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, DataTable dt, out string errorMessage)
{
bool result = false;
errorMessage = "";
using (SqlConnection conn = new SqlConnection(connectionString))
{
try
{
conn.Open();
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
{
dsCommand.UpdateCommand = new SqlCommand(procedureName, conn);
dsCommand.UpdateCommand.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < sqlParameters.Length; i++)
{
dsCommand.UpdateCommand.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);
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
TestConnection();
ApplicationLog.WriteLog(e, "\r\nExecuteStoredProcedure\r\n存储过程\r\n" + procedureName + "\r\n连接字符串\r\n" + connectionString);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
/// <summary>
/// 增加记录后,返回自动编号
/// </summary>
/// <param name="sql"></param>
/// <param name="newID"></param>
/// <returns></returns>
public static bool ExecuteNonQuery_newID(string sql, out long newID)
{
sql += ";select @@identity";
string connectionString;
connectionString = ApplicationConfig.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存储过程\r\n" + sql + "\r\n连接字符串\r\n" + connectionString);
return false;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DataLinkMesWork")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MesWork")]
[assembly: AssemblyProduct("DataLink")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("97127b87-d43d-457c-9894-5f2244e4d2e7")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("20.20.07.06")]
[assembly: AssemblyFileVersion("20.20.07.06")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataLinkMesWork.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataLinkMesWork.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,136 @@
namespace DataLinkMesWork
{
partial class Reg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Reg));
this.textBox_CopyRightCode = new System.Windows.Forms.TextBox();
this.textBox_SerialNumberStr = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.button_Reg = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// textBox_CopyRightCode
//
this.textBox_CopyRightCode.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox_CopyRightCode.Location = new System.Drawing.Point(183, 177);
this.textBox_CopyRightCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox_CopyRightCode.Name = "textBox_CopyRightCode";
this.textBox_CopyRightCode.Size = new System.Drawing.Size(379, 50);
this.textBox_CopyRightCode.TabIndex = 4;
//
// textBox_SerialNumberStr
//
this.textBox_SerialNumberStr.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox_SerialNumberStr.Location = new System.Drawing.Point(183, 55);
this.textBox_SerialNumberStr.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox_SerialNumberStr.Name = "textBox_SerialNumberStr";
this.textBox_SerialNumberStr.Size = new System.Drawing.Size(379, 50);
this.textBox_SerialNumberStr.TabIndex = 5;
this.textBox_SerialNumberStr.Text = "bhijepcn";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(27, 192);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(131, 38);
this.label2.TabIndex = 2;
this.label2.Text = "授权码";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(27, 59);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(131, 38);
this.label1.TabIndex = 3;
this.label1.Text = "注册码";
//
// button_Reg
//
this.button_Reg.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button_Reg.Location = new System.Drawing.Point(324, 287);
this.button_Reg.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button_Reg.Name = "button_Reg";
this.button_Reg.Size = new System.Drawing.Size(239, 56);
this.button_Reg.TabIndex = 6;
this.button_Reg.Text = "注册";
this.button_Reg.UseVisualStyleBackColor = true;
this.button_Reg.Click += new System.EventHandler(this.Button_Reg_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.InitialImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.InitialImage")));
this.pictureBox1.Location = new System.Drawing.Point(13, 265);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(283, 97);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;
//
// Reg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(616, 401);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button_Reg);
this.Controls.Add(this.textBox_CopyRightCode);
this.Controls.Add(this.textBox_SerialNumberStr);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "Reg";
this.Text = "注册系统MESWORK";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox_CopyRightCode;
private System.Windows.Forms.TextBox textBox_SerialNumberStr;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button_Reg;
private System.Windows.Forms.PictureBox pictureBox1;
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace DataLinkMesWork
{
public partial class Reg : Form
{
public Reg()
{
InitializeComponent();
string sn;
KeyWordTest.KeyWordNew(out sn);
textBox_SerialNumberStr.Text = sn;
}
/// <summary>
/// 注册,改写注册表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Reg_Click(object sender, EventArgs e)
{
string AppValue;
AppValue = textBox_CopyRightCode.Text;
ChangeConfig( AppValue);
string SerialNumberStr;
if (KeyWordTest.KeyWordNew(out SerialNumberStr))
{
MessageBox.Show("注册成功");
}
else
{
MessageBox.Show("注册失败");
}
this.Close();
}
public void ChangeConfig(string sn)
{
System.IO.File.WriteAllText(KeyWordTest.pathConfigFileSN, sn);
}
}
}

View File

@@ -0,0 +1,583 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAoYAAADMCAYAAADu1mJaAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
JQAAgIMAAPn/AACA6QAAdTAAAOpgAA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44etjH7AVVPf1lpr
rbU0fth2oR91Wym/tdZaa20IP2y70g+9KOW11lprrZXgh+0w+vEnqm2ttdZaK8UP2+H6x2BrrbXWTvZ/
/8//B/11Gg+rfed2AAAAAElFTkSuQmCC
</value>
</data>
<data name="pictureBox1.InitialImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAoYAAADMCAYAAADu1mJaAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsTAAALEwEAmpwYAAArnklE
QVR4Xu3bW5LkWowdWI1JM+6Rdhuj2rN4GYvhAA/4xscKU3kdbDw8Zdc/pP/z//yf/9vO9/+u0NvWWmut
tV3ww3YI/RD8izJaa6211srww7Yb/eDLUm5rrbXW2jB+2Erpx10V9WuttdZa24QftmH6Ebc3zdFaa621
FsYP2yb6sXYWzddaa6219id+2FL0w+wqNG9rrbXWGvHD9pV+hF2d9mittdZa+4cfNtKPrUpH9lv2aq21
1lrrH4Zf6EdVJfUU1VZRv9Zaa629ED9s/AFVRf2ilFdJPVtrrbX2EvzwpfRDqYr6jVKfSurZWmuttQfj
hy+iH0RV1G8v6l9F/VprrbX2QPzw4fTjp4r6HU1zVVG/1lprrT0EP3wg/cippJ5XoFmrqF9rrbXWbowf
PoR+zFRSz6vR3HtQ79Zaa63dDD+8Of1wqaJ+V6O5j6J5WmuttXYT/PCG9COlivpdjeY+m+ZsrbXW2oXx
w5vQj5FK6nklmvmqNH9rrbXWLoYfXph+dFRSzyvRzKOO6vOhfq211lq7AH54QfqBUUX9rkZzj1APUW0l
9WyttdbaSfjhReiHRBX1uxrNPUI9MpRZRf1aa621djB+eCL9aKiiflejuUeoRwX1qqJ+rbXWWjsAPzyY
fhxUUb+r0dyj1Gcv6l9F/VprrbW2E354AP0IqKSeV6O5R6jH0TRXFfVrrbXWovTfllH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Y6c78heWZqttdZaaxfGD29OP1LO
cMRMV9t5Mt+7tdZaazfCDx9CP1rOcKVZ9rK8fWuttdZuiB8+kH7MtHG6dWuttdZuih8+mH7ctBzdtbXW
WmsPwA9fQD942t90x9Zaa609CD98Gf0Iav9LN2uttdbaA/HDl9KPorfSfVprrbX2cPzw5fRD6S10j9Za
a629BD9s/+jH09No79Zaa629ED9sv+gH1d1pz9Zaa629GD9sf9KPrDvRTq211lpr/cNwgH50XZXmb621
1lr7D37YUvRD7Co0b2uttdYa8cO2mX6cHU1ztdZaa619xQ/bMP1g25vmaK211loL44etjH7AVVPf1lpr
rbU0fth2oR91Wym/tdZaa20IP2y70g+9KOW11lprrZXgh+0w+vEnqm2ttdZaK8UP2+H6x2BrrbXWTvZ/
/8//B/11Gg+rfed2AAAAAElFTkSuQmCC
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABMLAAATCwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKEgMgChczIA
occyAKHqMgChmTIAoTwyAKEJMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQQyAKEvMgChdzIA
odYyAKH7MgCh/zIAof8yAKH/MgCh6jIAoacyAKFJMgChEjIAoQAyAKEAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChADIAoQoyAKE+MgChkTIA
oeoyAKH+MgCh+TIAoe0yAKH+MgCh/zIAofwyAKH3MgCh/jIAofgyAKHBMgChZDIAoR4yAKEBM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VIyAKEcMgChADIAoQEyAKETMgChRzIAoZ8yAKHGMgChvzIA
oWQyAKEtMgChMzIAoY8yAKHvMgCh5zIAoa8yAKFcMgChHDIAoQMyAKEAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAADIAoQAyAKECMgChFTIAoVcyAKGaMgCh3DIAodEyAKGaMgChSDIAoQsyAKEAMgChATIA
oSUyAKGGMgCh6TIAofEyAKHhMgChtzIAoXAyAKErMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKElMgChXTIAobgyAKHbMgChxTIA
oYUyAKFbMgChqzIAodEyAKHLMgChhDIAoTsyAKELMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChCzIA
oTcyAKGTMgCh0zIAofAyAKG2MgChWjIAoRcyAKEBMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA/+Af//+AB//8AAD/8AAAP8AIAA8AGDABARg+AQEYD4ERGAPxMZgAcTOY
ADEzmDAxM5g8MTKIPzEgCDDxIAgwMSB4MAEgeDgBJHg+ATxAD8E8AAHxOAAAMQAAAAEAAwABABwgAQBE
BAEBwAABAEAAA+AAAA/4AAB//wAD///gD/8=
</value>
</data>
</root>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
</packages>