180 lines
6.5 KiB
C#
180 lines
6.5 KiB
C#
|
|
using CleanMachineHMI.Domain.Enums;
|
|||
|
|
using CleanMachineHMI.Domain.Models.ViewModels;
|
|||
|
|
using CleanMachineHMI.forms;
|
|||
|
|
using CleanMachineHMI.frmChild;
|
|||
|
|
using CleanMachineHMI.Utils;
|
|||
|
|
using ComponentFactory.Krypton.Toolkit;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace CleanMachineHMI
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 应用配置
|
|||
|
|
/// </summary>
|
|||
|
|
public static class GlobalHelper
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 主窗体_New
|
|||
|
|
/// </summary>
|
|||
|
|
public static frmMainNew MainFormNew{ get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 登陆窗体
|
|||
|
|
/// </summary>
|
|||
|
|
public static frmLogin LoginForm { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 基础信息窗体容器
|
|||
|
|
/// </summary>
|
|||
|
|
public static frmBase BaseForm { get; set; }
|
|||
|
|
|
|||
|
|
public static frmIoMonitorNew IoMonitor_2 { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 所有窗体模型
|
|||
|
|
/// </summary>
|
|||
|
|
public static List<FormModel<Type>> FrmModelList { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 语言编码
|
|||
|
|
/// </summary>
|
|||
|
|
public static string LanguageCode { get; set; } = AppConfigHelper.Get("LanguageCode");
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 用户信息
|
|||
|
|
/// </summary>
|
|||
|
|
public static UserInfo UserInfo { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 参数列表
|
|||
|
|
/// </summary>
|
|||
|
|
public static DataTable ParameterList { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 角色菜单权限数据
|
|||
|
|
/// </summary>
|
|||
|
|
public static DataTable RoleMenuPermission { get; set; }
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static List<BasPlcItemMd> PlcItemMdList { get; set; }
|
|||
|
|
public static List<BasPlcItemMd> PlcItemMd_D_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<BasPlcItemMd> PlcItemMd_M_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<BasPlcItemMd> PlcItemMd_X_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<BasPlcItemMd> PlcItemMd_Y_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<Bas_WarningMd> BasWarningMd_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<CM_WarningLogMd> CmWarningLogMd_List { get; set; }
|
|||
|
|
|
|||
|
|
public static List<CM_WarningLogMd> CmWarningLogMd_List_1 { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 参数列表
|
|||
|
|
/// </summary>
|
|||
|
|
public static bool CanOperate { get; set; }
|
|||
|
|
/// <summary>
|
|||
|
|
/// 系统是否运行
|
|||
|
|
/// </summary>
|
|||
|
|
public static bool SysThIsRunFlag { get; set; }
|
|||
|
|
#region 委托事件
|
|||
|
|
//定义一个委托类型的事件
|
|||
|
|
public static event EventHandler<EventArgs> OnShowX_Y_Status;
|
|||
|
|
public static bool eventLock = false;
|
|||
|
|
public static void ShowX_Y_Status(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!eventLock)
|
|||
|
|
{
|
|||
|
|
OnShowX_Y_Status?.Invoke(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//定义一个委托类型的事件
|
|||
|
|
public static event EventHandler<EventArgs> OnShowSensorStatus;
|
|||
|
|
public static void ShowSensorStatus(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!eventLock)
|
|||
|
|
{
|
|||
|
|
OnShowSensorStatus?.Invoke(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//定义一个委托类型的事件
|
|||
|
|
public static event EventHandler<EventArgs> OnShowMainFrmAlarmMsg;
|
|||
|
|
public static bool eventAlarmLock = false;
|
|||
|
|
public static void ShowMainFrmAlarmMsg(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!eventAlarmLock)
|
|||
|
|
{
|
|||
|
|
OnShowMainFrmAlarmMsg?.Invoke(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public static frmPopupWarningMsg PopupWarningMsgForm { get; set; }
|
|||
|
|
//定义一个委托类型的事件
|
|||
|
|
public static event EventHandler<EventArgs> OnSyncFinishPalletData;
|
|||
|
|
public static void SyncFinishPalletData(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
OnSyncFinishPalletData?.Invoke(sender, e);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取拖盘号
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static string GetPalletCode()
|
|||
|
|
{
|
|||
|
|
string currDateStr = DateTime.Now.ToString("yyyyMMdd");
|
|||
|
|
string PalletIndexPrefix = AppConfigHelper.Get("PalletIndexPrefix");
|
|||
|
|
string PalletIndexDateMsg = AppConfigHelper.Get("PalletIndexDateMsg");
|
|||
|
|
int PalletIndexLen = Convert.ToInt32(AppConfigHelper.Get("PalletIndexLen"));
|
|||
|
|
int PalletIndexValue = Convert.ToInt32(AppConfigHelper.Get("PalletIndexValue"));
|
|||
|
|
if (currDateStr == PalletIndexDateMsg)
|
|||
|
|
{
|
|||
|
|
PalletIndexValue++;
|
|||
|
|
string tmpPalletCode = PalletIndexPrefix + currDateStr + PalletIndexValue.ToString().PadLeft(PalletIndexLen, '0');
|
|||
|
|
AppConfigHelper.Update("PalletIndexValue", PalletIndexValue.ToString());
|
|||
|
|
return tmpPalletCode;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
PalletIndexValue = 1;
|
|||
|
|
string tmpPalletCode = PalletIndexPrefix + currDateStr + PalletIndexValue.ToString().PadLeft(PalletIndexLen, '0');
|
|||
|
|
AppConfigHelper.Update("PalletIndexValue", PalletIndexValue.ToString());
|
|||
|
|
AppConfigHelper.Update("PalletIndexDateMsg", currDateStr);
|
|||
|
|
return tmpPalletCode;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据自定义特性和窗体的绑定原理,
|
|||
|
|
/// 自动加载所有的窗体数据。
|
|||
|
|
/// </summary>
|
|||
|
|
public static void LoadAllFormData()
|
|||
|
|
{
|
|||
|
|
var types = Assembly.GetExecutingAssembly().GetTypes().Where(x => x.GetCustomAttributes(typeof(FormTypeAttribute), false).Count() > 0);
|
|||
|
|
FrmModelList = new List<FormModel<Type>>();
|
|||
|
|
foreach (var item in types)
|
|||
|
|
{
|
|||
|
|
FormTypeAttribute tmpAttribute = (FormTypeAttribute)item.GetCustomAttribute(typeof(FormTypeAttribute));
|
|||
|
|
FrmModelList.Add(new FormModel<Type>
|
|||
|
|
{
|
|||
|
|
//Form = (UserControl)Activator.CreateInstance(item),
|
|||
|
|
Form = item,
|
|||
|
|
FormType = tmpAttribute.Value
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
//MainForm = (frmMain)FrmModelList.Find(x => x.FormType == EnumFormType.Main).Form;
|
|||
|
|
//MainFormNew = (frmMainNew)FrmModelList.Find(x => x.FormType == EnumFormType.Main).Form;
|
|||
|
|
//LoginForm = (frmLogin)FrmModelList.Find(x => x.FormType == EnumFormType.Login).Form;
|
|||
|
|
LoginForm = new frmLogin();
|
|||
|
|
CanOperate = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|