|
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using BPASmartClient.CustomResource.Pages.Enums;
- using BPASmartClient.CustomResource.Pages.Model;
- using BPASmartClient.CustomResource.Pages.View;
- using BPASmartClient.CustomResource.Pages.ViewModel;
- using BPASmartClient.Helper;
- using BPASmartClient.JXJFoodBigStation.Model;
- using BPASmartClient.JXJFoodBigStation.Model.Siemens;
-
- namespace BPASmartClient.JXJFoodBigStation
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- public static Window MainWindow;
- public EventWaitHandle ProgramStarted { get; set; }
- protected override void OnStartup(StartupEventArgs e)
- {
- bool createNew;
- ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "BigStationApp", out createNew);
- if (!createNew)
- {
- MessageBox.Show("程序已启动");
- App.Current.Shutdown();
- Environment.Exit(0);
- }
- BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
- base.OnStartup(e);
- MenuInit();
- DataInit();
- MainView mv = new MainView();
- ProcessControl.GetInstance.Init();
- LoginView lv = new LoginView();
- var res = lv.ShowDialog();
- if (res != null && res == true)
- {
- MessageNotify.GetInstance.ShowUserLog("用户登录");
- mv.Show();
- }
- else
- mv.Close();
- MainWindow = mv;
- }
-
- protected override void OnExit(ExitEventArgs e)
- {
- Json<LocalRecipe>.Save();
- Json<RemoteRecipe>.Save();
- Json<RawMaterialData>.Save();
- Json<BomMaterial>.Save();
- base.OnExit(e);
- MessageNotify.GetInstance.LogSave();
- ThreadManage.GetInstance().Dispose();
- }
-
- private void MenuInit()
- {
- #region 配方管理菜单
- ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "配方管理",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.RecipeReceiveView"
- });
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "本地配方下发",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.RecipeSendDownView"
- });
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "西门子配方下发",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.SiemensRecipeSendDownView"
- });
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "配方管理",
- Alias = "Recipe Management",
- subMenumodels = RecipeManage,
- });
- #endregion
- #region 料仓管理
- ObservableCollection<SubMenumodel> StockBinManage = new ObservableCollection<SubMenumodel>();
- StockBinManage.Add(new SubMenumodel()
- {
- SubMenuName = "料仓原料配置",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.StockBinRawMaterialView"
- });
- StockBinManage.Add(new SubMenumodel()
- {
- SubMenuName = "MES原料数据",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.BomOfMaterialView"
- });
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "料仓管理",
- Alias = "Recipe Management",
- subMenumodels = StockBinManage,
- });
- #endregion
- #region 消息日志
- ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "操作日志",
- SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.UserLogView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "运行日志",
- SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.RunLogView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "报警记录",
- SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.AlarmView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "调试日志",
- SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.DebugLogView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "消息日志",
- Alias = "Message Log",
- subMenumodels = InfoLog,
- });
- #endregion
-
- #region 硬件设备监控
- ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "设备状态",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.HardwareStatusView"
- });
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "通讯状态",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.HKPlcCommMonitorView"
- });
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "手动流程",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodBigStation",
- ToggleWindowPath = "View.ManualFlowView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "设备监控",
- Alias = "Device Monitor",
- subMenumodels = DeviceMonitor,
- });
- #endregion
-
- #region 用户管理
- ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "用户登录",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.SubPagLoginView"
- });
-
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "密码修改",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.PasswordChangeView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "用户管理",
- Alias = "User Management",
- subMenumodels = UserManager,
- });
- #endregion
- }
-
- private void DataInit()
- {
- //Config.GetInstance.Init();
- //Json<LocaPar>.Read();
- Json<LocalRecipe>.Read();
- Json<RemoteRecipe>.Read();
- Json<RawMaterialData>.Read();
- Json<BomMaterial>.Read();
- }
-
- }
- }
|