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