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

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