You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Controls.Default;
using Mesnac.Controls.Base;
using Mesnac.Codd.Session;
using System.Data;
using Mesnac.Action.Base;
namespace Mesnac.Action.Feeding.Report
{
#region 操作日志初始化
public class OperateReportInit : FeedingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
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)
{
startdate.MCValue = DateTime.Now;
starttime.MCValue = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00";
}
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)
{
enddate.MCValue = DateTime.Now.AddDays(1).ToShortDateString(); ;
endtime.MCValue = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00";
}
}
}
#endregion
#region 操作日志查询
public class OperateReportSelect : FeedingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
DbMCControl mcButton = this.GetDbMCControlByBaseControlKey("mcbuttonSearch").FirstOrDefault();
if (mcButton == null)
{
base.LogError("{操作日志报表} 缺少key值为mcbuttonSearch查询按钮...");
return;
}
StringBuilder sqlsb = new StringBuilder();
sqlsb.Append(@"select * from dbo.SysLog left join dbo.BasUser on SysLog.userid=BasUser.ObjID
left join dbo.BasRole on BasUser.RoleID=BasRole.ObjID where 1=1 ");
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)
{
sqlsb.AppendLine(@"AND SysLog.recordtime>='" + Convert.ToDateTime(startdate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(starttime.MCValue).ToShortTimeString() + "' ");
}
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)
{
sqlsb.AppendLine(@"AND SysLog.recordtime<='" + Convert.ToDateTime(enddate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(endtime.MCValue).ToShortTimeString() + "' ");
}
DbHelper dbHelper = NewDbHelper(mcButton.DesignSource);
if (dbHelper == null)
{
return;
}
dbHelper.ClearParameter();
dbHelper.CommandType = CommandType.Text;
string sqlstr = sqlsb.ToString();
dbHelper.CommandText = sqlstr;
DataTable table = dbHelper.ToDataTable();
DbMCControl opetatereportgrid = this.GetDbMCControlByBaseControlKey("mcdatagridviewList").FirstOrDefault();
if (opetatereportgrid == null)
{
base.LogError("{操作日志报表} 缺少key值为mcdatagridviewList的报表控件...");
return;
}
opetatereportgrid.BaseControl.BindDataSource = table;
}
}
#endregion
}