private async Task PerformExportEntityDescription(string folder, Guid idImportJob, string solutionName, DateTime?createdOn) { var service = await GetService(); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.CreatingEntityDescription); try { string fileName = EntityFileNameFormatter.GetImportJobFileName(service.ConnectionData.Name, solutionName, createdOn, EntityFileNameFormatter.Headers.EntityDescription, "txt"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var repository = new ImportJobRepository(service); var importJob = await repository.GetByIdAsync(idImportJob, new ColumnSet(true)); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, importJob, EntityFileNameFormatter.ImportJobIgnoreFields, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.ExportedEntityDescriptionForConnectionFormat3 , service.ConnectionData.Name , importJob.LogicalName , filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingEntityDescriptionCompleted); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingEntityDescriptionFailed); } }
private async Task PerformExportXmlToFile(string folder, Guid idImportJob, string solutionName, DateTime?createdOn, string fieldName, string fieldTitle) { if (!this.IsControlsEnabled) { return; } var service = await GetService(); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.ExportingXmlFieldToFileFormat1, fieldTitle); try { var repository = new ImportJobRepository(service); var importJob = await repository.GetByIdAsync(idImportJob, new ColumnSet(fieldName)); string xmlContent = importJob.GetAttributeValue <string>(fieldName); string filePath = await CreateFileAsync(service.ConnectionData, folder, solutionName, createdOn, fieldTitle, xmlContent); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileCompletedFormat1, fieldName); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileFailedFormat1, fieldName); } }
private async Task ShowExistingImportJobs() { if (!this.IsControlsEnabled) { return; } ConnectionData connectionData = GetSelectedConnection(); ToggleControls(connectionData, false, Properties.OutputStrings.LoadingImportJobs); string textName = string.Empty; txtBFilter.Dispatcher.Invoke(() => { this._itemsSource.Clear(); textName = txtBFilter.Text.Trim().ToLower(); }); IEnumerable <ImportJob> list = Enumerable.Empty <ImportJob>(); try { var service = await GetService(); if (service != null) { var repository = new ImportJobRepository(service); list = await repository.GetListAsync(textName, new ColumnSet( ImportJob.Schema.Attributes.importjobid , ImportJob.Schema.Attributes.name , ImportJob.Schema.Attributes.solutionname , ImportJob.Schema.Attributes.startedon , ImportJob.Schema.Attributes.progress , ImportJob.Schema.Attributes.completedon , ImportJob.Schema.Attributes.createdon , ImportJob.Schema.Attributes.createdby , ImportJob.Schema.Attributes.importcontext , ImportJob.Schema.Attributes.operationcontext )); SwitchEntityDatesToLocalTime(list); } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } list = FilterList(list, textName); LoadImportJobs(list); ToggleControls(connectionData, true, Properties.OutputStrings.LoadingImportJobsCompletedFormat1, list.Count()); }
private async Task PerformExportFormattedResults(string folder, Guid idImportJob, string solutionName, DateTime?createdOn) { if (!this.IsControlsEnabled) { return; } var service = await GetService(); string name = string.Format("{0} at {1:yyyy.MM.dd HH-mm-ss}", solutionName, createdOn); string fieldTitle = "FormattedResults"; string fileName = EntityFileNameFormatter.GetImportJobFileName(service.ConnectionData.Name, solutionName, createdOn, fieldTitle, "xml"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.ExportingXmlFieldToFileFormat1, fieldTitle); try { var repository = new ImportJobRepository(service); var formattedResults = await repository.GetFormattedResultsAsync(idImportJob); if (!string.IsNullOrEmpty(formattedResults)) { try { File.WriteAllText(filePath, formattedResults, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutputFilePathUri(service.ConnectionData, filePath); if (IsExcelInstalled()) { this._iWriteToOutput.WriteToOutputFilePathUriToOpenInExcel(service.ConnectionData, filePath); if (chBOpenFormattedResultsInExcel.IsChecked.GetValueOrDefault()) { this._iWriteToOutput.OpenFileInExcel(service.ConnectionData, filePath); } else if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } } else if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, service.ConnectionData.Name, ImportJob.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, service.ConnectionData.Name, ImportJob.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); } ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileCompletedFormat1, fieldTitle); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingXmlFieldToFileFailedFormat1, fieldTitle); } }