private async Task PerformExportEntityDescriptionAsync(string folder, Guid idTeamTemplate, string name) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingEntityDescription); try { string fileName = EntityFileNameFormatter.GetTeamTemplateFileName(service.ConnectionData.Name, name, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var repository = new TeamTemplateRepository(service); var TeamTemplate = await repository.GetByIdAsync(idTeamTemplate, ColumnSetInstances.AllColumns); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, TeamTemplate, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3 , service.ConnectionData.Name , TeamTemplate.LogicalName , filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionCompleted); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionFailed); } }
private async Task ShowExistingTeamTemplates() { if (!this.IsControlsEnabled) { return; } var connectionData = GetSelectedConnection(); ToggleControls(connectionData, false, Properties.OutputStrings.LoadingTeamTemplates); string textName = string.Empty; this.Dispatcher.Invoke(() => { this._itemsSource.Clear(); textName = txtBFilter.Text.Trim().ToLower(); }); IEnumerable <TeamTemplate> list = Enumerable.Empty <TeamTemplate>(); try { var service = await GetService(); if (service != null) { var repository = new TeamTemplateRepository(service); list = await repository.GetListAsync(textName , new ColumnSet ( TeamTemplate.Schema.Attributes.teamtemplateid , TeamTemplate.Schema.Attributes.teamtemplatename , TeamTemplate.Schema.Attributes.defaultaccessrightsmask , TeamTemplate.Schema.Attributes.issystem , TeamTemplate.Schema.Attributes.description ) ); } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } this.lstVwTeamTemplates.Dispatcher.Invoke(() => { foreach (var teamTemplate in list) { string entityName = string.Empty; if (teamTemplate.ObjectTypeCode.HasValue) { if (connectionData != null && connectionData.EntitiesIntellisenseData != null && connectionData.EntitiesIntellisenseData.Entities != null ) { var entityIntellisense = connectionData.EntitiesIntellisenseData.Entities.Values.FirstOrDefault(e => e.ObjectTypeCode == teamTemplate.ObjectTypeCode.Value); if (entityIntellisense != null) { entityName = entityIntellisense.EntityLogicalName; } } } var item = new EntityViewItem(teamTemplate, entityName); this._itemsSource.Add(item); } if (this.lstVwTeamTemplates.Items.Count == 1) { this.lstVwTeamTemplates.SelectedItem = this.lstVwTeamTemplates.Items[0]; } }); ToggleControls(connectionData, true, Properties.OutputStrings.LoadingTeamTemplatesCompletedFormat1, list.Count()); }