|
- 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.DosingSystem.View;
- using BPA.Helper;
-
- namespace BPASmartClient.DosingSystem
- {
- /// <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, "DosingSystem", out createNew);
- if (!createNew)
- {
- MessageBox.Show("程序已启动");
- App.Current.Shutdown();
- Environment.Exit(0);
- }
- base.OnStartup(e);
- BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
- MenuInit();
- DataInit();
- ThreadManage.GetInstance().Start(new Action(() =>
- {
- DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
- }), "设备初始化");
- MainView mv = new MainView();
- mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1";
- LoginView lv = new LoginView();
- var res = lv.ShowDialog();
- if (res != null && res == true)
- {
- BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录");
- mv.Show();
- }
- else
- mv.Close();
- MainWindow = mv;
- }
-
- protected override void OnExit(ExitEventArgs e)
- {
- base.OnExit(e);
- Json<LocaPar>.Save();
- Json<DevicePar>.Save();
- BPASmartClient.CustomResource.Pages.Model.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.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.RecipeSettingsView"
- });
-
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "配方下发",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.RecipeControlView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- MainMenuName = "配方管理",
- Alias = "Recipe Management",
- subMenumodels = RecipeManage,
- });
- #endregion
-
- #region 参数设置
- ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "原料参数设置",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.DeviceMaterialParView"
- });
-
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "设备参数设置",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.CommParSetView"
- });
-
- //ParSet.Add(new SubMenumodel()
- //{
- // SubMenuName = "出料口管理设置",
- // SubMenuPermission = new Permission[] { Permission.管理员 },
- // AssemblyName = "BPASmartClient.DosingSystem",
- // ToggleWindowPath = "View.OutletManagementView"
- //});
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- MainMenuName = "参数设置",
- Alias = "Parameter Set",
- subMenumodels = ParSet,
- });
- #endregion
-
- #region 手动控制
- ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
- ManualControl.Add(new SubMenumodel()
- {
- SubMenuName = "气缸手动控制",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.ManualControlView"
- });
-
- ManualControl.Add(new SubMenumodel()
- {
- SubMenuName = "输送带手动控制",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.ConveyerBeltManualView"
- });
- //ManualControl.Add(new SubMenumodel()
- //{
- // SubMenuName = "料仓控制",
- // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- // AssemblyName = "BPASmartClient.DosingSystem",
- // ToggleWindowPath = "View.StockControlView"
- //});
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "手动控制",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- Alias = "Parameter Set",
- subMenumodels = ManualControl,
- });
- #endregion
-
- #region 消息日志
- ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "操作日志",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.UserLogView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "运行日志",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.RunLogView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "报警记录",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.AlarmView"
- });
-
- InfoLog.Add(new SubMenumodel()
- {
- SubMenuName = "调试日志",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.DebugLogView"
- });
-
- //InfoLog.Add(new SubMenumodel()
- //{
- // SubMenuName = "报表数据",
- // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
- // AssemblyName = "BPASmartClient.CustomResource",
- // ToggleWindowPath = "Pages.View.ReportView"
- //});
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "消息日志",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- Alias = "Message Log",
- subMenumodels = InfoLog,
- });
- #endregion
-
- #region 硬件设备监控
- ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "原料设备列表",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.DeviceListView"
- });
-
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "设备状态",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.DosingSystem",
- ToggleWindowPath = "View.HardwareStatusView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "设备监控",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- Alias = "Device Monitor",
- subMenumodels = DeviceMonitor,
- });
- #endregion
-
- #region 用户管理
- ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "用户登录",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.SubPagLoginView"
- });
-
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "密码修改",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.PasswordChangeView"
- });
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "用户管理",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.UserManagerView"
- });
-
- //UserManager.Add(new SubMenumodel()
- //{
- // SubMenuName = "NFC登录管理",
- // SubMenuPermission = new Permission[] { Permission.管理员 },
- // AssemblyName = "BPASmartClient.CustomResource",
- // ToggleWindowPath = "Pages.View.NfcSetView"
- //});
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "用户管理",
- MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
- Alias = "User Management",
- subMenumodels = UserManager,
- });
- #endregion
- }
-
- private void DataInit()
- {
- //Config.GetInstance.Init();
- Json<LocaPar>.Read();
- Json<DevicePar>.Read();
- Json<LocaMaterial>.Read();
- }
-
- }
- }
|