终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

254 linhas
10 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 BPA.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. SystemHelper.GetInstance.CreateDesktopShortcut();
  37. base.OnStartup(e);
  38. MenuInit();
  39. DataInit();
  40. MainView mv = new MainView();
  41. mv.TitleName = "自动化产线-大料站上位机控制系统";
  42. ProcessControl.GetInstance.Init();
  43. LoginView lv = new LoginView();
  44. var res = lv.ShowDialog();
  45. if (res != null && res == true)
  46. {
  47. MessageNotify.GetInstance.ShowUserLog("用户登录");
  48. mv.Show();
  49. }
  50. else
  51. mv.Close();
  52. MainWindow = mv;
  53. }
  54. protected override void OnExit(ExitEventArgs e)
  55. {
  56. Json<LocalRecipe>.Save();
  57. Json<RemoteRecipe>.Save();
  58. Json<RawMaterialData>.Save();
  59. Json<BomMaterial>.Save();
  60. base.OnExit(e);
  61. MessageNotify.GetInstance.LogSave();
  62. TaskManage.GetInstance.Dispose();
  63. }
  64. private void MenuInit()
  65. {
  66. #region 配方管理菜单
  67. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  68. RecipeManage.Add(new SubMenumodel()
  69. {
  70. SubMenuName = "配方管理",
  71. SubMenuPermission = new Permission[] { Permission.管理员 },
  72. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  73. ToggleWindowPath = "View.RecipeReceiveView"
  74. });
  75. RecipeManage.Add(new SubMenumodel()
  76. {
  77. SubMenuName = "本地配方下发",
  78. SubMenuPermission = new Permission[] { Permission.管理员 },
  79. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  80. ToggleWindowPath = "View.RecipeSendDownView"
  81. });
  82. RecipeManage.Add(new SubMenumodel()
  83. {
  84. SubMenuName = "西门子配方下发",
  85. SubMenuPermission = new Permission[] { Permission.管理员 },
  86. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  87. ToggleWindowPath = "View.SiemensRecipeSendDownView"
  88. });
  89. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  90. {
  91. MainMenuIcon = "&#xe683;",
  92. MainMenuName = "配方管理",
  93. Alias = "Recipe Management",
  94. subMenumodels = RecipeManage,
  95. });
  96. #endregion
  97. #region 料仓管理
  98. ObservableCollection<SubMenumodel> StockBinManage = new ObservableCollection<SubMenumodel>();
  99. StockBinManage.Add(new SubMenumodel()
  100. {
  101. SubMenuName = "料仓原料配置",
  102. SubMenuPermission = new Permission[] { Permission.管理员 },
  103. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  104. ToggleWindowPath = "View.StockBinRawMaterialView"
  105. });
  106. StockBinManage.Add(new SubMenumodel()
  107. {
  108. SubMenuName = "MES原料数据",
  109. SubMenuPermission = new Permission[] { Permission.管理员 },
  110. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  111. ToggleWindowPath = "View.BomOfMaterialView"
  112. });
  113. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  114. {
  115. MainMenuIcon = "&#xe683;",
  116. MainMenuName = "料仓管理",
  117. Alias = "Recipe Management",
  118. subMenumodels = StockBinManage,
  119. });
  120. #endregion
  121. #region 消息日志
  122. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  123. InfoLog.Add(new SubMenumodel()
  124. {
  125. SubMenuName = "操作日志",
  126. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  127. AssemblyName = "BPASmartClient.CustomResource",
  128. ToggleWindowPath = "Pages.View.UserLogView"
  129. });
  130. InfoLog.Add(new SubMenumodel()
  131. {
  132. SubMenuName = "运行日志",
  133. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  134. AssemblyName = "BPASmartClient.CustomResource",
  135. ToggleWindowPath = "Pages.View.RunLogView"
  136. });
  137. InfoLog.Add(new SubMenumodel()
  138. {
  139. SubMenuName = "报警记录",
  140. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  141. AssemblyName = "BPASmartClient.CustomResource",
  142. ToggleWindowPath = "Pages.View.AlarmView"
  143. });
  144. InfoLog.Add(new SubMenumodel()
  145. {
  146. SubMenuName = "调试日志",
  147. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  148. AssemblyName = "BPASmartClient.CustomResource",
  149. ToggleWindowPath = "Pages.View.DebugLogView"
  150. });
  151. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  152. {
  153. MainMenuIcon = "&#xe668;",
  154. MainMenuName = "消息日志",
  155. Alias = "Message Log",
  156. subMenumodels = InfoLog,
  157. });
  158. #endregion
  159. #region 硬件设备监控
  160. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  161. DeviceMonitor.Add(new SubMenumodel()
  162. {
  163. SubMenuName = "设备状态",
  164. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  165. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  166. ToggleWindowPath = "View.HardwareStatusView"
  167. });
  168. DeviceMonitor.Add(new SubMenumodel()
  169. {
  170. SubMenuName = "通讯状态",
  171. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  172. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  173. ToggleWindowPath = "View.HKPlcCommMonitorView"
  174. });
  175. DeviceMonitor.Add(new SubMenumodel()
  176. {
  177. SubMenuName = "全局变量",
  178. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  179. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  180. ToggleWindowPath = "View.GlobalVarMonitorView"
  181. });
  182. DeviceMonitor.Add(new SubMenumodel()
  183. {
  184. SubMenuName = "手动流程",
  185. SubMenuPermission = new Permission[] { Permission.管理员 },
  186. AssemblyName = "BPASmartClient.JXJFoodBigStation",
  187. ToggleWindowPath = "View.ManualFlowView"
  188. });
  189. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  190. {
  191. MainMenuIcon = "&#xe603;",
  192. MainMenuName = "设备监控",
  193. Alias = "Device Monitor",
  194. subMenumodels = DeviceMonitor,
  195. });
  196. #endregion
  197. #region 用户管理
  198. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  199. UserManager.Add(new SubMenumodel()
  200. {
  201. SubMenuName = "用户登录",
  202. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  203. AssemblyName = "BPASmartClient.CustomResource",
  204. ToggleWindowPath = "Pages.View.SubPagLoginView"
  205. });
  206. UserManager.Add(new SubMenumodel()
  207. {
  208. SubMenuName = "密码修改",
  209. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  210. AssemblyName = "BPASmartClient.CustomResource",
  211. ToggleWindowPath = "Pages.View.PasswordChangeView"
  212. });
  213. UserManager.Add(new SubMenumodel()
  214. {
  215. SubMenuName = "用户管理",
  216. SubMenuPermission = new Permission[] { Permission.管理员 },
  217. AssemblyName = "BPASmartClient.CustomResource",
  218. ToggleWindowPath = "Pages.View.UserManagerView"
  219. });
  220. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  221. {
  222. MainMenuIcon = "&#xe66d;",
  223. MainMenuName = "用户管理",
  224. Alias = "User Management",
  225. subMenumodels = UserManager,
  226. });
  227. #endregion
  228. }
  229. private void DataInit()
  230. {
  231. //Config.GetInstance.Init();
  232. //Json<LocaPar>.Read();
  233. Json<LocalRecipe>.Read();
  234. Json<RemoteRecipe>.Read();
  235. Json<RawMaterialData>.Read();
  236. Json<BomMaterial>.Read();
  237. }
  238. }
  239. }