using System;
using BP.DA;
using BP.En;
namespace BP.WF.DTS
{
///
/// 同步待办时间戳 的摘要说明
///
public class DTS_GenerWorkFlowTimeSpan : Method
{
///
/// 同步待办时间戳
///
public DTS_GenerWorkFlowTimeSpan()
{
this.Title = "同步待办时间戳,状态,流程注册表的时间段(本周,上周,2周以前,3其他。).";
this.Help = "该方法每周一自动执行,如果不能自动执行就手动执行";
this.GroupName = "流程自动执行定时任务";
}
///
/// 设置执行变量
///
///
public override void Init()
{
//this.Warning = "您确定要执行吗?";
//HisAttrs.AddTBString("P1", null, "原密码", true, false, 0, 10, 10);
//HisAttrs.AddTBString("P2", null, "新密码", true, false, 0, 10, 10);
//HisAttrs.AddTBString("P3", null, "确认", true, false, 0, 10, 10);
}
///
/// 当前的操纵员是否可以执行这个方法
///
public override bool IsCanDo
{
get
{
return true;
}
}
///
/// 执行
///
/// 返回执行结果
public override object Do()
{
//只能在周1执行.
DateTime dtNow = DateTime.Now;
//设置为开始的日期为周1.
DateTime dtBegin = DateTime.Now;
dtBegin = dtBegin.AddDays(-7);
for (int i = 0; i < 8; i++)
{
if (dtBegin.DayOfWeek == DayOfWeek.Monday)
break;
dtBegin = dtBegin.AddDays(-1);
}
//结束日期为当前.
DateTime dtEnd = dtBegin.AddDays(7);
//默认都设置为本周
string sql = "UPDATE WF_GenerWorkFlow SET TSpan=" + (int)TSpan.ThisWeek;
DBAccess.RunSQL(sql);
//设置为上周.
sql = "UPDATE WF_GenerWorkFlow SET TSpan=" + (int)TSpan.NextWeek + " WHERE RDT >= '" + dtBegin.ToString(DataType.SysDataFormat) + " 00:00' AND RDT <= '" + dtEnd.ToString(DataType.SysDataFormat) + " 00:00'";
DBAccess.RunSQL(sql);
dtBegin = dtBegin.AddDays(-7);
dtEnd = dtEnd.AddDays(-7);
//把上周的,设置为两个周以前.
sql = "UPDATE WF_GenerWorkFlow SET TSpan=" + (int)TSpan.TowWeekAgo + " WHERE RDT >= '" + dtBegin.ToString(DataType.SysDataFormat) + " 00:00' AND RDT <= '" + dtEnd.ToString(DataType.SysDataFormat) + " 00:00' ";
DBAccess.RunSQL(sql);
//把上周的,设置为更早.
sql = "UPDATE WF_GenerWorkFlow SET TSpan=" + (int)TSpan.More + " WHERE RDT <= '" + dtBegin.ToString(DataType.SysDataFormat) + " 00:00' ";
DBAccess.RunSQL(sql);
return "执行成功...";
}
}
}