using Estsh.Client.Common.HttpClientUtil;
using System.Collections;
namespace Estsh.Client.Base
{
///
/// 工步基类
///
public class StepBase : UserControl
{
private Hashtable _context;
private Form _parentForm;
public int action { get; set; }
//PASS上一次成功扫描时间
public static DateTime _lastPassDatetime;
///
/// 参数上下文
/// 存放平台传递过来的参数
/// 本工步需要输出的参数也放到这个里面
///
public Hashtable Context
{
get
{
return this._context;
}
set
{
this._context = value;
}
}
///
/// HttpClient请求帮助类
///
public HttpClientHelper httpClient { get; private set; }
///
/// 初始化上下文
///
///
///
public void InitContext(Hashtable context, HttpClientHelper httpClient, Form parentForm)
{
this.Context = context;
this.httpClient = httpClient;
this._parentForm = parentForm;
}
///
/// ActionEventHandler
///
public delegate void ActionEventHandler(object sender, EventArgs e);
///
/// ComplateEventHandler
///
public delegate void ComplateEventHandler(object sender, EventArgs e);
///
/// ErrorEventHandler
///
public delegate void ErrorEventHandler(object sender, EventArgs e);
///
/// ShowMessageEventHandler
///
public delegate void ShowMessageEventHandler(object sender, string msg);
///
/// 工步开始操作事件
///
public event ActionEventHandler OnAction;
///
/// 工步完成事件
///
public event ComplateEventHandler OnComplated;
///
/// 工步执行错误事件
///
public event ErrorEventHandler OnFailed;
///
/// 显示消息事件
///
public event ShowMessageEventHandler OnShowMessage;
///
/// 工步开始操作事件的处理
///
///
///
protected void Action(object sender, EventArgs e)
{
if (OnAction != null)
{
OnAction(sender, e);
}
}
///
/// 工步完成事件的处理
///
///
///
protected void Complate(object sender, EventArgs e)
{
if (OnComplated != null)
{
OnComplated(sender, e);
}
}
///
/// 工步错误事件的处理
///
///
///
protected void Error(object sender, EventArgs e)
{
if (OnFailed != null)
{
OnFailed(sender, e);
}
}
///
/// 显示消息的事件处理
///
///
///
protected void ShowMessage(object sender, string msg)
{
if (OnShowMessage != null)
{
OnShowMessage(sender, msg);
}
}
///
/// 执行工步
///
/// 执行结果
public virtual bool Do()
{
return true;
}
///
/// 执行释放工步时间控件资源
///
/// 执行结果
public virtual bool TickDispose()
{
return true;
}
#region 工步跳出
///
/// 工步跳出
///
public delegate void StopStepEventHandler(int type);
///
/// 工步跳出
///
public event StopStepEventHandler OnStopStep;
///
/// 工步跳出
///
/// 1:返工跳出
protected void StopStep(int type)
{
if (OnStopStep != null)
{
OnStopStep(type);
}
}
#endregion
}
}