Beispiel #1
0
        private void OnExecuteLoadJournal()
        {
            _applicationGlobalCommands.SelectFileToOpen(_localizerService.GetLocalizedString("OpenJournal"),
                                                        " UJR файл (*.ujr)|*.ujr" + "|Все файлы (*.*)|*.* ").OnSuccess(info =>
            {
                var loadedJournal = _typesContainer.Resolve <ISerializerService>()
                                    .DeserializeFromFile <IUniconJournal>(info.FullName);
                if (!JournalStructureHelper.IsJournalStructureSimilar(_uniconJournal, loadedJournal))
                {
                    if (!_applicationGlobalCommands.AskUserGlobal(
                            _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                                 .JOURNAL_STRUCTURE_WARNING_MESSAGE),
                            _localizerService.GetLocalizedString("Warning")))
                    {
                        return;
                    }
                }

                Table = new DynamicDataTable(JournalParametersNameList, null, true);
                RaisePropertyChanged(nameof(Table));
                RaisePropertyChanged(nameof(JournalParametersNameList));
                _journalLoaderProvider
                .GetJournalLoader(DeviceContext, _uniconJournal, _loaderHooks)
                .LoadFromReadyModelList(loadedJournal.JournalRecords);
                _wasLoadedOnce = true;
                _logService.LogMessage(_localizerService
                                       .GetLocalizedString("JournalOpened") + " " + info.FullName);
            });
        }
        private bool ValidateDevice()
        {
            DeviceEditorValidationViewModel.RefreshErrors.Execute(null);
            if (!DeviceEditorValidationViewModel.IsSuccess)
            {
                var res = _applicationGlobalCommands.AskUserGlobal(
                    _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                         .VALIDATION_ERRORS_CONTINUE),
                    _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages.VALIDATION_ERRORS), this,
                    _localizerService.GetLocalizedString("Yes"), _localizerService.GetLocalizedString("No"));
                return(res);
            }

            return(true);
        }
Beispiel #3
0
        public IRuntimeBaseValuesViewModel CreateRuntimeBaseValuesViewModel(
            IConfigurationBaseValues configurationBaseValues, DeviceContext deviceContext)
        {
            if (configurationBaseValues == null)
            {
                return(new RuntimeBaseValuesViewModel(new List <IRuntimeBaseValueViewModel>()));
            }

            return(new RuntimeBaseValuesViewModel(configurationBaseValues.BaseValues.Select(value =>
                                                                                            new RuntimeBaseValueViewModel(value.Name, new RelayCommand(
                                                                                                                              () =>
            {
                if (_applicationGlobalCommands.AskUserGlobal(
                        _localizerService.GetLocalizedString(ApplicationGlobalNames.DialogStrings
                                                             .ARE_YOU_SURE_TO_APPLY_VALUES) + ": " + value.Name,
                        _localizerService.GetLocalizedString("BasicValues")))
                {
                    var addresses = value.LocalMemoryValues.Keys.ToArray();
                    foreach (var address in addresses)
                    {
                        if (deviceContext.DeviceMemory.LocalMemoryValues.ContainsKey(address))
                        {
                            deviceContext.DeviceMemory.LocalMemoryValues[address] =
                                value.LocalMemoryValues[address];
                        }
                        else
                        {
                            deviceContext.DeviceMemory.LocalMemoryValues.Add(address,
                                                                             value.LocalMemoryValues[address]);
                        }
                    }

                    foreach (var address in addresses)
                    {
                        deviceContext.DeviceEventsDispatcher.TriggerLocalAddressSubscription(
                            address, 1, MemoryKind.UshortMemory);
                    }
                }
            }
                                                                                                                              ))).Cast <IRuntimeBaseValueViewModel>().ToList()));
        }