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

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