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

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