SettingViewModel.cs 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  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.Globalization;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows;
  19. using Team.FFFeederService.Interfaces;
  20. using TeamAAS_VP.Controls;
  21. using TeamAAS_VP.Core;
  22. using TeamAAS_VP.Core.Cameras;
  23. using TeamAAS_VP.Core.Lights;
  24. using TeamAAS_VP.Enums;
  25. using TeamAAS_VP.Events;
  26. using TeamAAS_VP.Interfaces;
  27. using TeamAAS_VP.Models;
  28. using TeamAAS_VP.Models.Lights;
  29. using TeamAAS_VP.Resources.Languages;
  30. using TeamAAS_VP.Services;
  31. using TeamAAS_VP.ViewModels.User;
  32. using TouchSocket.Core;
  33. using WPFLocalizeExtension.Engine;
  34. namespace TeamAAS_VP.ViewModels
  35. {
  36. public class SettingViewModel : BindableBase, IConfirmNavigationRequest
  37. {
  38. IRegionManager _regionManager;
  39. IEventAggregator _eventAggregator;
  40. IContainerProvider _container;
  41. IDialogService _dialogService;
  42. IConfigService _configService;
  43. IRobotService _robotService;
  44. ICameraService _cameraService;
  45. IFeederService _feeder_service;
  46. IFeederService _feederService;
  47. IPlcService _plcService;
  48. IProductService _productService;
  49. ISystemDatabaseService _systemDatabaseService;
  50. bool isFirstLoad = true;
  51. #region 属性
  52. private Management _management;
  53. public Management management
  54. {
  55. get { return _management; }
  56. set { SetProperty(ref _management, value); }
  57. }
  58. private ObservableCollection<RobotInfo> _RobotList;
  59. public ObservableCollection<RobotInfo> RobotList
  60. {
  61. get { return _RobotList; }
  62. set { SetProperty(ref _RobotList, value); }
  63. }
  64. private ObservableCollection<CameraInfo> _CameraList;
  65. public ObservableCollection<CameraInfo> CameraList
  66. {
  67. get { return _CameraList; }
  68. set { SetProperty(ref _CameraList, value); }
  69. }
  70. private ObservableCollection<FeederInfo> _FeederList;
  71. public ObservableCollection<FeederInfo> FeederList
  72. {
  73. get { return _FeederList; }
  74. set { SetProperty(ref _FeederList, value); }
  75. }
  76. private ObservableCollection<PlcInfo> _PlcList;
  77. public ObservableCollection<PlcInfo> PlcList
  78. {
  79. get { return _PlcList; }
  80. set { SetProperty(ref _PlcList, value); }
  81. }
  82. private Language _CurrentLanguage;
  83. public Language CurrentLanguage
  84. {
  85. get { return _CurrentLanguage; }
  86. set { SetProperty(ref _CurrentLanguage, value); }
  87. }
  88. private RobotInfo _SelectRobot;
  89. /// <summary>
  90. /// 选中的机器人
  91. /// </summary>
  92. public RobotInfo SelectRobot
  93. {
  94. get { return _SelectRobot; }
  95. set
  96. {
  97. SetProperty(ref _SelectRobot, value);
  98. if (value != null && (value.RobotBrand == RobotBrand.XYZ_Platform || value.RobotBrand == RobotBrand.XYZU_Platform))
  99. {
  100. RobotSelectedPlc = PlcList.FirstOrDefault(p => p.Id == value.PLC);
  101. var root = _robotService.GetRobot(SelectRobot.Id);
  102. if (root != null)
  103. {
  104. //ResultsValues.Clear();
  105. //var res = root.GetNodesValue();
  106. //for (int i = 0; i < res.Count; i++)
  107. //{
  108. // if (res[i].StatusCode.Code != 2150891520)
  109. // {
  110. // ResultsValues.Add(res[i].Value.ToString());
  111. // }
  112. // else
  113. // {
  114. // break;
  115. // }
  116. //}
  117. }
  118. }
  119. }
  120. }
  121. private FeederInfo _SelectFeeder;
  122. /// <summary>
  123. /// 选中的Feeder
  124. /// </summary>
  125. public FeederInfo SelectFeeder
  126. {
  127. get { return _SelectFeeder; }
  128. set { SetProperty(ref _SelectFeeder, value); }
  129. }
  130. private PlcInfo _SelectPlc;
  131. public PlcInfo SelectPlc
  132. {
  133. get { return _SelectPlc; }
  134. set { SetProperty(ref _SelectPlc, value); }
  135. }
  136. private ObservableCollection<string> _ResultsValues = new ObservableCollection<string>();
  137. public ObservableCollection<string> ResultsValues { get => _ResultsValues; set => _ResultsValues = value; }
  138. private CameraInfo _SelectCamera;
  139. /// <summary>
  140. /// 选中的Camera
  141. /// </summary>
  142. public CameraInfo SelectCamera
  143. {
  144. get { return _SelectCamera; }
  145. set { SetProperty(ref _SelectCamera, value); }
  146. }
  147. private double _Title1;
  148. public double Title1
  149. {
  150. get { return _Title1; }
  151. set { SetProperty(ref _Title1, value); }
  152. }
  153. private double _Title2;
  154. public double Title2
  155. {
  156. get { return _Title2; }
  157. set { SetProperty(ref _Title2, value); }
  158. }
  159. private double _Title3;
  160. public double Title3
  161. {
  162. get { return _Title3; }
  163. set { SetProperty(ref _Title3, value); }
  164. }
  165. private double _Title4;
  166. public double Title4
  167. {
  168. get { return _Title4; }
  169. set { SetProperty(ref _Title4, value); }
  170. }
  171. private double _Body1;
  172. public double Body1
  173. {
  174. get { return _Body1; }
  175. set { SetProperty(ref _Body1, value); }
  176. }
  177. private double _Body2;
  178. public double Body2
  179. {
  180. get { return _Body2; }
  181. set { SetProperty(ref _Body2, value); }
  182. }
  183. private double _Body3;
  184. public double Body3
  185. {
  186. get { return _Body3; }
  187. set { SetProperty(ref _Body3, value); }
  188. }
  189. private double _Body4;
  190. public double Body4
  191. {
  192. get { return _Body4; }
  193. set { SetProperty(ref _Body4, value); }
  194. }
  195. private double _Captions1;
  196. public double Captions1
  197. {
  198. get { return _Captions1; }
  199. set { SetProperty(ref _Captions1, value); }
  200. }
  201. private double _Captions2;
  202. public double Captions2
  203. {
  204. get { return _Captions2; }
  205. set { SetProperty(ref _Captions2, value); }
  206. }
  207. private double _Captions3;
  208. public double Captions3
  209. {
  210. get { return _Captions3; }
  211. set { SetProperty(ref _Captions3, value); }
  212. }
  213. private double _Captions4;
  214. public double Captions4
  215. {
  216. get { return _Captions4; }
  217. set { SetProperty(ref _Captions4, value); }
  218. }
  219. private PlcInfo _RobotSelectedPlc;
  220. public PlcInfo RobotSelectedPlc
  221. {
  222. get { return _RobotSelectedPlc; }
  223. set
  224. {
  225. SetProperty(ref _RobotSelectedPlc, value);
  226. if (SelectRobot != null)
  227. {
  228. if (value != null)
  229. {
  230. SelectRobot.PLC = value.Id;
  231. }
  232. else
  233. {
  234. SelectRobot.PLC = Guid.Empty;
  235. }
  236. }
  237. }
  238. }
  239. private BgModbusTcp _BgModbus;
  240. public BgModbusTcp BgModbus
  241. {
  242. get { return _BgModbus; }
  243. set { SetProperty(ref _BgModbus, value); }
  244. }
  245. private BgTcpIP _BgTcp;
  246. public BgTcpIP BgTcp
  247. {
  248. get { return _BgTcp; }
  249. set { SetProperty(ref _BgTcp, value); }
  250. }
  251. private ObservableCollection<LightControllerConfig> _LightControllerList;
  252. public ObservableCollection<LightControllerConfig> LightControllerList
  253. {
  254. get { return _LightControllerList; }
  255. set { SetProperty(ref _LightControllerList, value); }
  256. }
  257. private LightControllerConfig _SelectLightController;
  258. public LightControllerConfig SelectLightController
  259. {
  260. get { return _SelectLightController; }
  261. set { SetProperty(ref _SelectLightController, value); }
  262. }
  263. #endregion
  264. #region 命令
  265. public DelegateCommand LoadedCommand { get; set; }
  266. private DelegateCommand _AddRobotCommand;
  267. public DelegateCommand AddRobotCommand =>
  268. _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
  269. private DelegateCommand _RemoveCommand;
  270. public DelegateCommand RemoveCommand =>
  271. _RemoveCommand ?? (_RemoveCommand = new DelegateCommand(ExecuteRemoveCommand));
  272. private DelegateCommand _AddFeederCommand;
  273. public DelegateCommand AddFeederCommand =>
  274. _AddFeederCommand ?? (_AddFeederCommand = new DelegateCommand(ExecuteAddFeederCommand));
  275. private DelegateCommand _RemoveFeederCommand;
  276. public DelegateCommand RemoveFeederCommand =>
  277. _RemoveFeederCommand ?? (_RemoveFeederCommand = new DelegateCommand(ExecuteRemoveFeederCommand));
  278. private DelegateCommand<string> _SelectLanguageCommand;
  279. public DelegateCommand<string> SelectLanguageCommand =>
  280. _SelectLanguageCommand ?? (_SelectLanguageCommand = new DelegateCommand<string>(ExecuteSelectLanguageCommand));
  281. private DelegateCommand _SaveRobotsCommand;
  282. public DelegateCommand SaveRobotsCommand =>
  283. _SaveRobotsCommand ?? (_SaveRobotsCommand = new DelegateCommand(ExecuteSaveRobotsCommand));
  284. private DelegateCommand _SaveFeedersCommand;
  285. public DelegateCommand SaveFeedersCommand =>
  286. _SaveFeedersCommand ?? (_SaveFeedersCommand = new DelegateCommand(ExecuteSaveFeedersCommand));
  287. private DelegateCommand<string> _SaveCommunicateCommand;
  288. public DelegateCommand<string> SaveCommunicateCommand =>
  289. _SaveCommunicateCommand ?? (_SaveCommunicateCommand = new DelegateCommand<string>(ExecuteSaveCommunicateCommand));
  290. private DelegateCommand _AddCameraCommand;
  291. public DelegateCommand AddCameraCommand =>
  292. _AddCameraCommand ?? (_AddCameraCommand = new DelegateCommand(ExecuteAddCameraCommand));
  293. private DelegateCommand _EditCameraCommand;
  294. public DelegateCommand EditCameraCommand =>
  295. _EditCameraCommand ?? (_EditCameraCommand = new DelegateCommand(ExecuteEditCameraCommand));
  296. private DelegateCommand _RemoveCameraCommand;
  297. public DelegateCommand RemoveCameraCommand =>
  298. _RemoveCameraCommand ?? (_RemoveCameraCommand = new DelegateCommand(ExecuteRemoveCameraCommand));
  299. private DelegateCommand _SaveCamerasCommand;
  300. public DelegateCommand SaveCamerasCommand =>
  301. _SaveCamerasCommand ?? (_SaveCamerasCommand = new DelegateCommand(ExecuteSaveCamerasCommand));
  302. private DelegateCommand _AddPlcCommand;
  303. public DelegateCommand AddPlcCommand =>
  304. _AddPlcCommand ?? (_AddPlcCommand = new DelegateCommand(ExecuteAddPlcCommand));
  305. private DelegateCommand _RemovePlcCommand;
  306. public DelegateCommand RemovePlcCommand =>
  307. _RemovePlcCommand ?? (_RemovePlcCommand = new DelegateCommand(ExecuteRemovePlcCommand));
  308. private DelegateCommand _SavePlcsCommand;
  309. public DelegateCommand SavePlcsCommand =>
  310. _SavePlcsCommand ?? (_SavePlcsCommand = new DelegateCommand(ExecuteSavePlcsCommand));
  311. private DelegateCommand _AddLightControllerCommand;
  312. public DelegateCommand AddLightControllerCommand => _AddLightControllerCommand ?? (_AddLightControllerCommand = new DelegateCommand(ExecuteAddLightControllerCommand));
  313. private DelegateCommand _RemoveLightControllerCommand;
  314. public DelegateCommand RemoveLightControllerCommand => _RemoveLightControllerCommand ?? (_RemoveLightControllerCommand = new DelegateCommand(ExecuteRemoveLightControllerCommand));
  315. private DelegateCommand _SaveLightControllersCommand;
  316. public DelegateCommand SaveLightControllersCommand => _SaveLightControllersCommand ?? (_SaveLightControllersCommand = new DelegateCommand(ExecuteSaveLightControllersCommand));
  317. #endregion
  318. #region 事件
  319. #endregion
  320. public SettingViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService,
  321. IConfigService configService, IRobotService robotService, ICameraService cameraService, IFeederService feederService, IPlcService plcService,
  322. IProductService productService, ISystemDatabaseService systemDatabaseService)
  323. {
  324. _regionManager = regionManager;
  325. _eventAggregator = ea;
  326. _container = container;
  327. _dialogService = dialogService;
  328. _configService = configService;
  329. _robotService = robotService;
  330. _cameraService = cameraService;
  331. _feederService = feederService;
  332. _plcService = plcService;
  333. _productService = productService;
  334. _systemDatabaseService = systemDatabaseService;
  335. management = _container.Resolve<Management>();
  336. LoadedCommand = new DelegateCommand(OnLoad);
  337. //订阅权限登录事件
  338. _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
  339. }
  340. #region 方法
  341. #region 机器人
  342. private void ExecuteAddRobotCommand()
  343. {
  344. _dialogService.ShowDialog("AddRobot", rst =>
  345. {
  346. //对话框关闭之后的回调函数,可以在这解析结果。
  347. ButtonResult result1 = rst.Result;
  348. if (result1 == ButtonResult.OK)
  349. {
  350. var param = rst.Parameters.GetValue<RobotInfo>("Robot");
  351. var robot = new RobotInfo()
  352. {
  353. Id = param.Id,
  354. RobotName = param.RobotName,
  355. ConnectType = param.ConnectType,
  356. RobotBrand = param.RobotBrand,
  357. IP = param.IP,
  358. Port = param.Port,
  359. Terminator = param.Terminator,
  360. };
  361. RobotList.Add(robot);
  362. _configService.AddOrUpdateRobot(robot);
  363. _robotService.CreateRobot(robot.Id, robot);
  364. //对所有产品也进行添加
  365. _productService.AddRobotPointToProduct(robot.Id, robot.RobotName);
  366. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
  367. }
  368. });
  369. }
  370. void ExecuteRemoveCommand()
  371. {
  372. if (MessageBox.Show(Lang.是否移除机器人, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  373. {
  374. // 找到要删除的机器人
  375. var robotToRemove = RobotList.FirstOrDefault(r => r.Id == SelectRobot.Id);
  376. if (robotToRemove != null)
  377. {
  378. RobotList.Remove(robotToRemove);
  379. _configService.RemoveRobot(robotToRemove.Id);
  380. _robotService.RemoveRobot(robotToRemove.Id);
  381. //对所有产品也进行移除
  382. _productService.RemoveRobotPointFromProduct(robotToRemove.Id);
  383. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  384. }
  385. }
  386. }
  387. async void ExecuteSaveRobotsCommand()
  388. {
  389. var view = new ShowMessage($"AAS", Lang.是否保存机器人);
  390. //show the dialog
  391. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  392. if (result != null && result is bool)
  393. {
  394. if (((bool)result))
  395. {
  396. foreach (var item in RobotList)
  397. {
  398. _configService.AddOrUpdateRobot(item);
  399. }
  400. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  401. }
  402. }
  403. }
  404. #endregion
  405. #region 相机
  406. /// <summary>
  407. /// 保存所有相机
  408. /// </summary>
  409. async void ExecuteSaveCamerasCommand()
  410. {
  411. var view = new ShowMessage($"AAS", Lang.是否保存相机配置);
  412. //show the dialog
  413. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  414. if (result != null && result is bool)
  415. {
  416. if (((bool)result))
  417. {
  418. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  419. //management.SaveCamerasDeviceConfig();
  420. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  421. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  422. }
  423. }
  424. }
  425. /// <summary>
  426. /// 移除相机
  427. /// </summary>
  428. void ExecuteRemoveCameraCommand()
  429. {
  430. if (MessageBox.Show(Lang.是否移除相机, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  431. {
  432. // 找到要删除的相机
  433. var cameraToRemove = CameraList.FirstOrDefault(r => r.Id == SelectCamera.Id);
  434. if (cameraToRemove != null)
  435. {
  436. _configService.RemoveCamera(cameraToRemove.Id);
  437. _cameraService.RemoveCamera(cameraToRemove.Id);
  438. var root = _configService.GetAllCameras();
  439. CameraList = new ObservableCollection<CameraInfo>(root);
  440. foreach (var item in CameraList)
  441. {
  442. _cameraService.UpdateCameraNumber(item.Id, item.CameraNo);
  443. }
  444. //对所有产品也进行移除
  445. _productService.RemoveCameraFromProduct(cameraToRemove.Id);
  446. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  447. }
  448. }
  449. }
  450. /// <summary>
  451. /// 编辑相机
  452. /// </summary>
  453. void ExecuteEditCameraCommand()
  454. {
  455. if (SelectCamera == null) return;
  456. bool isSelectedCameraBrandSucced = false;
  457. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  458. IDialogParameters parameters1 = new DialogParameters();
  459. parameters1.Add("CameraBrand", SelectCamera.CameraBrand);
  460. _dialogService.ShowDialog("SelectCameraBrand", parameters1, rst =>
  461. {
  462. if (rst.Result == ButtonResult.OK)
  463. {
  464. isSelectedCameraBrandSucced = true;
  465. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  466. }
  467. else
  468. {
  469. return;
  470. }
  471. });
  472. if (!isSelectedCameraBrandSucced) { return; }
  473. (bool isInstalled, string version) result = (false, "");
  474. string softwarename = "";
  475. switch (cameraBrand)
  476. {
  477. case CameraBrand.HikRobot_MVS:
  478. softwarename = "MVS";
  479. result = MvCamera.CheckSoftwareInstalled();
  480. break;
  481. case CameraBrand.Basler_Pylon:
  482. softwarename = "Pylon 7";
  483. result = BaslerCamera.CheckSoftwareInstalled();
  484. break;
  485. case CameraBrand.IRayple:
  486. softwarename = "MV Viewer";
  487. result = AHuaCamera.CheckSoftwareInstalled();
  488. break;
  489. case CameraBrand.Cognex:
  490. softwarename = "Cognex VisionPro";
  491. result = CognexCamera.CheckSoftwareInstalled();
  492. break;
  493. case CameraBrand.Galaxy:
  494. softwarename = "Galaxy Viewer";
  495. result = GalaxyCamera.CheckSoftwareInstalled();
  496. break;
  497. default:
  498. break;
  499. }
  500. if (!result.isInstalled)
  501. {
  502. if (string.IsNullOrEmpty(result.version))
  503. {
  504. //未安装
  505. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  506. }
  507. else
  508. {
  509. //版本较低
  510. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  511. }
  512. return;
  513. }
  514. //编辑前的相机名称
  515. string oldCameraName = SelectCamera.CameraName;
  516. IDialogParameters parameters = new DialogParameters();
  517. parameters.Add("CameraBrand", cameraBrand);
  518. parameters.Add("Camera", SelectCamera.Copy());
  519. _dialogService.ShowDialog("EditCamera", parameters, rst =>
  520. {
  521. //对话框关闭之后的回调函数,可以在这解析结果。
  522. ButtonResult result1 = rst.Result;
  523. if (result1 == ButtonResult.OK)
  524. {
  525. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  526. SelectCamera.CameraName = param.CameraName;
  527. SelectCamera.SerialNumber = param.SerialNumber;
  528. SelectCamera.Model = param.Model;
  529. SelectCamera.ManufacturerName = param.ManufacturerName;
  530. SelectCamera.CameraType = param.CameraType;
  531. SelectCamera.CameraBrand = param.CameraBrand;
  532. SelectCamera.CameraIp = param.CameraIp;
  533. _configService.AddOrUpdateCamera(SelectCamera);
  534. if (oldCameraName != param.CameraName)
  535. {
  536. //对所有产品也进行修改
  537. _productService.UpdateCameraNameInProduct(SelectCamera.Id, SelectCamera.CameraName);
  538. }
  539. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  540. }
  541. });
  542. }
  543. /// <summary>
  544. /// 增加相机
  545. /// </summary>
  546. void ExecuteAddCameraCommand()
  547. {
  548. bool isSelectedCameraBrandSucced = false;
  549. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  550. _dialogService.ShowDialog("SelectCameraBrand", rst =>
  551. {
  552. if (rst.Result == ButtonResult.OK)
  553. {
  554. isSelectedCameraBrandSucced = true;
  555. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  556. }
  557. else
  558. {
  559. return;
  560. }
  561. });
  562. if (!isSelectedCameraBrandSucced) { return; }
  563. ;
  564. (bool isInstalled, string version) result = (false, "");
  565. string softwarename = "";
  566. switch (cameraBrand)
  567. {
  568. case CameraBrand.HikRobot_MVS:
  569. softwarename = "MVS";
  570. result = MvCamera.CheckSoftwareInstalled();
  571. break;
  572. case CameraBrand.Basler_Pylon:
  573. softwarename = "Pylon 7";
  574. result = BaslerCamera.CheckSoftwareInstalled();
  575. break;
  576. case CameraBrand.IRayple:
  577. softwarename = "MV Viewer";
  578. result = AHuaCamera.CheckSoftwareInstalled();
  579. break;
  580. case CameraBrand.Cognex:
  581. softwarename = "Cognex VisionPro";
  582. result = CognexCamera.CheckSoftwareInstalled();
  583. break;
  584. case CameraBrand.Galaxy:
  585. softwarename = "Galaxy Viewer";
  586. result = GalaxyCamera.CheckSoftwareInstalled();
  587. break;
  588. default:
  589. break;
  590. }
  591. if (!result.isInstalled)
  592. {
  593. if (string.IsNullOrEmpty(result.version))
  594. {
  595. //未安装
  596. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  597. }
  598. else
  599. {
  600. //版本较低
  601. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  602. }
  603. return;
  604. }
  605. IDialogParameters parameters = new DialogParameters();
  606. parameters.Add("CameraBrand", cameraBrand);
  607. _dialogService.ShowDialog("AddCamera", parameters, rst =>
  608. {
  609. //对话框关闭之后的回调函数,可以在这解析结果。
  610. ButtonResult result1 = rst.Result;
  611. if (result1 == ButtonResult.OK)
  612. {
  613. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  614. var camera = new CameraInfo()
  615. {
  616. Id = param.Id,
  617. CameraName = param.CameraName,
  618. SerialNumber = param.SerialNumber,
  619. Model = param.Model,
  620. ManufacturerName = param.ManufacturerName,
  621. CameraType = param.CameraType,
  622. CameraBrand = param.CameraBrand,
  623. CameraIp = param.CameraIp
  624. };
  625. CameraList.Add(camera);
  626. _configService.AddOrUpdateCamera(camera);
  627. _cameraService.CreateCamera(camera.Id, camera);
  628. //对所有产品也进行添加
  629. _productService.AddCameraToProduct(camera.Id, camera.CameraName);
  630. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  631. }
  632. });
  633. }
  634. #endregion
  635. #region Feeder
  636. void ExecuteAddFeederCommand()
  637. {
  638. _dialogService.ShowDialog("AddFeeder", rst =>
  639. {
  640. //对话框关闭之后的回调函数,可以在这解析结果。
  641. ButtonResult result1 = rst.Result;
  642. if (result1 == ButtonResult.OK)
  643. {
  644. var param = rst.Parameters.GetValue<FeederInfo>("Feeder");
  645. var feeder = new FeederInfo()
  646. {
  647. Id = param.Id,
  648. FeederName = param.FeederName,
  649. ConnectType = param.ConnectType,
  650. FeederBrand = param.FeederBrand,
  651. IP = param.IP,
  652. Port = param.Port
  653. };
  654. FeederList.Add(feeder);
  655. _configService.AddOrUpdateFeeder(feeder);
  656. _feederService.CreateFeeder(feeder.Id, feeder.FeederNo, feeder.FeederName, feeder.IP, feeder.Port, feeder.FeederBrand);
  657. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  658. }
  659. });
  660. }
  661. void ExecuteRemoveFeederCommand()
  662. {
  663. if (MessageBox.Show(Lang.是否移除Feeder, " AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  664. {
  665. // 找到要删除的机器人
  666. var feederToRemove = FeederList.FirstOrDefault(r => r.Id == SelectFeeder.Id);
  667. if (feederToRemove != null)
  668. {
  669. _configService.RemoveFeeder(feederToRemove.Id);
  670. _feederService.RemoveFeeder(feederToRemove.Id);
  671. var root = _configService.GetAllFeeders();
  672. FeederList = new ObservableCollection<FeederInfo>(root);
  673. foreach (var item in FeederList)
  674. {
  675. _feederService.UpdateFeederNo(item.Id, item.FeederNo);
  676. }
  677. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  678. }
  679. }
  680. }
  681. async void ExecuteSaveFeedersCommand()
  682. {
  683. var view = new ShowMessage($"AAS", Lang.是否保存Feeder);
  684. //show the dialog
  685. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  686. if (result != null && result is bool)
  687. {
  688. if (((bool)result))
  689. {
  690. foreach (var item in FeederList)
  691. {
  692. _configService.AddOrUpdateFeeder(item);
  693. }
  694. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  695. }
  696. }
  697. }
  698. #endregion
  699. #region PLC
  700. /// <summary>
  701. /// 保存PLC
  702. /// </summary>
  703. async void ExecuteSavePlcsCommand()
  704. {
  705. var view = new ShowMessage($"AAS", Lang.是否保存PLC);
  706. //show the dialog
  707. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  708. if (result != null && result is bool)
  709. {
  710. if (((bool)result))
  711. {
  712. foreach (var item in PlcList)
  713. {
  714. _configService.AddOrUpdatePlc(item);
  715. }
  716. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  717. }
  718. }
  719. }
  720. /// <summary>
  721. /// 移除PLC
  722. /// </summary>
  723. void ExecuteRemovePlcCommand()
  724. {
  725. if (MessageBox.Show(Lang.是否移除PLC, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  726. {
  727. // 找到要删除的plc
  728. var plcToRemove = PlcList.FirstOrDefault(r => r.Id == SelectPlc.Id);
  729. if (plcToRemove != null)
  730. {
  731. _configService.RemovePlc(plcToRemove.Id);
  732. _plcService.RemovePlc(plcToRemove.Id);
  733. var root = _configService.GetAllPlcs();
  734. PlcList = new ObservableCollection<PlcInfo>(root);
  735. foreach (var item in PlcList)
  736. {
  737. _plcService.UpdatePlcNumber(item.Id, item.Index);
  738. }
  739. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  740. }
  741. }
  742. }
  743. /// <summary>
  744. /// 增加PLC
  745. /// </summary>
  746. void ExecuteAddPlcCommand()
  747. {
  748. _dialogService.ShowDialog("AddPlc", rst =>
  749. {
  750. //对话框关闭之后的回调函数,可以在这解析结果。
  751. ButtonResult result1 = rst.Result;
  752. if (result1 == ButtonResult.OK)
  753. {
  754. var param = rst.Parameters.GetValue<PlcInfo>("PLC");
  755. var plc = new PlcInfo()
  756. {
  757. Id = param.Id,
  758. Name = param.Name,
  759. CommunicationType = param.CommunicationType,
  760. EndpointUrl = param.EndpointUrl,
  761. };
  762. PlcList.Add(plc);
  763. _configService.AddOrUpdatePlc(plc);
  764. _plcService.CreatePlc(plc.Id, plc);
  765. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  766. }
  767. });
  768. }
  769. #endregion
  770. #region Light handlers
  771. void ExecuteAddLightControllerCommand()
  772. {
  773. // open dialog to add light controller (similar to robots)
  774. _dialogService.ShowDialog("AddLightController", rst =>
  775. {
  776. if (rst.Result == ButtonResult.OK)
  777. {
  778. var param = rst.Parameters.GetValue<LightControllerConfig>("LightController");
  779. // assign id and defaults if needed
  780. if (param.Id == 0)
  781. param.Id = (LightControllerList?.Count ?? 0) + 1;
  782. LightControllerList.Add(param);
  783. _configService.AddOrUpdateLightController(param);
  784. SelectLightController = param;
  785. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "添加完成", Duration = 1 });
  786. }
  787. });
  788. }
  789. void ExecuteRemoveLightControllerCommand()
  790. {
  791. if (SelectLightController == null) return;
  792. if (MessageBox.Show("是否移除光源控制器?", "AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  793. {
  794. _configService.RemoveLightController(SelectLightController.Id);
  795. LightControllerList.Remove(SelectLightController);
  796. SelectLightController = null;
  797. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "移除完成", Duration = 1 });
  798. }
  799. }
  800. async void ExecuteSaveLightControllersCommand()
  801. {
  802. var view = new ShowMessage($"AAS", "是否保存光源控制器配置?");
  803. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  804. if (result != null && result is bool && (bool)result)
  805. {
  806. foreach (var item in LightControllerList)
  807. {
  808. _configService.AddOrUpdateLightController(item);
  809. }
  810. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "完成", Duration = 1 });
  811. }
  812. }
  813. #endregion
  814. #region 通讯
  815. async void ExecuteSaveCommunicateCommand(string parm)
  816. {
  817. if (parm == "TCPIP")
  818. {
  819. var view = new ShowMessage($"AAS", Lang.是否保存后台TCP通讯配置);
  820. //show the dialog
  821. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  822. if (result != null && result is bool)
  823. {
  824. if (((bool)result))
  825. {
  826. _configService.SetBgTcp(BgTcp);
  827. _configService.SaveBgTcp();
  828. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  829. }
  830. }
  831. }
  832. else if (parm == "ModbusTCP")
  833. {
  834. var view = new ShowMessage($"AAS", Lang.是否保存后台ModbusTCP通讯配置);
  835. //show the dialog
  836. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  837. if (result != null && result is bool)
  838. {
  839. if (((bool)result))
  840. {
  841. _configService.SetBgModbusTcp(BgModbus);
  842. _configService.SaveBgModbusTcp();
  843. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  844. }
  845. }
  846. }
  847. else
  848. {
  849. return;
  850. }
  851. }
  852. #endregion
  853. #region 语言
  854. void ExecuteSelectLanguageCommand(string language)
  855. {
  856. if (string.Equals(language, "ChineseSimplified"))
  857. {
  858. CurrentLanguage = Enums.Language.ChineseSimplified;
  859. var sysConfig = _configService.GetSystemConfiguration();
  860. sysConfig.CurrentLanguage = CurrentLanguage;
  861. _configService.SaveSystemConfiguration(sysConfig);
  862. var culture = new CultureInfo("zh-CN");
  863. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  864. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  865. LocalizeDictionary.Instance.Culture = culture;
  866. Lang.Culture = culture;
  867. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  868. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  869. }
  870. else if (string.Equals(language, "ChineseTraditional"))
  871. {
  872. CurrentLanguage = Enums.Language.ChineseTraditional;
  873. var sysConfig = _configService.GetSystemConfiguration();
  874. sysConfig.CurrentLanguage = CurrentLanguage;
  875. _configService.SaveSystemConfiguration(sysConfig);
  876. var culture = new CultureInfo("zh-TW");
  877. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  878. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  879. LocalizeDictionary.Instance.Culture = culture;
  880. Lang.Culture = culture;
  881. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  882. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  883. }
  884. else if (string.Equals(language, "English"))
  885. {
  886. CurrentLanguage = Enums.Language.English;
  887. var sysConfig = _configService.GetSystemConfiguration();
  888. sysConfig.CurrentLanguage = CurrentLanguage;
  889. _configService.SaveSystemConfiguration(sysConfig);
  890. var culture = new CultureInfo("en");
  891. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  892. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  893. LocalizeDictionary.Instance.Culture = culture;
  894. Lang.Culture = culture;
  895. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  896. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  897. }
  898. else if (string.Equals(language, "Japanese"))
  899. {
  900. CurrentLanguage = Enums.Language.Japanese;
  901. var sysConfig = _configService.GetSystemConfiguration();
  902. sysConfig.CurrentLanguage = CurrentLanguage;
  903. _configService.SaveSystemConfiguration(sysConfig);
  904. var culture = new CultureInfo("ja-JP");
  905. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  906. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  907. LocalizeDictionary.Instance.Culture = culture;
  908. Lang.Culture = culture;
  909. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  910. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  911. }
  912. }
  913. #endregion
  914. private void OnLoad()
  915. {
  916. }
  917. private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
  918. {
  919. switch (e.PropertyName)
  920. {
  921. case "Title1":
  922. Application.Current.Resources["Font.Size.Title1"] = Title1;
  923. break;
  924. case "Title2":
  925. Application.Current.Resources["Font.Size.Title2"] = Title2;
  926. break;
  927. case "Title3":
  928. Application.Current.Resources["Font.Size.Title3"] = Title3;
  929. break;
  930. case "Title4":
  931. Application.Current.Resources["Font.Size.Title4"] = Title4;
  932. break;
  933. case "Body1":
  934. Application.Current.Resources["Font.Size.Body1"] = Body1;
  935. break;
  936. case "Body2":
  937. Application.Current.Resources["Font.Size.Body2"] = Body2;
  938. break;
  939. case "Body3":
  940. Application.Current.Resources["Font.Size.Body3"] = Body3;
  941. break;
  942. case "Body4":
  943. Application.Current.Resources["Font.Size.Body4"] = Body4;
  944. break;
  945. case "Captions1":
  946. Application.Current.Resources["Font.Size.Captions1"] = Captions1;
  947. break;
  948. case "Captions2":
  949. Application.Current.Resources["Font.Size.Captions2"] = Captions2;
  950. break;
  951. case "Captions3":
  952. Application.Current.Resources["Font.Size.Captions3"] = Captions3;
  953. break;
  954. case "Captions4":
  955. Application.Current.Resources["Font.Size.Captions4"] = Captions4;
  956. break;
  957. default:
  958. break;
  959. }
  960. }
  961. #endregion
  962. #region 继承
  963. /// <summary>
  964. /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
  965. /// </summary>
  966. /// <param name="navigationContext"></param>
  967. /// <param name="continuationCallback"></param>
  968. public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
  969. {
  970. continuationCallback(true);
  971. }
  972. /// <summary>
  973. /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
  974. /// </summary>
  975. /// <param name="navigationContext"></param>
  976. /// <exception cref="NotImplementedException"></exception>
  977. public async void OnNavigatedTo(NavigationContext navigationContext)
  978. {
  979. if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
  980. {
  981. IsAllowEdit = false;
  982. }
  983. else
  984. {
  985. IsAllowEdit = true;
  986. }
  987. if (RobotList == null)
  988. {
  989. RobotList = new ObservableCollection<RobotInfo>();
  990. var robots = _configService.GetAllRobots();
  991. foreach (var robot in robots)
  992. {
  993. RobotList.Add(robot);
  994. }
  995. }
  996. if (CameraList == null)
  997. {
  998. CameraList = new ObservableCollection<CameraInfo>();
  999. var cameras = _configService.GetAllCameras();
  1000. foreach (var camera in cameras)
  1001. {
  1002. CameraList.Add(camera);
  1003. }
  1004. }
  1005. if (FeederList == null)
  1006. {
  1007. FeederList = new ObservableCollection<FeederInfo>();
  1008. var feeders = _configService.GetAllFeeders();
  1009. foreach (var feeder in feeders)
  1010. {
  1011. FeederList.Add(feeder);
  1012. }
  1013. }
  1014. if (PlcList == null)
  1015. {
  1016. PlcList = new ObservableCollection<PlcInfo>();
  1017. var plcs = _configService.GetAllPlcs();
  1018. foreach (var plc in plcs)
  1019. {
  1020. PlcList.Add(plc);
  1021. }
  1022. }
  1023. // load light controllers
  1024. if (LightControllerList == null)
  1025. {
  1026. LightControllerList = new ObservableCollection<LightControllerConfig>();
  1027. var controllers = _configService.GetAllLightControllers();
  1028. foreach (var ctrl in controllers)
  1029. {
  1030. LightControllerList.Add(ctrl);
  1031. }
  1032. }
  1033. if (BgTcp == null)
  1034. {
  1035. BgTcp = _configService.GetBgTcp();
  1036. }
  1037. if (BgModbus == null)
  1038. {
  1039. BgModbus = _configService.GetBgModbusTcp();
  1040. }
  1041. CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
  1042. if (isFirstLoad)
  1043. {
  1044. Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
  1045. Title2 = (double)Application.Current.Resources["Font.Size.Title2"];
  1046. Title3 = (double)Application.Current.Resources["Font.Size.Title3"];
  1047. Title4 = (double)Application.Current.Resources["Font.Size.Title4"];
  1048. Body1 = (double)Application.Current.Resources["Font.Size.Body1"];
  1049. Body2 = (double)Application.Current.Resources["Font.Size.Body2"];
  1050. Body3 = (double)Application.Current.Resources["Font.Size.Body3"];
  1051. Body4 = (double)Application.Current.Resources["Font.Size.Body4"];
  1052. Captions1 = (double)Application.Current.Resources["Font.Size.Captions1"];
  1053. Captions2 = (double)Application.Current.Resources["Font.Size.Captions2"];
  1054. Captions3 = (double)Application.Current.Resources["Font.Size.Captions3"];
  1055. Captions4 = (double)Application.Current.Resources["Font.Size.Captions4"];
  1056. this.PropertyChanged += OnPropertyChanged;
  1057. isFirstLoad = false;
  1058. }
  1059. }
  1060. /// <summary>
  1061. /// 是否允许导航到此视图模型。
  1062. /// </summary>
  1063. /// <param name="navigationContext"></param>
  1064. /// <returns></returns>
  1065. public bool IsNavigationTarget(NavigationContext navigationContext)
  1066. {
  1067. return true;
  1068. }
  1069. /// <summary>
  1070. /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
  1071. /// </summary>
  1072. /// <param name="navigationContext"></param>
  1073. public void OnNavigatedFrom(NavigationContext navigationContext)
  1074. {
  1075. }
  1076. #endregion
  1077. private bool _IsAllowEdit = false;
  1078. public bool IsAllowEdit
  1079. {
  1080. get { return _IsAllowEdit; }
  1081. set { SetProperty(ref _IsAllowEdit, value); }
  1082. }
  1083. private void LoginChange(Models.User user)
  1084. {
  1085. if (user.userPart == Enums.UserPart.Operator)
  1086. {
  1087. IsAllowEdit = false;
  1088. }
  1089. else
  1090. {
  1091. IsAllowEdit = true;
  1092. }
  1093. }
  1094. }
  1095. }