/// <summary> /// Called when click [import data execute]. /// </summary> /// <param name="pars">The pars.</param> private void OnImportDataExecute(object pars) { var dataImport = _directoryComputerImporter.DirectoryComputerCollections.Where(c => c.Id == 0).ToList(); if (dataImport.Count > 0) { var result = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <ImportFolderComputerResponse>( sc.ImportFolderComputer, dataImport)); if (result == null) { DialogHelper.Alert("Can not receive status data"); return; } DialogHelper.Alert(result.Message); if (_folderId.HasValue) { MakeTree(_folderId.Value, !string.IsNullOrWhiteSpace(ApplicationContext.SearchText), ApplicationContext.SearchText); } _directoryComputerImporter = null; FilePath = string.Empty; _view.Close(); } else { DialogHelper.Alert("There is no data to insert."); } }
/// <summary> /// Called when [open folder dialog execute]. /// </summary> /// <param name="pars">The pars.</param> private void OnOpenFolderDialogExecute(object pars) { var dlg = new OpenFileDialog { Multiselect = false, CheckFileExists = true }; if (!string.IsNullOrWhiteSpace(FilePath)) { if (File.Exists(FilePath)) { dlg.InitialDirectory = Path.GetDirectoryName(FilePath); dlg.FileName = Path.GetFileName(FilePath); } else if (System.IO.Directory.Exists(FilePath)) { dlg.InitialDirectory = FilePath; } else { dlg.InitialDirectory = Path.GetPathRoot(FilePath); } } if (dlg.ShowDialog() == DialogResult.OK) { FilePath = dlg.FileName; _directoryComputerImporter = new DirectoryComputerImporter(FilePath, GetDirectoryComputerTree()); if (!_directoryComputerImporter.IsValid) { //DialogHelper.Warning(_directoryComputerImporter.Message); DialogHelper.Warning("The data format is invalid."); FilePath = string.Empty; } } }
private void OnExecuteImport_Dowork(object sender, DoWorkEventArgs e) { try { _view.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action)(() => { ApplicationContext.IsBusy = true; CommandManager.InvalidateRequerySuggested(); var dataImport = _directoryComputerImporter.DirectoryComputerCollections.Where(c => c.Id == 0).ToList(); if (dataImport.Count > 0) { var result = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <ImportFolderComputerResponse>( sc.ImportFolderComputer, dataImport)); if (result == null) { DialogHelper.Alert("Can not receive status data"); return; } _directoryComputerImporter = null; FilePath = string.Empty; } else { DialogHelper.Alert("There is no data to insert."); } })); } catch (Exception) { ApplicationContext.IsBusy = false; } }
/// <summary> /// Handles the <see cref="E:BrowseFile_Dowork" /> event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> void OnBrowseFile_Dowork(object sender, DoWorkEventArgs e) { VisibleSimulate = Visibility.Visible; //MenuButtonStyle = _view.FindResource("MenuButtonHover") as Style; _mainViewModel.IsBusy = true; FilePath = e.Argument.ToString(); if (_directoryComputerImporter != null) { ReloadData(CurrentDirectoryNode.NodeId); } CurrentDirectoryNode.IsExpanded = true; _directoryComputerImporter = new DirectoryComputerImporter(FilePath, GetDirectoryTree()); }
/// <summary> /// Executes the cancel. /// </summary> /// <param name="obj">The object.</param> private void ExecuteCancel(object obj) { _directoryComputerImporter = null; if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(CurrentDirectoryNode.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); FilePath = string.Empty; }
public void LoadFolderId(int?folderId) { FilePath = string.Empty; _directoryComputerImporter = null; _folderId = folderId; }