using System;
using System.Threading;
using System.Collections;
using System.Data;
using BP.DA;
using BP.En;
using BP.Web;
namespace BP.Sys.Base
{
///
/// 事件基类
///
abstract public class EventBase
{
#region 属性.
public Entity HisEn = null;
private Row _SysPara = null;
///
/// 参数
///
public Row SysPara
{
get
{
if (_SysPara == null)
_SysPara = new Row();
return _SysPara;
}
set
{
_SysPara = value;
}
}
///
/// 成功信息
///
public string SucessInfo = null;
private string _title = null;
///
/// 标题
///
public string Title
{
get
{
if (_title == null)
_title = "未命名";
return _title;
}
set
{
_title = value;
}
}
#endregion 属性.
#region 系统参数
///
/// 表单ID
///
public string FK_Mapdata
{
get
{
return this.GetValStr("FK_MapData");
}
}
///
/// 事件类型
///
public string EventSource
{
get
{
return this.GetValStr("EventSource");
}
}
#endregion
#region 常用属性.
///
/// 工作ID
///
public int OID
{
get
{
return this.GetValInt("OID");
}
}
///
/// 工作ID
///
public Int64 WorkID
{
get
{
if (this.OID == 0)
return this.GetValInt64("WorkID"); /*有可能开始节点的WorkID=0*/
return this.OID;
}
}
///
/// FID
///
public Int64 FID
{
get
{
return this.GetValInt64("FID");
}
}
///
/// 流程编号
///
public string FK_Flow
{
get
{
return this.GetValStr("FK_Flow");
}
}
///
/// 节点编号
///
public int FK_Node
{
get
{
try
{
return this.GetValInt("FK_Node");
}
catch {
return 0;
}
}
}
///
/// 传过来的WorkIDs集合,子流程.
///
public string WorkIDs
{
get
{
return this.GetValStr("WorkIDs");
}
}
///
/// 编号集合s
///
public string Nos
{
get
{
return this.GetValStr("Nos");
}
}
#endregion 常用属性.
#region 获取参数方法
public DateTime GetValDateTime(string key)
{
string str= this.SysPara.GetValByKey(key).ToString();
return DataType.ParseSysDateTime2DateTime(str);
}
///
/// 获取字符串参数
///
/// key
/// 如果为Nul,或者不存在就抛出异常
public string GetValStr(string key)
{
return this.SysPara.GetValByKey(key).ToString();
}
///
/// 获取Int64的数值
///
/// 键值
/// 如果为Nul,或者不存在就抛出异常
public Int64 GetValInt64(string key)
{
return Int64.Parse(this.GetValStr(key));
}
///
/// 获取int的数值
///
/// 键值
/// 如果为Nul,或者不存在就抛出异常
public int GetValInt(string key)
{
return int.Parse(this.GetValStr(key));
}
#endregion 获取参数方法
///
/// 事件基类
///
public EventBase()
{
}
///
/// 执行事件
/// 1,如果遇到错误就抛出异常信息,前台界面就会提示错误并不向下执行。
/// 2,执行成功,把执行的结果赋给SucessInfo变量,如果不需要提示就赋值为空或者为null。
/// 3,所有的参数都可以从 this.SysPara.GetValByKey中获取。
///
abstract public void Do();
///
/// 获得最后一个action的ID.
///
///
public string GetLastActionTrackID()
{
string sql = "SELECT MyPK FROM ND" + int.Parse(this.FK_Flow) + "Track WHERE WorkID=" + this.WorkID + " AND NDFrom=" + this.FK_Node + " ORDER BY RDT ";
DataTable dt=DBAccess.RunSQLReturnTable(sql);
if (dt.Rows.Count == 0)
return null;
return dt.Rows[0][0].ToString();
}
}
}