|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Alarm.LRAlarmLog
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警记录查询业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SelectAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime);
|
|
|
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("报警记录-查询..");
|
|
|
|
|
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
|
|
|
|
|
StringBuilder sbSql = new StringBuilder("SELECT Alarm_PLC, Alarm_Cn_Info, Alarm_OccurTime,Alarm_ClearTime, Alarm_Other_Info FROM LR_Alarmlog, Pmt_Alarm WHERE Pmt_Alarm.Alarm_ID=LR_Alarmlog.Alarm_ID ");
|
|
|
|
|
|
|
|
|
|
List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
|
|
|
|
|
IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
|
|
|
|
|
IBaseControl starttime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "starttime").FirstOrDefault().BaseControl;
|
|
|
|
|
if (startdate != null && starttime != null)
|
|
|
|
|
{
|
|
|
|
|
sbSql.AppendLine(@"AND LR_Alarmlog.Alarm_OccurTime>='" + Convert.ToDateTime(startdate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(starttime.MCValue).ToShortTimeString() + "' ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{报警记录} 缺少key值为startdate或者starttime的时间查询条件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
IBaseControl enddate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "enddate").FirstOrDefault().BaseControl;
|
|
|
|
|
IBaseControl endtime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "endtime").FirstOrDefault().BaseControl;
|
|
|
|
|
if (enddate != null && endtime != null)
|
|
|
|
|
{
|
|
|
|
|
sbSql.AppendLine(@"AND LR_Alarmlog.Alarm_OccurTime<='" + Convert.ToDateTime(enddate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(endtime.MCValue).ToShortTimeString() + "' ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{报警记录} 缺少key值为enddate或者enddate的时间查询条件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sbSql.Append(" ORDER BY Alarm_OccurTime desc");
|
|
|
|
|
|
|
|
|
|
dbHelper.CommandText = sbSql.ToString();
|
|
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
//刷新DataGridView数据
|
|
|
|
|
DbMCControl dgLRAlarmlog = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "LR_Alarmlog").FirstOrDefault();
|
|
|
|
|
if (dgLRAlarmlog == null || !(dgLRAlarmlog.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Warn("{报警记录-查询} 缺少报警记录DataGridView控件...");
|
|
|
|
|
runtime.IsReturn = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dgLRAlarmlog.BaseControl.BindDataSource = table;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|