async public Task <ExportResult> ExportObjectsFromFinExe(ServerSetupModel serverSetup, ExportFilterModel exportFilter) { var result = await Task.Factory.StartNew(() => { ExportFinexeHandling fileHandeling = new ExportFinexeHandling() { FinsqlPath = serverSetup.FinExePath, ServerName = serverSetup.Server, Database = serverSetup.Database, NTAuthentication = serverSetup.UseNTAuthentication }; fileHandeling.OnExportError += FileHandeling_OnExportError; if (!serverSetup.UseNTAuthentication) { fileHandeling.Username = serverSetup.UserName; fileHandeling.Password = serverSetup.Password; } fileHandeling.Filter = ExportFilter.CreateFilterString(exportFilter); if (!fileHandeling.ExportObjects(out string exportedObjectsPath, out string message)) { return(new ExportResult { Success = false, ExportedObjectsPath = exportedObjectsPath, Message = message }); } return(new ExportResult { Success = true, ExportedObjectsPath = exportedObjectsPath, Message = message }); }); return(result); }
private void ServerSettings() { if (!IsDestinationFolderSet()) { return; } SettingsHelper settingsHelper = new SettingsHelper(DestinationFolder); ServerSetupModel currentServerSetup = settingsHelper.ReadServerSettings(); ExportFilterModel exportFilter = settingsHelper.ReadFilterSettings(); if (_dialogService.ShowServerSettings(ref currentServerSetup)) { settingsHelper.SerializeToSettingsFile(currentServerSetup, exportFilter); } }
private async void ImportFinExeFile() { if (!IsDestinationFolderSet()) { return; } SettingsHelper settingHelper = new SettingsHelper(DestinationFolder); ExportFilterModel exportFilter = settingHelper.ReadFilterSettings(); SettingsHelper reader = new SettingsHelper(DestinationFolder); ServerSetupModel serverSetup = reader.ReadServerSettings(); if (_dialogService.ImportFromFinExe(DestinationFolder, ref exportFilter)) { await Export(settingHelper, exportFilter, serverSetup); } }
public void SerializeToSettingsFile(ServerSetupModel serverSetupModel, ExportFilterModel exportFilterModel) { if (string.IsNullOrEmpty(Folder) || string.IsNullOrEmpty(SettingsSubFolder)) { return; } DirectoryInfo di = Directory.CreateDirectory(GetSettingsFolder()); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; SettingsModel model = new SettingsModel(); model.ServerSetupModel = serverSetupModel; model.ExportFilterModel = exportFilterModel; string settingsString = JsonConvert.SerializeObject(model); File.WriteAllText(GetSettingsFilePath(), settingsString); }
public bool ShowServerSettings(ref ServerSetupModel serverSetup) { ServerSetupDialogService dialogService = new ServerSetupDialogService(); ServerSetupViewModel viewModel = new ServerSetupViewModel(dialogService, serverSetup); ServerSetupView view = new ServerSetupView(); view.DataContext = viewModel; bool?dialogResult = view.ShowDialog(); serverSetup = viewModel.ServerSetup; if ((dialogResult.HasValue) && (dialogResult.Value)) { return(dialogResult.Value); } return(false); }
public void ShowServerSetupDialog() { SettingsHelper settingsHelper = new SettingsHelper(_destinationFolder); ServerSetupModel currentServerSetup = settingsHelper.ReadServerSettings(); ExportFilterModel exportFilter = settingsHelper.ReadFilterSettings(); // TODO: not part of MVVM Start ServerSetupDialogService dialogService = new ServerSetupDialogService(); ServerSetupViewModel viewModel = new ServerSetupViewModel(dialogService, currentServerSetup); ServerSetupView view = new ServerSetupView(); view.DataContext = viewModel; // TODO: not part of MVVM Stop bool?dialogResult = view.ShowDialog(); currentServerSetup = viewModel.ServerSetup; if ((dialogResult.HasValue) && (dialogResult.Value)) { settingsHelper.SerializeToSettingsFile(currentServerSetup, exportFilter); } }
public ServerSetupViewModel(IServerSetupDialogService dialogService, ServerSetupModel serverSetup) { _dialogService = dialogService; _serverSetup = serverSetup; }
private async Task Export(SettingsHelper settingHelper, ExportFilterModel exportFilter, ServerSetupModel serverSetup) { ExportFinexeHelper exportFinExe = new ExportFinexeHelper(); exportFinExe.OnExportError += ExportFinExe_OnExportError; StartWorking("Importing"); var result = await exportFinExe.ExportObjectsFromFinExe(serverSetup, exportFilter); if (result.Success) { string[] importFiles = new string[] { result.ExportedObjectsPath }; ImportFiles(importFiles); // Save Config settingHelper.SerializeToSettingsFile(serverSetup, exportFilter); } else { if (!string.IsNullOrEmpty(result.Message)) { _dialogService.ShowErrorMessage("Import Object Files Error", result.Message); } } StopWorking(); }