|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Technical;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Station
|
|
|
|
|
{
|
|
|
|
|
public class RefreshAction : ChemicalWeighingAction,IAction
|
|
|
|
|
{
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新计划事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnRefreshRecipe;
|
|
|
|
|
|
|
|
|
|
#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<RefreshAction>.Debug("工位管理—刷新工位业务...");
|
|
|
|
|
|
|
|
|
|
#region 事件订阅
|
|
|
|
|
|
|
|
|
|
if (true)
|
|
|
|
|
{
|
|
|
|
|
//通用调用刷新工位事件订阅
|
|
|
|
|
|
|
|
|
|
Mesnac.Basic.InvokeHelper.OnRefreshRecipe -= Process_Event;
|
|
|
|
|
Mesnac.Basic.InvokeHelper.OnRefreshRecipe += Process_Event;
|
|
|
|
|
|
|
|
|
|
//添加工位后,要刷新工位
|
|
|
|
|
InsertAction.OnInsertStation -= Process_Event;
|
|
|
|
|
InsertAction.OnInsertStation += Process_Event;
|
|
|
|
|
|
|
|
|
|
//删除工位后,要刷新本地工位
|
|
|
|
|
DeleteAction.OnDeleteStation -= Process_Event;
|
|
|
|
|
DeleteAction.OnDeleteStation += Process_Event;
|
|
|
|
|
|
|
|
|
|
//修改次数数后,要刷新本地工位
|
|
|
|
|
ModifyAction.OnModifyStation -= Process_Event;
|
|
|
|
|
ModifyAction.OnModifyStation += Process_Event;
|
|
|
|
|
|
|
|
|
|
IsFirstRun = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_station").FirstOrDefault(); //获取配方管理控件
|
|
|
|
|
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{工位管理—刷新工位}缺少本机台工位网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._clientGridControl = clientGridControl;
|
|
|
|
|
|
|
|
|
|
this.DoWork();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void DoWork()
|
|
|
|
|
{
|
|
|
|
|
#region 业务实现
|
|
|
|
|
|
|
|
|
|
string equipCode = base.CurrEquipCode; //当前机台
|
|
|
|
|
DataTable table = StationHelper.GetStationList();
|
|
|
|
|
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<RefreshAction>.Warn("刷新本地计划失败:本地计划控件为Null...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 触发事件, 刷新客户端计划
|
|
|
|
|
|
|
|
|
|
if (OnRefreshRecipe != null)
|
|
|
|
|
{
|
|
|
|
|
OnRefreshRecipe(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
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|