终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

298 řádky
13 KiB

  1. using BPASmartClient.CustomResource.Pages.ViewModel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Configuration;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. namespace BPASmartClient.TourismCollege
  12. {
  13. /// <summary>
  14. /// Interaction logic for App.xaml
  15. /// </summary>
  16. public partial class App : Application
  17. {
  18. public static Window MainWindow;
  19. protected override void OnStartup(StartupEventArgs e)
  20. {
  21. bool createNew;
  22. MessageLog.GetInstance.NotifyShow = new Action<string>(o =>
  23. {
  24. DebugLogViewModel.MessageModels.Add(new MessageModel()
  25. {
  26. LogInfo = o,
  27. Forground = System.Windows.Media.Brushes.DeepSkyBlue
  28. });
  29. });
  30. MessageLog.GetInstance.NotifyShowEx = new Action<string>(o =>
  31. {
  32. DebugLogViewModel.MessageModels.Add(new MessageModel()
  33. {
  34. LogInfo = o,
  35. Forground = System.Windows.Media.Brushes.Red
  36. });
  37. });
  38. new EventWaitHandle(false, EventResetMode.AutoReset, "BPASmartClient.TourismCollege", out createNew);
  39. if (!createNew)
  40. {
  41. MessageBox.Show("程序已启动");
  42. App.Current.Shutdown();
  43. Environment.Exit(0);
  44. }
  45. base.OnStartup(e);
  46. SystemHelper.GetInstance.CreateDesktopShortcut();
  47. MenuInit();
  48. DataInit();
  49. MainView mv = new MainView();
  50. mv.TitleName = $"智能炒锅控制系统";
  51. LoginView lv = new LoginView();
  52. var res = lv.ShowDialog();
  53. if (res != null && res == true)
  54. {
  55. BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录");
  56. mv.Show();
  57. }
  58. else
  59. mv.Close();
  60. MainWindow = mv;
  61. }
  62. protected override void OnExit(ExitEventArgs e)
  63. {
  64. base.OnExit(e);
  65. BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave();
  66. ThreadManage.GetInstance().Dispose();
  67. }
  68. private void MenuInit()
  69. {
  70. NfcServer.GetInstance.Init();
  71. #region 配方管理菜单
  72. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  73. RecipeManage.Add(new SubMenumodel()
  74. {
  75. SubMenuName = "配方管理",
  76. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  77. AssemblyName = "BPASmartClient.DosingSystem",
  78. ToggleWindowPath = "View.RecipeSettingsView"
  79. });
  80. RecipeManage.Add(new SubMenumodel()
  81. {
  82. SubMenuName = "配方下发",
  83. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  84. AssemblyName = "BPASmartClient.DosingSystem",
  85. ToggleWindowPath = "View.RecipeControlView"
  86. });
  87. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  88. {
  89. MainMenuIcon = "&#xe683;",
  90. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  91. MainMenuName = "配方管理",
  92. Alias = "Recipe Management",
  93. subMenumodels = RecipeManage,
  94. });
  95. #endregion
  96. #region 参数设置
  97. ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
  98. ParSet.Add(new SubMenumodel()
  99. {
  100. SubMenuName = "原料参数设置",
  101. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  102. AssemblyName = "BPASmartClient.DosingSystem",
  103. ToggleWindowPath = "View.DeviceMaterialParView"
  104. });
  105. ParSet.Add(new SubMenumodel()
  106. {
  107. SubMenuName = "设备参数设置",
  108. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  109. AssemblyName = "BPASmartClient.DosingSystem",
  110. ToggleWindowPath = "View.CommParSetView"
  111. });
  112. //ParSet.Add(new SubMenumodel()
  113. //{
  114. // SubMenuName = "出料口管理设置",
  115. // SubMenuPermission = new Permission[] { Permission.管理员 },
  116. // AssemblyName = "BPASmartClient.DosingSystem",
  117. // ToggleWindowPath = "View.OutletManagementView"
  118. //});
  119. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  120. {
  121. MainMenuIcon = "&#xe62d;",
  122. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  123. MainMenuName = "参数设置",
  124. Alias = "Parameter Set",
  125. subMenumodels = ParSet,
  126. });
  127. #endregion
  128. #region 手动控制
  129. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  130. ManualControl.Add(new SubMenumodel()
  131. {
  132. SubMenuName = "气缸手动控制",
  133. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  134. AssemblyName = "BPASmartClient.DosingSystem",
  135. ToggleWindowPath = "View.ManualControlView"
  136. });
  137. ManualControl.Add(new SubMenumodel()
  138. {
  139. SubMenuName = "输送带手动控制",
  140. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  141. AssemblyName = "BPASmartClient.DosingSystem",
  142. ToggleWindowPath = "View.ConveyerBeltManualView"
  143. });
  144. ManualControl.Add(new SubMenumodel()
  145. {
  146. SubMenuName = "配料输送带控制",
  147. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  148. AssemblyName = "BPASmartClient.DosingSystem",
  149. ToggleWindowPath = "View.TempManageControlView"
  150. });
  151. //ManualControl.Add(new SubMenumodel()
  152. //{
  153. // SubMenuName = "料仓控制",
  154. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  155. // AssemblyName = "BPASmartClient.DosingSystem",
  156. // ToggleWindowPath = "View.StockControlView"
  157. //});
  158. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  159. {
  160. MainMenuIcon = "&#xe622;",
  161. MainMenuName = "手动控制",
  162. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  163. Alias = "Parameter Set",
  164. subMenumodels = ManualControl,
  165. });
  166. #endregion
  167. #region 消息日志
  168. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  169. InfoLog.Add(new SubMenumodel()
  170. {
  171. SubMenuName = "操作日志",
  172. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  173. AssemblyName = "BPASmartClient.CustomResource",
  174. ToggleWindowPath = "Pages.View.UserLogView"
  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.RunLogView"
  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.AlarmView"
  189. });
  190. InfoLog.Add(new SubMenumodel()
  191. {
  192. SubMenuName = "调试日志",
  193. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  194. AssemblyName = "BPASmartClient.CustomResource",
  195. ToggleWindowPath = "Pages.View.DebugLogView"
  196. });
  197. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  198. {
  199. MainMenuIcon = "&#xe668;",
  200. MainMenuName = "消息日志",
  201. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  202. Alias = "Message Log",
  203. subMenumodels = InfoLog,
  204. });
  205. #endregion
  206. #region 硬件设备监控
  207. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  208. DeviceMonitor.Add(new SubMenumodel()
  209. {
  210. SubMenuName = "原料设备列表",
  211. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  212. AssemblyName = "BPASmartClient.DosingSystem",
  213. ToggleWindowPath = "View.DeviceListView"
  214. });
  215. DeviceMonitor.Add(new SubMenumodel()
  216. {
  217. SubMenuName = "设备状态",
  218. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  219. AssemblyName = "BPASmartClient.DosingSystem",
  220. ToggleWindowPath = "View.HardwareStatusView"
  221. });
  222. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  223. {
  224. MainMenuIcon = "&#xe603;",
  225. MainMenuName = "设备监控",
  226. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  227. Alias = "Device Monitor",
  228. subMenumodels = DeviceMonitor,
  229. });
  230. #endregion
  231. #region 用户管理
  232. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  233. UserManager.Add(new SubMenumodel()
  234. {
  235. SubMenuName = "用户登录",
  236. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  237. AssemblyName = "BPASmartClient.CustomResource",
  238. ToggleWindowPath = "Pages.View.SubPagLoginView"
  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.PasswordChangeView"
  246. });
  247. UserManager.Add(new SubMenumodel()
  248. {
  249. SubMenuName = "用户管理",
  250. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
  251. AssemblyName = "BPASmartClient.CustomResource",
  252. ToggleWindowPath = "Pages.View.UserManagerView"
  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. }
  267. }
  268. }