| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033 |
- using ICSharpCode.AvalonEdit.Search;
- using log4net;
- using MaterialDesignThemes.Wpf;
- using NPOI.SS.Formula.Functions;
- using Opc.Ua;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Ioc;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Drawing.Drawing2D;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Reflection.Metadata;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web;
- using System.Windows;
- using System.Windows.Controls;
- using Team.FFFeederService.Interfaces;
- using TeamAAS_VP.Controls;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Core.Cameras;
- using TeamAAS_VP.Core.Lights;
- using TeamAAS_VP.Enums;
- using TeamAAS_VP.Events;
- using TeamAAS_VP.Interfaces;
- using TeamAAS_VP.Models;
- using TeamAAS_VP.Models.Feeder;
- using TeamAAS_VP.Models.Lights;
- using TeamAAS_VP.Models.Torque;
- using TeamAAS_VP.Resources.Languages;
- using TeamAAS_VP.Services;
- using TeamAAS_VP.ViewModels.User;
- using TouchSocket.Core;
- using WPFLocalizeExtension.Engine;
- namespace TeamAAS_VP.ViewModels
- {
- public class SettingViewModel : BindableBase, IConfirmNavigationRequest
- {
- IRegionManager _regionManager;
- IEventAggregator _eventAggregator;
- IContainerProvider _container;
- IDialogService _dialogService;
- IConfigService _configService;
- IRobotService _robotService;
- ICameraService _cameraService;
- IFeederService _feeder_service;
- IFeederService _feederService;
- IPlcService _plcService;
- IProductService _productService;
- ISystemDatabaseService _systemDatabaseService;
- bool isFirstLoad = true;
- #region 属性
- private Management _management;
- public Management management
- {
- get { return _management; }
- set { SetProperty(ref _management, value); }
- }
- private ObservableCollection<RobotInfo> _RobotList;
- public ObservableCollection<RobotInfo> RobotList
- {
- get { return _RobotList; }
- set { SetProperty(ref _RobotList, value); }
- }
- private ObservableCollection<CameraInfo> _CameraList;
- public ObservableCollection<CameraInfo> CameraList
- {
- get { return _CameraList; }
- set { SetProperty(ref _CameraList, value); }
- }
- private ObservableCollection<FeederInfo> _FeederList;
- public ObservableCollection<FeederInfo> FeederList
- {
- get { return _FeederList; }
- set { SetProperty(ref _FeederList, value); }
- }
- private ObservableCollection<PlcInfo> _PlcList;
- public ObservableCollection<PlcInfo> PlcList
- {
- get { return _PlcList; }
- set { SetProperty(ref _PlcList, value); }
- }
- private Language _CurrentLanguage;
- public Language CurrentLanguage
- {
- get { return _CurrentLanguage; }
- set { SetProperty(ref _CurrentLanguage, value); }
- }
- private RobotInfo _SelectRobot;
- /// <summary>
- /// 选中的机器人
- /// </summary>
- public RobotInfo SelectRobot
- {
- get { return _SelectRobot; }
- set
- {
- SetProperty(ref _SelectRobot, value);
- if (value != null && (value.RobotBrand == RobotBrand.XYZ_Platform || value.RobotBrand == RobotBrand.XYZU_Platform))
- {
- RobotSelectedPlc = PlcList.FirstOrDefault(p => p.Id == value.PLC);
- var root = _robotService.GetRobot(SelectRobot.Id);
- if (root != null)
- {
- //ResultsValues.Clear();
- //var res = root.GetNodesValue();
- //for (int i = 0; i < res.Count; i++)
- //{
- // if (res[i].StatusCode.Code != 2150891520)
- // {
- // ResultsValues.Add(res[i].Value.ToString());
- // }
- // else
- // {
- // break;
- // }
- //}
- }
- }
- }
- }
- private FeederInfo _SelectFeeder;
- /// <summary>
- /// 选中的Feeder
- /// </summary>
- public FeederInfo SelectFeeder
- {
- get { return _SelectFeeder; }
- set { SetProperty(ref _SelectFeeder, value); }
- }
- private PlcInfo _SelectPlc;
- public PlcInfo SelectPlc
- {
- get { return _SelectPlc; }
- set { SetProperty(ref _SelectPlc, value); }
- }
- private ObservableCollection<string> _ResultsValues = new ObservableCollection<string>();
- public ObservableCollection<string> ResultsValues { get => _ResultsValues; set => _ResultsValues = value; }
- private CameraInfo _SelectCamera;
- /// <summary>
- /// 选中的Camera
- /// </summary>
- public CameraInfo SelectCamera
- {
- get { return _SelectCamera; }
- set { SetProperty(ref _SelectCamera, value); }
- }
- private ObservableCollection<ScrewFeederInfo> _ScrewFeederList;
- /// <summary>
- /// 螺丝供料器列表
- /// </summary>
- public ObservableCollection<ScrewFeederInfo> ScrewFeederList
- {
- get { return _ScrewFeederList; }
- set { SetProperty(ref _ScrewFeederList, value); }
- }
- private ScrewFeederInfo _SelectScrewFeeder;
- public ScrewFeederInfo SelectScrewFeeder
- {
- get { return _SelectScrewFeeder; }
- set { SetProperty(ref _SelectScrewFeeder, value); }
- }
- private double _Title1;
- public double Title1
- {
- get { return _Title1; }
- set { SetProperty(ref _Title1, value); }
- }
- private double _Title2;
- public double Title2
- {
- get { return _Title2; }
- set { SetProperty(ref _Title2, value); }
- }
- private double _Title3;
- public double Title3
- {
- get { return _Title3; }
- set { SetProperty(ref _Title3, value); }
- }
- private double _Title4;
- public double Title4
- {
- get { return _Title4; }
- set { SetProperty(ref _Title4, value); }
- }
- private double _Body1;
- public double Body1
- {
- get { return _Body1; }
- set { SetProperty(ref _Body1, value); }
- }
- private double _Body2;
- public double Body2
- {
- get { return _Body2; }
- set { SetProperty(ref _Body2, value); }
- }
- private double _Body3;
- public double Body3
- {
- get { return _Body3; }
- set { SetProperty(ref _Body3, value); }
- }
- private double _Body4;
- public double Body4
- {
- get { return _Body4; }
- set { SetProperty(ref _Body4, value); }
- }
- private double _Captions1;
- public double Captions1
- {
- get { return _Captions1; }
- set { SetProperty(ref _Captions1, value); }
- }
- private double _Captions2;
- public double Captions2
- {
- get { return _Captions2; }
- set { SetProperty(ref _Captions2, value); }
- }
- private double _Captions3;
- public double Captions3
- {
- get { return _Captions3; }
- set { SetProperty(ref _Captions3, value); }
- }
- private double _Captions4;
- public double Captions4
- {
- get { return _Captions4; }
- set { SetProperty(ref _Captions4, value); }
- }
- private PlcInfo _RobotSelectedPlc;
- public PlcInfo RobotSelectedPlc
- {
- get { return _RobotSelectedPlc; }
- set
- {
- SetProperty(ref _RobotSelectedPlc, value);
- if (SelectRobot != null)
- {
- if (value != null)
- {
- SelectRobot.PLC = value.Id;
- }
- else
- {
- SelectRobot.PLC = Guid.Empty;
- }
- }
- }
- }
- private BgModbusTcp _BgModbus;
- public BgModbusTcp BgModbus
- {
- get { return _BgModbus; }
- set { SetProperty(ref _BgModbus, value); }
- }
- private BgTcpIP _BgTcp;
- public BgTcpIP BgTcp
- {
- get { return _BgTcp; }
- set { SetProperty(ref _BgTcp, value); }
- }
- private ObservableCollection<LightControllerConfig> _LightControllerList;
- public ObservableCollection<LightControllerConfig> LightControllerList
- {
- get { return _LightControllerList; }
- set { SetProperty(ref _LightControllerList, value); }
- }
- private LightControllerConfig _SelectLightController;
- public LightControllerConfig SelectLightController
- {
- get { return _SelectLightController; }
- set { SetProperty(ref _SelectLightController, value); }
- }
- // 设备信息列表
- private ObservableCollection<DeviceInfo> _DeviceInfoList;
- public ObservableCollection<DeviceInfo> DeviceInfoList
- {
- get { return _DeviceInfoList; }
- set { SetProperty(ref _DeviceInfoList, value); }
- }
- // 当前选中的设备信息
- private DeviceInfo _SelectDeviceInfo;
- public DeviceInfo SelectDeviceInfo
- {
- get { return _SelectDeviceInfo; }
- set { SetProperty(ref _SelectDeviceInfo, value); }
- }
- // 兼容旧代码,DeviceInfo 指向当前选中的设备或第一个设备
- public DeviceInfo DeviceInfo
- {
- get { return _SelectDeviceInfo ?? DeviceInfoList?.FirstOrDefault(); }
- set
- {
- if (value != null && DeviceInfoList != null)
- {
- var existing = DeviceInfoList.FirstOrDefault(d => d.DeviceNo == value.DeviceNo);
- if (existing != null)
- {
- var index = DeviceInfoList.IndexOf(existing);
- DeviceInfoList[index] = value;
- }
- }
- RaisePropertyChanged();
- }
- }
- private CTQ_Data _dataInfo;
- public CTQ_Data DataInfo
- {
- get { return _dataInfo; }
- set { SetProperty(ref _dataInfo, value); }
- }
- private SerialPortConfig _CardReaderConfig;
- public SerialPortConfig CardReaderConfig
- {
- get { return _CardReaderConfig; }
- set { SetProperty(ref _CardReaderConfig, value); }
- }
- private TorqueSerialPortConfig _TorqueReadConfig;
- public TorqueSerialPortConfig TorqueReadConfig
- {
- get { return _TorqueReadConfig; }
- set { SetProperty(ref _TorqueReadConfig, value); }
- }
- private WorkShift _WorkShift;
- public WorkShift WorkShifts
- {
- get { return _WorkShift; }
- set { SetProperty(ref _WorkShift, value); }
- }
- private ObservableCollection<ProductModel> _ProductList;
- public ObservableCollection<ProductModel> ProductList
- {
- get { return _ProductList; }
- set { SetProperty(ref _ProductList, value); }
- }
- private ProductWithMes _ProMesInfo = new ProductWithMes();
- public ProductWithMes ProMesInfo
- {
- get { return _ProMesInfo; }
- set { SetProperty(ref _ProMesInfo, value); }
- }
- private ProductModel _SelectProduct;
- public ProductModel SelectProduct
- {
- get { return _SelectProduct; }
- set { SetProperty(ref _SelectProduct, value); }
- }
- #endregion
- #region 命令
- public DelegateCommand LoadedCommand { get; set; }
- private DelegateCommand _SaveSystemParametersCommand;
- public DelegateCommand SaveSystemParametersCommand =>
- _SaveSystemParametersCommand ?? (_SaveSystemParametersCommand = new DelegateCommand(ExecuteSaveSystemParametersCommand));
- private DelegateCommand _AddRobotCommand;
- public DelegateCommand AddRobotCommand =>
- _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
- private DelegateCommand _RemoveCommand;
- public DelegateCommand RemoveCommand =>
- _RemoveCommand ?? (_RemoveCommand = new DelegateCommand(ExecuteRemoveCommand));
- private DelegateCommand _AddFeederCommand;
- public DelegateCommand AddFeederCommand =>
- _AddFeederCommand ?? (_AddFeederCommand = new DelegateCommand(ExecuteAddFeederCommand));
- private DelegateCommand _RemoveFeederCommand;
- public DelegateCommand RemoveFeederCommand =>
- _RemoveFeederCommand ?? (_RemoveFeederCommand = new DelegateCommand(ExecuteRemoveFeederCommand));
- private DelegateCommand<string> _SelectLanguageCommand;
- public DelegateCommand<string> SelectLanguageCommand =>
- _SelectLanguageCommand ?? (_SelectLanguageCommand = new DelegateCommand<string>(ExecuteSelectLanguageCommand));
- private DelegateCommand _SaveRobotsCommand;
- public DelegateCommand SaveRobotsCommand =>
- _SaveRobotsCommand ?? (_SaveRobotsCommand = new DelegateCommand(ExecuteSaveRobotsCommand));
- private DelegateCommand _SaveFeedersCommand;
- public DelegateCommand SaveFeedersCommand =>
- _SaveFeedersCommand ?? (_SaveFeedersCommand = new DelegateCommand(ExecuteSaveFeedersCommand));
- private DelegateCommand<string> _SaveCommunicateCommand;
- public DelegateCommand<string> SaveCommunicateCommand =>
- _SaveCommunicateCommand ?? (_SaveCommunicateCommand = new DelegateCommand<string>(ExecuteSaveCommunicateCommand));
- private DelegateCommand _AddCameraCommand;
- public DelegateCommand AddCameraCommand =>
- _AddCameraCommand ?? (_AddCameraCommand = new DelegateCommand(ExecuteAddCameraCommand));
- private DelegateCommand _EditCameraCommand;
- public DelegateCommand EditCameraCommand =>
- _EditCameraCommand ?? (_EditCameraCommand = new DelegateCommand(ExecuteEditCameraCommand));
- private DelegateCommand _RemoveCameraCommand;
- public DelegateCommand RemoveCameraCommand =>
- _RemoveCameraCommand ?? (_RemoveCameraCommand = new DelegateCommand(ExecuteRemoveCameraCommand));
- private DelegateCommand _SaveCamerasCommand;
- public DelegateCommand SaveCamerasCommand =>
- _SaveCamerasCommand ?? (_SaveCamerasCommand = new DelegateCommand(ExecuteSaveCamerasCommand));
- private DelegateCommand _AddPlcCommand;
- public DelegateCommand AddPlcCommand =>
- _AddPlcCommand ?? (_AddPlcCommand = new DelegateCommand(ExecuteAddPlcCommand));
- private DelegateCommand _RemovePlcCommand;
- public DelegateCommand RemovePlcCommand =>
- _RemovePlcCommand ?? (_RemovePlcCommand = new DelegateCommand(ExecuteRemovePlcCommand));
- private DelegateCommand _SavePlcsCommand;
- public DelegateCommand SavePlcsCommand =>
- _SavePlcsCommand ?? (_SavePlcsCommand = new DelegateCommand(ExecuteSavePlcsCommand));
- private DelegateCommand _AddLightControllerCommand;
- public DelegateCommand AddLightControllerCommand => _AddLightControllerCommand ?? (_AddLightControllerCommand = new DelegateCommand(ExecuteAddLightControllerCommand));
- private DelegateCommand _RemoveLightControllerCommand;
- public DelegateCommand RemoveLightControllerCommand => _RemoveLightControllerCommand ?? (_RemoveLightControllerCommand = new DelegateCommand(ExecuteRemoveLightControllerCommand));
- private DelegateCommand _SaveLightControllersCommand;
- public DelegateCommand SaveLightControllersCommand => _SaveLightControllersCommand ?? (_SaveLightControllersCommand = new DelegateCommand(ExecuteSaveLightControllersCommand));
- private DelegateCommand _SaveDeviceInfoCommand;
- public DelegateCommand SaveDeviceInfoCommand => _SaveDeviceInfoCommand ?? (_SaveDeviceInfoCommand = new DelegateCommand(ExecuteSaveDeviceInfoCommand));
- private DelegateCommand _AddDeviceInfoCommand;
- public DelegateCommand AddDeviceInfoCommand => _AddDeviceInfoCommand ?? (_AddDeviceInfoCommand = new DelegateCommand(ExecuteAddDeviceInfoCommand));
- private DelegateCommand _RemoveDeviceInfoCommand;
- public DelegateCommand RemoveDeviceInfoCommand => _RemoveDeviceInfoCommand ?? (_RemoveDeviceInfoCommand = new DelegateCommand(ExecuteRemoveDeviceInfoCommand));
- private DelegateCommand _BrowseScrewCurvePathCommand;
- public DelegateCommand BrowseScrewCurvePathCommand => _BrowseScrewCurvePathCommand ?? (_BrowseScrewCurvePathCommand = new DelegateCommand(ExecuteBrowseScrewCurvePathCommand));
- private DelegateCommand _AddScrewFeederCommand;
- public DelegateCommand AddScrewFeederCommand =>
- _AddScrewFeederCommand ?? (_AddScrewFeederCommand = new DelegateCommand(ExecuteAddScrewFeederCommand));
- private DelegateCommand _RemoveScrewFeederCommand;
- public DelegateCommand RemoveScrewFeederCommand =>
- _RemoveScrewFeederCommand ?? (_RemoveScrewFeederCommand = new DelegateCommand(ExecuteRemoveScrewFeederCommand));
- private DelegateCommand _SaveScrewFeedersCommand;
- public DelegateCommand SaveScrewFeedersCommand =>
- _SaveScrewFeedersCommand ?? (_SaveScrewFeedersCommand = new DelegateCommand(ExecuteSaveScrewFeedersCommand));
- private DelegateCommand<object> _LightModelChangedCommand;
- public DelegateCommand<object> LightModelChangedCommand =>
- _LightModelChangedCommand ?? (_LightModelChangedCommand = new DelegateCommand<object>(ExecuteLightModelChangedCommand));
- private DelegateCommand _SaveCardReaderConfigCommand;
- public DelegateCommand SaveCardReaderConfigCommand =>
- _SaveCardReaderConfigCommand ?? (_SaveCardReaderConfigCommand = new DelegateCommand(ExecuteSaveCardReaderConfigCommand));
- private DelegateCommand _SaveTorqueReaderConfigCommand;
- public DelegateCommand SaveTorqueReaderConfigCommand =>
- _SaveTorqueReaderConfigCommand ?? (_SaveTorqueReaderConfigCommand = new DelegateCommand(ExecuteSaveTorqueReaderConfigCommand));
- private DelegateCommand _SaveWorkShiftCommand;
- public DelegateCommand SaveWorkShiftCommand =>
- _SaveWorkShiftCommand ?? (_SaveWorkShiftCommand = new DelegateCommand(ExecuteSaveWorkShiftCommand));
- private DelegateCommand _SelectSaveImagePathCommand;
- public DelegateCommand SelectSaveImagePathCommand =>
- _SelectSaveImagePathCommand ?? (_SelectSaveImagePathCommand = new DelegateCommand(ExecuteSelectSaveImagePathCommand));
- private DelegateCommand _GetProWithMesCommand;
- public DelegateCommand GetProWithMesCommand =>
- _GetProWithMesCommand ?? (_GetProWithMesCommand = new DelegateCommand(ExecuteGetProWithMesCommand));
- private DelegateCommand _DeleteProWithMesCommand;
- public DelegateCommand DeleteProWithMesCommand =>
- _DeleteProWithMesCommand ?? (_DeleteProWithMesCommand = new DelegateCommand(ExecuteDeleteProWithMesCommand));
- private DelegateCommand _SaveProWithMesCommand;
- public DelegateCommand SaveProWithMesCommand =>
- _SaveProWithMesCommand ?? (_SaveProWithMesCommand = new DelegateCommand(ExecuteSaveProWithMesCommandAsync));
- private DelegateCommand _CheckStatusCommand;
- public DelegateCommand CheckStatusCommand =>
- _CheckStatusCommand ?? (_CheckStatusCommand = new DelegateCommand(ExecuteCheckStatusCommandCommand));
- #endregion
- #region 事件
- #endregion
- public SettingViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService,
- IConfigService configService, IRobotService robotService, ICameraService cameraService, IFeederService feederService, IPlcService plcService,
- IProductService productService, ISystemDatabaseService systemDatabaseService)
- {
- _regionManager = regionManager;
- _eventAggregator = ea;
- _container = container;
- _dialogService = dialogService;
- _configService = configService;
- _robotService = robotService;
- _cameraService = cameraService;
- _feederService = feederService;
- _plcService = plcService;
- _productService = productService;
- _systemDatabaseService = systemDatabaseService;
- management = _container.Resolve<Management>();
- LoadedCommand = new DelegateCommand(OnLoad);
- //订阅权限登录事件
- _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
- }
- #region 方法
- #region 机器人
- private void ExecuteAddRobotCommand()
- {
- _dialogService.ShowDialog("AddRobot", rst =>
- {
- //对话框关闭之后的回调函数,可以在这解析结果。
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<RobotInfo>("Robot");
- var robot = new RobotInfo()
- {
- Id = param.Id,
- RobotName = param.RobotName,
- ConnectType = param.ConnectType,
- RobotBrand = param.RobotBrand,
- IP = param.IP,
- Port = param.Port,
- Terminator = param.Terminator,
- };
- RobotList.Add(robot);
- _configService.AddOrUpdateRobot(robot);
- _robotService.CreateRobot(robot.Id, robot);
- //对所有产品也进行添加
- _productService.AddRobotPointToProduct(robot.Id, robot.RobotName);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
- }
- });
- }
- void ExecuteRemoveCommand()
- {
- if (MessageBox.Show(Lang.是否移除机器人, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- // 找到要删除的机器人
- var robotToRemove = RobotList.FirstOrDefault(r => r.Id == SelectRobot.Id);
- if (robotToRemove != null)
- {
- RobotList.Remove(robotToRemove);
- _configService.RemoveRobot(robotToRemove.Id);
- _robotService.RemoveRobot(robotToRemove.Id);
- //对所有产品也进行移除
- _productService.RemoveRobotPointFromProduct(robotToRemove.Id);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
- }
- }
- }
- async void ExecuteSaveRobotsCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存机器人);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- foreach (var item in RobotList)
- {
- var robot = _robotService.GetRobot(item.Id);
- if (robot != null)
- {
- //更新连接参数
- robot.SafeZ = item.SafeZ;
- }
- _configService.AddOrUpdateRobot(item);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- #endregion
- #region 相机
- /// <summary>
- /// 保存所有相机
- /// </summary>
- async void ExecuteSaveCamerasCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存相机配置);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
- //management.SaveCamerasDeviceConfig();
- //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- /// <summary>
- /// 移除相机
- /// </summary>
- void ExecuteRemoveCameraCommand()
- {
- if (MessageBox.Show(Lang.是否移除相机, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- // 找到要删除的相机
- var cameraToRemove = CameraList.FirstOrDefault(r => r.Id == SelectCamera.Id);
- if (cameraToRemove != null)
- {
- _configService.RemoveCamera(cameraToRemove.Id);
- _cameraService.RemoveCamera(cameraToRemove.Id);
- var root = _configService.GetAllCameras();
- CameraList = new ObservableCollection<CameraInfo>(root);
- foreach (var item in CameraList)
- {
- _cameraService.UpdateCameraNumber(item.Id, item.CameraNo);
- }
- //对所有产品也进行移除
- _productService.RemoveCameraFromProduct(cameraToRemove.Id);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- /// <summary>
- /// 编辑相机
- /// </summary>
- void ExecuteEditCameraCommand()
- {
- if (SelectCamera == null) return;
- bool isSelectedCameraBrandSucced = false;
- CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
- IDialogParameters parameters1 = new DialogParameters();
- parameters1.Add("CameraBrand", SelectCamera.CameraBrand);
- _dialogService.ShowDialog("SelectCameraBrand", parameters1, rst =>
- {
- if (rst.Result == ButtonResult.OK)
- {
- isSelectedCameraBrandSucced = true;
- cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
- }
- else
- {
- return;
- }
- });
- if (!isSelectedCameraBrandSucced) { return; }
- (bool isInstalled, string version) result = (false, "");
- string softwarename = "";
- switch (cameraBrand)
- {
- case CameraBrand.HikRobot_MVS:
- softwarename = "MVS";
- result = MvCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Basler_Pylon:
- softwarename = "Pylon 7";
- result = BaslerCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.IRayple:
- softwarename = "MV Viewer";
- result = AHuaCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Cognex:
- softwarename = "Cognex VisionPro";
- result = CognexCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Galaxy:
- softwarename = "Galaxy Viewer";
- result = GalaxyCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Opt:
- softwarename = "OPT Camera Viewer";
- result = OptCamera.CheckSoftwareInstalled();
- break;
- default:
- break;
- }
- if (!result.isInstalled)
- {
- if (string.IsNullOrEmpty(result.version))
- {
- //未安装
- MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- }
- else
- {
- //版本较低
- MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- }
- return;
- }
- //编辑前的相机名称
- string oldCameraName = SelectCamera.CameraName;
- IDialogParameters parameters = new DialogParameters();
- parameters.Add("CameraBrand", cameraBrand);
- parameters.Add("Camera", SelectCamera.Copy());
- _dialogService.ShowDialog("EditCamera", parameters, rst =>
- {
- //对话框关闭之后的回调函数,可以在这解析结果。
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<CameraInfo>("Camera");
- SelectCamera.CameraName = param.CameraName;
- SelectCamera.SerialNumber = param.SerialNumber;
- SelectCamera.Model = param.Model;
- SelectCamera.ManufacturerName = param.ManufacturerName;
- SelectCamera.CameraType = param.CameraType;
- SelectCamera.CameraBrand = param.CameraBrand;
- SelectCamera.CameraIp = param.CameraIp;
- _configService.AddOrUpdateCamera(SelectCamera);
- if (oldCameraName != param.CameraName)
- {
- //对所有产品也进行修改
- _productService.UpdateCameraNameInProduct(SelectCamera.Id, SelectCamera.CameraName);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- });
- }
- /// <summary>
- /// 增加相机
- /// </summary>
- void ExecuteAddCameraCommand()
- {
- bool isSelectedCameraBrandSucced = false;
- CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
- _dialogService.ShowDialog("SelectCameraBrand", rst =>
- {
- if (rst.Result == ButtonResult.OK)
- {
- isSelectedCameraBrandSucced = true;
- cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
- }
- else
- {
- return;
- }
- });
- if (!isSelectedCameraBrandSucced) { return; }
- ;
- (bool isInstalled, string version) result = (false, "");
- string softwarename = "";
- switch (cameraBrand)
- {
- case CameraBrand.HikRobot_MVS:
- softwarename = "MVS";
- result = MvCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Basler_Pylon:
- softwarename = "Pylon 7";
- result = BaslerCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.IRayple:
- softwarename = "MV Viewer";
- result = AHuaCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Cognex:
- softwarename = "Cognex VisionPro";
- result = CognexCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Galaxy:
- softwarename = "Galaxy Viewer";
- result = GalaxyCamera.CheckSoftwareInstalled();
- break;
- case CameraBrand.Opt:
- softwarename = "OPT Camera Viewer";
- result = OptCamera.CheckSoftwareInstalled();
- break;
- default:
- break;
- }
- if (!result.isInstalled)
- {
- if (string.IsNullOrEmpty(result.version))
- {
- //未安装
- MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- }
- else
- {
- //版本较低
- MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
- }
- return;
- }
- IDialogParameters parameters = new DialogParameters();
- parameters.Add("CameraBrand", cameraBrand);
- _dialogService.ShowDialog("AddCamera", parameters, rst =>
- {
- //对话框关闭之后的回调函数,可以在这解析结果。
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<CameraInfo>("Camera");
- var camera = new CameraInfo()
- {
- Id = param.Id,
- CameraName = param.CameraName,
- SerialNumber = param.SerialNumber,
- Model = param.Model,
- ManufacturerName = param.ManufacturerName,
- CameraType = param.CameraType,
- CameraBrand = param.CameraBrand,
- CameraIp = param.CameraIp
- };
- CameraList.Add(camera);
- _configService.AddOrUpdateCamera(camera);
- _cameraService.CreateCamera(camera.Id, camera);
- //对所有产品也进行添加
- _productService.AddCameraToProduct(camera.Id, camera.CameraName);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- });
- }
- #endregion
- #region Feeder
- void ExecuteAddFeederCommand()
- {
- _dialogService.ShowDialog("AddFeeder", rst =>
- {
- //对话框关闭之后的回调函数,可以在这解析结果。
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<FeederInfo>("Feeder");
- var feeder = new FeederInfo()
- {
- Id = param.Id,
- FeederName = param.FeederName,
- ConnectType = param.ConnectType,
- FeederBrand = param.FeederBrand,
- IP = param.IP,
- Port = param.Port
- };
- FeederList.Add(feeder);
- _configService.AddOrUpdateFeeder(feeder);
- _feederService.CreateFeeder(feeder.Id, feeder.FeederNo, feeder.FeederName, feeder.IP, feeder.Port, feeder.FeederBrand);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
- }
- });
- }
- void ExecuteRemoveFeederCommand()
- {
- if (MessageBox.Show(Lang.是否移除Feeder, " AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- // 找到要删除的机器人
- var feederToRemove = FeederList.FirstOrDefault(r => r.Id == SelectFeeder.Id);
- if (feederToRemove != null)
- {
- _configService.RemoveFeeder(feederToRemove.Id);
- _feederService.RemoveFeeder(feederToRemove.Id);
- var root = _configService.GetAllFeeders();
- FeederList = new ObservableCollection<FeederInfo>(root);
- foreach (var item in FeederList)
- {
- _feederService.UpdateFeederNo(item.Id, item.FeederNo);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
- }
- }
- }
- async void ExecuteSaveFeedersCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存Feeder);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- foreach (var item in FeederList)
- {
- _configService.AddOrUpdateFeeder(item);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- #endregion
- #region PLC
- /// <summary>
- /// 保存PLC
- /// </summary>
- async void ExecuteSavePlcsCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存PLC);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- foreach (var item in PlcList)
- {
- _configService.AddOrUpdatePlc(item);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- /// <summary>
- /// 移除PLC
- /// </summary>
- void ExecuteRemovePlcCommand()
- {
- if (MessageBox.Show(Lang.是否移除PLC, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- // 找到要删除的plc
- var plcToRemove = PlcList.FirstOrDefault(r => r.Id == SelectPlc.Id);
- if (plcToRemove != null)
- {
- _configService.RemovePlc(plcToRemove.Id);
- _plcService.RemovePlc(plcToRemove.Id);
- var root = _configService.GetAllPlcs();
- PlcList = new ObservableCollection<PlcInfo>(root);
- foreach (var item in PlcList)
- {
- _plcService.UpdatePlcNumber(item.Id, item.Index);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
- }
- }
- }
- /// <summary>
- /// 增加PLC
- /// </summary>
- void ExecuteAddPlcCommand()
- {
- _dialogService.ShowDialog("AddPlc", rst =>
- {
- //对话框关闭之后的回调函数,可以在这解析结果。
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<PlcInfo>("PLC");
- var plc = new PlcInfo()
- {
- Id = param.Id,
- Name = param.Name,
- CommunicationType = param.CommunicationType,
- EndpointUrl = param.EndpointUrl,
- };
- PlcList.Add(plc);
- _configService.AddOrUpdatePlc(plc);
- _plcService.CreatePlc(plc.Id, plc);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
- }
- });
- }
- #endregion
- #region Light handlers
- void ExecuteAddLightControllerCommand()
- {
- // open dialog to add light controller (similar to robots)
- _dialogService.ShowDialog("AddLightController", rst =>
- {
- if (rst.Result == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<LightControllerConfig>("LightController");
- // assign id and defaults if needed
- if (param.Id == 0)
- param.Id = (LightControllerList?.Count ?? 0) + 1;
- LightControllerList.Add(param);
- _configService.AddOrUpdateLightController(param);
- SelectLightController = param;
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
- }
- });
- }
- void ExecuteRemoveLightControllerCommand()
- {
- if (SelectLightController == null) return;
- if (MessageBox.Show(Lang.是否移除光源控制器, "AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- _configService.RemoveLightController(SelectLightController.Id);
- LightControllerList.Remove(SelectLightController);
- SelectLightController = null;
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
- }
- }
- async void ExecuteSaveLightControllersCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存光源控制器配置);
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool && (bool)result)
- {
- foreach (var item in LightControllerList)
- {
- _configService.AddOrUpdateLightController(item);
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- /// <summary>
- /// 光源型号改变
- /// </summary>
- void ExecuteLightModelChangedCommand(object obj)
- {
- try
- {
- if (obj == null)
- {
- return;
- }
- if (obj is LightControllerConfig lc)
- {
- lc.Init();
- }
- }
- catch (Exception)
- {
- }
- }
- #endregion
- #region 螺丝供料器
- /// <summary>
- /// 保存所有螺丝供料器
- /// </summary>
- async void ExecuteSaveScrewFeedersCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存螺丝供料器);
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool && (bool)result)
- {
- if (ScrewFeederList != null)
- {
- foreach (var item in ScrewFeederList)
- {
- try
- {
- _configService.AddOrUpdateScrewFeeder(item);
- }
- catch (Exception ex)
- {
- // 记录或通知错误,但继续处理其它项
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- /// <summary>
- /// 移除螺丝供料器
- /// </summary>
- void ExecuteRemoveScrewFeederCommand()
- {
- if (SelectScrewFeeder == null) return;
- if (MessageBox.Show(Lang.是否移除螺丝供料器, "AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
- try
- {
- var toRemove = ScrewFeederList?.FirstOrDefault(s => s.Id == SelectScrewFeeder.Id);
- if (toRemove != null)
- {
- _configService.RemoveScrewFeeder(toRemove.Id);
- // 重新加载列表以保持序号/配置一致(与其他类似实现一致)
- var root = _configService.GetAllScrewFeeders();
- ScrewFeederList = new ObservableCollection<ScrewFeederInfo>(root);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
- }
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- }
- /// <summary>
- /// 添加螺丝供料器
- /// </summary>
- void ExecuteAddScrewFeederCommand()
- {
- _dialogService.ShowDialog("AddScrewFeeder", rst =>
- {
- ButtonResult result1 = rst.Result;
- if (result1 == ButtonResult.OK)
- {
- var param = rst.Parameters.GetValue<ScrewFeederInfo>("ScrewFeeder");
- if (param != null)
- {
- if (ScrewFeederList == null)
- {
- ScrewFeederList = new ObservableCollection<ScrewFeederInfo>();
- }
- try
- {
- param = _configService.AddOrUpdateScrewFeeder(param);
- // 直接添加对话框返回的对象(也可以根据需要映射字段)
- ScrewFeederList.Add(param);
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
- }
- }
- });
- }
- #endregion
- #region 通讯
- async void ExecuteSaveCommunicateCommand(string parm)
- {
- if (parm == "TCPIP")
- {
- var view = new ShowMessage($"AAS", Lang.是否保存后台TCP通讯配置);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- _configService.SetBgTcp(BgTcp);
- _configService.SaveBgTcp();
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- else if (parm == "ModbusTCP")
- {
- var view = new ShowMessage($"AAS", Lang.是否保存后台ModbusTCP通讯配置);
- //show the dialog
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool)
- {
- if (((bool)result))
- {
- _configService.SetBgModbusTcp(BgModbus);
- _configService.SaveBgModbusTcp();
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- }
- else
- {
- return;
- }
- }
- #endregion
- #region 语言
- void ExecuteSelectLanguageCommand(string language)
- {
- if (string.Equals(language, "ChineseSimplified"))
- {
- CurrentLanguage = Enums.Language.ChineseSimplified;
- _configService.SetCurrentLanguage(CurrentLanguage);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
- }
- else if (string.Equals(language, "ChineseTraditional"))
- {
- CurrentLanguage = Enums.Language.ChineseTraditional;
- _configService.SetCurrentLanguage(CurrentLanguage);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
- }
- else if (string.Equals(language, "English"))
- {
- CurrentLanguage = Enums.Language.English;
- _configService.SetCurrentLanguage(CurrentLanguage);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
- }
- else if (string.Equals(language, "Japanese"))
- {
- CurrentLanguage = Enums.Language.Japanese;
- _configService.SetCurrentLanguage(CurrentLanguage);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
- }
- else if (string.Equals(language, "Vietnamese"))
- {
- CurrentLanguage = Enums.Language.Vietnamese;
- _configService.SetCurrentLanguage(CurrentLanguage);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
- }
- }
- #endregion
- #region 生产排班
- private void ExecuteSaveWorkShiftCommand()
- {
- try
- {
- FileHelper.WriteJsonFile(WorkShifts, FilePath.WorkShiftParamPath);
- _eventAggregator.GetEvent<WorkShiftUpdateNotification>().Publish(WorkShifts);
- }
- catch (Exception)
- { }
- }
- #endregion
- private void OnLoad()
- {
- try
- {
- this.WorkShifts = FileHelper.ReadJsonFile<WorkShift>(FilePath.WorkShiftParamPath);
- }
- catch (Exception)
- {
- }
- }
- private void ExecuteCheckStatusCommandCommand()
- {
- _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
- }
- private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- switch (e.PropertyName)
- {
- case "Title1":
- Application.Current.Resources["Font.Size.Title1"] = Title1;
- break;
- case "Title2":
- Application.Current.Resources["Font.Size.Title2"] = Title2;
- break;
- case "Title3":
- Application.Current.Resources["Font.Size.Title3"] = Title3;
- break;
- case "Title4":
- Application.Current.Resources["Font.Size.Title4"] = Title4;
- break;
- case "Body1":
- Application.Current.Resources["Font.Size.Body1"] = Body1;
- break;
- case "Body2":
- Application.Current.Resources["Font.Size.Body2"] = Body2;
- break;
- case "Body3":
- Application.Current.Resources["Font.Size.Body3"] = Body3;
- break;
- case "Body4":
- Application.Current.Resources["Font.Size.Body4"] = Body4;
- break;
- case "Captions1":
- Application.Current.Resources["Font.Size.Captions1"] = Captions1;
- break;
- case "Captions2":
- Application.Current.Resources["Font.Size.Captions2"] = Captions2;
- break;
- case "Captions3":
- Application.Current.Resources["Font.Size.Captions3"] = Captions3;
- break;
- case "Captions4":
- Application.Current.Resources["Font.Size.Captions4"] = Captions4;
- break;
- default:
- break;
- }
- }
- #endregion
- #region 继承
- /// <summary>
- /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <param name="continuationCallback"></param>
- public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
- {
- continuationCallback(true);
- }
- /// <summary>
- /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <exception cref="NotImplementedException"></exception>
- public async void OnNavigatedTo(NavigationContext navigationContext)
- {
- if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
- if (RobotList == null)
- {
- RobotList = new ObservableCollection<RobotInfo>();
- var robots = _configService.GetAllRobots();
- foreach (var robot in robots)
- {
- RobotList.Add(robot);
- }
- }
- if (CameraList == null)
- {
- CameraList = new ObservableCollection<CameraInfo>();
- var cameras = _configService.GetAllCameras();
- foreach (var camera in cameras)
- {
- CameraList.Add(camera);
- }
- }
- if (FeederList == null)
- {
- FeederList = new ObservableCollection<FeederInfo>();
- var feeders = _configService.GetAllFeeders();
- foreach (var feeder in feeders)
- {
- FeederList.Add(feeder);
- }
- }
- if (PlcList == null)
- {
- PlcList = new ObservableCollection<PlcInfo>();
- var plcs = _configService.GetAllPlcs();
- foreach (var plc in plcs)
- {
- PlcList.Add(plc);
- }
- }
- // load light controllers
- if (LightControllerList == null)
- {
- LightControllerList = new ObservableCollection<LightControllerConfig>();
- var controllers = _configService.GetAllLightControllers();
- foreach (var ctrl in controllers)
- {
- LightControllerList.Add(ctrl);
- }
- }
- if (BgTcp == null)
- {
- BgTcp = _configService.GetBgTcp();
- }
- if (BgModbus == null)
- {
- BgModbus = _configService.GetBgModbusTcp();
- }
- if (DeviceInfoList == null || DeviceInfoList.Count == 0)
- {
- // load device info list (支持多设备)
- var devices = _configService.GetAllDeviceInfos();
- DeviceInfoList = new ObservableCollection<DeviceInfo>(devices);
- // 默认选中第一个设备
- if (DeviceInfoList.Count > 0)
- {
- SelectDeviceInfo = DeviceInfoList[0];
- }
- }
- if (ScrewFeederList == null)
- {
- var screwFeeders = _configService.GetAllScrewFeeders();
- ScrewFeederList = new ObservableCollection<ScrewFeederInfo>(screwFeeders);
- }
- if (CardReaderConfig == null)
- {
- // load card reader config
- CardReaderConfig = _configService.GetCardReaderConfig();
- }
- if (TorqueReadConfig == null)
- {
- TorqueReadConfig = _configService.GetTorqueReaderConfig();
- }
- CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
- // load system parameters into UI
- var sys = _configService.GetSystemConfiguration();
- if (sys != null)
- {
- WorkMode = sys.WorkMode;
- PickPointNum = sys.PickPointNum;
- DowmCameraNum = sys.DowmCameraNum;
- WorkMode = sys.WorkMode;
- PickPointNum = sys.PickPointNum;
- DowmCameraNum = sys.DowmCameraNum;
- UpCameraPickNum = sys.UpCameraPickNum;
- UpCameraPutNum = sys.UpCameraPutNum;
- UPCameracheckNum = sys.UPCameracheckNum;
- FixedCameraPickNum = sys.FixedCameraPickNum;
- FixedCameraPutNum = sys.FixedCameraPutNum;
- FixedCameracheckNum = sys.FixedCameracheckNum;
- ScrewTeachNum = sys.ScrewTeachNum;
- IsSaveScrewCurve = sys.IsSaveScrewCurve;
- ScrewCurvePath = sys.ScrewCurvePath;
- IsBasePartCodeGetSN = sys.IsBasePartCodeGetSN;
- IsBasePartCodeChooseScrew = sys.IsBasePartCodeChooseScrew;
- IsBasePartOpenLight = sys.IsBasePartOpenLight;
- IsBasePartOpenLightKB = sys.IsBasePartOpenLightKB;
- IsMesResult = sys.IsMesResult;
- ChooseScrewModel = sys.ChooseScrewModel;
- }
- if (isFirstLoad)
- {
- Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
- Title2 = (double)Application.Current.Resources["Font.Size.Title2"];
- Title3 = (double)Application.Current.Resources["Font.Size.Title3"];
- Title4 = (double)Application.Current.Resources["Font.Size.Title4"];
- Body1 = (double)Application.Current.Resources["Font.Size.Body1"];
- Body2 = (double)Application.Current.Resources["Font.Size.Body2"];
- Body3 = (double)Application.Current.Resources["Font.Size.Body3"];
- Body4 = (double)Application.Current.Resources["Font.Size.Body4"];
- Captions1 = (double)Application.Current.Resources["Font.Size.Captions1"];
- Captions2 = (double)Application.Current.Resources["Font.Size.Captions2"];
- Captions3 = (double)Application.Current.Resources["Font.Size.Captions3"];
- Captions4 = (double)Application.Current.Resources["Font.Size.Captions4"];
- this.PropertyChanged += OnPropertyChanged;
- isFirstLoad = false;
- }
- try
- {
- ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogError("加载产品列表时出错", ex);
- }
- }
- /// <summary>
- /// 是否允许导航到此视图模型。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <returns></returns>
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- /// <summary>
- /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
- /// </summary>
- /// <param name="navigationContext"></param>
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- #endregion
- private bool _IsAllowEdit = false;
- public bool IsAllowEdit
- {
- get { return _IsAllowEdit; }
- set { SetProperty(ref _IsAllowEdit, value); }
- }
- private void LoginChange(Models.User user)
- {
- if (user.userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
- }
- #region 系统参数
- private bool _IsBasePartCodeGetSN;
- /// <summary>
- /// 是否基于零件码获取流程码
- /// </summary>
- public bool IsBasePartCodeGetSN
- {
- get { return _IsBasePartCodeGetSN; }
- set { SetProperty(ref _IsBasePartCodeGetSN, value); }
- }
- private bool _IsBasePartOpenLight;
- /// <summary>
- /// 是否启用最后一次拍照关闭光源
- /// </summary>
- public bool IsBasePartOpenLight
- {
- get { return _IsBasePartOpenLight; }
- set { SetProperty(ref _IsBasePartOpenLight, value); }
- }
- private bool _IsBasePartOpenLightKB;
- /// <summary>
- /// 是否启用KB复检
- /// </summary>
- public bool IsBasePartOpenLightKB
- {
- get { return _IsBasePartOpenLightKB; }
- set { SetProperty(ref _IsBasePartOpenLightKB, value); }
- }
- private bool _IsMesResult;
- public bool IsMesResult
- {
- get { return _IsMesResult; }
- set { SetProperty(ref _IsMesResult, value); }
- }
- private bool _IsBasePartCodeChooseScrew;
- /// <summary>
- /// 是否通过零件码判断螺丝型号
- /// </summary>
- public bool IsBasePartCodeChooseScrew
- {
- get { return _IsBasePartCodeChooseScrew; }
- set { SetProperty(ref _IsBasePartCodeChooseScrew, value); }
- }
- private string _ChooseScrewModel;
- /// <summary>
- /// 螺丝型号判断,如******123**,*为忽略字符
- /// </summary>
- public string ChooseScrewModel
- {
- get { return _ChooseScrewModel; }
- set { SetProperty(ref _ChooseScrewModel, value); }
- }
- private Int16 _WorkMode = 0;
- /// <summary>
- /// 工作模式 =1 拍1打1, =2 拍1打所有,=3:先拍1打1打3颗再拍2打所有
- /// </summary>
- public Int16 WorkMode
- {
- get { return _WorkMode; }
- set { SetProperty(ref _WorkMode, value); }
- }
- private Int16 _PickPointNum = 0;
- /// <summary>
- /// 取料位置 =0 不需要取料 =1 需要取料
- /// </summary>
- public Int16 PickPointNum
- {
- get { return _PickPointNum; }
- set { SetProperty(ref _PickPointNum, value); }
- }
- private Int16 _DowmCameraNum = 0;
- /// <summary>
- /// 下相机拍照次数
- /// </summary>
- public Int16 DowmCameraNum
- {
- get => _DowmCameraNum;
- set => SetProperty(ref _DowmCameraNum, value);
- }
- private Int16 _UpCameraPickNum = 0;
- /// <summary>
- /// 上相机取料拍照次数
- /// </summary>
- public Int16 UpCameraPickNum
- {
- get => _UpCameraPickNum;
- set => SetProperty(ref _UpCameraPickNum, value);
- }
- private Int16 _UpCameraPutNum = 0;
- /// <summary>
- /// 上相机放料拍照次数
- /// </summary>
- public Int16 UpCameraPutNum
- {
- get => _UpCameraPutNum;
- set => SetProperty(ref _UpCameraPutNum, value);
- }
- private Int16 _UPCameracheckNum = 0;
- /// <summary>
- /// 上相机锁附/组装次数
- /// </summary>
- public Int16 UPCameracheckNum
- {
- get => _UPCameracheckNum;
- set => SetProperty(ref _UPCameracheckNum, value);
- }
- private Int16 _FixedCameraPickNum = 0;
- /// <summary>
- /// 取料固定位置拍产品相机数量
- /// </summary>
- public Int16 FixedCameraPickNum
- {
- get => _FixedCameraPickNum;
- set => SetProperty(ref _FixedCameraPickNum, value);
- }
- private Int16 _FixedCameraPutNum = 0;
- /// <summary>
- /// 锁附/组装固定位置拍产品相机数量
- /// </summary>
- public Int16 FixedCameraPutNum
- {
- get => _FixedCameraPutNum;
- set => SetProperty(ref _FixedCameraPutNum, value);
- }
- private Int16 _FixedCameracheckNum = 0;
- /// <summary>
- /// 固定相机检测锁附/组装次数
- /// </summary>
- public Int16 FixedCameracheckNum
- {
- get => _FixedCameracheckNum;
- set => SetProperty(ref _FixedCameracheckNum, value);
- }
- private Int16 _ScrewTeachNum = 0;
- /// <summary>
- /// 披头矫正的模式,1:初始化时矫正,2:每个产品矫正一次,3:每颗螺丝矫正一次
- /// </summary>
- public Int16 ScrewTeachNum
- {
- get => _ScrewTeachNum;
- set => SetProperty(ref _ScrewTeachNum, value);
- }
- private bool _IsSaveScrewCurve;
- /// <summary>
- /// 是否保存锁付曲线图
- /// </summary>
- public bool IsSaveScrewCurve
- {
- get { return _IsSaveScrewCurve; }
- set { SetProperty(ref _IsSaveScrewCurve, value); }
- }
- private string _ScrewCurvePath;
- /// <summary>
- /// 锁付曲线图保存路径
- /// </summary>
- public string ScrewCurvePath
- {
- get { return _ScrewCurvePath; }
- set { SetProperty(ref _ScrewCurvePath, value); }
- }
- /// <summary>
- /// 选择锁付曲线图保存路径
- /// </summary>
- void ExecuteBrowseScrewCurvePathCommand()
- {
- try
- {
- using (var dlg = new System.Windows.Forms.FolderBrowserDialog())
- {
- dlg.Description = "选择锁付曲线图保存路径";
- dlg.ShowNewFolderButton = true;
- if (!string.IsNullOrEmpty(ScrewCurvePath)) dlg.SelectedPath = ScrewCurvePath;
- var result = dlg.ShowDialog();
- if (result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes)
- {
- ScrewCurvePath = dlg.SelectedPath;
- }
- }
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 2 });
- }
- }
- /// <summary>
- /// 保存系统参数
- /// </summary>
- async void ExecuteSaveSystemParametersCommand()
- {
- var view = new ShowMessage($"AAS", Lang.是否保存系统参数);
- var result = await DialogHost.Show(view, "RootDialog", null, null, null);
- if (result != null && result is bool && (bool)result)
- {
- try
- {
- var sysConfig = _configService.GetSystemConfiguration();
- sysConfig.WorkMode = WorkMode;
- sysConfig.PickPointNum = PickPointNum;
- sysConfig.DowmCameraNum = DowmCameraNum;
- sysConfig.UpCameraPickNum = UpCameraPickNum;
- sysConfig.UpCameraPutNum = UpCameraPutNum;
- sysConfig.UPCameracheckNum = UPCameracheckNum;
- sysConfig.FixedCameraPickNum = FixedCameraPickNum;
- sysConfig.FixedCameraPutNum = FixedCameraPutNum;
- sysConfig.FixedCameracheckNum = FixedCameracheckNum;
- sysConfig.ScrewTeachNum = ScrewTeachNum;
- sysConfig.IsSaveScrewCurve = IsSaveScrewCurve;
- sysConfig.ScrewCurvePath = ScrewCurvePath;
- sysConfig.IsBasePartCodeGetSN = IsBasePartCodeGetSN;
- sysConfig.IsBasePartCodeChooseScrew = IsBasePartCodeChooseScrew;
- sysConfig.IsMesResult = IsMesResult;
- sysConfig.IsBasePartOpenLightKB = IsBasePartOpenLightKB;
- sysConfig.IsBasePartOpenLight = IsBasePartOpenLight;
- sysConfig.ChooseScrewModel = ChooseScrewModel;
- _configService.SaveSystemConfiguration(sysConfig);
- await management.WriteSystemParameterToPlcAsync(sysConfig);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- _eventAggregator.GetEvent<CurrentStatusNotification>().Publish();
- }
- }
- }
- /// <summary>
- /// 保存读卡器配置
- /// </summary>
- void ExecuteSaveCardReaderConfigCommand()
- {
- try
- {
- _configService.SaveCardReaderConfig(CardReaderConfig);
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- void ExecuteSaveTorqueReaderConfigCommand()
- {
- try
- {
- _configService.SaveTorqueReaderConfig(TorqueReadConfig);
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- #endregion
- #region 设备信息
- /// <summary>
- /// 保存当前选中的设备信息
- /// </summary>
- void ExecuteSaveDeviceInfoCommand()
- {
- try
- {
- if (DeviceInfoList != null && DeviceInfoList.Count > 0)
- {
- // 保存所有设备信息
- _configService.SaveAllDeviceInfos(DeviceInfoList);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- /// <summary>
- /// 添加新设备
- /// </summary>
- void ExecuteAddDeviceInfoCommand()
- {
- try
- {
- var newDevice = _configService.AddDeviceInfo();
- if (DeviceInfoList == null)
- {
- DeviceInfoList = new ObservableCollection<DeviceInfo>();
- }
- DeviceInfoList.Add(newDevice);
- SelectDeviceInfo = newDevice;
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- /// <summary>
- /// 删除当前选中的设备
- /// </summary>
- void ExecuteRemoveDeviceInfoCommand()
- {
- try
- {
- if (SelectDeviceInfo != null && DeviceInfoList != null && DeviceInfoList.Count > 1)
- {
- var deviceNo = SelectDeviceInfo.DeviceNo;
- if (_configService.RemoveDeviceInfo(deviceNo))
- {
- DeviceInfoList.Remove(SelectDeviceInfo);
- SelectDeviceInfo = DeviceInfoList.FirstOrDefault();
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
- }
- }
- else
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "至少保留一个设备", Duration = 2 });
- }
- }
- catch (Exception ex)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
- }
- }
- /// <summary>
- /// 选择CSV存储路径
- /// </summary>
- void ExecuteSelectSaveImagePathCommand()
- {
- if (SelectDeviceInfo == null)
- {
- return;
- }
- using (System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog())
- {
- // Optional: set the initial directory
- //dialog.SelectedPath = @"C:\";
- // Show the folder browser dialog
- System.Windows.Forms.DialogResult result = dialog.ShowDialog();
- if (result == System.Windows.Forms.DialogResult.OK)
- {
- SelectDeviceInfo.SaveCsvPath = dialog.SelectedPath;
- }
- }
- }
- #endregion
- #region 产品与mes绑定
- private async void ExecuteGetProWithMesCommand()
- {
- var v = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
- if (v == null)
- {
- ProMesInfo.ProductCode = "";
- ProMesInfo.ProductColor = "";
- ProMesInfo.ProductLoadMode = 0;
- }
- else
- {
- ProMesInfo.ProductCode = v.ProductCode;
- ProMesInfo.ProductColor = v.ProductColor;
- ProMesInfo.ProductLoadMode = v.ProductLoadMode;
- }
- }
- private async void ExecuteDeleteProWithMesCommand()
- {
- var v = await _systemDatabaseService.DeleteProWithMesAsync(SelectProduct);
- if (v > 0)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "删除成功", Duration = 1 });
- var F = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
- if (F == null)
- {
- ProMesInfo.ProductCode = "";
- ProMesInfo.ProductColor = "";
- ProMesInfo.ProductLoadMode = 0;
- }
- }
- }
- private async void ExecuteSaveProWithMesCommandAsync()
- {
- var v = await _systemDatabaseService.QueryProductWithMesAsync(SelectProduct);
- if (v == null)
- {
- await _systemDatabaseService.InsertProWithMesAsync(ProMesInfo, SelectProduct);
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "添加成功", Duration = 1 });
- }
- else
- {
- var n = await _systemDatabaseService.UpdateProductWithMesAsync(ProMesInfo, SelectProduct);
- if (n > 0)
- {
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "更新成功", Duration = 1 });
- }
- }
- }
- #endregion
- private DelegateCommand _testCommand;
- public DelegateCommand testCommand =>
- _testCommand ?? (_testCommand = new DelegateCommand(Execute_testCommand));
-
- private async void Execute_testCommand()
- {
- }
- }
- }
|