You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.1 KiB
108 lines
3.1 KiB
3 months ago
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.Log
|
||
|
{
|
||
|
public class LogErrDAL
|
||
|
{
|
||
|
public static string TableName = "LogErr";
|
||
|
public string GetTableName()
|
||
|
{
|
||
|
return TableName;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 查询全部错误信息
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public DataTable Search_Info()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"select * from " + TableName + " order by ErrTime desc";
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public DataTable Search_InfoByTime(DateTime stime, DateTime etime)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"select * from " + TableName + @"
|
||
|
where ErrTime>=@stime and ErrTime<=@etime order by ErrTime desc";
|
||
|
|
||
|
SqlParameter[] param = new SqlParameter[2];
|
||
|
param[0] = new SqlParameter("@stime", SqlDbType.DateTime);
|
||
|
param[0].Value = stime;
|
||
|
|
||
|
param[1] = new SqlParameter("@etime", SqlDbType.DateTime);
|
||
|
param[1].Value = etime;
|
||
|
|
||
|
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 添加错误信息
|
||
|
/// </summary>
|
||
|
/// <param name="mod"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool Add_Info(LogErrModel mod)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
#region 添加数据
|
||
|
string sql = "";
|
||
|
SqlParameter[] param = null;
|
||
|
sql = "INSERT INTO " + TableName + " (ID,ErrContent,ErrSource";
|
||
|
sql += ") VALUES (";
|
||
|
sql += "@ID,";
|
||
|
sql += "@ErrContent,";
|
||
|
sql += "@ErrSource)";
|
||
|
|
||
|
#region 添加参数
|
||
|
param = new SqlParameter[3];
|
||
|
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
|
||
|
param[0].Value = mod.ID;
|
||
|
|
||
|
param[1] = new SqlParameter("@ErrContent", SqlDbType.VarChar);
|
||
|
param[1].Value = mod.ErrContent;
|
||
|
|
||
|
param[2] = new SqlParameter("@ErrSource", SqlDbType.VarChar);
|
||
|
param[2].Value = mod.ErrSource;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
|
||
|
#endregion
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|