using BPASmartClient.AGV.Feedback; using BPASmartClient.CustomResource.Pages.Enums; using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.Pages.View; using BPASmartClient.Helper; using BPASmartClient.HubHelper; using FryPot_DosingSystem.Control; using FryPot_DosingSystem.Model; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace FryPot_DosingSystem { /// /// Interaction logic for App.xaml /// public partial class App : Application { public static Window MainWindow; protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); SystemHelper.GetInstance.CreateDesktopShortcut(); MenuInite(); LoginDataInite(); MainView mv = new MainView(); LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) { mv.Show(); MessageLog.GetInstance.ShowUserLog("用户登录"); DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 HubHelper.GetInstance.Connect("192.168.1.40", 8089); AlarmHelper.Init(); } else mv.Close(); MainWindow = mv; //HubHelper.GetInstance.Report = new Action((o) => //{ // var res = JsonConvert.DeserializeObject(o.ToString()); //}); //HubHelper.GetInstance.Upstreamrequest = new Action((o) => //{ // var res = JsonConvert.DeserializeObject(o.ToString()); //}); //本地服务连接 } protected override void OnExit(ExitEventArgs e) { base.OnExit(e); Json.Save(); MessageLog.GetInstance.LogSave(); } private void MenuInite() { NfcServer.GetInstance.Init(); #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); RecipeManage.Add(new SubMenumodel() { SubMenuName = "配方管理", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.RecipeManageView" }); RecipeManage.Add(new SubMenumodel() { SubMenuName = "配方下发", SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.RecipesSendDown" }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", MainMenuName = "配方管理", Alias = "Recipe Management", MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, subMenumodels = RecipeManage, }); #endregion #region 消息日志 ObservableCollection InfoLog = new ObservableCollection(); 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 = "FryPot_DosingSystem", ToggleWindowPath = "View.SqliteDataView" }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", MainMenuName = "消息日志", Alias = "Message Log", MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, subMenumodels = InfoLog, }); #endregion #region 参数设置 ObservableCollection ParamSet = new ObservableCollection(); ParamSet.Add(new SubMenumodel() { SubMenuName = "PLC通讯设置", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.DeviceListVIew" }); ParamSet.Add(new SubMenumodel() { SubMenuName = "PLC变量配置", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.VariableConfigView" }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", MainMenuName = "参数设置", Alias = "Parameters Set", MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, subMenumodels = ParamSet, }); #endregion #region 硬件设备监控 ObservableCollection DeviceMonitor = new ObservableCollection(); //DeviceMonitor.Add(new SubMenumodel() //{ // SubMenuName = "PLC通讯设置", // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, // AssemblyName = "FryPot_DosingSystem", // ToggleWindowPath = "View.DeviceListVIew" //}); //DeviceMonitor.Add(new SubMenumodel() //{ // SubMenuName = "PLC变量配置", // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, // AssemblyName = "BPASmartClient.CustomResource", // ToggleWindowPath = "Pages.View.VariableConfigView" //}); DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "滚筒线运行状态", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.HardWareStatusView" }); DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "炒锅状态数据监控", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.FryPotMonitorView" }); DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "AGV视图", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.AgvView" }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", MainMenuName = "设备监控", Alias = "Device Monitor", MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, subMenumodels = DeviceMonitor, }); #endregion #region 用户管理 ObservableCollection UserManager = new ObservableCollection(); 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.管理员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.PasswordChangeView" }); UserManager.Add(new SubMenumodel() { SubMenuName = "用户管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.UserManageView" }); 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", MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 }, subMenumodels = UserManager, }); #endregion #region 调试界面 ObservableCollection DebugManage = new ObservableCollection(); DebugManage.Add(new SubMenumodel() { SubMenuName = "单一流程调试", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.DebugView" }); #endregion MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", MainMenuName = "调试界面", Alias = "Debug Management", MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, subMenumodels = DebugManage, }); } private void LoginDataInite() { Config.GetInstance.Init();//用户数据初始化 Json.Read(); } } }