예제 #1
0
        public async void Execute(object parameter)
        {
            SlfTestViewModel _viewModel = (SlfTestViewModel)parameter;

            this.IsCanExecute = false;
            this.IsCanExecute = await Task.Run <bool>(() =>
            {
                try
                {
                    _viewModel.StatusString = String.Empty;
                    _viewModel.ResultString = String.Empty;
                    _viewModel.StatusString = String.Empty;

                    int _filesCount = 0;

                    SlfFile _slf   = new SlfFile(_viewModel.FileName);
                    int _fileCount = _slf.Extract(false);
                    _filesCount   += _fileCount;

                    _viewModel.ResultString = String.Format(
                        "{0} files extract", _filesCount);

                    _viewModel.StatusString = "Done";
                }
                catch (Exception exc)
                {
                    _viewModel.ErrorString = Common.GetErrorString(exc);
                }

                return(true);
            });
        }
예제 #2
0
        public async void Execute(object parameter)
        {
            SlfTestViewModel _viewModel = (SlfTestViewModel)parameter;
            DirectoryInfo    _dir       = new DirectoryInfo(_viewModel.FolderName);

            this.CanExecuteProperty = false;
            this.CanExecuteProperty = await Task.Run <bool>(() =>
            {
                try
                {
                    _viewModel.StatusString = String.Empty;
                    _viewModel.ResultString = String.Empty;
                    _viewModel.StatusString = String.Empty;

                    int _count      = 0;
                    int _filesCount = 0;
                    foreach (FileInfo _file in _dir.GetFiles("*.SLF"))
                    {
                        _viewModel.StatusString = String.Format("{0} processing ...", _file.Name);

                        SlfFile _slf   = new SlfFile(_file.FullName);
                        int _fileCount = _slf.Extract(false);
                        _filesCount   += _fileCount;

                        _viewModel.ResultString = String.Format(
                            "{0} files processed. {1} files extract", ++_count, _filesCount);
                    }

                    _viewModel.StatusString = "Done";
                }
                catch (Exception exc)
                {
                    _viewModel.ErrorString = Common.GetErrorString(exc);
                }

                return(true);
            });
        }