private void DownloadFile(object parameter) { try { if (parameter != null) { var downloadingDocument = parameter as DocumentModel; if (downloadingDocument.DocUrl != null) { FTPHelper.DownloadFile(downloadingDocument.DocUrl); MessageBox.Show($"Document has been downloaded to '{Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Downloads")}'", "Download Succes", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Invalid FTP Path for the document download", "Invalid Path", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { App.Current.Dispatcher.Invoke((Action) delegate { ParentLayout.ShowMessageAsync("Error", ex.Message, MessageDialogStyle.Affirmative, new MetroDialogSettings() { ColorScheme = MetroDialogColorScheme.Accented }); }); } }
private void SelectFile(object parameter) { try { App.Current.Dispatcher.Invoke((Action) delegate { OpenFileDialog fileDialog = new OpenFileDialog(); //fileDialog.Filter = "Excel Sheets (*.xlsx)|*.xlsx|Excel Old(*.xls)|*xls"; if (fileDialog.ShowDialog() == true) { FilePath = fileDialog.FileName; } }); } catch (Exception ex) { App.Current.Dispatcher.Invoke((Action) delegate { ParentLayout.ShowMessageAsync("Error", ex.Message, MessageDialogStyle.Affirmative, new MetroDialogSettings() { ColorScheme = MetroDialogColorScheme.Accented }); }); } }