终端一体化运控平台
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.
 
 
 

224 lines
8.9 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> StockBinManage = new ObservableCollection<SubMenumodel>();
  93. StockBinManage.Add(new SubMenumodel()
  94. {
  95. SubMenuName = "料仓原料配置",
  96. SubMenuPermission = new Permission[] { Permission.管理员 },
  97. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  98. ToggleWindowPath = "View.StockBinRawMaterialView"
  99. });
  100. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  101. {
  102. MainMenuIcon = "&#xe683;",
  103. MainMenuName = "料仓管理",
  104. Alias = "Recipe Management",
  105. subMenumodels = StockBinManage,
  106. });
  107. #endregion
  108. #region 消息日志
  109. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  110. InfoLog.Add(new SubMenumodel()
  111. {
  112. SubMenuName = "操作日志",
  113. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  114. AssemblyName = "BPASmartClient.CustomResource",
  115. ToggleWindowPath = "Pages.View.UserLogView"
  116. });
  117. InfoLog.Add(new SubMenumodel()
  118. {
  119. SubMenuName = "运行日志",
  120. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  121. AssemblyName = "BPASmartClient.CustomResource",
  122. ToggleWindowPath = "Pages.View.RunLogView"
  123. });
  124. InfoLog.Add(new SubMenumodel()
  125. {
  126. SubMenuName = "报警记录",
  127. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  128. AssemblyName = "BPASmartClient.CustomResource",
  129. ToggleWindowPath = "Pages.View.AlarmView"
  130. });
  131. InfoLog.Add(new SubMenumodel()
  132. {
  133. SubMenuName = "调试日志",
  134. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  135. AssemblyName = "BPASmartClient.CustomResource",
  136. ToggleWindowPath = "Pages.View.DebugLogView"
  137. });
  138. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  139. {
  140. MainMenuIcon = "&#xe668;",
  141. MainMenuName = "消息日志",
  142. Alias = "Message Log",
  143. subMenumodels = InfoLog,
  144. });
  145. #endregion
  146. #region 硬件设备监控
  147. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  148. DeviceMonitor.Add(new SubMenumodel()
  149. {
  150. SubMenuName = "设备状态",
  151. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  152. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  153. ToggleWindowPath = "View.HardwareStatusView"
  154. });
  155. DeviceMonitor.Add(new SubMenumodel()
  156. {
  157. SubMenuName = "通讯状态",
  158. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  159. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  160. ToggleWindowPath = "View.HKPlcCommMonitorView"
  161. });
  162. DeviceMonitor.Add(new SubMenumodel()
  163. {
  164. SubMenuName = "手动流程",
  165. SubMenuPermission = new Permission[] { Permission.管理员 },
  166. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  167. ToggleWindowPath = "View.ManualFlowView"
  168. });
  169. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  170. {
  171. MainMenuIcon = "&#xe603;",
  172. MainMenuName = "设备监控",
  173. Alias = "Device Monitor",
  174. subMenumodels = DeviceMonitor,
  175. });
  176. #endregion
  177. #region 用户管理
  178. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  179. UserManager.Add(new SubMenumodel()
  180. {
  181. SubMenuName = "用户登录",
  182. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  183. AssemblyName = "BPASmartClient.CustomResource",
  184. ToggleWindowPath = "Pages.View.SubPagLoginView"
  185. });
  186. UserManager.Add(new SubMenumodel()
  187. {
  188. SubMenuName = "密码修改",
  189. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  190. AssemblyName = "BPASmartClient.CustomResource",
  191. ToggleWindowPath = "Pages.View.PasswordChangeView"
  192. });
  193. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  194. {
  195. MainMenuIcon = "&#xe66d;",
  196. MainMenuName = "用户管理",
  197. Alias = "User Management",
  198. subMenumodels = UserManager,
  199. });
  200. #endregion
  201. }
  202. private void DataInit()
  203. {
  204. //Config.GetInstance.Init();
  205. //Json<LocaPar>.Read();
  206. Json<LocalRecipe>.Read();
  207. }
  208. }
  209. }