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

304 line
12 KiB

  1. using BPASmartClient.JXJFoodSmallStation.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Configuration;
  6. using System.Data;
  7. using System.Linq;
  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.JXJFoodSmallStation.Model.Siemens;
  16. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  17. using System.Threading;
  18. namespace BPASmartClient.JXJFoodSmallStation
  19. {
  20. /// <summary>
  21. /// Interaction logic for App.xaml
  22. /// </summary>
  23. public partial class App : Application
  24. {
  25. public static Window MainWindow;
  26. public EventWaitHandle ProgramStarted { get; set; }
  27. protected override void OnStartup(StartupEventArgs e)
  28. {
  29. bool createNew;
  30. ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "SmallStationApp", out createNew);
  31. if (!createNew)
  32. {
  33. MessageBox.Show("程序已启动");
  34. App.Current.Shutdown();
  35. Environment.Exit(0);
  36. }
  37. BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
  38. base.OnStartup(e);
  39. MenuInit();
  40. DataInit();
  41. DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
  42. MainView mv = new MainView();
  43. ProcessControl.GetInstance.Init();
  44. LoginView lv = new LoginView();
  45. var res = lv.ShowDialog();
  46. if (res != null && res == true)
  47. {
  48. MessageNotify.GetInstance.ShowUserLog("用户登录");
  49. mv.Show();
  50. }
  51. else
  52. mv.Close();
  53. MainWindow = mv;
  54. }
  55. protected override void OnExit(ExitEventArgs e)
  56. {
  57. base.OnExit(e);
  58. Json<LocaPar>.Save();
  59. Json<LocalRecipeDataColl>.Save();
  60. Json<RemoteRecipeDataColl>.Save();
  61. MessageNotify.GetInstance.LogSave();
  62. ThreadManage.GetInstance().Dispose();
  63. }
  64. private void MenuInit()
  65. {
  66. //NfcServer.GetInstance.Init();
  67. #region 配方管理菜单
  68. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  69. RecipeManage.Add(new SubMenumodel()
  70. {
  71. SubMenuName = "味魔方配方管理",
  72. SubMenuPermission = new Permission[] { Permission.管理员 },
  73. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  74. ToggleWindowPath = "View.RecipeSettingsView"
  75. });
  76. RecipeManage.Add(new SubMenumodel()
  77. {
  78. SubMenuName = "味魔方配方下发",
  79. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
  80. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  81. ToggleWindowPath = "View.RecipeControlView"
  82. });
  83. RecipeManage.Add(new SubMenumodel()
  84. {
  85. SubMenuName = "本地配方管理",
  86. SubMenuPermission = new Permission[] { Permission.管理员 },
  87. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  88. ToggleWindowPath = "View.RecipeReceiveView"
  89. });
  90. RecipeManage.Add(new SubMenumodel()
  91. {
  92. SubMenuName = "西门子配方管理",
  93. SubMenuPermission = new Permission[] { Permission.管理员 },
  94. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  95. ToggleWindowPath = "View.SiemensRecipeReceiveView"
  96. });
  97. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  98. {
  99. MainMenuIcon = "&#xe683;",
  100. MainMenuName = "配方管理",
  101. Alias = "Recipe Management",
  102. subMenumodels = RecipeManage,
  103. });
  104. #endregion
  105. #region 参数设置
  106. ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
  107. ParSet.Add(new SubMenumodel()
  108. {
  109. SubMenuName = "柔性味魔方参数设置",
  110. SubMenuPermission = new Permission[] { Permission.管理员 },
  111. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  112. ToggleWindowPath = "View.DeviceMaterialParView"
  113. });
  114. ParSet.Add(new SubMenumodel()
  115. {
  116. SubMenuName = "粉仓参数设置",
  117. SubMenuPermission = new Permission[] { Permission.管理员 },
  118. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  119. ToggleWindowPath = "View.WindSendParView"
  120. });
  121. ParSet.Add(new SubMenumodel()
  122. {
  123. SubMenuName = "系统参数设置",
  124. SubMenuPermission = new Permission[] { Permission.管理员 },
  125. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  126. ToggleWindowPath = "View.SystemParView"
  127. });
  128. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  129. {
  130. MainMenuIcon = "&#xe62d;",
  131. MainMenuName = "参数设置",
  132. Alias = "Parameter Set",
  133. subMenumodels = ParSet,
  134. });
  135. #endregion
  136. #region 手动控制
  137. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  138. ManualControl.Add(new SubMenumodel()
  139. {
  140. SubMenuName = "手动控制硬件",
  141. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  142. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  143. ToggleWindowPath = "View.ManualControlView"
  144. });
  145. /*ManualControl.Add(new SubMenumodel()
  146. {
  147. SubMenuName = "手动控制信号",
  148. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  149. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  150. ToggleWindowPath = "View.ManualCommView"
  151. });*/
  152. ManualControl.Add(new SubMenumodel()
  153. {
  154. SubMenuName = "手动控制流程",
  155. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  156. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  157. ToggleWindowPath = "View.ManualFlowView"
  158. });
  159. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  160. {
  161. MainMenuIcon = "&#xe622;",
  162. MainMenuName = "手动控制",
  163. Alias = "Parameter Set",
  164. subMenumodels = ManualControl,
  165. });
  166. #endregion
  167. #region 消息日志
  168. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  169. InfoLog.Add(new SubMenumodel()
  170. {
  171. SubMenuName = "操作日志",
  172. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  173. AssemblyName = "BPASmartClient.CustomResource",
  174. ToggleWindowPath = "Pages.View.UserLogView"
  175. });
  176. InfoLog.Add(new SubMenumodel()
  177. {
  178. SubMenuName = "运行日志",
  179. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  180. AssemblyName = "BPASmartClient.CustomResource",
  181. ToggleWindowPath = "Pages.View.RunLogView"
  182. });
  183. InfoLog.Add(new SubMenumodel()
  184. {
  185. SubMenuName = "报警记录",
  186. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  187. AssemblyName = "BPASmartClient.CustomResource",
  188. ToggleWindowPath = "Pages.View.AlarmView"
  189. });
  190. InfoLog.Add(new SubMenumodel()
  191. {
  192. SubMenuName = "调试日志",
  193. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  194. AssemblyName = "BPASmartClient.CustomResource",
  195. ToggleWindowPath = "Pages.View.DebugLogView"
  196. });
  197. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  198. {
  199. MainMenuIcon = "&#xe668;",
  200. MainMenuName = "消息日志",
  201. Alias = "Message Log",
  202. subMenumodels = InfoLog,
  203. });
  204. #endregion
  205. #region 硬件设备监控
  206. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  207. DeviceMonitor.Add(new SubMenumodel()
  208. {
  209. SubMenuName = "原料设备列表",
  210. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  211. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  212. ToggleWindowPath = "View.DeviceListView"
  213. });
  214. DeviceMonitor.Add(new SubMenumodel()
  215. {
  216. SubMenuName = "设备状态",
  217. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  218. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  219. ToggleWindowPath = "View.HardwareStatusView"
  220. });
  221. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  222. {
  223. MainMenuIcon = "&#xe603;",
  224. MainMenuName = "设备监控",
  225. Alias = "Device Monitor",
  226. subMenumodels = DeviceMonitor,
  227. });
  228. #endregion
  229. #region 用户管理
  230. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  231. UserManager.Add(new SubMenumodel()
  232. {
  233. SubMenuName = "用户登录",
  234. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  235. AssemblyName = "BPASmartClient.CustomResource",
  236. ToggleWindowPath = "Pages.View.SubPagLoginView"
  237. });
  238. UserManager.Add(new SubMenumodel()
  239. {
  240. SubMenuName = "密码修改",
  241. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  242. AssemblyName = "BPASmartClient.CustomResource",
  243. ToggleWindowPath = "Pages.View.PasswordChangeView"
  244. });
  245. UserManager.Add(new SubMenumodel()
  246. {
  247. SubMenuName = "用户管理",
  248. SubMenuPermission = new Permission[] { Permission.管理员 },
  249. AssemblyName = "BPASmartClient.CustomResource",
  250. ToggleWindowPath = "Pages.View.UserManagerView"
  251. });
  252. /* UserManager.Add(new SubMenumodel()
  253. {
  254. SubMenuName = "NFC登录设置",
  255. SubMenuPermission = new Permission[] { Permission.管理员 },
  256. AssemblyName = "BPASmartClient.CustomResource",
  257. ToggleWindowPath = "Pages.View.NfcSetView"
  258. });*/
  259. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  260. {
  261. MainMenuIcon = "&#xe66d;",
  262. MainMenuName = "用户管理",
  263. Alias = "User Management",
  264. subMenumodels = UserManager,
  265. });
  266. #endregion
  267. }
  268. private void DataInit()
  269. {
  270. //Config.GetInstance.Init();
  271. Json<LocaPar>.Read();
  272. Json<DevicePar>.Read();
  273. Json<WindSendDevicePar>.Read();
  274. Json<LocalRecipeDataColl>.Read();
  275. Json<RemoteRecipeDataColl>.Read();
  276. }
  277. }
  278. }