终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

208 rivejä
8.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using BPASmartClient.CustomResource.Pages.Enums;
  11. using BPASmartClient.CustomResource.Pages.Model;
  12. using BPASmartClient.CustomResource.Pages.View;
  13. using BPASmartClient.CustomResource.Pages.ViewModel;
  14. using BPASmartClient.Helper;
  15. using BPASmartClient.JXJFoodBigStation.Model;
  16. namespace BPASmartClient.JXJFoodBigStation
  17. {
  18. /// <summary>
  19. /// Interaction logic for App.xaml
  20. /// </summary>
  21. public partial class App : Application
  22. {
  23. public static Window MainWindow;
  24. public EventWaitHandle ProgramStarted { get; set; }
  25. protected override void OnStartup(StartupEventArgs e)
  26. {
  27. bool createNew;
  28. ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "BigStationApp", out createNew);
  29. if (!createNew)
  30. {
  31. MessageBox.Show("程序已启动");
  32. App.Current.Shutdown();
  33. Environment.Exit(0);
  34. }
  35. BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
  36. base.OnStartup(e);
  37. MenuInit();
  38. DataInit();
  39. MainView mv = new MainView();
  40. ProcessControl.GetInstance.Init();
  41. LoginView lv = new LoginView();
  42. var res = lv.ShowDialog();
  43. if (res != null && res == true)
  44. {
  45. MessageNotify.GetInstance.ShowUserLog("用户登录");
  46. mv.Show();
  47. }
  48. else
  49. mv.Close();
  50. MainWindow = mv;
  51. }
  52. protected override void OnExit(ExitEventArgs e)
  53. {
  54. base.OnExit(e);
  55. MessageNotify.GetInstance.LogSave();
  56. ThreadManage.GetInstance().Dispose();
  57. }
  58. private void MenuInit()
  59. {
  60. #region 配方管理菜单
  61. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  62. RecipeManage.Add(new SubMenumodel()
  63. {
  64. SubMenuName = "配方管理",
  65. SubMenuPermission = new Permission[] { Permission.管理员 },
  66. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  67. ToggleWindowPath = "View.RecipeReceiveView"
  68. });
  69. RecipeManage.Add(new SubMenumodel()
  70. {
  71. SubMenuName = "本地配方下发",
  72. SubMenuPermission = new Permission[] { Permission.管理员 },
  73. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  74. ToggleWindowPath = "View.RecipeSendDownView"
  75. });
  76. RecipeManage.Add(new SubMenumodel()
  77. {
  78. SubMenuName = "西门子配方下发",
  79. SubMenuPermission = new Permission[] { Permission.管理员 },
  80. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  81. ToggleWindowPath = "View.SiemensRecipeSendDownView"
  82. });
  83. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  84. {
  85. MainMenuIcon = "&#xe683;",
  86. MainMenuName = "配方管理",
  87. Alias = "Recipe Management",
  88. subMenumodels = RecipeManage,
  89. });
  90. #endregion
  91. #region 消息日志
  92. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  93. InfoLog.Add(new SubMenumodel()
  94. {
  95. SubMenuName = "操作日志",
  96. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  97. AssemblyName = "BPASmartClient.CustomResource",
  98. ToggleWindowPath = "Pages.View.UserLogView"
  99. });
  100. InfoLog.Add(new SubMenumodel()
  101. {
  102. SubMenuName = "运行日志",
  103. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  104. AssemblyName = "BPASmartClient.CustomResource",
  105. ToggleWindowPath = "Pages.View.RunLogView"
  106. });
  107. InfoLog.Add(new SubMenumodel()
  108. {
  109. SubMenuName = "报警记录",
  110. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  111. AssemblyName = "BPASmartClient.CustomResource",
  112. ToggleWindowPath = "Pages.View.AlarmView"
  113. });
  114. InfoLog.Add(new SubMenumodel()
  115. {
  116. SubMenuName = "调试日志",
  117. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  118. AssemblyName = "BPASmartClient.CustomResource",
  119. ToggleWindowPath = "Pages.View.DebugLogView"
  120. });
  121. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  122. {
  123. MainMenuIcon = "&#xe668;",
  124. MainMenuName = "消息日志",
  125. Alias = "Message Log",
  126. subMenumodels = InfoLog,
  127. });
  128. #endregion
  129. #region 硬件设备监控
  130. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  131. DeviceMonitor.Add(new SubMenumodel()
  132. {
  133. SubMenuName = "设备状态",
  134. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  135. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  136. ToggleWindowPath = "View.HardwareStatusView"
  137. });
  138. DeviceMonitor.Add(new SubMenumodel()
  139. {
  140. SubMenuName = "通讯状态",
  141. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  142. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  143. ToggleWindowPath = "View.HKPlcCommMonitorView"
  144. });
  145. DeviceMonitor.Add(new SubMenumodel()
  146. {
  147. SubMenuName = "手动流程",
  148. SubMenuPermission = new Permission[] { Permission.管理员 },
  149. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  150. ToggleWindowPath = "View.ManualFlowView"
  151. });
  152. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  153. {
  154. MainMenuIcon = "&#xe603;",
  155. MainMenuName = "设备监控",
  156. Alias = "Device Monitor",
  157. subMenumodels = DeviceMonitor,
  158. });
  159. #endregion
  160. #region 用户管理
  161. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  162. UserManager.Add(new SubMenumodel()
  163. {
  164. SubMenuName = "用户登录",
  165. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  166. AssemblyName = "BPASmartClient.CustomResource",
  167. ToggleWindowPath = "Pages.View.SubPagLoginView"
  168. });
  169. UserManager.Add(new SubMenumodel()
  170. {
  171. SubMenuName = "密码修改",
  172. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  173. AssemblyName = "BPASmartClient.CustomResource",
  174. ToggleWindowPath = "Pages.View.PasswordChangeView"
  175. });
  176. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  177. {
  178. MainMenuIcon = "&#xe66d;",
  179. MainMenuName = "用户管理",
  180. Alias = "User Management",
  181. subMenumodels = UserManager,
  182. });
  183. #endregion
  184. }
  185. private void DataInit()
  186. {
  187. //Config.GetInstance.Init();
  188. //Json<LocaPar>.Read();
  189. Json<LocalRecipe>.Read();
  190. }
  191. }
  192. }