|
|
|
|
using DevExpress.Data.Filtering.Helpers;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.PptPlan;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Product.XlPlan;
|
|
|
|
|
using Mesnac.Communication;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Show
|
|
|
|
|
{
|
|
|
|
|
public class XlInitAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 字段定义
|
|
|
|
|
bool flag = true;
|
|
|
|
|
public static bool IsFirstRun = true; //是否首次运行
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
//private DbMCControl _planDateControl = null; //计划日期
|
|
|
|
|
//private DbMCControl _pptShiftControl = null; //班次
|
|
|
|
|
private DbMCControl _clientGridControl = null; //本地计划控件
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
|
|
|
|
#region 首次执行,进行事件订阅
|
|
|
|
|
|
|
|
|
|
if (IsFirstRun)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Debug("小料展示界面-窗体初始化业务...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (IsFirstRun) {
|
|
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(10000);
|
|
|
|
|
timer.Elapsed += new ElapsedEventHandler(ServerStart);
|
|
|
|
|
timer.AutoReset = true;
|
|
|
|
|
timer.Enabled = true;
|
|
|
|
|
timer.Start();
|
|
|
|
|
|
|
|
|
|
IsFirstRun = false;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 初始化
|
|
|
|
|
|
|
|
|
|
#region 获取界面控件
|
|
|
|
|
|
|
|
|
|
string source = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//DbMCControl planDateControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[xl_plan].[Plan_Date]").FirstOrDefault();
|
|
|
|
|
//DbMCControl pptShiftControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Shiftime").FirstOrDefault();
|
|
|
|
|
//DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_plan").FirstOrDefault(); //获取本机台计划网格控件
|
|
|
|
|
|
|
|
|
|
//if (planDateControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InitFormAction>.Error("{当班计划-窗体加载} 缺少日期选择控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (pptShiftControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<InitFormAction>.Error("{当班计划-窗体加载} 缺少班次组合框控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (clientGridControl == null)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<XlInitAction>.Error("{小料展示界面-窗体加载} 缺少计划列表网格控件...");
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//this._runtime = runtime;
|
|
|
|
|
//this._clientGridControl = clientGridControl;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化操作
|
|
|
|
|
|
|
|
|
|
//DataGridView clientGrid = (clientGridControl.BaseControl as DataGridView);
|
|
|
|
|
|
|
|
|
|
//this.InitGridViewEvent(clientGrid);
|
|
|
|
|
//this.InitData();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
#region 网格事件处理方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化网格样式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dgv">DataGridView网格控件对象</param>
|
|
|
|
|
private void InitGridViewEvent(DataGridView dgv)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化界面控件数据
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面控件数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitData()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void ServerStart(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
flag = false;
|
|
|
|
|
|
|
|
|
|
var lblRecipeName = base.GetControlById("lblRecipeName") as System.Windows.Forms.Label;//配方名称
|
|
|
|
|
var lblStandardWeight = base.GetControlById("lblStandardWeight") as System.Windows.Forms.Label;//标重
|
|
|
|
|
|
|
|
|
|
List<Xl_DowLoadPlan> materialList = PlanHelper.GetExecPlan();//正在执行的任务
|
|
|
|
|
if (materialList == null) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in materialList)
|
|
|
|
|
{
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
lblRecipeName.Text = item.Recipe_Name;
|
|
|
|
|
lblRecipeName.Text = item.Recipe_Name;
|
|
|
|
|
lblStandardWeight.Text = item.Total_Weight.ToString();
|
|
|
|
|
//lblActualWeight.Text = item.Total_Weight.ToString();
|
|
|
|
|
//lblSetError.Text = item.Total_Error.ToString();
|
|
|
|
|
//lblTotalBatch.Text = item.Plan_Num.ToString();
|
|
|
|
|
//lblCurrentBatch.Text = (item.Real_Num + 1).ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_weigh").FirstOrDefault(); //获取本机台计划控件
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Error("{首页展示}缺少本机台计划网格控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
//本地计划
|
|
|
|
|
if (clientGridControl != null && clientGridControl.BaseControl != null)
|
|
|
|
|
{
|
|
|
|
|
var data = PlanHelper.GetExecPlanDataTable();
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = null;
|
|
|
|
|
//clientGridControl.BaseControl.BindDataSource = materialList;
|
|
|
|
|
clientGridControl.BaseControl.BindDataSource = data;
|
|
|
|
|
// clientGridControl.BaseControl.DataSource = new BindingSource(new BindingList<FileData>(buffer_list), null);
|
|
|
|
|
#region 根据计划状态处理背景色
|
|
|
|
|
|
|
|
|
|
DataGridView clientGrid = clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
SetBackColor(clientGrid);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Warn("接在首页展示物料失败:本地计划控件为Null...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}finally
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 设置(网格控件)计划状态背景色
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置计划状态背景色
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="grid"></param>
|
|
|
|
|
public static void SetBackColor(DataGridView grid)
|
|
|
|
|
{
|
|
|
|
|
lock (String.Empty)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (grid == null || grid.Visible == false)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Warn("设置背景色失败:网格控件为null或不可见");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid.ClearSelection(); //清空选中行
|
|
|
|
|
grid.ColumnHeadersHeight = 25;
|
|
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
|
|
grid.RowHeadersVisible = false;
|
|
|
|
|
grid.RowTemplate.Height = 28;
|
|
|
|
|
grid.RowsDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12, System.Drawing.FontStyle.Bold);
|
|
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
|
|
{
|
|
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(220, 220, 220); //灰色
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<XlInitAction>.Error("设置背景色失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|