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

286 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. 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.管理员 },
  63. AssemblyName = "BPASmartClient.DosingSystem",
  64. ToggleWindowPath = "View.RecipeSettingsView"
  65. });
  66. RecipeManage.Add(new SubMenumodel()
  67. {
  68. SubMenuName = "配方下发",
  69. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
  70. AssemblyName = "BPASmartClient.DosingSystem",
  71. ToggleWindowPath = "View.RecipeControlView"
  72. });
  73. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  74. {
  75. MainMenuIcon = "&#xe683;",
  76. MainMenuName = "配方管理",
  77. Alias = "Recipe Management",
  78. subMenumodels = RecipeManage,
  79. });
  80. #endregion
  81. #region 参数设置
  82. ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
  83. ParSet.Add(new SubMenumodel()
  84. {
  85. SubMenuName = "原料参数设置",
  86. SubMenuPermission = new Permission[] { Permission.管理员 },
  87. AssemblyName = "BPASmartClient.DosingSystem",
  88. ToggleWindowPath = "View.DeviceMaterialParView"
  89. });
  90. ParSet.Add(new SubMenumodel()
  91. {
  92. SubMenuName = "设备参数设置",
  93. SubMenuPermission = new Permission[] { Permission.管理员 },
  94. AssemblyName = "BPASmartClient.DosingSystem",
  95. ToggleWindowPath = "View.CommParSetView"
  96. });
  97. //ParSet.Add(new SubMenumodel()
  98. //{
  99. // SubMenuName = "出料口管理设置",
  100. // SubMenuPermission = new Permission[] { Permission.管理员 },
  101. // AssemblyName = "BPASmartClient.DosingSystem",
  102. // ToggleWindowPath = "View.OutletManagementView"
  103. //});
  104. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  105. {
  106. MainMenuIcon = "&#xe62d;",
  107. MainMenuName = "参数设置",
  108. Alias = "Parameter Set",
  109. subMenumodels = ParSet,
  110. });
  111. #endregion
  112. #region 手动控制
  113. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  114. ManualControl.Add(new SubMenumodel()
  115. {
  116. SubMenuName = "气缸手动控制",
  117. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  118. AssemblyName = "BPASmartClient.DosingSystem",
  119. ToggleWindowPath = "View.ManualControlView"
  120. });
  121. ManualControl.Add(new SubMenumodel()
  122. {
  123. SubMenuName = "输送带手动控制",
  124. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  125. AssemblyName = "BPASmartClient.DosingSystem",
  126. ToggleWindowPath = "View.ConveyerBeltManualView"
  127. });
  128. //ManualControl.Add(new SubMenumodel()
  129. //{
  130. // SubMenuName = "料仓控制",
  131. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  132. // AssemblyName = "BPASmartClient.DosingSystem",
  133. // ToggleWindowPath = "View.StockControlView"
  134. //});
  135. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  136. {
  137. MainMenuIcon = "&#xe622;",
  138. MainMenuName = "手动控制",
  139. Alias = "Parameter Set",
  140. subMenumodels = ManualControl,
  141. });
  142. #endregion
  143. #region 消息日志
  144. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  145. InfoLog.Add(new SubMenumodel()
  146. {
  147. SubMenuName = "操作日志",
  148. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  149. AssemblyName = "BPASmartClient.CustomResource",
  150. ToggleWindowPath = "Pages.View.UserLogView"
  151. });
  152. InfoLog.Add(new SubMenumodel()
  153. {
  154. SubMenuName = "运行日志",
  155. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  156. AssemblyName = "BPASmartClient.CustomResource",
  157. ToggleWindowPath = "Pages.View.RunLogView"
  158. });
  159. InfoLog.Add(new SubMenumodel()
  160. {
  161. SubMenuName = "报警记录",
  162. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  163. AssemblyName = "BPASmartClient.CustomResource",
  164. ToggleWindowPath = "Pages.View.AlarmView"
  165. });
  166. InfoLog.Add(new SubMenumodel()
  167. {
  168. SubMenuName = "调试日志",
  169. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  170. AssemblyName = "BPASmartClient.CustomResource",
  171. ToggleWindowPath = "Pages.View.DebugLogView"
  172. });
  173. //InfoLog.Add(new SubMenumodel()
  174. //{
  175. // SubMenuName = "报表数据",
  176. // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  177. // AssemblyName = "BPASmartClient.CustomResource",
  178. // ToggleWindowPath = "Pages.View.ReportView"
  179. //});
  180. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  181. {
  182. MainMenuIcon = "&#xe668;",
  183. MainMenuName = "消息日志",
  184. Alias = "Message Log",
  185. subMenumodels = InfoLog,
  186. });
  187. #endregion
  188. #region 硬件设备监控
  189. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  190. DeviceMonitor.Add(new SubMenumodel()
  191. {
  192. SubMenuName = "原料设备列表",
  193. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  194. AssemblyName = "BPASmartClient.DosingSystem",
  195. ToggleWindowPath = "View.DeviceListView"
  196. });
  197. DeviceMonitor.Add(new SubMenumodel()
  198. {
  199. SubMenuName = "设备状态",
  200. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  201. AssemblyName = "BPASmartClient.DosingSystem",
  202. ToggleWindowPath = "View.HardwareStatusView"
  203. });
  204. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  205. {
  206. MainMenuIcon = "&#xe603;",
  207. MainMenuName = "设备监控",
  208. Alias = "Device Monitor",
  209. subMenumodels = DeviceMonitor,
  210. });
  211. #endregion
  212. #region 用户管理
  213. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  214. UserManager.Add(new SubMenumodel()
  215. {
  216. SubMenuName = "用户登录",
  217. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  218. AssemblyName = "BPASmartClient.CustomResource",
  219. ToggleWindowPath = "Pages.View.SubPagLoginView"
  220. });
  221. UserManager.Add(new SubMenumodel()
  222. {
  223. SubMenuName = "密码修改",
  224. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  225. AssemblyName = "BPASmartClient.CustomResource",
  226. ToggleWindowPath = "Pages.View.PasswordChangeView"
  227. });
  228. UserManager.Add(new SubMenumodel()
  229. {
  230. SubMenuName = "用户管理",
  231. SubMenuPermission = new Permission[] { Permission.管理员 },
  232. AssemblyName = "BPASmartClient.CustomResource",
  233. ToggleWindowPath = "Pages.View.UserManagerView"
  234. });
  235. //UserManager.Add(new SubMenumodel()
  236. //{
  237. // SubMenuName = "NFC登录管理",
  238. // SubMenuPermission = new Permission[] { Permission.管理员 },
  239. // AssemblyName = "BPASmartClient.CustomResource",
  240. // ToggleWindowPath = "Pages.View.NfcSetView"
  241. //});
  242. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  243. {
  244. MainMenuIcon = "&#xe66d;",
  245. MainMenuName = "用户管理",
  246. Alias = "User Management",
  247. subMenumodels = UserManager,
  248. });
  249. #endregion
  250. }
  251. private void DataInit()
  252. {
  253. //Config.GetInstance.Init();
  254. Json<LocaPar>.Read();
  255. Json<DevicePar>.Read();
  256. Json<LocaMaterial>.Read();
  257. }
  258. }
  259. }