using DevExpress.XtraRichEdit.Import.Doc;
using Mesnac.Action.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.BinManage
{
public class RefreshBinAction : ChemicalWeighingAction, IAction
{
#region 事件定义
///
/// 刷新计划事件
///
public static event EventHandler OnRefreshPlan;
#endregion
#region 字段定义
private static bool IsFirstRun = true; //是否首次执行
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null; //网格计划控件
#endregion
#region IAction接口实现
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
ICSharpCode.Core.LoggingService.Debug("料仓管理—刷新料仓...");
#region 事件订阅
if (true)
{
IsFirstRun = false;
}
#endregion
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Bin").FirstOrDefault(); //获取本机台计划控件
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService.Error("{刷新料仓}缺少本机台计划网格控件...");
return;
}
this._clientGridControl = clientGridControl;
this.DoWork();
}
#endregion
#region 方法定义
///
/// 刷新计划
///
protected void DoWork()
{
#region 业务实现
string equipCode = base.CurrEquipCode; //当前机台
DataTable table = BinHelper.getBin();
lock (String.Empty)
{
if (this._clientGridControl != null && this._clientGridControl.BaseControl != null)
{
this._clientGridControl.BaseControl.BindDataSource = null;
this._clientGridControl.BaseControl.BindDataSource = table;
}
else
{
ICSharpCode.Core.LoggingService.Warn("刷新料仓信息失败:物料数据控件为Null...");
}
}
#endregion
#region 触发事件, 刷新客户端计划
if (OnRefreshPlan != null)
{
OnRefreshPlan(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
}
#endregion
#region 事件处理方法
private void Process_Event(object sender, EventArgs e)
{
if (sender is RuntimeParameter)
{
this.Run(sender as RuntimeParameter);
}
else
{
this.Run(this._runtime);
}
}
#endregion
}
}