基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,372 @@
|
||||
using Lskj.Data.Api.BLL;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// cs调用bs接口推送辅助类
|
||||
/// </summary>
|
||||
public class ApiHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口传入参数模型
|
||||
/// </summary>
|
||||
public Interface.Api.ModuleEventPms mep { get; private set; }
|
||||
/// <summary>
|
||||
/// bs接口调用类
|
||||
/// </summary>
|
||||
public ApiHandler apiHandler { get; private set; }
|
||||
/// <summary>
|
||||
/// bs接口集合
|
||||
/// </summary>
|
||||
public List<ApiHandlerModel> apiHandlerModels { get; private set; }
|
||||
/// <summary>
|
||||
/// 接口执行返回值
|
||||
/// </summary>
|
||||
public string apiResutMsg { get; private set; }
|
||||
/// <summary>
|
||||
/// 模块编号
|
||||
/// </summary>
|
||||
public string moduleId;
|
||||
/// <summary>
|
||||
/// 主键名
|
||||
/// </summary>
|
||||
public string idValue;
|
||||
/// <summary>
|
||||
/// 主键值
|
||||
/// </summary>
|
||||
public string primaryKey;
|
||||
/// <summary>
|
||||
/// 操作表名
|
||||
/// </summary>
|
||||
public string tabName;
|
||||
/// <summary>
|
||||
/// 右键id
|
||||
/// </summary>
|
||||
public int contextMenuId;
|
||||
/// <summary>
|
||||
/// 选中行数据
|
||||
/// </summary>
|
||||
public Hashtable masterData;
|
||||
/// <summary>
|
||||
/// 执行方法名
|
||||
/// </summary>
|
||||
private string execStr;
|
||||
/// <summary>
|
||||
/// 其他调用
|
||||
/// </summary>
|
||||
/// <param name="moduleId"></param>
|
||||
/// <param name="idValue"></param>
|
||||
/// <param name="primaryKey"></param>
|
||||
/// <param name="tabName"></param>
|
||||
/// <param name="contextMenuId"></param>
|
||||
/// <param name="foucusRow"></param>
|
||||
public ApiHelper(string moduleId, string idValue, string primaryKey, string tabName, int contextMenuId, DataRow foucusRow = null)
|
||||
{
|
||||
this.idValue = idValue;
|
||||
this.moduleId = moduleId;
|
||||
this.tabName = tabName;
|
||||
this.primaryKey = primaryKey;
|
||||
this.contextMenuId = contextMenuId;
|
||||
this.masterData = GetHashTab(foucusRow);
|
||||
}
|
||||
/// <summary>
|
||||
/// 右键调用
|
||||
/// </summary>
|
||||
/// <param name="moduleId"></param>
|
||||
/// <param name="contextMenuId"></param>
|
||||
/// <param name="foucusRow"></param>
|
||||
public ApiHelper(string moduleId, int contextMenuId, DataRow foucusRow)
|
||||
{
|
||||
this.moduleId = moduleId;
|
||||
this.contextMenuId = contextMenuId;
|
||||
this.masterData = GetHashTab(foucusRow);
|
||||
}
|
||||
/// <summary>
|
||||
/// 接口推送
|
||||
/// </summary>
|
||||
/// <param name="operateEvent"></param>
|
||||
/// <param name="actionType"></param>
|
||||
/// <param name="isSend"></param>
|
||||
public void OnEvent(Interface.Api.OperateEvent operateEvent, Interface.Api.ActionType actionType, bool isSend = true)
|
||||
{
|
||||
execStr = GetExecStr(actionType);
|
||||
string apiMsg = "";
|
||||
mep = new Interface.Api.ModuleEventPms();
|
||||
bool isShowApiRtnMessage = false;
|
||||
try
|
||||
{
|
||||
#region Api属性值设置
|
||||
mep.ModuleId = moduleId;
|
||||
mep.OperEvent = operateEvent;
|
||||
mep.IdValue = idValue;
|
||||
mep.ContextMenuId = contextMenuId;
|
||||
mep.MasterData = masterData;
|
||||
mep.AcType = actionType;
|
||||
string Autogrowcolumn = SqlHelper.ExecuteScalar(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", this.tabName)) + ""; ;//自增长列
|
||||
if (Autogrowcolumn.Equals(this.primaryKey, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Autogrowcolumn) && actionType == Interface.Api.ActionType.Add)
|
||||
mep.IdValue = GetAutoIdValue(tabName, Autogrowcolumn);
|
||||
}
|
||||
if (actionType == Interface.Api.ActionType.Add)
|
||||
mep.IdentityId = GetAutoIdValue(tabName, Autogrowcolumn);//新增获取自增字段
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.tabName) && !string.IsNullOrEmpty(this.primaryKey) && !string.IsNullOrEmpty(mep.IdValue))
|
||||
{
|
||||
mep.IdentityId = GetPrimaryAutoId(Autogrowcolumn, this.primaryKey, this.idValue, this.tabName);//否则获取主键字段
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
string showMessageTagSql = "select top 1 * from p_systemtab";
|
||||
DataTable dataTable = SqlHelper.ExecuteDataTable(showMessageTagSql);
|
||||
if (dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("IsApiShowRtnMessage"))
|
||||
{
|
||||
isShowApiRtnMessage = (dataTable.Rows[0]["IsApiShowRtnMessage"] + "").Equals("1") ? true : false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
isShowApiRtnMessage = false;
|
||||
}
|
||||
#endregion
|
||||
apiHandler = new Lskj.Data.Api.BLL.ApiHandler();
|
||||
apiHandlerModels = new List<ApiHandlerModel>();
|
||||
apiHandler._dataImpl = new Data.Api.DataImpl();
|
||||
apiHandler._dataImpl.dbOperator = new Lskj.Data.ADO.Template.DbTemplate(string.Format("server={0};database={1};persist security info=true;user id=lserpAdmin;password=lserp110;max pool size = 512;", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase), "system.data.sqlclient");
|
||||
if (isSend)//是否发送数据
|
||||
{
|
||||
apiHandler.GetEventApiSendData(mep, apiHandlerModels);
|
||||
apiHandler.SendEventApiData(apiHandlerModels);
|
||||
}
|
||||
else
|
||||
{
|
||||
apiHandler.GetEventApiSendData(mep, apiHandlerModels);
|
||||
}
|
||||
this.apiResutMsg = apiHandler.GetApiReturnMsg(apiHandlerModels);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//MessageBox.Show(ex.Message);
|
||||
//if (!isSend)
|
||||
// throw;//非执行状态抛出异常外部弹框
|
||||
apiMsg += string.Format("{0}推送失败,原因:{1}\r\n", execStr, ex.Message);
|
||||
this.apiResutMsg = apiMsg;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//bool allowShowMsg = false;
|
||||
//try
|
||||
//{
|
||||
// allowShowMsg = apiHandlerModels[0].sendApis[0].AllowShowMsg;
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
//}
|
||||
//if (!allowShowMsg)
|
||||
//{
|
||||
// this.apiResutMsg = "";//屏蔽弹出提示框
|
||||
//}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 未发送时执行调用
|
||||
/// </summary>
|
||||
public void OnEvent()
|
||||
{
|
||||
string apiMsg = "";
|
||||
try
|
||||
{
|
||||
if (apiHandler != null)
|
||||
{
|
||||
apiHandler.SendEventApiData(apiHandlerModels);
|
||||
this.apiResutMsg = apiHandler.GetApiReturnMsg(apiHandlerModels);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
apiMsg += string.Format("{0}推送失败,原因:{1}\r\n", execStr, ex.Message);
|
||||
this.apiResutMsg = apiMsg;
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.apiResutMsg = "";//屏蔽弹出提示框
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断是否配置接口数据
|
||||
/// </summary>
|
||||
/// <param name="operateEvent"></param>
|
||||
/// <param name="moduleId"></param>
|
||||
/// <param name="contextMenuId"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExecEventApi(Interface.Api.OperateEvent operateEvent, string moduleId, int contextMenuId)
|
||||
{
|
||||
try
|
||||
{
|
||||
string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'p_systemEventApiTab') and xtype='U'";
|
||||
DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab);
|
||||
if (apiTab.Rows.Count > 0)
|
||||
{
|
||||
string sqlStr = "";
|
||||
if (!string.IsNullOrEmpty(contextMenuId + "") && !(contextMenuId + "").Equals("0"))
|
||||
{
|
||||
sqlStr = string.Format("select * from p_systemEventApiTab where actionType=0 and charIndex(','+eType+',',',{0},')>0 and charIndex(',{1},',','+convert(varchar,contextMenuId)+',')>0 order by orderValue", operateEvent, contextMenuId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlStr = string.Format("select * from p_systemEventApiTab where actionType=0 and charIndex(','+eType+',',',{0},')>0 and charIndex(',{1},',','+convert(varchar,dllcoid)+',')>0 order by orderValue", operateEvent, moduleId);
|
||||
}
|
||||
DataTable tbVal = SqlHelper.ExecuteDataTable(sqlStr);
|
||||
if (tbVal.Rows.Count > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断是否配置接口日志数据
|
||||
/// </summary>
|
||||
/// <param name="operateEvent"></param>
|
||||
/// <param name="moduleId"></param>
|
||||
/// <param name="contextMenuId"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExecEventApiLog()
|
||||
{
|
||||
try
|
||||
{
|
||||
string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'p_systemEventApiLogTab') and xtype='U'";
|
||||
DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab);
|
||||
if (apiTab.Rows.Count > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取对应主键值的自增长值
|
||||
/// </summary>
|
||||
/// <param name="autogrowcolumn"></param>
|
||||
/// <param name="keyField"></param>
|
||||
/// <param name="autogrowvalue"></param>
|
||||
/// <param name="tabName"></param>
|
||||
/// <returns></returns>
|
||||
private string GetPrimaryAutoId(string autogrowcolumn, string keyField, string autogrowvalue, string tabName)
|
||||
{
|
||||
string value = "";
|
||||
if (!string.IsNullOrEmpty(autogrowcolumn))
|
||||
{
|
||||
string sql = "select {0} from {1} where {2}='{3}'";
|
||||
sql = string.Format(sql, autogrowcolumn, tabName, keyField, autogrowvalue);
|
||||
value = SqlHelper.ExecuteScalar(sql) + "";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#region 获取自增长主键值
|
||||
/// <summary>
|
||||
/// 获取自增长主键值
|
||||
/// </summary>
|
||||
/// <param name="tabName"></param>
|
||||
/// <param name="autogrowcolumn"></param>
|
||||
/// <returns></returns>
|
||||
private string GetAutoIdValue(string tabName, string autogrowcolumn)
|
||||
{
|
||||
string autogrowvalue = "";
|
||||
if (!string.IsNullOrEmpty(autogrowcolumn))
|
||||
autogrowvalue = SqlHelper.ExecuteScalar(string.Format("select ident_current('{0}')", tabName)) + "";
|
||||
return autogrowvalue;
|
||||
}
|
||||
#endregion
|
||||
#region dataRow转hashTable
|
||||
/// <summary>
|
||||
/// dataRow转hashTable
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private Hashtable GetHashTab(DataRow row)
|
||||
{
|
||||
Hashtable hashtable = new Hashtable();
|
||||
if (row != null)
|
||||
{
|
||||
foreach (DataColumn col in row.Table.Columns)
|
||||
{
|
||||
hashtable.Add(col.ColumnName.ToLower(), row[col] + "");
|
||||
}
|
||||
}
|
||||
return hashtable;
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 获取执行操作的中文意思
|
||||
/// </summary>
|
||||
/// <param name="actionType"></param>
|
||||
/// <returns></returns>
|
||||
private string GetExecStr(Interface.Api.ActionType actionType)
|
||||
{
|
||||
string execStr = "";
|
||||
switch (actionType)
|
||||
{
|
||||
case Interface.Api.ActionType.None:
|
||||
break;
|
||||
case Interface.Api.ActionType.Load:
|
||||
break;
|
||||
case Interface.Api.ActionType.Add:
|
||||
execStr = "新增";
|
||||
break;
|
||||
case Interface.Api.ActionType.Update:
|
||||
execStr = "更新";
|
||||
break;
|
||||
case Interface.Api.ActionType.Delete:
|
||||
execStr = "删除";
|
||||
break;
|
||||
case Interface.Api.ActionType.Obsolete:
|
||||
break;
|
||||
case Interface.Api.ActionType.EscObsolete:
|
||||
break;
|
||||
case Interface.Api.ActionType.Submit:
|
||||
execStr = "提交审核";
|
||||
break;
|
||||
case Interface.Api.ActionType.EscSubmit:
|
||||
break;
|
||||
case Interface.Api.ActionType.Audit:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditBack:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditClose:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditPress:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditPause:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditForward:
|
||||
break;
|
||||
case Interface.Api.ActionType.AuditHand:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return execStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
/******************************
|
||||
* 说明:数据库连接参数配置类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-07-24
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Win32;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using Lskj.Util;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库连接参数配置类
|
||||
/// </summary>
|
||||
public sealed class DBConfig
|
||||
{
|
||||
private static string _regKey = "AA_LS_Erp V2.0";
|
||||
private static DBConfig _instance = null;
|
||||
/// <summary>
|
||||
/// DBConfig静态单例对象
|
||||
/// </summary>
|
||||
/// <value>The instance.</value>
|
||||
public static DBConfig Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DBConfig();
|
||||
_instance.ReadConfig();
|
||||
_instance.WriteConfig(false);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
public static DBConfig MesInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DBConfig();
|
||||
_instance.ReadConfig(false, true);
|
||||
_instance.WriteConfig(false);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据库名
|
||||
/// </summary>
|
||||
public string DataBase;
|
||||
/// <summary>
|
||||
/// 帐套
|
||||
/// </summary>
|
||||
public string DataBook;
|
||||
/// <summary>
|
||||
/// 服务器名(登录服务器)
|
||||
/// </summary>
|
||||
public string ServerName;
|
||||
/// <summary>
|
||||
/// 登录名
|
||||
/// </summary>
|
||||
public string LoginName;
|
||||
/// <summary>
|
||||
/// 通知员工ID
|
||||
/// </summary>
|
||||
public string NoticeUserID;
|
||||
/// <summary>
|
||||
/// 通知员工姓名
|
||||
/// </summary>
|
||||
public string NoticeUserName;
|
||||
/// <summary>
|
||||
/// 系统筛选id
|
||||
/// </summary>
|
||||
public string ProGramme;
|
||||
/// <summary>
|
||||
/// 文件升级标志
|
||||
/// </summary>
|
||||
public bool UpdateSet;
|
||||
///<summary>
|
||||
///智能客户端启动
|
||||
///</summary>
|
||||
public bool SmallClient;
|
||||
///<summary>
|
||||
///智能客户端启动
|
||||
///</summary>
|
||||
public bool NoticeClient;
|
||||
/// <summary>
|
||||
/// The notice show window
|
||||
/// </summary>
|
||||
public bool NoticeShowWindow;
|
||||
/// <summary>
|
||||
/// The notice flicker
|
||||
/// </summary>
|
||||
public bool NoticeFlicker;
|
||||
/// <summary>
|
||||
/// The notice exit
|
||||
/// </summary>
|
||||
public bool NoticeExit;
|
||||
/// <summary>
|
||||
/// 内外外网标志
|
||||
/// </summary>
|
||||
public bool Internet;
|
||||
/// <summary>
|
||||
/// 是否注册过高拍仪
|
||||
/// </summary>
|
||||
public bool IsCmpCapture;
|
||||
///<summary>
|
||||
///是否记住密码
|
||||
///</summary>
|
||||
public bool IsRemPwd;
|
||||
///<summary>
|
||||
///选中内网
|
||||
///</summary>
|
||||
public bool IsInternalNetwork;
|
||||
///<summary>
|
||||
///内网地址
|
||||
///</summary>
|
||||
public string InternalNetworkAddress;
|
||||
///<summary>
|
||||
///外网地址
|
||||
///</summary>
|
||||
public string ExternalNetworkAddress;
|
||||
/// <summary>
|
||||
/// 班次
|
||||
/// </summary>
|
||||
public string BCName;
|
||||
public bool IsConsumer;
|
||||
public string Connection;
|
||||
public string dephiConnection;
|
||||
public string Connection1 = "QkYyNjE3QTcxQjc4RDFFMDlERjlFMDc1QkIyMDVGRjdDRUIyMEVEOUM5NjBCQjc5NTA5NzdEQTk0MkNEQTE1RTFGMEIwMThFNUJDQTE0RjE1NjQwM0U5QTYxMThCMDY2MTA4NkE2OTIxNTNBQjQ0MjRDMDIwM0Q5OEVDQjkwQTVCN0RENjJBODkxNUNGOUM5OEI5RTEzN0E3ODBERjg2OURCNEQ5QTlCMzhCQUZGQ0FBNUREMjY4M0FCODg2RTkxMDRERTQ3MjRGQTE1MERDOTJGRDFDRjY2REQ1ODYyREUzN0RGM0ZBQzc4NzJENjIwNDg4RUUyNkI3ODE1RjlDM0I0MjNCQzcyOENDN0VDMTg0QUU0MjgwMDVDMENBOUZF";
|
||||
public string Connection2 = "Njk5NTI5NDE5RUI2ODM4MEQ5MEJFQkU3NzM3REQxQThDREM4NzRFNUY3QzYzMkVEOEEzODRBMzJBRjIwRUY4Njg4Qjg3M0Q1MTY3MjAxRkY2OTNGMzk3MUZBRjMxMzdDQ0U4RjMxQUVERjdBQzI5MEExNjQ3ODlDNkEwODVBMUJDMUJGN0U2RUJENkMwQzhERTFCNzgyMjg1MjBFQkE2MkU4NjMyQjBEMDY0QjQ0MzVDQ0QxMjMzQTA3NjI3QjQyOTczQUJBMUI0OUNGMkE5REYzOTI2NDFBRTY3QzFGQTJCRDFDNUIzQ0FCMzA4QzEwMjc2MTI5QjU2MzgxMjBDN0MwNUFGNUU3QTdBRTI2REQzREEyM0FFM0I2MUVGMzYw";
|
||||
public string Connection3 = "NjQ0OTQzRTY1MkUwQUUxQTdCQTlBRjkwRjI4QkU1MTRDNTc5RDI0RTg5Q0Q5RjU2QjQ3RjY4REY2NEY1QjM5QUNCREIzMTBDRUMxREQ5NzlBREUxMjQ5NzdCM0Y0RUM1Qjc2MEI3MzFFNTcxQ0Q5MzA5RTI5RUFGNDQxOTMyRkQ1RTdDNjcyRTFCQjUyM0Y4RkE2NEE2N0QyNzEyQzVCRTcyOUJBRTYxMjMzRjYwMjg5NzIyRjJGOTdDMzE0NTQ0MjIwQzFBNEI4MDI0OUNFNTJDMzlEOEMwNjY1MjA3M0YyQkQ0NDRDOTg5REMxMUVCMDM1MUU0OTEzQzQwRDBDQ0E3Rjk4QjgyNzRFRjYzQzBEMDcxQzVFMjdCMTIxNkE2MzI0MEIyNDkwOERGNUFDMjRGMEYxRkFFNzJEQTIwM0EyRjU0N0U4OEFENDBEMjEzNUY1OTI5NUUxRDM1N0I0Rg==";
|
||||
public string Connection4 = "NjU3MDQ0Q0JDREI0Mjc2OUY4RTBCOEIxMjBDOEM4MEQ2QUMwMjNEOUVDOTQ4NEMwRDE2RDdEMTQwNEQwODg3MURBMzRENkIxNEFENEYwQTcyMkEwMTE0NDhDM0NGNUZBQ0U4RjMxQUVERjdBQzI5MEExNjQ3ODlDNkEwODVBMUI3NDlCRkU1RDBGQUI0RUJFODlFNkE5MzlFNkIzODAyODEyRjFGQzE4NjVCMEM2OThDRDgzRUY4M0ZGNEExRkEyRUFGQzE4NTg1QkZBMEMwRTI5NzAzQzkzMzY2RUU0Mzc5RkI4NkVDRTM3NDNBMTk0ODJBQTNDNUY2RDlGMzU3MUEyOUEzOEI5RjA3NzA2NjM1NUNFM0U5RjNCNzMzM0RBMUY2MDkxQUZDQ0YxN0Q5MDgwOEY0NzZEMUM3MjQyMkRBOUY2N0NFRUE3MTkwNzk0OTA2NUYyRDJBMEM4RUU4OQ==";
|
||||
public string Connection5 = "QkYyNjE3QTcxQjc4RDFFMDlERjlFMDc1QkIyMDVGRjdDRUIyMEVEOUM5NjBCQjc5NTA5NzdEQTk0MkNEQTE1RTFGMEIwMThFNUJDQTE0RjE1NjQwM0U5QTYxMThCMDY2RjA1ODM0OUM0MDQ3RkQ3MkQ0NkEzQUIyRURFRUVGNzVEQjA0OTZDNUEwNUYxMkZBMTNENTdGODFFRjk5RTI0MTA2MjVGRUJDNTFFQTg3NUE1Q0I1MjAxOTI2QjNBNTM1QUQ1OTE4NUFEODU3MjYxNUNFNzk5MEU4RDgxRUM1NDlDRjM3RTZDOTQzRjExQzkwRTUyQzg1RDA0QzMzMzdCNjZBNjNEN0EyNjdBOTE3NEQ0RUE0NjMzMjhBOTYwQTVGOERDN0M3NzgxODA2RDM3MDU1QjBCREQzN0M1Njk4NEQ=";
|
||||
public string Connection6 = "Njk5NTI5NDE5RUI2ODM4MEQ5MEJFQkU3NzM3REQxQThDREM4NzRFNUY3QzYzMkVEOEEzODRBMzJBRjIwRUY4Njg4Qjg3M0Q1MTY3MjAxRkY2OTNGMzk3MUZBRjMxMzdDQ0U4RjMxQUVERjdBQzI5MEExNjQ3ODlDNkEwODVBMUI3NDlCRkU1RDBGQUI0RUJFODlFNkE5MzlFNkIzODAyODEyRjFGQzE4NjVCMEM2OThDRDgzRUY4M0ZGNEExRkEyRUFGQzE4NTg1QkZBMEMwRTI5NzAzQzkzMzY2RUU0Mzc5RkI4NkVDRTM3NDNBMTk0ODJBQTNDNUY2RDlGMzU3MTcwNkFDOUM4Qjg5RUE3RkJDRTgzQjQ4RUJBMzI5RjFE";
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:读取注册表配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void ReadConfig(bool isRefConfigFlag = false, bool isMesLogin = false)//isRefConfigFlag是否更改DB
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
|
||||
try
|
||||
{
|
||||
RegistryKey erpKey = regKey.CreateSubKey("AA_LS_Erp V2.0");
|
||||
erpKey.CreateSubKey("File");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
|
||||
DataBase = subKey.GetValue("datastr", "") + "";
|
||||
ServerName = subKey.GetValue("ServerName", "") + "";
|
||||
InternalNetworkAddress = subKey.GetValue("InternalNetworkAddress", "") + "";
|
||||
ExternalNetworkAddress= subKey.GetValue("ExternalNetworkAddress", "") + "";
|
||||
|
||||
IsInternalNetwork = (subKey.GetValue("IsInternalNetwork", "") + "").Equals("1");
|
||||
LoginName = subKey.GetValue("LoginName", "") + "";
|
||||
UpdateSet = subKey.GetValue("UpdateSet", "0") + "" == "1" || subKey.GetValue("UpdateSet", "0") + "" == "True" ? true : false;
|
||||
SmallClient = subKey.GetValue("SmallClient", "0") + "" == "1" || subKey.GetValue("SmallClient", "0") + "" == "True" ? true : false;
|
||||
NoticeClient = subKey.GetValue("NoticeClient", "0") + "" == "1" || subKey.GetValue("NoticeClient", "0") + "" == "True" ? true : false;
|
||||
Internet = subKey.GetValue("Internet", "1") + "" == "0" ? true : false;
|
||||
IsConsumer = subKey.GetValue("IsConsumer", "1") + "" == "1" ? true : false;
|
||||
ProGramme = subKey.GetValue("ProGramme", "") + "";
|
||||
NoticeUserName = subKey.GetValue("NoticeUserName", "") + "";
|
||||
NoticeUserID = subKey.GetValue("NoticeUserID", "") + "";
|
||||
NoticeShowWindow = subKey.GetValue("NoticeShowWindow", "0") + "" == "1" || subKey.GetValue("NoticeShowWindow", "0") + "" == "True" ? true : false;
|
||||
NoticeFlicker = subKey.GetValue("NoticeFlicker", "0") + "" == "0" || subKey.GetValue("NoticeFlicker", "0") + "" == "False" ? false : true;
|
||||
NoticeExit = subKey.GetValue("NoticeExit", "0") + "" == "1" || subKey.GetValue("NoticeExit", "0") + "" == "True" ? true : false;
|
||||
IsRemPwd = subKey.GetValue("IsRemPwd", "0") + "" == "1" || subKey.GetValue("IsRemPwd", "0") + "" == "True" ? true : false;
|
||||
if (subKey.GetValue("IsCmpCapture") == null)
|
||||
{
|
||||
subKey.SetValue("IsCmpCapture", 0);
|
||||
}
|
||||
IsCmpCapture = subKey.GetValue("IsCmpCapture", "0") + "" == "1" || subKey.GetValue("IsCmpCapture", "0") + "" == "True" ? true : false;
|
||||
try
|
||||
{
|
||||
DataBook = subKey.GetValue("DataBook", "") + "";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemResources.ini");
|
||||
if (File.Exists(file))
|
||||
{
|
||||
string lastIPPort = string.Format("{0}:{1}", IniHelper.Read("SystemResources.ini", "LocalLastIP"), IniHelper.Read("SystemResources.ini", "LocalLastPort"));
|
||||
string downloadAESStrKey = string.Format("DownloadAESStr_{0}", lastIPPort);
|
||||
string[] downloadAESStrValue = IniHelper.Read("SystemResources.ini", downloadAESStrKey).Split('^');
|
||||
string downloadAESStr = downloadAESStrValue.Length == 2 ? downloadAESStrValue[1] : "";
|
||||
string configFlag = IniHelper.Read("SystemResources.ini", "FrmConfigFlag");
|
||||
if (configFlag.Equals("1") && !isRefConfigFlag && !isMesLogin)
|
||||
{
|
||||
//string args = AESUtil.Decrypt(File.ReadAllText(file));
|
||||
if (!string.IsNullOrEmpty(downloadAESStr))
|
||||
{
|
||||
string args = AESUtil.Decrypt(downloadAESStr);
|
||||
string[] controlAfgs = args.Split('^');
|
||||
if (controlAfgs != null && controlAfgs.Length == 5)
|
||||
{
|
||||
ServerName = controlAfgs[0];
|
||||
DataBase = controlAfgs[1];
|
||||
string str = "Server={0};Database={1};Persist Security Info=True;User ID=" + controlAfgs[2] + ";Password=" + controlAfgs[3] + ";Connection Timeout=5;MultipleActiveResultSets=true";
|
||||
string dephistr = "Provider=SQLOLEDB.1;Server={0};Database={1};Persist Security Info=True;User ID=" + controlAfgs[2] + ";Password=" + controlAfgs[3] + ";Connection Timeout=5";
|
||||
Connection = AESUtil.Encrypt(str);
|
||||
dephiConnection = AESUtil.Encrypt(dephistr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:激活高拍仪控件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-31 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void SetActiveOcx(string subkeyName)
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
subKey.SetValue(subkeyName, 1);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:写配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void WriteConfig(bool isWriteSaDFlag)
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
if (isWriteSaDFlag)
|
||||
{
|
||||
subKey.SetValue("datastr", DataBase);
|
||||
subKey.SetValue("ServerName", ServerName);
|
||||
subKey.SetValue("InternalNetworkAddress", InternalNetworkAddress);
|
||||
subKey.SetValue("ExternalNetworkAddress", ExternalNetworkAddress);
|
||||
subKey.SetValue("IsInternalNetwork", IsInternalNetwork ? "1" : "0");
|
||||
}
|
||||
subKey.SetValue("LoginName", LoginName);
|
||||
subKey.SetValue("UpdateSet", UpdateSet);
|
||||
subKey.SetValue("SmallClient", SmallClient);
|
||||
subKey.SetValue("NoticeClient", NoticeClient);
|
||||
subKey.SetValue("DataBook", DataBook);
|
||||
subKey.SetValue("NoticeUserID", NoticeUserID);
|
||||
subKey.SetValue("ProGramme", ProGramme);
|
||||
subKey.SetValue("NoticeUserName", NoticeUserName);
|
||||
subKey.SetValue("NoticeShowWindow", NoticeShowWindow);
|
||||
subKey.SetValue("NoticeFlicker", NoticeFlicker);
|
||||
subKey.SetValue("NoticeExit", NoticeExit);
|
||||
subKey.SetValue("IsRemPwd", IsRemPwd);
|
||||
subKey.Close();
|
||||
}
|
||||
|
||||
|
||||
public void WriteConfig()
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
subKey.SetValue("datastr", DataBase);
|
||||
subKey.SetValue("ServerName", ServerName);
|
||||
subKey.SetValue("InternalNetworkAddress", InternalNetworkAddress);
|
||||
subKey.SetValue("ExternalNetworkAddress", ExternalNetworkAddress);
|
||||
subKey.SetValue("IsInternalNetwork", IsInternalNetwork ? "1" : "0");
|
||||
subKey.SetValue("LoginName", LoginName);
|
||||
subKey.SetValue("UpdateSet", UpdateSet);
|
||||
subKey.SetValue("SmallClient", SmallClient);
|
||||
subKey.SetValue("NoticeClient", NoticeClient);
|
||||
subKey.SetValue("DataBook", DataBook);
|
||||
subKey.SetValue("NoticeUserID", NoticeUserID);
|
||||
subKey.SetValue("ProGramme", ProGramme);
|
||||
subKey.SetValue("NoticeUserName", NoticeUserName);
|
||||
subKey.SetValue("NoticeShowWindow", NoticeShowWindow);
|
||||
subKey.SetValue("NoticeFlicker", NoticeFlicker);
|
||||
subKey.SetValue("NoticeExit", NoticeExit);
|
||||
subKey.SetValue("IsRemPwd", IsRemPwd);
|
||||
subKey.Close();
|
||||
}
|
||||
public void WriteConfig(string Key, string Value)
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
subKey.SetValue(Key, Value);
|
||||
subKey.Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取C#连接字符串</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetConnection(string Connection = "")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Connection))
|
||||
{
|
||||
return string.Format(AESUtil.Decrypt(Connection), ServerName, DataBase);
|
||||
}
|
||||
return IsConsumer ? string.Format(AESUtil.Decrypt(Connection1), ServerName, DataBase) : string.Format(AESUtil.Decrypt(Connection5), ServerName, DataBase);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取delphi连接字符串</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetDelphiConnection(string Connection = "")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Connection))
|
||||
{
|
||||
return string.Format(AESUtil.Decrypt(Connection), ServerName, DataBase);
|
||||
}
|
||||
return IsConsumer ? string.Format(AESUtil.Decrypt(Connection2), ServerName, DataBase) : string.Format(AESUtil.Decrypt(Connection6), ServerName, DataBase);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-03-28 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetLsCrmConnection()
|
||||
{
|
||||
return Internet ? AESUtil.Decrypt(Connection3) : AESUtil.Decrypt(Connection4);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:创建数据库连接</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool CreateConnection(string Connection = "")
|
||||
{
|
||||
|
||||
string connStr = GetConnection(Connection);
|
||||
if (SqlHelper._connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlHelper._connection.Close();
|
||||
SqlHelper._connection.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
SqlHelper._connection = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
SqlHelper._connection = new SqlConnection(connStr);
|
||||
SqlHelper._connection.Open();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteLog(ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2A1BE6AC-1077-491B-A754-C5822FE8121E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Lskj.Core</RootNamespace>
|
||||
<AssemblyName>Lskj.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\Debug\AllMethodXml\Lskj.Core.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Lskj.Data.ADO, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Lskj.Data.ADO.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.Data.Api, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Lskj.Data.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.Web.Core, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Lskj.Web.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.WebErp.Core, Version=1.0.0.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Lskj.WebErp.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\引用DLL\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApiHelper.cs" />
|
||||
<Compile Include="SmartX1Api.cs" />
|
||||
<Compile Include="SqlHelper.cs" />
|
||||
<Compile Include="DBConfig.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lskj.Interface.Api\Lskj.Interface.Api.csproj">
|
||||
<Project>{24e9a18a-baf8-4052-809e-582b4fc6a8c4}</Project>
|
||||
<Name>Lskj.Interface.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj">
|
||||
<Project>{A51BF642-6543-4DE3-8948-83F558B72BD4}</Project>
|
||||
<Name>Lskj.Util</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Lskj.PubDBUtil")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Lskj.PubDBUtil")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("38d8b9e4-c79a-428c-83bd-27077f41d727")]
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 内部版本号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1 @@
|
||||
Lskj.Core类库:只存放数据库相关公共类
|
||||
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
public class SmartX1Api
|
||||
{
|
||||
|
||||
|
||||
// Find
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber);
|
||||
|
||||
//open
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4);
|
||||
//close
|
||||
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Close(int keyHandle);
|
||||
|
||||
//checkExist
|
||||
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1CheckExist(int keyHandle);
|
||||
|
||||
//getUid
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid);
|
||||
|
||||
//ReadStorage
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//WriteStorage
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//PageLogin
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length);
|
||||
|
||||
//PageLogout
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageLogout(int keyHandle, int pageNo);
|
||||
|
||||
//ReadPage
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer);
|
||||
|
||||
//WritePage
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//ReadMem
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer);
|
||||
|
||||
//WriteMem
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer);
|
||||
|
||||
//encrypt
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer);
|
||||
|
||||
//desDecrypt
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer);
|
||||
|
||||
//led
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Led(int keyHandle, int state);
|
||||
|
||||
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue);
|
||||
|
||||
[DllImport("SmartX1App.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1GetSoftVersion(int keyHandle, int[] version);
|
||||
|
||||
public static string TridesEncrypt(string data, string key, Encoding encoding)
|
||||
{
|
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
|
||||
des.Key = Encoding.Default.GetBytes(key);
|
||||
des.Mode = CipherMode.ECB;
|
||||
|
||||
des.Padding = PaddingMode.PKCS7;
|
||||
|
||||
ICryptoTransform DesEncrypt = des.CreateEncryptor();
|
||||
byte[] dataBytes = encoding.GetBytes(data);
|
||||
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length);
|
||||
return Convert.ToBase64String(outPut);
|
||||
|
||||
}
|
||||
|
||||
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding)
|
||||
{
|
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
|
||||
des.Key = Encoding.Default.GetBytes(key);
|
||||
des.Padding = PaddingMode.PKCS7;
|
||||
des.Mode = CipherMode.ECB;
|
||||
ICryptoTransform DesDecEncrypt = des.CreateDecryptor();
|
||||
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length);
|
||||
return encoding.GetString(outValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SmartX1_X64
|
||||
{
|
||||
// Find
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber);
|
||||
|
||||
//open
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4);
|
||||
//close
|
||||
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Close(int keyHandle);
|
||||
|
||||
//checkExist
|
||||
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1CheckExist(int keyHandle);
|
||||
|
||||
//getUid
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid);
|
||||
|
||||
//ReadStorage
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//WriteStorage
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//PageLogin
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length);
|
||||
|
||||
//PageLogout
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageLogout(int keyHandle, int pageNo);
|
||||
|
||||
//ReadPage
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer);
|
||||
|
||||
//WritePage
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer);
|
||||
|
||||
//ReadMem
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer);
|
||||
|
||||
//WriteMem
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer);
|
||||
|
||||
//encrypt
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer);
|
||||
|
||||
//desDecrypt
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer);
|
||||
|
||||
//led
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1Led(int keyHandle, int state);
|
||||
|
||||
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue);
|
||||
|
||||
[DllImport("SmartX1AppX64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int SmartX1GetSoftVersion(int keyHandle, int[] version);
|
||||
|
||||
public static string TridesEncrypt(string data, string key, Encoding encoding)
|
||||
{
|
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
|
||||
des.Key = Encoding.Default.GetBytes(key);
|
||||
des.Mode = CipherMode.ECB;
|
||||
|
||||
des.Padding = PaddingMode.PKCS7;
|
||||
|
||||
ICryptoTransform DesEncrypt = des.CreateEncryptor();
|
||||
byte[] dataBytes = encoding.GetBytes(data);
|
||||
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length);
|
||||
return Convert.ToBase64String(outPut);
|
||||
|
||||
}
|
||||
|
||||
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding)
|
||||
{
|
||||
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
|
||||
des.Key = Encoding.Default.GetBytes(key);
|
||||
des.Padding = PaddingMode.PKCS7;
|
||||
des.Mode = CipherMode.ECB;
|
||||
ICryptoTransform DesDecEncrypt = des.CreateDecryptor();
|
||||
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length);
|
||||
return encoding.GetString(outValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,725 @@
|
||||
/******************************
|
||||
* 说明:数据库操作类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-07-24
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库操作类
|
||||
/// </summary>
|
||||
public static class SqlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据连接
|
||||
/// </summary>
|
||||
public static SqlConnection _connection;
|
||||
/// <summary>
|
||||
/// 请求超时时间
|
||||
/// </summary>
|
||||
public static int CommandTimeout;
|
||||
#region ExecuteAdapter
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取适配器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>SqlDataAdapter.</returns>
|
||||
public static SqlDataAdapter ExecuteAdapter(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlDataAdapter adapter;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
adapter = new SqlDataAdapter(cmd);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取适配器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>SqlDataAdapter.</returns>
|
||||
public static SqlDataAdapter ExecuteAdapter(CommandType cmdType, string cmdText)
|
||||
{
|
||||
SqlDataAdapter adapter;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
adapter = new SqlDataAdapter(cmd);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataTable
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回DataTable</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>DataTable.</returns>
|
||||
public static DataTable ExecuteDataTable(string cmdText)
|
||||
{
|
||||
return ExecuteDataSet(cmdText).Tables[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回DataTable</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>DataTable.</returns>
|
||||
public static DataTable ExecuteDataTable(string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
return ExecuteDataSet(CommandType.Text, cmdText, "temp", commandParameters).Tables[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-15 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteObject(string fieldName, string cmdText)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
result = ExecuteDataSet(cmdText).Tables[0].Rows[0][fieldName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-27 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteObject(string fieldName, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
result = ExecuteDataSet(CommandType.Text, cmdText, "temp", commandParameters).Tables[0].Rows[0][fieldName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-15 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static string ExecuteString(string fieldName, string cmdText)
|
||||
{
|
||||
object obj = ExecuteObject(fieldName, cmdText);
|
||||
return obj == null ? "" : obj.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-27 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string ExecuteString(string fieldName, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
object obj = ExecuteObject(fieldName, cmdText, commandParameters);
|
||||
return obj == null ? "" : obj.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataSet
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="tabName">Name of the tab.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(int cmdType, string cmdText, string tabName, params SqlParameter[] commandParameters)
|
||||
{
|
||||
CommandType _cmdType = CommandType.Text;
|
||||
switch (cmdType)
|
||||
{
|
||||
case 4:
|
||||
_cmdType = CommandType.StoredProcedure;
|
||||
break;
|
||||
case 512:
|
||||
_cmdType = CommandType.TableDirect;
|
||||
break;
|
||||
}
|
||||
return ExecuteDataSet(_cmdType, cmdText, tabName, commandParameters);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">语句类型存储过程或者sql语句</param>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <param name="commandParameters">参数</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(CommandType cmdType, string cmdText, string tabName, params SqlParameter[] commandParameters)
|
||||
{
|
||||
DataSet set2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);//sql参数处理
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);//创建对象,与sql命令对象绑定
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, tabName);//填充数据。第二个参数是数据集中内存表的名字,可以与数据库中的不同
|
||||
//adapter.FillSchema(dataSet, SchemaType.Mapped, tabName);
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.StartsWith("在从服务器接收结果时发生传输级错误") ||
|
||||
e.Message.StartsWith("在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误") ||
|
||||
e.Message.StartsWith("在向服务器发送请求时发生传输级错误"))
|
||||
{
|
||||
throw new Exception("无法连接服务器,请检查网络连接.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(e.Message + " SQL=[ " + cmdText + " ]", e);
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
return set2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">语句类型存储过程或者sql语句</param>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(CommandType cmdType, string cmdText, string tabName)
|
||||
{
|
||||
return ExecuteDataSet(cmdType, cmdText, tabName, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(string cmdText)
|
||||
{
|
||||
return ExecuteDataSet(CommandType.Text, cmdText, "temp");
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="procedureName">Name of the procedure.</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <param name="parameterNames">The parameter names.</param>
|
||||
/// <param name="parameterValues">The parameter values.</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(string procedureName, string tabName, string[] parameterNames, object[] parameterValues)
|
||||
{
|
||||
DataSet set2;
|
||||
try
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand(procedureName, _connection);
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
if (parameterNames != null && parameterValues != null)
|
||||
{
|
||||
for (int i = 0; i < parameterNames.Length && i < parameterValues.Length; i++)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(parameterNames[i], parameterValues[i]);
|
||||
}
|
||||
}
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, tabName);
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return set2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteNonQuery
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.StartsWith("在从服务器接收结果时发生传输级错误") ||
|
||||
e.Message.StartsWith("在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误") ||
|
||||
e.Message.StartsWith("在向服务器发送请求时发生传输级错误"))
|
||||
{
|
||||
throw new Exception("无法连接服务器,请检查网络连接.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(e.Message + " SQL=[ " + cmdText + " ]", e);
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程,带事务</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(CommandType cmdType, string cmdText, SqlTransaction Trans,int a ,params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
|
||||
PrepareCommand(cmd, _connection, Trans, cmdType, cmdText, commandParameters);
|
||||
num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.StartsWith("在从服务器接收结果时发生传输级错误") ||
|
||||
e.Message.StartsWith("在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误") ||
|
||||
e.Message.StartsWith("在向服务器发送请求时发生传输级错误"))
|
||||
{
|
||||
throw new Exception("无法连接服务器,请检查网络连接.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(e.Message + " SQL=[ " + cmdText + " ]", e);
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(CommandType cmdType, string cmdText)
|
||||
{
|
||||
return ExecuteNonQuery(CommandType.Text, cmdText, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(string cmdText)
|
||||
{
|
||||
return ExecuteNonQuery(CommandType.Text, cmdText);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteReader
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集(只读、只进)</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>SqlDataReader.</returns>
|
||||
public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlDataReader reader2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
SqlDataReader reader = cmd.ExecuteReader();
|
||||
cmd.Parameters.Clear();
|
||||
reader2 = reader;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return reader2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteCommand
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回SqlCommand(只读、只进)</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>SqlDataReader.</returns>
|
||||
public static SqlCommand ExecuteCommand(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteScalar
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="Connectionection">The connectionection.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(SqlConnection Connectionection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, Connectionection, null, cmdType, cmdText, commandParameters);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.StartsWith("在从服务器接收结果时发生传输级错误") ||
|
||||
e.Message.StartsWith("在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误") ||
|
||||
e.Message.StartsWith("在向服务器发送请求时发生传输级错误"))
|
||||
{
|
||||
throw new Exception("无法连接服务器,请检查网络连接.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(e.Message + " SQL=[ " + cmdText + " ]", e);
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(CommandType cmdType, string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, CommandType.Text, cmdText, null);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列,带事务</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(string cmdText,SqlTransaction Trans,int a,int b)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, Trans, CommandType.Text, cmdText, null);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrepareCommand
|
||||
/// <summary>
|
||||
/// <para>说明: sql参数处理</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmd">The command.</param>
|
||||
/// <param name="Connection">The connection.</param>
|
||||
/// <param name="trans">The trans.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="cmdParms">The command parms.</param>
|
||||
private static void PrepareCommand(SqlCommand cmd, SqlConnection Connection, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
|
||||
{
|
||||
if (Connection.State != ConnectionState.Open)
|
||||
{
|
||||
Connection.Open();
|
||||
}
|
||||
cmd.Connection = Connection;
|
||||
cmd.CommandTimeout = CommandTimeout;
|
||||
cmd.CommandText = cmdText;
|
||||
if (trans != null)
|
||||
{
|
||||
cmd.Transaction = trans;
|
||||
}
|
||||
cmd.CommandType = cmdType;
|
||||
if (cmdParms != null)
|
||||
{
|
||||
foreach (SqlParameter parameter in cmdParms)
|
||||
{
|
||||
cmd.Parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NPOI" publicKeyToken="0df73ec7942b34e1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.3.1" newVersion="2.1.3.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user