|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- using BPASmartClient.JXJFoodSmallStation.Model;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- 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.JXJFoodSmallStation.Model.Siemens;
- using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
- using System.Threading;
-
- namespace BPASmartClient.JXJFoodSmallStation
- {
- /// <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, "SmallStationApp", out createNew);
- if (!createNew)
- {
- MessageBox.Show("程序已启动");
- App.Current.Shutdown();
- Environment.Exit(0);
- }
- BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
- base.OnStartup(e);
-
- MenuInit();
- DataInit();
- Init();
- MainView mv = new MainView();
- LoginView lv = new LoginView();
- var res = lv.ShowDialog();
- if (res != null && res == true)
- {
- MessageNotify.GetInstance.ShowUserLog("用户登录");
- mv.Show();
- }
- else
- mv.Close();
- MainWindow = mv;
- }
- private async void Init()
- {
- await Task.Run(new Action(() =>
- {
- DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
- ProcessControl.GetInstance.Init();
- }));
- }
-
- protected override void OnExit(ExitEventArgs e)
- {
- base.OnExit(e);
- Json<LocaPar>.Save();
- Json<LocalRecipeDataColl>.Save();
- Json<RemoteRecipeDataColl>.Save();
- MessageNotify.GetInstance.LogSave();
- ThreadManage.GetInstance().Dispose();
- }
-
- private void MenuInit()
- {
- //NfcServer.GetInstance.Init();
-
- #region 配方管理菜单
- ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
- //RecipeManage.Add(new SubMenumodel()
- //{
- // SubMenuName = "味魔方配方管理",
- // SubMenuPermission = new Permission[] { Permission.管理员 },
- // AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- // ToggleWindowPath = "View.RecipeSettingsView"
- //});
-
- //RecipeManage.Add(new SubMenumodel()
- //{
- // SubMenuName = "味魔方配方下发",
- // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
- // AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- // ToggleWindowPath = "View.RecipeControlView"
- //});
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "本地配方管理",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.RecipeReceiveView"
- });
- RecipeManage.Add(new SubMenumodel()
- {
- SubMenuName = "西门子配方管理",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.SiemensRecipeReceiveView"
- });
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "配方管理",
- Alias = "Recipe Management",
- subMenumodels = RecipeManage,
- });
- #endregion
-
- #region 参数设置
- ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "味魔方参数设置",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.DeviceMaterialParView"
- });
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "粉仓参数设置",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.WindSendParView"
- });
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "系统参数设置",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.SystemParView"
- });
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "原料与料仓管理",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.StockBinRawMaterialView"
- });
- ParSet.Add(new SubMenumodel()
- {
- SubMenuName = "西门子物料管理",
- SubMenuPermission = new Permission[] { Permission.管理员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.BomOfMaterialView"
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- 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.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.ManualControlView"
- });
- /*ManualControl.Add(new SubMenumodel()
- {
- SubMenuName = "手动控制信号",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.ManualCommView"
-
- });*/
- ManualControl.Add(new SubMenumodel()
- {
- SubMenuName = "手动控制流程",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.ManualFlowView"
-
- });
- ManualControl.Add(new SubMenumodel()
- {
- SubMenuName = "机器人设备控制",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.RobotView"
-
- });
-
- MenuManage.GetInstance.menuModels.Add(new MenuModel()
- {
- MainMenuIcon = "",
- MainMenuName = "手动控制",
- Alias = "Parameter Set",
- subMenumodels = ManualControl,
- });
- #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.RecipeCompleteView"
- });
-
- 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.技术员, 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.JXJFoodSmallStation",
- ToggleWindowPath = "View.DeviceListView"
- });
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "Plc变量监控",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.PlcVarMonitorView"
- });
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "流程变量监控",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.ProcessMonitorView"
- });
- DeviceMonitor.Add(new SubMenumodel()
- {
- SubMenuName = "设备状态",
- SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
- AssemblyName = "BPASmartClient.JXJFoodSmallStation",
- ToggleWindowPath = "View.HardwareStatusView"
- });
-
- 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.技术员 },
- AssemblyName = "BPASmartClient.CustomResource",
- ToggleWindowPath = "Pages.View.PasswordChangeView"
- });
- UserManager.Add(new SubMenumodel()
- {
- SubMenuName = "用户管理",
- SubMenuPermission = new 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 = "用户管理",
- Alias = "User Management",
- subMenumodels = UserManager,
- });
- #endregion
- }
-
- private void DataInit()
- {
- //Config.GetInstance.Init();
- Json<LocaPar>.Read();
- Json<DevicePar>.Read();
- Json<WindSendDevicePar>.Read();
- Json<LocalRecipeDataColl>.Read();
- Json<RemoteRecipeDataColl>.Read();
- }
-
- }
- }
|