Example #1
0
        public FlashUploadCommandVM(IRUSDevice device, IFlashDumpDataParserFactory parserFactory, IFlashDumpSaver flashDumpSaver, IFlashDumpLoader dumpLoader, BusyObject busy)
        {
            _device         = device ?? throw new ArgumentNullException(nameof(device));
            _parserFactory  = parserFactory;
            _flashDumpSaver = flashDumpSaver;
            IsBusy          = busy ?? throw new ArgumentNullException(nameof(busy));

            SaveDump = new ActionCommand(saveDumpAsync, () => _dump != null && IsBusy.IsNotBusy, IsBusy);

            async Task saveDumpAsync()
            {
                try
                {
                    var path = IOUtils.RequestFileSavingPath("BIN(*.bin)|*.bin");
                    if (path != null)
                    {
                        using (var targetDumpFile = File.Create(path))
                        {
                            await _dump.SaveDumpAsync(targetDumpFile, _flashDumpSaver, new AsyncOperationInfo());
                        }

                        await dumpLoader.LoadAsync(path, new AsyncOperationInfo());

                        UserInteracting.ReportSuccess("Сохранение дампа Flash-памяти", "Файл успешно сохранен");
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorEverywhere("Ошибка сохранения дампа Flash-памяти", ex);
                }
            }
        }
Example #2
0
        public async Task SaveDumpAsync(Stream destination, IFlashDumpSaver flashDumpSaver, AsyncOperationInfo operationInfo)
        {
            var parsedRows = await _parsingResult.GetParsedDataStreamAsync(operationInfo);

            var rawDump = new FileStream(_rawDumpPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            await flashDumpSaver.SaveAsync(_device, _rowDescriptors, rawDump, parsedRows, destination, operationInfo);
        }
Example #3
0
 static FlashDumpSaverFactory()
 {
     Instance = new FlashDumpSaverFactory();
 }