终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

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