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

App.xaml.cs 13 KiB

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