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

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