终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

239 rindas
9.5 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. Json<BomMaterial>.Save();
  59. base.OnExit(e);
  60. MessageNotify.GetInstance.LogSave();
  61. ThreadManage.GetInstance().Dispose();
  62. }
  63. private void MenuInit()
  64. {
  65. #region 配方管理菜单
  66. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  67. RecipeManage.Add(new SubMenumodel()
  68. {
  69. SubMenuName = "配方管理",
  70. SubMenuPermission = new Permission[] { Permission.管理员 },
  71. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  72. ToggleWindowPath = "View.RecipeReceiveView"
  73. });
  74. RecipeManage.Add(new SubMenumodel()
  75. {
  76. SubMenuName = "本地配方下发",
  77. SubMenuPermission = new Permission[] { Permission.管理员 },
  78. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  79. ToggleWindowPath = "View.RecipeSendDownView"
  80. });
  81. RecipeManage.Add(new SubMenumodel()
  82. {
  83. SubMenuName = "西门子配方下发",
  84. SubMenuPermission = new Permission[] { Permission.管理员 },
  85. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  86. ToggleWindowPath = "View.SiemensRecipeSendDownView"
  87. });
  88. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  89. {
  90. MainMenuIcon = "&#xe683;",
  91. MainMenuName = "配方管理",
  92. Alias = "Recipe Management",
  93. subMenumodels = RecipeManage,
  94. });
  95. #endregion
  96. #region 料仓管理
  97. ObservableCollection<SubMenumodel> StockBinManage = new ObservableCollection<SubMenumodel>();
  98. StockBinManage.Add(new SubMenumodel()
  99. {
  100. SubMenuName = "料仓原料配置",
  101. SubMenuPermission = new Permission[] { Permission.管理员 },
  102. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  103. ToggleWindowPath = "View.StockBinRawMaterialView"
  104. });
  105. StockBinManage.Add(new SubMenumodel()
  106. {
  107. SubMenuName = "MES原料数据",
  108. SubMenuPermission = new Permission[] { Permission.管理员 },
  109. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  110. ToggleWindowPath = "View.BomOfMaterialView"
  111. });
  112. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  113. {
  114. MainMenuIcon = "&#xe683;",
  115. MainMenuName = "料仓管理",
  116. Alias = "Recipe Management",
  117. subMenumodels = StockBinManage,
  118. });
  119. #endregion
  120. #region 消息日志
  121. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  122. InfoLog.Add(new SubMenumodel()
  123. {
  124. SubMenuName = "操作日志",
  125. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  126. AssemblyName = "BPASmartClient.CustomResource",
  127. ToggleWindowPath = "Pages.View.UserLogView"
  128. });
  129. InfoLog.Add(new SubMenumodel()
  130. {
  131. SubMenuName = "运行日志",
  132. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  133. AssemblyName = "BPASmartClient.CustomResource",
  134. ToggleWindowPath = "Pages.View.RunLogView"
  135. });
  136. InfoLog.Add(new SubMenumodel()
  137. {
  138. SubMenuName = "报警记录",
  139. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  140. AssemblyName = "BPASmartClient.CustomResource",
  141. ToggleWindowPath = "Pages.View.AlarmView"
  142. });
  143. InfoLog.Add(new SubMenumodel()
  144. {
  145. SubMenuName = "调试日志",
  146. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  147. AssemblyName = "BPASmartClient.CustomResource",
  148. ToggleWindowPath = "Pages.View.DebugLogView"
  149. });
  150. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  151. {
  152. MainMenuIcon = "&#xe668;",
  153. MainMenuName = "消息日志",
  154. Alias = "Message Log",
  155. subMenumodels = InfoLog,
  156. });
  157. #endregion
  158. #region 硬件设备监控
  159. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  160. DeviceMonitor.Add(new SubMenumodel()
  161. {
  162. SubMenuName = "设备状态",
  163. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  164. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  165. ToggleWindowPath = "View.HardwareStatusView"
  166. });
  167. DeviceMonitor.Add(new SubMenumodel()
  168. {
  169. SubMenuName = "通讯状态",
  170. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  171. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  172. ToggleWindowPath = "View.HKPlcCommMonitorView"
  173. });
  174. DeviceMonitor.Add(new SubMenumodel()
  175. {
  176. SubMenuName = "手动流程",
  177. SubMenuPermission = new Permission[] { Permission.管理员 },
  178. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  179. ToggleWindowPath = "View.ManualFlowView"
  180. });
  181. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  182. {
  183. MainMenuIcon = "&#xe603;",
  184. MainMenuName = "设备监控",
  185. Alias = "Device Monitor",
  186. subMenumodels = DeviceMonitor,
  187. });
  188. #endregion
  189. #region 用户管理
  190. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  191. UserManager.Add(new SubMenumodel()
  192. {
  193. SubMenuName = "用户登录",
  194. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  195. AssemblyName = "BPASmartClient.CustomResource",
  196. ToggleWindowPath = "Pages.View.SubPagLoginView"
  197. });
  198. UserManager.Add(new SubMenumodel()
  199. {
  200. SubMenuName = "密码修改",
  201. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  202. AssemblyName = "BPASmartClient.CustomResource",
  203. ToggleWindowPath = "Pages.View.PasswordChangeView"
  204. });
  205. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  206. {
  207. MainMenuIcon = "&#xe66d;",
  208. MainMenuName = "用户管理",
  209. Alias = "User Management",
  210. subMenumodels = UserManager,
  211. });
  212. #endregion
  213. }
  214. private void DataInit()
  215. {
  216. //Config.GetInstance.Init();
  217. //Json<LocaPar>.Read();
  218. Json<LocalRecipe>.Read();
  219. Json<RemoteRecipe>.Read();
  220. Json<RawMaterialData>.Read();
  221. Json<BomMaterial>.Read();
  222. }
  223. }
  224. }