SettingViewModel.cs 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769
  1. using ICSharpCode.AvalonEdit.Search;
  2. using MaterialDesignThemes.Wpf;
  3. using NPOI.SS.Formula.Functions;
  4. using Opc.Ua;
  5. using Prism.Commands;
  6. using Prism.Events;
  7. using Prism.Ioc;
  8. using Prism.Mvvm;
  9. using Prism.Regions;
  10. using Prism.Services.Dialogs;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.ComponentModel;
  15. using System.Drawing.Drawing2D;
  16. using System.Globalization;
  17. using System.IO;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Web;
  21. using System.Windows;
  22. using Team.FFFeederService.Interfaces;
  23. using TeamAAS_VP.Controls;
  24. using TeamAAS_VP.Core;
  25. using TeamAAS_VP.Core.Cameras;
  26. using TeamAAS_VP.Core.Lights;
  27. using TeamAAS_VP.Enums;
  28. using TeamAAS_VP.Events;
  29. using TeamAAS_VP.Interfaces;
  30. using TeamAAS_VP.Models;
  31. using TeamAAS_VP.Models.Lights;
  32. using TeamAAS_VP.Models.Scanner;
  33. using TeamAAS_VP.Resources.Languages;
  34. using TeamAAS_VP.Services;
  35. using TeamAAS_VP.ViewModels.User;
  36. using TouchSocket.Core;
  37. using WPFLocalizeExtension.Engine;
  38. namespace TeamAAS_VP.ViewModels
  39. {
  40. public class SettingViewModel : BindableBase, IConfirmNavigationRequest
  41. {
  42. IRegionManager _regionManager;
  43. IEventAggregator _eventAggregator;
  44. IContainerProvider _container;
  45. IDialogService _dialogService;
  46. IConfigService _configService;
  47. IRobotService _robotService;
  48. IScannerService _scannerService;
  49. ICameraService _cameraService;
  50. IFeederService _feeder_service;
  51. IFeederService _feederService;
  52. IPlcService _plcService;
  53. IProductService _productService;
  54. ISystemDatabaseService _systemDatabaseService;
  55. bool isFirstLoad = true;
  56. #region 属性
  57. private ScanRs232ConfigModel _ScanConfig;
  58. public ScanRs232ConfigModel ScanConfig
  59. {
  60. get { return _ScanConfig; }
  61. set { SetProperty(ref _ScanConfig, value); }
  62. }
  63. private bool _IsSaveScrewCurve;
  64. /// <summary>
  65. /// 是否保存锁付曲线图
  66. /// </summary>
  67. public bool IsSaveScrewCurve
  68. {
  69. get { return _IsSaveScrewCurve; }
  70. set { SetProperty(ref _IsSaveScrewCurve, value); }
  71. }
  72. private Management _management;
  73. public Management management
  74. {
  75. get { return _management; }
  76. set { SetProperty(ref _management, value); }
  77. }
  78. private ObservableCollection<RobotInfo> _RobotList;
  79. public ObservableCollection<RobotInfo> RobotList
  80. {
  81. get { return _RobotList; }
  82. set { SetProperty(ref _RobotList, value); }
  83. }
  84. private ObservableCollection<ScannerInfo> _ScannerList;
  85. public ObservableCollection<ScannerInfo> ScannerList
  86. {
  87. get { return _ScannerList; }
  88. set { SetProperty(ref _ScannerList, value); }
  89. }
  90. private ObservableCollection<CameraInfo> _CameraList;
  91. public ObservableCollection<CameraInfo> CameraList
  92. {
  93. get { return _CameraList; }
  94. set { SetProperty(ref _CameraList, value); }
  95. }
  96. private ObservableCollection<FeederInfo> _FeederList;
  97. public ObservableCollection<FeederInfo> FeederList
  98. {
  99. get { return _FeederList; }
  100. set { SetProperty(ref _FeederList, value); }
  101. }
  102. private ObservableCollection<PlcInfo> _PlcList;
  103. public ObservableCollection<PlcInfo> PlcList
  104. {
  105. get { return _PlcList; }
  106. set { SetProperty(ref _PlcList, value); }
  107. }
  108. private Language _CurrentLanguage;
  109. public Language CurrentLanguage
  110. {
  111. get { return _CurrentLanguage; }
  112. set { SetProperty(ref _CurrentLanguage, value); }
  113. }
  114. private RobotInfo _SelectRobot;
  115. /// <summary>
  116. /// 选中的机器人
  117. /// </summary>
  118. public RobotInfo SelectRobot
  119. {
  120. get { return _SelectRobot; }
  121. set
  122. {
  123. SetProperty(ref _SelectRobot, value);
  124. if (value != null && (value.RobotBrand == RobotBrand.XYZ_Platform || value.RobotBrand == RobotBrand.XYZU_Platform))
  125. {
  126. RobotSelectedPlc = PlcList.FirstOrDefault(p => p.Id == value.PLC);
  127. var root = _robotService.GetRobot(SelectRobot.Id);
  128. if (root != null)
  129. {
  130. //ResultsValues.Clear();
  131. //var res = root.GetNodesValue();
  132. //for (int i = 0; i < res.Count; i++)
  133. //{
  134. // if (res[i].StatusCode.Code != 2150891520)
  135. // {
  136. // ResultsValues.Add(res[i].Value.ToString());
  137. // }
  138. // else
  139. // {
  140. // break;
  141. // }
  142. //}
  143. }
  144. }
  145. }
  146. }
  147. private ScannerInfo _SelectScanner;
  148. /// <summary>
  149. /// 选中的扫码枪
  150. /// </summary>
  151. public ScannerInfo SelectScanner
  152. {
  153. get { return _SelectScanner; }
  154. set
  155. {
  156. SetProperty(ref _SelectScanner, value);
  157. }
  158. }
  159. private FeederInfo _SelectFeeder;
  160. /// <summary>
  161. /// 选中的Feeder
  162. /// </summary>
  163. public FeederInfo SelectFeeder
  164. {
  165. get { return _SelectFeeder; }
  166. set { SetProperty(ref _SelectFeeder, value); }
  167. }
  168. private PlcInfo _SelectPlc;
  169. public PlcInfo SelectPlc
  170. {
  171. get { return _SelectPlc; }
  172. set { SetProperty(ref _SelectPlc, value); }
  173. }
  174. private ObservableCollection<ProductModel> _ProductList;
  175. public ObservableCollection<ProductModel> ProductList
  176. {
  177. get { return _ProductList; }
  178. set { SetProperty(ref _ProductList, value); }
  179. }
  180. private ObservableCollection<string> _ResultsValues = new ObservableCollection<string>();
  181. public ObservableCollection<string> ResultsValues { get => _ResultsValues; set => _ResultsValues = value; }
  182. private CameraInfo _SelectCamera;
  183. /// <summary>
  184. /// 选中的Camera
  185. /// </summary>
  186. public CameraInfo SelectCamera
  187. {
  188. get { return _SelectCamera; }
  189. set { SetProperty(ref _SelectCamera, value); }
  190. }
  191. private double _Title1;
  192. public double Title1
  193. {
  194. get { return _Title1; }
  195. set { SetProperty(ref _Title1, value); }
  196. }
  197. private double _Title2;
  198. public double Title2
  199. {
  200. get { return _Title2; }
  201. set { SetProperty(ref _Title2, value); }
  202. }
  203. private double _Title3;
  204. public double Title3
  205. {
  206. get { return _Title3; }
  207. set { SetProperty(ref _Title3, value); }
  208. }
  209. private double _Title4;
  210. public double Title4
  211. {
  212. get { return _Title4; }
  213. set { SetProperty(ref _Title4, value); }
  214. }
  215. private double _Body1;
  216. public double Body1
  217. {
  218. get { return _Body1; }
  219. set { SetProperty(ref _Body1, value); }
  220. }
  221. private double _Body2;
  222. public double Body2
  223. {
  224. get { return _Body2; }
  225. set { SetProperty(ref _Body2, value); }
  226. }
  227. private double _Body3;
  228. public double Body3
  229. {
  230. get { return _Body3; }
  231. set { SetProperty(ref _Body3, value); }
  232. }
  233. private double _Body4;
  234. public double Body4
  235. {
  236. get { return _Body4; }
  237. set { SetProperty(ref _Body4, value); }
  238. }
  239. private double _Captions1;
  240. public double Captions1
  241. {
  242. get { return _Captions1; }
  243. set { SetProperty(ref _Captions1, value); }
  244. }
  245. private double _Captions2;
  246. public double Captions2
  247. {
  248. get { return _Captions2; }
  249. set { SetProperty(ref _Captions2, value); }
  250. }
  251. private double _Captions3;
  252. public double Captions3
  253. {
  254. get { return _Captions3; }
  255. set { SetProperty(ref _Captions3, value); }
  256. }
  257. private double _Captions4;
  258. public double Captions4
  259. {
  260. get { return _Captions4; }
  261. set { SetProperty(ref _Captions4, value); }
  262. }
  263. private PlcInfo _RobotSelectedPlc;
  264. public PlcInfo RobotSelectedPlc
  265. {
  266. get { return _RobotSelectedPlc; }
  267. set
  268. {
  269. SetProperty(ref _RobotSelectedPlc, value);
  270. if (SelectRobot != null)
  271. {
  272. if (value != null)
  273. {
  274. SelectRobot.PLC = value.Id;
  275. }
  276. else
  277. {
  278. SelectRobot.PLC = Guid.Empty;
  279. }
  280. }
  281. }
  282. }
  283. private BgModbusTcp _BgModbus;
  284. public BgModbusTcp BgModbus
  285. {
  286. get { return _BgModbus; }
  287. set { SetProperty(ref _BgModbus, value); }
  288. }
  289. private BgTcpIP _BgTcp;
  290. public BgTcpIP BgTcp
  291. {
  292. get { return _BgTcp; }
  293. set { SetProperty(ref _BgTcp, value); }
  294. }
  295. private ObservableCollection<LightControllerConfig> _LightControllerList;
  296. public ObservableCollection<LightControllerConfig> LightControllerList
  297. {
  298. get { return _LightControllerList; }
  299. set { SetProperty(ref _LightControllerList, value); }
  300. }
  301. private LightControllerConfig _SelectLightController;
  302. public LightControllerConfig SelectLightController
  303. {
  304. get { return _SelectLightController; }
  305. set { SetProperty(ref _SelectLightController, value); }
  306. }
  307. private string _ScrewCurvePath;
  308. /// <summary>
  309. /// 锁付曲线图保存路径
  310. /// </summary>
  311. public string ScrewCurvePath
  312. {
  313. get { return _ScrewCurvePath; }
  314. set { SetProperty(ref _ScrewCurvePath, value); }
  315. }
  316. private DeviceInfo _DeviceInfo;
  317. public DeviceInfo DeviceInfo
  318. {
  319. get { return _DeviceInfo; }
  320. set { SetProperty(ref _DeviceInfo, value); }
  321. }
  322. private SerialPortConfig _CardReaderConfig;
  323. public SerialPortConfig CardReaderConfig
  324. {
  325. get { return _CardReaderConfig; }
  326. set { SetProperty(ref _CardReaderConfig, value); }
  327. }
  328. private ProductWithMes _ProMesInfo = new ProductWithMes();
  329. public ProductWithMes ProMesInfo
  330. {
  331. get { return _ProMesInfo; }
  332. set { SetProperty(ref _ProMesInfo, value); }
  333. }
  334. private ProductModel _SelectProduct;
  335. public ProductModel SelectProduct
  336. {
  337. get { return _SelectProduct; }
  338. set { SetProperty(ref _SelectProduct, value); }
  339. }
  340. #endregion
  341. #region 命令
  342. public DelegateCommand LoadedCommand { get; set; }
  343. private DelegateCommand _SaveSystemParametersCommand;
  344. public DelegateCommand SaveSystemParametersCommand =>
  345. _SaveSystemParametersCommand ?? (_SaveSystemParametersCommand = new DelegateCommand(ExecuteSaveSystemParametersCommand));
  346. private DelegateCommand _AddRobotCommand;
  347. public DelegateCommand AddRobotCommand =>
  348. _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
  349. private DelegateCommand _AddScannerCommand;
  350. public DelegateCommand AddScannerCommand =>
  351. _AddScannerCommand ?? (_AddScannerCommand = new DelegateCommand(ExecuteAddScannerCommand));
  352. private DelegateCommand _RemoveCommand;
  353. public DelegateCommand RemoveCommand =>
  354. _RemoveCommand ?? (_RemoveCommand = new DelegateCommand(ExecuteRemoveCommand));
  355. private DelegateCommand _RemoveScannerCommand;
  356. public DelegateCommand RemoveScannerCommand =>
  357. _RemoveScannerCommand ?? (_RemoveScannerCommand = new DelegateCommand(ExecuteRemoveScannerCommand));
  358. private DelegateCommand _AddFeederCommand;
  359. public DelegateCommand AddFeederCommand =>
  360. _AddFeederCommand ?? (_AddFeederCommand = new DelegateCommand(ExecuteAddFeederCommand));
  361. private DelegateCommand _RemoveFeederCommand;
  362. public DelegateCommand RemoveFeederCommand =>
  363. _RemoveFeederCommand ?? (_RemoveFeederCommand = new DelegateCommand(ExecuteRemoveFeederCommand));
  364. private DelegateCommand<string> _SelectLanguageCommand;
  365. public DelegateCommand<string> SelectLanguageCommand =>
  366. _SelectLanguageCommand ?? (_SelectLanguageCommand = new DelegateCommand<string>(ExecuteSelectLanguageCommand));
  367. private DelegateCommand _SaveRobotsCommand;
  368. public DelegateCommand SaveRobotsCommand =>
  369. _SaveRobotsCommand ?? (_SaveRobotsCommand = new DelegateCommand(ExecuteSaveRobotsCommand));
  370. private DelegateCommand _SaveScannerCommand;
  371. public DelegateCommand SaveScannerCommand =>
  372. _SaveScannerCommand ?? (_SaveScannerCommand = new DelegateCommand(ExecuteSaveScannersCommand));
  373. private DelegateCommand _SaveFeedersCommand;
  374. public DelegateCommand SaveFeedersCommand =>
  375. _SaveFeedersCommand ?? (_SaveFeedersCommand = new DelegateCommand(ExecuteSaveFeedersCommand));
  376. private DelegateCommand<string> _SaveCommunicateCommand;
  377. public DelegateCommand<string> SaveCommunicateCommand =>
  378. _SaveCommunicateCommand ?? (_SaveCommunicateCommand = new DelegateCommand<string>(ExecuteSaveCommunicateCommand));
  379. private DelegateCommand _AddCameraCommand;
  380. public DelegateCommand AddCameraCommand =>
  381. _AddCameraCommand ?? (_AddCameraCommand = new DelegateCommand(ExecuteAddCameraCommand));
  382. private DelegateCommand _EditCameraCommand;
  383. public DelegateCommand EditCameraCommand =>
  384. _EditCameraCommand ?? (_EditCameraCommand = new DelegateCommand(ExecuteEditCameraCommand));
  385. private DelegateCommand _RemoveCameraCommand;
  386. public DelegateCommand RemoveCameraCommand =>
  387. _RemoveCameraCommand ?? (_RemoveCameraCommand = new DelegateCommand(ExecuteRemoveCameraCommand));
  388. private DelegateCommand _SaveCamerasCommand;
  389. public DelegateCommand SaveCamerasCommand =>
  390. _SaveCamerasCommand ?? (_SaveCamerasCommand = new DelegateCommand(ExecuteSaveCamerasCommand));
  391. private DelegateCommand _AddPlcCommand;
  392. public DelegateCommand AddPlcCommand =>
  393. _AddPlcCommand ?? (_AddPlcCommand = new DelegateCommand(ExecuteAddPlcCommand));
  394. private DelegateCommand _RemovePlcCommand;
  395. public DelegateCommand RemovePlcCommand =>
  396. _RemovePlcCommand ?? (_RemovePlcCommand = new DelegateCommand(ExecuteRemovePlcCommand));
  397. private DelegateCommand _SavePlcsCommand;
  398. public DelegateCommand SavePlcsCommand =>
  399. _SavePlcsCommand ?? (_SavePlcsCommand = new DelegateCommand(ExecuteSavePlcsCommand));
  400. private DelegateCommand _AddLightControllerCommand;
  401. public DelegateCommand AddLightControllerCommand => _AddLightControllerCommand ?? (_AddLightControllerCommand = new DelegateCommand(ExecuteAddLightControllerCommand));
  402. private DelegateCommand _RemoveLightControllerCommand;
  403. public DelegateCommand RemoveLightControllerCommand => _RemoveLightControllerCommand ?? (_RemoveLightControllerCommand = new DelegateCommand(ExecuteRemoveLightControllerCommand));
  404. private DelegateCommand _SaveLightControllersCommand;
  405. public DelegateCommand SaveLightControllersCommand => _SaveLightControllersCommand ?? (_SaveLightControllersCommand = new DelegateCommand(ExecuteSaveLightControllersCommand));
  406. private DelegateCommand _BrowseScrewCurvePathCommand;
  407. public DelegateCommand BrowseScrewCurvePathCommand => _BrowseScrewCurvePathCommand ?? (_BrowseScrewCurvePathCommand = new DelegateCommand(ExecuteBrowseScrewCurvePathCommand));
  408. private DelegateCommand _SaveDeviceInfoCommand;
  409. public DelegateCommand SaveDeviceInfoCommand => _SaveDeviceInfoCommand ?? (_SaveDeviceInfoCommand = new DelegateCommand(ExecuteSaveDeviceInfoCommand));
  410. private DelegateCommand _SelectSaveImagePathCommand;
  411. public DelegateCommand SelectSaveImagePathCommand =>
  412. _SelectSaveImagePathCommand ?? (_SelectSaveImagePathCommand = new DelegateCommand(ExecuteSelectSaveImagePathCommand));
  413. private DelegateCommand _SaveCardReaderConfigCommand;
  414. public DelegateCommand SaveCardReaderConfigCommand =>
  415. _SaveCardReaderConfigCommand ?? (_SaveCardReaderConfigCommand = new DelegateCommand(ExecuteSaveCardReaderConfigCommand));
  416. private DelegateCommand _GetProWithMesCommand;
  417. public DelegateCommand GetProWithMesCommand =>
  418. _GetProWithMesCommand ?? (_GetProWithMesCommand = new DelegateCommand(ExecuteGetProWithMesCommand));
  419. private DelegateCommand _DeleteProWithMesCommand;
  420. public DelegateCommand DeleteProWithMesCommand =>
  421. _DeleteProWithMesCommand ?? (_DeleteProWithMesCommand = new DelegateCommand(ExecuteDeleteProWithMesCommand));
  422. private DelegateCommand _SaveProWithMesCommand;
  423. public DelegateCommand SaveProWithMesCommand =>
  424. _SaveProWithMesCommand ?? (_SaveProWithMesCommand = new DelegateCommand(ExecuteSaveProWithMesCommandAsync));
  425. private DelegateCommand _CheckStatusCommand;
  426. public DelegateCommand CheckStatusCommand =>
  427. _CheckStatusCommand ?? (_CheckStatusCommand = new DelegateCommand(ExecuteCheckStatusCommandCommand));
  428. #endregion
  429. #region 事件
  430. #endregion
  431. public SettingViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService,
  432. IConfigService configService, IRobotService robotService, ICameraService cameraService, IFeederService feederService, IPlcService plcService,
  433. IProductService productService, ISystemDatabaseService systemDatabaseService,IScannerService scannerService)
  434. {
  435. _regionManager = regionManager;
  436. _eventAggregator = ea;
  437. _container = container;
  438. _dialogService = dialogService;
  439. _configService = configService;
  440. _robotService = robotService;
  441. _cameraService = cameraService;
  442. _feederService = feederService;
  443. _plcService = plcService;
  444. _productService = productService;
  445. _scannerService = scannerService;
  446. _systemDatabaseService = systemDatabaseService;
  447. management = _container.Resolve<Management>();
  448. LoadedCommand = new DelegateCommand(OnLoad);
  449. //订阅权限登录事件
  450. _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
  451. }
  452. #region 方法
  453. #region 扫码枪
  454. private void ExecuteAddScannerCommand()
  455. {
  456. _dialogService.ShowDialog("AddScanner", rst =>
  457. {
  458. //对话框关闭之后的回调函数,可以在这解析结果。
  459. ButtonResult result1 = rst.Result;
  460. if (result1 == ButtonResult.OK)
  461. {
  462. var param = rst.Parameters.GetValue<ScannerInfo>("Scanner");
  463. var scanner = new ScannerInfo()
  464. {
  465. Id = param.Id,
  466. ScannerName = param.ScannerName,
  467. ConnectType = param.ConnectType,
  468. ScannerBrand = param.ScannerBrand,
  469. IP = param.IP,
  470. Port = param.Port,
  471. Terminator = param.Terminator,
  472. };
  473. ScannerList.Add(scanner);
  474. _configService.AddOrUpdateScanner(scanner);
  475. _scannerService.CreateScanner(scanner.Id, scanner);
  476. //对所有产品也进行添加
  477. _productService.AddScannerPointToProduct(scanner.Id, scanner.ScannerName);
  478. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
  479. }
  480. });
  481. }
  482. void ExecuteRemoveScannerCommand()
  483. {
  484. if (MessageBox.Show(Lang.是否移除扫码枪, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  485. {
  486. // 找到要删除的扫描枪
  487. var scannerToRemove = ScannerList.FirstOrDefault(s => s.Id == SelectScanner.Id);
  488. if (scannerToRemove != null)
  489. {
  490. ScannerList.Remove(scannerToRemove);
  491. _configService.RemoveScanner(scannerToRemove.Id);
  492. _scannerService.RemoveScanner(scannerToRemove.Id);
  493. //对所有产品也进行移除
  494. _productService.RemoveScannerPointFromProduct(scannerToRemove.Id);
  495. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  496. }
  497. }
  498. }
  499. async void ExecuteSaveScannersCommand()
  500. {
  501. var view = new ShowMessage($"AAS", Lang.是否保存扫码枪);
  502. //show the dialog
  503. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  504. if (result != null && result is bool)
  505. {
  506. if (((bool)result))
  507. {
  508. foreach (var item in ScannerList)
  509. {
  510. _configService.AddOrUpdateScanner(item);
  511. }
  512. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  513. }
  514. }
  515. }
  516. #endregion
  517. #region 机器人
  518. private void ExecuteAddRobotCommand()
  519. {
  520. _dialogService.ShowDialog("AddRobot", rst =>
  521. {
  522. //对话框关闭之后的回调函数,可以在这解析结果。
  523. ButtonResult result1 = rst.Result;
  524. if (result1 == ButtonResult.OK)
  525. {
  526. var param = rst.Parameters.GetValue<RobotInfo>("Robot");
  527. var robot = new RobotInfo()
  528. {
  529. Id = param.Id,
  530. RobotName = param.RobotName,
  531. ConnectType = param.ConnectType,
  532. RobotBrand = param.RobotBrand,
  533. IP = param.IP,
  534. Port = param.Port,
  535. Terminator = param.Terminator,
  536. };
  537. RobotList.Add(robot);
  538. _configService.AddOrUpdateRobot(robot);
  539. _robotService.CreateRobot(robot.Id, robot);
  540. //对所有产品也进行添加
  541. _productService.AddRobotPointToProduct(robot.Id, robot.RobotName);
  542. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
  543. }
  544. });
  545. }
  546. void ExecuteRemoveCommand()
  547. {
  548. if (MessageBox.Show(Lang.是否移除机器人, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  549. {
  550. // 找到要删除的机器人
  551. var robotToRemove = RobotList.FirstOrDefault(r => r.Id == SelectRobot.Id);
  552. if (robotToRemove != null)
  553. {
  554. RobotList.Remove(robotToRemove);
  555. _configService.RemoveRobot(robotToRemove.Id);
  556. _robotService.RemoveRobot(robotToRemove.Id);
  557. //对所有产品也进行移除
  558. _productService.RemoveRobotPointFromProduct(robotToRemove.Id);
  559. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  560. }
  561. }
  562. }
  563. async void ExecuteSaveRobotsCommand()
  564. {
  565. var view = new ShowMessage($"AAS", Lang.是否保存机器人);
  566. //show the dialog
  567. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  568. if (result != null && result is bool)
  569. {
  570. if (((bool)result))
  571. {
  572. foreach (var item in RobotList)
  573. {
  574. _configService.AddOrUpdateRobot(item);
  575. }
  576. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  577. }
  578. }
  579. }
  580. #endregion
  581. #region 相机
  582. /// <summary>
  583. /// 保存所有相机
  584. /// </summary>
  585. async void ExecuteSaveCamerasCommand()
  586. {
  587. var view = new ShowMessage($"AAS", Lang.是否保存相机配置);
  588. //show the dialog
  589. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  590. if (result != null && result is bool)
  591. {
  592. if (((bool)result))
  593. {
  594. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  595. //management.SaveCamerasDeviceConfig();
  596. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  597. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  598. }
  599. }
  600. }
  601. /// <summary>
  602. /// 移除相机
  603. /// </summary>
  604. void ExecuteRemoveCameraCommand()
  605. {
  606. if (MessageBox.Show(Lang.是否移除相机, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  607. {
  608. // 找到要删除的相机
  609. var cameraToRemove = CameraList.FirstOrDefault(r => r.Id == SelectCamera.Id);
  610. if (cameraToRemove != null)
  611. {
  612. _configService.RemoveCamera(cameraToRemove.Id);
  613. _cameraService.RemoveCamera(cameraToRemove.Id);
  614. var root = _configService.GetAllCameras();
  615. CameraList = new ObservableCollection<CameraInfo>(root);
  616. foreach (var item in CameraList)
  617. {
  618. _cameraService.UpdateCameraNumber(item.Id, item.CameraNo);
  619. }
  620. //对所有产品也进行移除
  621. _productService.RemoveCameraFromProduct(cameraToRemove.Id);
  622. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  623. }
  624. }
  625. }
  626. /// <summary>
  627. /// 编辑相机
  628. /// </summary>
  629. void ExecuteEditCameraCommand()
  630. {
  631. if (SelectCamera == null) return;
  632. bool isSelectedCameraBrandSucced = false;
  633. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  634. IDialogParameters parameters1 = new DialogParameters();
  635. parameters1.Add("CameraBrand", SelectCamera.CameraBrand);
  636. _dialogService.ShowDialog("SelectCameraBrand", parameters1, rst =>
  637. {
  638. if (rst.Result == ButtonResult.OK)
  639. {
  640. isSelectedCameraBrandSucced = true;
  641. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  642. }
  643. else
  644. {
  645. return;
  646. }
  647. });
  648. if (!isSelectedCameraBrandSucced) { return; }
  649. (bool isInstalled, string version) result = (false, "");
  650. string softwarename = "";
  651. switch (cameraBrand)
  652. {
  653. case CameraBrand.HikRobot_MVS:
  654. softwarename = "MVS";
  655. result = MvCamera.CheckSoftwareInstalled();
  656. break;
  657. case CameraBrand.Basler_Pylon:
  658. softwarename = "Pylon 7";
  659. result = BaslerCamera.CheckSoftwareInstalled();
  660. break;
  661. case CameraBrand.IRayple:
  662. softwarename = "MV Viewer";
  663. result = AHuaCamera.CheckSoftwareInstalled();
  664. break;
  665. case CameraBrand.Cognex:
  666. softwarename = "Cognex VisionPro";
  667. result = CognexCamera.CheckSoftwareInstalled();
  668. break;
  669. case CameraBrand.Galaxy:
  670. softwarename = "Galaxy Viewer";
  671. result = GalaxyCamera.CheckSoftwareInstalled();
  672. break;
  673. case CameraBrand.Opt:
  674. softwarename = "OPT Camera Viewer";
  675. result = OptCamera.CheckSoftwareInstalled();
  676. break;
  677. case CameraBrand.SSZN:
  678. softwarename = "SSZN Camera Viewer";
  679. result = SSZNCamera.CheckSoftwareInstalled();
  680. break;
  681. case CameraBrand.IKap:
  682. softwarename = "Ikap Camera Viewer";
  683. result = IKapCamera.CheckSoftwareInstalled();
  684. break;
  685. default:
  686. break;
  687. }
  688. if (!result.isInstalled)
  689. {
  690. if (string.IsNullOrEmpty(result.version))
  691. {
  692. //未安装
  693. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  694. }
  695. else
  696. {
  697. //版本较低
  698. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  699. }
  700. return;
  701. }
  702. //编辑前的相机名称
  703. string oldCameraName = SelectCamera.CameraName;
  704. IDialogParameters parameters = new DialogParameters();
  705. parameters.Add("CameraBrand", cameraBrand);
  706. parameters.Add("Camera", SelectCamera.Copy());
  707. _dialogService.ShowDialog("EditCamera", parameters, rst =>
  708. {
  709. //对话框关闭之后的回调函数,可以在这解析结果。
  710. ButtonResult result1 = rst.Result;
  711. if (result1 == ButtonResult.OK)
  712. {
  713. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  714. SelectCamera.CameraName = param.CameraName;
  715. SelectCamera.SerialNumber = param.SerialNumber;
  716. SelectCamera.Model = param.Model;
  717. SelectCamera.ManufacturerName = param.ManufacturerName;
  718. SelectCamera.CameraType = param.CameraType;
  719. SelectCamera.CameraBrand = param.CameraBrand;
  720. SelectCamera.CameraIp = param.CameraIp;
  721. _configService.AddOrUpdateCamera(SelectCamera);
  722. if (oldCameraName != param.CameraName)
  723. {
  724. //对所有产品也进行修改
  725. _productService.UpdateCameraNameInProduct(SelectCamera.Id, SelectCamera.CameraName);
  726. }
  727. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  728. }
  729. });
  730. }
  731. /// <summary>
  732. /// 增加相机
  733. /// </summary>
  734. void ExecuteAddCameraCommand()
  735. {
  736. bool isSelectedCameraBrandSucced = false;
  737. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  738. _dialogService.ShowDialog("SelectCameraBrand", rst =>
  739. {
  740. if (rst.Result == ButtonResult.OK)
  741. {
  742. isSelectedCameraBrandSucced = true;
  743. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  744. }
  745. else
  746. {
  747. return;
  748. }
  749. });
  750. if (!isSelectedCameraBrandSucced) { return; }
  751. ;
  752. (bool isInstalled, string version) result = (false, "");
  753. string softwarename = "";
  754. switch (cameraBrand)
  755. {
  756. case CameraBrand.HikRobot_MVS:
  757. softwarename = "MVS";
  758. result = MvCamera.CheckSoftwareInstalled();
  759. break;
  760. case CameraBrand.Basler_Pylon:
  761. softwarename = "Pylon 7";
  762. result = BaslerCamera.CheckSoftwareInstalled();
  763. break;
  764. case CameraBrand.IRayple:
  765. softwarename = "MV Viewer";
  766. result = AHuaCamera.CheckSoftwareInstalled();
  767. break;
  768. case CameraBrand.Cognex:
  769. softwarename = "Cognex VisionPro";
  770. result = CognexCamera.CheckSoftwareInstalled();
  771. break;
  772. case CameraBrand.Galaxy:
  773. softwarename = "Galaxy Viewer";
  774. result = GalaxyCamera.CheckSoftwareInstalled();
  775. break;
  776. case CameraBrand.Opt:
  777. softwarename = "OPT Camera Viewer";
  778. result = OptCamera.CheckSoftwareInstalled();
  779. break;
  780. case CameraBrand.SSZN:
  781. softwarename = "SSZN Camera Viewer";
  782. result = OptCamera.CheckSoftwareInstalled();
  783. break;
  784. default:
  785. break;
  786. }
  787. if (!result.isInstalled)
  788. {
  789. if (string.IsNullOrEmpty(result.version))
  790. {
  791. //未安装
  792. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  793. }
  794. else
  795. {
  796. //版本较低
  797. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  798. }
  799. return;
  800. }
  801. IDialogParameters parameters = new DialogParameters();
  802. parameters.Add("CameraBrand", cameraBrand);
  803. _dialogService.ShowDialog("AddCamera", parameters, rst =>
  804. {
  805. //对话框关闭之后的回调函数,可以在这解析结果。
  806. ButtonResult result1 = rst.Result;
  807. if (result1 == ButtonResult.OK)
  808. {
  809. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  810. var camera = new CameraInfo()
  811. {
  812. Id = param.Id,
  813. CameraName = param.CameraName,
  814. SerialNumber = param.SerialNumber,
  815. Model = param.Model,
  816. ManufacturerName = param.ManufacturerName,
  817. CameraType = param.CameraType,
  818. CameraBrand = param.CameraBrand,
  819. CameraIp = param.CameraIp
  820. };
  821. CameraList.Add(camera);
  822. _configService.AddOrUpdateCamera(camera);
  823. _cameraService.CreateCamera(camera.Id, camera);
  824. //对所有产品也进行添加
  825. _productService.AddCameraToProduct(camera.Id, camera.CameraName);
  826. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  827. }
  828. });
  829. }
  830. #endregion
  831. #region Feeder
  832. void ExecuteAddFeederCommand()
  833. {
  834. _dialogService.ShowDialog("AddFeeder", rst =>
  835. {
  836. //对话框关闭之后的回调函数,可以在这解析结果。
  837. ButtonResult result1 = rst.Result;
  838. if (result1 == ButtonResult.OK)
  839. {
  840. var param = rst.Parameters.GetValue<FeederInfo>("Feeder");
  841. var feeder = new FeederInfo()
  842. {
  843. Id = param.Id,
  844. FeederName = param.FeederName,
  845. ConnectType = param.ConnectType,
  846. FeederBrand = param.FeederBrand,
  847. IP = param.IP,
  848. Port = param.Port
  849. };
  850. FeederList.Add(feeder);
  851. _configService.AddOrUpdateFeeder(feeder);
  852. _feederService.CreateFeeder(feeder.Id, feeder.FeederNo, feeder.FeederName, feeder.IP, feeder.Port, feeder.FeederBrand);
  853. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  854. }
  855. });
  856. }
  857. void ExecuteRemoveFeederCommand()
  858. {
  859. if (MessageBox.Show(Lang.是否移除Feeder, " AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  860. {
  861. // 找到要删除的机器人
  862. var feederToRemove = FeederList.FirstOrDefault(r => r.Id == SelectFeeder.Id);
  863. if (feederToRemove != null)
  864. {
  865. _configService.RemoveFeeder(feederToRemove.Id);
  866. _feederService.RemoveFeeder(feederToRemove.Id);
  867. var root = _configService.GetAllFeeders();
  868. FeederList = new ObservableCollection<FeederInfo>(root);
  869. foreach (var item in FeederList)
  870. {
  871. _feederService.UpdateFeederNo(item.Id, item.FeederNo);
  872. }
  873. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  874. }
  875. }
  876. }
  877. async void ExecuteSaveFeedersCommand()
  878. {
  879. var view = new ShowMessage($"AAS", Lang.是否保存Feeder);
  880. //show the dialog
  881. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  882. if (result != null && result is bool)
  883. {
  884. if (((bool)result))
  885. {
  886. foreach (var item in FeederList)
  887. {
  888. _configService.AddOrUpdateFeeder(item);
  889. }
  890. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  891. }
  892. }
  893. }
  894. #endregion
  895. #region PLC
  896. /// <summary>
  897. /// 保存PLC
  898. /// </summary>
  899. async void ExecuteSavePlcsCommand()
  900. {
  901. var view = new ShowMessage($"AAS", Lang.是否保存PLC);
  902. //show the dialog
  903. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  904. if (result != null && result is bool)
  905. {
  906. if (((bool)result))
  907. {
  908. foreach (var item in PlcList)
  909. {
  910. _configService.AddOrUpdatePlc(item);
  911. }
  912. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  913. }
  914. }
  915. }
  916. /// <summary>
  917. /// 移除PLC
  918. /// </summary>
  919. void ExecuteRemovePlcCommand()
  920. {
  921. if (MessageBox.Show(Lang.是否移除PLC, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  922. {
  923. // 找到要删除的plc
  924. var plcToRemove = PlcList.FirstOrDefault(r => r.Id == SelectPlc.Id);
  925. if (plcToRemove != null)
  926. {
  927. _configService.RemovePlc(plcToRemove.Id);
  928. _plcService.RemovePlc(plcToRemove.Id);
  929. var root = _configService.GetAllPlcs();
  930. PlcList = new ObservableCollection<PlcInfo>(root);
  931. foreach (var item in PlcList)
  932. {
  933. _plcService.UpdatePlcNumber(item.Id, item.Index);
  934. }
  935. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  936. }
  937. }
  938. }
  939. /// <summary>
  940. /// 增加PLC
  941. /// </summary>
  942. void ExecuteAddPlcCommand()
  943. {
  944. _dialogService.ShowDialog("AddPlc", rst =>
  945. {
  946. //对话框关闭之后的回调函数,可以在这解析结果。
  947. ButtonResult result1 = rst.Result;
  948. if (result1 == ButtonResult.OK)
  949. {
  950. var param = rst.Parameters.GetValue<PlcInfo>("PLC");
  951. var plc = new PlcInfo()
  952. {
  953. Id = param.Id,
  954. Name = param.Name,
  955. CommunicationType = param.CommunicationType,
  956. EndpointUrl = param.EndpointUrl,
  957. };
  958. PlcList.Add(plc);
  959. _configService.AddOrUpdatePlc(plc);
  960. _plcService.CreatePlc(plc.Id, plc);
  961. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  962. }
  963. });
  964. }
  965. #endregion
  966. #region Light handlers
  967. void ExecuteAddLightControllerCommand()
  968. {
  969. // open dialog to add light controller (similar to robots)
  970. _dialogService.ShowDialog("AddLightController", rst =>
  971. {
  972. if (rst.Result == ButtonResult.OK)
  973. {
  974. var param = rst.Parameters.GetValue<LightControllerConfig>("LightController");
  975. // assign id and defaults if needed
  976. if (param.Id == 0)
  977. param.Id = (LightControllerList?.Count ?? 0) + 1;
  978. LightControllerList.Add(param);
  979. _configService.AddOrUpdateLightController(param);
  980. SelectLightController = param;
  981. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "添加完成", Duration = 1 });
  982. }
  983. });
  984. }
  985. void ExecuteRemoveLightControllerCommand()
  986. {
  987. if (SelectLightController == null) return;
  988. if (MessageBox.Show("是否移除光源控制器?", "AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  989. {
  990. _configService.RemoveLightController(SelectLightController.Id);
  991. LightControllerList.Remove(SelectLightController);
  992. SelectLightController = null;
  993. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "移除完成", Duration = 1 });
  994. }
  995. }
  996. async void ExecuteSaveLightControllersCommand()
  997. {
  998. var view = new ShowMessage($"AAS", "是否保存光源控制器配置?");
  999. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  1000. if (result != null && result is bool && (bool)result)
  1001. {
  1002. foreach (var item in LightControllerList)
  1003. {
  1004. _configService.AddOrUpdateLightController(item);
  1005. }
  1006. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "完成", Duration = 1 });
  1007. }
  1008. }
  1009. #endregion
  1010. #region 通讯
  1011. async void ExecuteSaveCommunicateCommand(string parm)
  1012. {
  1013. if (parm == "TCPIP")
  1014. {
  1015. var view = new ShowMessage($"AAS", Lang.是否保存后台TCP通讯配置);
  1016. //show the dialog
  1017. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  1018. if (result != null && result is bool)
  1019. {
  1020. if (((bool)result))
  1021. {
  1022. _configService.SetBgTcp(BgTcp);
  1023. _configService.SaveBgTcp();
  1024. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  1025. }
  1026. }
  1027. }
  1028. else if (parm == "ModbusTCP")
  1029. {
  1030. var view = new ShowMessage($"AAS", Lang.是否保存后台ModbusTCP通讯配置);
  1031. //show the dialog
  1032. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  1033. if (result != null && result is bool)
  1034. {
  1035. if (((bool)result))
  1036. {
  1037. _configService.SetBgModbusTcp(BgModbus);
  1038. _configService.SaveBgModbusTcp();
  1039. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  1040. }
  1041. }
  1042. }
  1043. else
  1044. {
  1045. return;
  1046. }
  1047. }
  1048. #endregion
  1049. #region 语言
  1050. void ExecuteSelectLanguageCommand(string language)
  1051. {
  1052. if (string.Equals(language, "ChineseSimplified"))
  1053. {
  1054. CurrentLanguage = Enums.Language.ChineseSimplified;
  1055. var sysConfig = _configService.GetSystemConfiguration();
  1056. sysConfig.CurrentLanguage = CurrentLanguage;
  1057. _configService.SaveSystemConfiguration(sysConfig);
  1058. var culture = new CultureInfo("zh-CN");
  1059. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  1060. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  1061. LocalizeDictionary.Instance.Culture = culture;
  1062. Lang.Culture = culture;
  1063. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  1064. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  1065. }
  1066. else if (string.Equals(language, "ChineseTraditional"))
  1067. {
  1068. CurrentLanguage = Enums.Language.ChineseTraditional;
  1069. var sysConfig = _configService.GetSystemConfiguration();
  1070. sysConfig.CurrentLanguage = CurrentLanguage;
  1071. _configService.SaveSystemConfiguration(sysConfig);
  1072. var culture = new CultureInfo("zh-TW");
  1073. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  1074. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  1075. LocalizeDictionary.Instance.Culture = culture;
  1076. Lang.Culture = culture;
  1077. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  1078. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  1079. }
  1080. else if (string.Equals(language, "English"))
  1081. {
  1082. CurrentLanguage = Enums.Language.English;
  1083. var sysConfig = _configService.GetSystemConfiguration();
  1084. sysConfig.CurrentLanguage = CurrentLanguage;
  1085. _configService.SaveSystemConfiguration(sysConfig);
  1086. var culture = new CultureInfo("en");
  1087. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  1088. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  1089. LocalizeDictionary.Instance.Culture = culture;
  1090. Lang.Culture = culture;
  1091. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  1092. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  1093. }
  1094. else if (string.Equals(language, "Japanese"))
  1095. {
  1096. CurrentLanguage = Enums.Language.Japanese;
  1097. var sysConfig = _configService.GetSystemConfiguration();
  1098. sysConfig.CurrentLanguage = CurrentLanguage;
  1099. _configService.SaveSystemConfiguration(sysConfig);
  1100. var culture = new CultureInfo("ja-JP");
  1101. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  1102. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  1103. LocalizeDictionary.Instance.Culture = culture;
  1104. Lang.Culture = culture;
  1105. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  1106. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  1107. }
  1108. }
  1109. #endregion
  1110. private void OnLoad()
  1111. {
  1112. if (!File.Exists(FilePath.ScanRS232ConfigPath))
  1113. {
  1114. var scan = new ScanRs232ConfigModel();
  1115. FileHelper.WriteJsonFile(scan, FilePath.ScanRS232ConfigPath);
  1116. }
  1117. this.ScanConfig = FileHelper.ReadJsonFile<ScanRs232ConfigModel>(FilePath.ScanRS232ConfigPath);
  1118. }
  1119. private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
  1120. {
  1121. switch (e.PropertyName)
  1122. {
  1123. case "Title1":
  1124. Application.Current.Resources["Font.Size.Title1"] = Title1;
  1125. break;
  1126. case "Title2":
  1127. Application.Current.Resources["Font.Size.Title2"] = Title2;
  1128. break;
  1129. case "Title3":
  1130. Application.Current.Resources["Font.Size.Title3"] = Title3;
  1131. break;
  1132. case "Title4":
  1133. Application.Current.Resources["Font.Size.Title4"] = Title4;
  1134. break;
  1135. case "Body1":
  1136. Application.Current.Resources["Font.Size.Body1"] = Body1;
  1137. break;
  1138. case "Body2":
  1139. Application.Current.Resources["Font.Size.Body2"] = Body2;
  1140. break;
  1141. case "Body3":
  1142. Application.Current.Resources["Font.Size.Body3"] = Body3;
  1143. break;
  1144. case "Body4":
  1145. Application.Current.Resources["Font.Size.Body4"] = Body4;
  1146. break;
  1147. case "Captions1":
  1148. Application.Current.Resources["Font.Size.Captions1"] = Captions1;
  1149. break;
  1150. case "Captions2":
  1151. Application.Current.Resources["Font.Size.Captions2"] = Captions2;
  1152. break;
  1153. case "Captions3":
  1154. Application.Current.Resources["Font.Size.Captions3"] = Captions3;
  1155. break;
  1156. case "Captions4":
  1157. Application.Current.Resources["Font.Size.Captions4"] = Captions4;
  1158. break;
  1159. default:
  1160. break;
  1161. }
  1162. }
  1163. private void ExecuteCheckStatusCommandCommand()
  1164. {
  1165. _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
  1166. }
  1167. #endregion
  1168. #region 继承
  1169. /// <summary>
  1170. /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
  1171. /// </summary>
  1172. /// <param name="navigationContext"></param>
  1173. /// <param name="continuationCallback"></param>
  1174. public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
  1175. {
  1176. continuationCallback(true);
  1177. }
  1178. /// <summary>
  1179. /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
  1180. /// </summary>
  1181. /// <param name="navigationContext"></param>
  1182. /// <exception cref="NotImplementedException"></exception>
  1183. public async void OnNavigatedTo(NavigationContext navigationContext)
  1184. {
  1185. if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
  1186. {
  1187. IsAllowEdit = false;
  1188. }
  1189. else
  1190. {
  1191. IsAllowEdit = true;
  1192. }
  1193. if (RobotList == null)
  1194. {
  1195. RobotList = new ObservableCollection<RobotInfo>();
  1196. var robots = _configService.GetAllRobots();
  1197. foreach (var robot in robots)
  1198. {
  1199. RobotList.Add(robot);
  1200. }
  1201. }
  1202. if (ScannerList == null)
  1203. {
  1204. ScannerList = new ObservableCollection<ScannerInfo>();
  1205. var scanners = _configService.GetAllScanners();
  1206. foreach (var scanner in scanners)
  1207. {
  1208. ScannerList.Add(scanner);
  1209. }
  1210. }
  1211. if (CameraList == null)
  1212. {
  1213. CameraList = new ObservableCollection<CameraInfo>();
  1214. var cameras = _configService.GetAllCameras();
  1215. foreach (var camera in cameras)
  1216. {
  1217. CameraList.Add(camera);
  1218. }
  1219. }
  1220. if (FeederList == null)
  1221. {
  1222. FeederList = new ObservableCollection<FeederInfo>();
  1223. var feeders = _configService.GetAllFeeders();
  1224. foreach (var feeder in feeders)
  1225. {
  1226. FeederList.Add(feeder);
  1227. }
  1228. }
  1229. if (PlcList == null)
  1230. {
  1231. PlcList = new ObservableCollection<PlcInfo>();
  1232. var plcs = _configService.GetAllPlcs();
  1233. foreach (var plc in plcs)
  1234. {
  1235. PlcList.Add(plc);
  1236. }
  1237. }
  1238. // load light controllers
  1239. if (LightControllerList == null)
  1240. {
  1241. LightControllerList = new ObservableCollection<LightControllerConfig>();
  1242. var controllers = _configService.GetAllLightControllers();
  1243. foreach (var ctrl in controllers)
  1244. {
  1245. LightControllerList.Add(ctrl);
  1246. }
  1247. }
  1248. if (BgTcp == null)
  1249. {
  1250. BgTcp = _configService.GetBgTcp();
  1251. }
  1252. if (BgModbus == null)
  1253. {
  1254. BgModbus = _configService.GetBgModbusTcp();
  1255. }
  1256. if (DeviceInfo == null)
  1257. {
  1258. DeviceInfo = _configService.GetDeviceInfo();
  1259. }
  1260. if (CardReaderConfig == null)
  1261. {
  1262. // load card reader config
  1263. CardReaderConfig = _configService.GetCardReaderConfig();
  1264. }
  1265. CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
  1266. // load system parameters into UI
  1267. var sys = _configService.GetSystemConfiguration();
  1268. if (sys != null)
  1269. {
  1270. WorkMode = sys.WorkMode;
  1271. PickPointNum = sys.PickPointNum;
  1272. DowmCameraNum = sys.DowmCameraNum;
  1273. WorkMode = sys.WorkMode;
  1274. PickPointNum = sys.PickPointNum;
  1275. DowmCameraNum = sys.DowmCameraNum;
  1276. UpCameraPickNum = sys.UpCameraPickNum;
  1277. UpCameraPutNum = sys.UpCameraPutNum;
  1278. UPCameracheckNum = sys.UPCameracheckNum;
  1279. FixedCameraPickNum = sys.FixedCameraPickNum;
  1280. FixedCameraPutNum = sys.FixedCameraPutNum;
  1281. FixedCameracheckNum = sys.FixedCameracheckNum;
  1282. IsSaveScrewCurve = sys.IsSaveScrewCurve;
  1283. ScrewCurvePath = sys.ScrewCurvePath;
  1284. }
  1285. if (isFirstLoad)
  1286. {
  1287. Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
  1288. Title2 = (double)Application.Current.Resources["Font.Size.Title2"];
  1289. Title3 = (double)Application.Current.Resources["Font.Size.Title3"];
  1290. Title4 = (double)Application.Current.Resources["Font.Size.Title4"];
  1291. Body1 = (double)Application.Current.Resources["Font.Size.Body1"];
  1292. Body2 = (double)Application.Current.Resources["Font.Size.Body2"];
  1293. Body3 = (double)Application.Current.Resources["Font.Size.Body3"];
  1294. Body4 = (double)Application.Current.Resources["Font.Size.Body4"];
  1295. Captions1 = (double)Application.Current.Resources["Font.Size.Captions1"];
  1296. Captions2 = (double)Application.Current.Resources["Font.Size.Captions2"];
  1297. Captions3 = (double)Application.Current.Resources["Font.Size.Captions3"];
  1298. Captions4 = (double)Application.Current.Resources["Font.Size.Captions4"];
  1299. this.PropertyChanged += OnPropertyChanged;
  1300. isFirstLoad = false;
  1301. }
  1302. try
  1303. {
  1304. ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
  1305. }
  1306. catch (Exception ex)
  1307. {
  1308. LogHelper.WriteLogError("加载产品列表时出错", ex);
  1309. }
  1310. }
  1311. /// <summary>
  1312. /// 是否允许导航到此视图模型。
  1313. /// </summary>
  1314. /// <param name="navigationContext"></param>
  1315. /// <returns></returns>
  1316. public bool IsNavigationTarget(NavigationContext navigationContext)
  1317. {
  1318. return true;
  1319. }
  1320. /// <summary>
  1321. /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
  1322. /// </summary>
  1323. /// <param name="navigationContext"></param>
  1324. public void OnNavigatedFrom(NavigationContext navigationContext)
  1325. {
  1326. }
  1327. #endregion
  1328. private bool _IsAllowEdit = false;
  1329. public bool IsAllowEdit
  1330. {
  1331. get { return _IsAllowEdit; }
  1332. set { SetProperty(ref _IsAllowEdit, value); }
  1333. }
  1334. private void LoginChange(Models.User user)
  1335. {
  1336. if (user.userPart == Enums.UserPart.Operator)
  1337. {
  1338. IsAllowEdit = false;
  1339. }
  1340. else
  1341. {
  1342. IsAllowEdit = true;
  1343. }
  1344. }
  1345. #region 系统参数
  1346. private Int16 _WorkMode = 0;
  1347. /// <summary>
  1348. /// 工作模式 =1 拍1打1 =2 拍1打所有
  1349. /// </summary>
  1350. public Int16 WorkMode
  1351. {
  1352. get { return _WorkMode; }
  1353. set { SetProperty(ref _WorkMode, value); }
  1354. }
  1355. private Int16 _PickPointNum = 0;
  1356. /// <summary>
  1357. /// 取料位置 =0 不需要取料 =1 需要取料
  1358. /// </summary>
  1359. public Int16 PickPointNum
  1360. {
  1361. get { return _PickPointNum; }
  1362. set { SetProperty(ref _PickPointNum, value); }
  1363. }
  1364. private Int16 _DowmCameraNum = 0;
  1365. /// <summary>
  1366. /// 下相机拍照次数
  1367. /// </summary>
  1368. public Int16 DowmCameraNum
  1369. {
  1370. get => _DowmCameraNum;
  1371. set => SetProperty(ref _DowmCameraNum, value);
  1372. }
  1373. private Int16 _UpCameraPickNum = 0;
  1374. /// <summary>
  1375. /// 上相机取料拍照次数
  1376. /// </summary>
  1377. public Int16 UpCameraPickNum
  1378. {
  1379. get => _UpCameraPickNum;
  1380. set => SetProperty(ref _UpCameraPickNum, value);
  1381. }
  1382. private Int16 _UpCameraPutNum = 0;
  1383. /// <summary>
  1384. /// 上相机放料拍照次数
  1385. /// </summary>
  1386. public Int16 UpCameraPutNum
  1387. {
  1388. get => _UpCameraPutNum;
  1389. set => SetProperty(ref _UpCameraPutNum, value);
  1390. }
  1391. private Int16 _UPCameracheckNum = 0;
  1392. /// <summary>
  1393. /// 上相机锁附/组装次数
  1394. /// </summary>
  1395. public Int16 UPCameracheckNum
  1396. {
  1397. get => _UPCameracheckNum;
  1398. set => SetProperty(ref _UPCameracheckNum, value);
  1399. }
  1400. private Int16 _FixedCameraPickNum = 0;
  1401. /// <summary>
  1402. /// 取料固定位置拍产品相机数量
  1403. /// </summary>
  1404. public Int16 FixedCameraPickNum
  1405. {
  1406. get => _FixedCameraPickNum;
  1407. set => SetProperty(ref _FixedCameraPickNum, value);
  1408. }
  1409. private Int16 _FixedCameraPutNum = 0;
  1410. /// <summary>
  1411. /// 锁附/组装固定位置拍产品相机数量
  1412. /// </summary>
  1413. public Int16 FixedCameraPutNum
  1414. {
  1415. get => _FixedCameraPutNum;
  1416. set => SetProperty(ref _FixedCameraPutNum, value);
  1417. }
  1418. private Int16 _FixedCameracheckNum = 0;
  1419. /// <summary>
  1420. /// 固定相机检测锁附/组装次数
  1421. /// </summary>
  1422. public Int16 FixedCameracheckNum
  1423. {
  1424. get => _FixedCameracheckNum;
  1425. set => SetProperty(ref _FixedCameracheckNum, value);
  1426. }
  1427. async void ExecuteSaveSystemParametersCommand()
  1428. {
  1429. var view = new ShowMessage($"AAS", "是否保存系统参数?");
  1430. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  1431. if (result != null && result is bool && (bool)result)
  1432. {
  1433. try
  1434. {
  1435. ExecuteSaveCardReaderConfigCommand();
  1436. FileHelper.WriteJsonFile(this.ScanConfig, FilePath.ScanRS232ConfigPath);
  1437. var sysConfig = _configService.GetSystemConfiguration();
  1438. sysConfig.WorkMode = WorkMode;
  1439. sysConfig.PickPointNum = PickPointNum;
  1440. sysConfig.DowmCameraNum = DowmCameraNum;
  1441. sysConfig.UpCameraPickNum = UpCameraPickNum;
  1442. sysConfig.UpCameraPutNum = UpCameraPutNum;
  1443. sysConfig.UPCameracheckNum = UPCameracheckNum;
  1444. sysConfig.FixedCameraPickNum = FixedCameraPickNum;
  1445. sysConfig.FixedCameraPutNum = FixedCameraPutNum;
  1446. sysConfig.FixedCameracheckNum = FixedCameracheckNum;
  1447. sysConfig.IsSaveScrewCurve = IsSaveScrewCurve;
  1448. sysConfig.ScrewCurvePath = ScrewCurvePath;
  1449. _configService.SaveSystemConfiguration(sysConfig);
  1450. await management.WriteSystemParameterToPlcAsync(sysConfig);
  1451. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  1452. }
  1453. catch (Exception ex)
  1454. {
  1455. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
  1456. }
  1457. }
  1458. }
  1459. /// <summary>
  1460. /// 选择锁付曲线图保存路径
  1461. /// </summary>
  1462. void ExecuteBrowseScrewCurvePathCommand()
  1463. {
  1464. try
  1465. {
  1466. using (var dlg = new System.Windows.Forms.FolderBrowserDialog())
  1467. {
  1468. dlg.Description = "选择锁付曲线图保存路径";
  1469. dlg.ShowNewFolderButton = true;
  1470. if (!string.IsNullOrEmpty(ScrewCurvePath)) dlg.SelectedPath = ScrewCurvePath;
  1471. var result = dlg.ShowDialog();
  1472. if (result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes)
  1473. {
  1474. ScrewCurvePath = dlg.SelectedPath;
  1475. }
  1476. }
  1477. }
  1478. catch (Exception ex)
  1479. {
  1480. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 2 });
  1481. }
  1482. }
  1483. /// <summary>
  1484. /// 保存读卡器配置
  1485. /// </summary>
  1486. void ExecuteSaveCardReaderConfigCommand()
  1487. {
  1488. try
  1489. {
  1490. _configService.SaveCardReaderConfig(CardReaderConfig);
  1491. }
  1492. catch (Exception ex)
  1493. {
  1494. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
  1495. }
  1496. }
  1497. #endregion
  1498. #region 设备信息
  1499. /// <summary>
  1500. /// 保存设备信息
  1501. /// </summary>
  1502. void ExecuteSaveDeviceInfoCommand()
  1503. {
  1504. try
  1505. {
  1506. if (DeviceInfo != null)
  1507. {
  1508. _configService.SaveDeviceInfo(DeviceInfo);
  1509. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  1510. }
  1511. }
  1512. catch (Exception ex)
  1513. {
  1514. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
  1515. }
  1516. }
  1517. /// <summary>
  1518. /// 选择CSV存储路径
  1519. /// </summary>
  1520. void ExecuteSelectSaveImagePathCommand()
  1521. {
  1522. if (DeviceInfo == null)
  1523. {
  1524. return;
  1525. }
  1526. using (System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog())
  1527. {
  1528. // Optional: set the initial directory
  1529. //dialog.SelectedPath = @"C:\";
  1530. // Show the folder browser dialog
  1531. System.Windows.Forms.DialogResult result = dialog.ShowDialog();
  1532. if (result == System.Windows.Forms.DialogResult.OK)
  1533. {
  1534. DeviceInfo.SaveCsvPath = dialog.SelectedPath;
  1535. }
  1536. }
  1537. }
  1538. #endregion
  1539. #region 产品与mes绑定
  1540. private async void ExecuteGetProWithMesCommand()
  1541. {
  1542. var v = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
  1543. if (v == null)
  1544. {
  1545. ProMesInfo.ProductCode = "";
  1546. ProMesInfo.ProductColor = "";
  1547. ProMesInfo.ProductLoadMode = 0;
  1548. }
  1549. else
  1550. {
  1551. ProMesInfo.ProductCode = v.ProductCode;
  1552. ProMesInfo.ProductColor = v.ProductColor;
  1553. ProMesInfo.ProductLoadMode = v.ProductLoadMode;
  1554. }
  1555. }
  1556. private async void ExecuteDeleteProWithMesCommand()
  1557. {
  1558. var v = await _systemDatabaseService.DeleteProWithMesAsync(SelectProduct);
  1559. if (v > 0)
  1560. {
  1561. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "删除成功", Duration = 1 });
  1562. var F = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
  1563. if (F == null)
  1564. {
  1565. ProMesInfo.ProductCode = "";
  1566. ProMesInfo.ProductColor = "";
  1567. ProMesInfo.ProductLoadMode = 0;
  1568. }
  1569. }
  1570. }
  1571. private async void ExecuteSaveProWithMesCommandAsync()
  1572. {
  1573. var v = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
  1574. if (v == null)
  1575. {
  1576. await _systemDatabaseService.InsertProWithMesAsync(ProMesInfo, SelectProduct);
  1577. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "添加成功", Duration = 1 });
  1578. }
  1579. else
  1580. {
  1581. var n = await _systemDatabaseService.UpdateProductWithMesAsync(ProMesInfo, SelectProduct);
  1582. if (n > 0)
  1583. {
  1584. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "更新成功", Duration = 1 });
  1585. }
  1586. }
  1587. }
  1588. #endregion
  1589. }
  1590. }