public async void Execute(object parameter) { SlfTestViewModel _viewModel = (SlfTestViewModel)parameter; this.IsCanExecute = false; DateTime _start = DateTime.Now; _viewModel.StatusString = String.Empty; _viewModel.ResultString = String.Empty; _viewModel.StatusString = String.Empty; try { SlfInfo _slf = await Task <SlfInfo> .Run(() => { _viewModel.StatusString = "Processed..."; DateTime _date = new DateTime(2000, 1, 1); return(_viewModel.DataAccess.DownloadSlfFile(_viewModel.FileName, _date, _viewModel.DataInfoId)); }); _viewModel.SlfItemSource.Add(_slf); _viewModel.StatusString = String.Format("Done. Duration {0}", DateTime.Now - _start); } catch (Exception exc) { _viewModel.ErrorString = Ja2Data.Common.GetErrorString(exc); } }
public async void Execute(object parameter) { SlfTestViewModel _viewModel = (SlfTestViewModel)parameter; this.IsCanExecute = false; DateTime _start = DateTime.Now; _viewModel.StatusString = String.Empty; _viewModel.ResultString = String.Empty; _viewModel.StatusString = String.Empty; try { List <string> _fileNames = _viewModel.DataAccess.GetSlfFilesNames(_viewModel.DataInfoId); foreach (string _fileName in _fileNames) { _viewModel.StatusString = String.Format("Processed {0}...", _fileName); string _fullFileName = Path.Combine(_viewModel.FolderName, _fileName); SlfInfo _slf = await Task <SlfInfo> .Run(() => { DateTime _date = new DateTime(2000, 1, 1); return(_viewModel.DataAccess.DownloadSlfFile(_fullFileName, _date, _viewModel.DataInfoId)); }); _viewModel.SlfItemSource.Add(_slf); } _viewModel.StatusString = String.Format("Done. Duration {0}", DateTime.Now - _start); } catch (Exception exc) { _viewModel.ErrorString = Ja2Data.Common.GetErrorString(exc); } }
public async void Execute(object parameter) { SlfTestViewModel _viewModel = (SlfTestViewModel)parameter; _viewModel.StatusString = String.Empty; _viewModel.ResultString = String.Empty; _viewModel.StatusString = String.Empty; int _rowCount = 0; this.IsCanExecute = false; DateTime _start = DateTime.Now; try { FileInfo _file = new FileInfo(_viewModel.FileName); _viewModel.StatusString = String.Format("{0} processing...", _file.Name); SlfInfo _slf = await Task <SlfInfo> .Run(() => { return(_viewModel.DataAccess.UploadSlfFile(_file.FullName, _viewModel.DataInfoId)); }); _rowCount += _slf.RowsInserted; _viewModel.SlfItemSource.Add(_slf); _viewModel.ResultString = String.Format("{0} rows inserted.\n", _rowCount); } catch (Exception exc) { _viewModel.ErrorString = Ja2Data.Common.GetErrorString(exc); } _viewModel.StatusString = String.Format("Done. Duration {0}", DateTime.Now - _start); this.IsCanExecute = true; }