private async Task PerformExportEntityDescription(string folder, Guid idSdkMessage, string name) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingEntityDescription); var repository = new SdkMessageRepository(service); var message = await repository.GetByIdAsync(idSdkMessage, ColumnSetInstances.AllColumns); string fileName = EntityFileNameFormatter.GetMessageFileName(service.ConnectionData.Name, name, EntityFileNameFormatter.Headers.EntityDescription); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, message, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3 , service.ConnectionData.Name , message.LogicalName , filePath ); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionCompleted); }
private string CreateFile(string folder, Guid idCustomControl, string name, string fieldTitle, FileExtension extension, string xmlContent) { ConnectionData connectionData = GetSelectedConnection(); if (connectionData == null) { return(null); } string fileName = EntityFileNameFormatter.GetCustomControlFileName(connectionData.Name, name, fieldTitle, extension); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(xmlContent)) { try { File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, CustomControl.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, CustomControl.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private void GetCurrentSystemFormJson(IOrganizationServiceExtented service, CommonConfiguration commonConfig, SystemForm systemForm) { string formJson = systemForm.FormJson; if (string.IsNullOrEmpty(formJson)) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, SystemForm.Schema.Headers.formjson); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); return; } formJson = ContentComparerHelper.FormatJson(formJson); commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string currentFileName = EntityFileNameFormatter.GetSystemFormFileName(service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name, SystemForm.Schema.Headers.formjson, FileExtension.json); string currentFilePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(currentFileName)); try { File.WriteAllText(currentFilePath, formJson, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, SystemForm.Schema.Headers.formjson, currentFilePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } this._iWriteToOutput.PerformAction(service.ConnectionData, currentFilePath); service.TryDispose(); }
private async Task GetCurrentEntityDescription(IOrganizationServiceExtented service, CommonConfiguration commonConfig, SystemForm systemForm) { commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string fileName = EntityFileNameFormatter.GetSystemFormFileName(service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt); string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); try { await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, systemForm, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3 , service.ConnectionData.Name , systemForm.LogicalName , filePath ); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); service.TryDispose(); }
private async Task ExecuteExportAssembly(string folder, Guid idAssembly, string name) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.ExportingPluginAssemblyBodyBinaryFormat1, name); var repository = new PluginAssemblyRepository(service); var assembly = await repository.GetAssemblyByIdRetrieveRequestAsync(idAssembly, new ColumnSet(PluginAssembly.Schema.Attributes.content)); string fileName = EntityFileNameFormatter.GetPluginAssemblyFileName(service.ConnectionData.Name, name, "Content", FileExtension.dll); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var array = Convert.FromBase64String(assembly.Content); File.WriteAllBytes(filePath, array); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, PluginAssembly.Schema.EntityLogicalName, name, "Content", filePath); if (File.Exists(filePath)) { if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } } ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ExportingPluginAssemblyBodyBinaryCompletedFormat1, name); }
private async Task PerformExportEntityDescription(string folder, Guid idReport, string name, string filename) { var service = await GetService(); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.CreatingEntityDescription); try { string fileName = EntityFileNameFormatter.GetReportFileName(service.ConnectionData.Name, name, idReport, EntityFileNameFormatter.Headers.EntityDescription, "txt"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var repository = new ReportRepository(service); var report = await repository.GetByIdAsync(idReport); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, report, EntityFileNameFormatter.ReportIgnoreFields, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.ExportedEntityDescriptionForConnectionFormat3 , service.ConnectionData.Name , report.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 string CreateFile(ConnectionData connectionData, string name, string nameUnique, Guid id, string fieldTitle, string siteMapXml) { string fileName = EntityFileNameFormatter.GetSiteMapFileName(connectionData.Name, name, id, fieldTitle, FileExtension.xml); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(siteMapXml)) { try { siteMapXml = ContentComparerHelper.FormatXmlByConfiguration( siteMapXml , _commonConfig , XmlOptionsControls.SiteMapXmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.SiteMapXmlSchema , siteMapUniqueName: nameUnique ?? string.Empty ); File.WriteAllText(filePath, siteMapXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, SiteMap.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, SiteMap.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private string CreateFile(ConnectionData connectionData, string folder, string solutionName, DateTime?createdOn, string fieldTitle, string xmlContent) { string fileName = EntityFileNameFormatter.GetImportJobFileName(connectionData.Name, solutionName, createdOn, fieldTitle, "xml"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); string name = string.Format("{0} at {1:yyyy.MM.dd HH-mm-ss}", solutionName, createdOn); if (!string.IsNullOrEmpty(xmlContent)) { try { xmlContent = ContentCoparerHelper.FormatXmlByConfiguration(xmlContent, _commonConfig, _xmlOptions); File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, connectionData.Name, ImportJob.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, connectionData.Name, ImportJob.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private async Task PerformExportEntityDescription(string folder, Guid idPluginAssembly, string name) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingEntityDescription); var repository = new PluginAssemblyRepository(service); var assembly = await repository.GetAssemblyByIdRetrieveRequestAsync(idPluginAssembly); string fileName = EntityFileNameFormatter.GetPluginAssemblyFileName(service.ConnectionData.Name, name, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, assembly, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3 , service.ConnectionData.Name , assembly.LogicalName , filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingEntityDescriptionCompleted); }
private string CreateFile(ConnectionData connectionData, string name, Guid id, string fieldTitle, string xmlContent) { string fileName = EntityFileNameFormatter.GetReportFileName(connectionData.Name, name, id, fieldTitle, "xml"); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(xmlContent)) { try { if (ContentCoparerHelper.TryParseXml(xmlContent, out var doc)) { xmlContent = doc.ToString(); } File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, connectionData.Name, Report.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { filePath = string.Empty; this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, connectionData.Name, Report.Schema.EntityLogicalName, name, fieldTitle); } return(filePath); }
private string CreateFile(ConnectionData connectionData, string name, string fieldTitle, string xmlContent, FileExtension extension) { name = Path.GetFileName(name); if (connectionData == null) { return(null); } string fileName = EntityFileNameFormatter.GetWebResourceFileName(connectionData.Name, name, fieldTitle, extension); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(xmlContent)) { try { File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, WebResource.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { filePath = string.Empty; this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, WebResource.Schema.EntityLogicalName, name, fieldTitle); } return(filePath); }
private void GetCurrentSavedQueryXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SavedQuery savedQuery) { string fieldName = SavedQueryRepository.GetFieldNameByXmlRoot(doc.Root.Name.ToString()); string fieldTitle = SavedQueryRepository.GetFieldTitleByXmlRoot(doc.Root.Name.ToString()); string xmlContent = savedQuery.GetAttributeValue <string>(fieldName); if (string.IsNullOrEmpty(xmlContent)) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SavedQuery.Schema.EntityLogicalName, savedQuery.Name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); return; } commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string currentFileName = EntityFileNameFormatter.GetSavedQueryFileName(service.ConnectionData.Name, savedQuery.ReturnedTypeCode, savedQuery.Name, fieldTitle, FileExtension.xml); string currentFilePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(currentFileName)); try { File.WriteAllText(currentFilePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SavedQuery.Schema.EntityLogicalName, savedQuery.Name, fieldTitle, currentFilePath); this._iWriteToOutput.PerformAction(service.ConnectionData, currentFilePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); service.TryDispose(); } }
private string CreateDescriptionFile(ConnectionData connectionData, string entityName, string name, string fieldTitle, string description) { string fileName = EntityFileNameFormatter.GetSavedQueryVisualizationFileName(connectionData.Name, entityName, name, fieldTitle, FileExtension.txt); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(description)) { try { File.WriteAllText(filePath, description, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, SavedQueryVisualization.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { filePath = string.Empty; this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, SavedQueryVisualization.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private string CreateFile(ConnectionData connectionData, string entityName, string name, string fieldTitle, string xmlContent) { string fileName = EntityFileNameFormatter.GetSavedQueryVisualizationFileName(connectionData.Name, entityName, name, fieldTitle, FileExtension.xml); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(xmlContent)) { try { xmlContent = ContentComparerHelper.FormatXmlByConfiguration( xmlContent , _commonConfig , XmlOptionsControls.SavedQueryVisualizationXmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.VisualizationDataDescriptionSchema ); File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, SavedQueryVisualization.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, SavedQueryVisualization.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private async Task PerformExportEntityDescription(string folder, Organization organization) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingEntityDescription); try { string fileName = EntityFileNameFormatter.GetOrganizationFileName(service.ConnectionData.Name, organization.Name, EntityFileNameFormatter.Headers.EntityDescription, FileExtension.txt); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); await EntityDescriptionHandler.ExportEntityDescriptionAsync(filePath, organization, service.ConnectionData); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedEntityDescriptionFormat3 , service.ConnectionData.Name , organization.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 string CreateDescriptionFile(string folder, string filePathConfiguration, string name, string description) { string fileName = EntityFileNameFormatter.GetPluginConfigurationFileName(Path.GetFileNameWithoutExtension(filePathConfiguration), name, FileExtension.txt); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(description)) { try { File.WriteAllText(filePath, description, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(null, filePathConfiguration); this._iWriteToOutput.WriteToOutput(null, "Plugin Assembly {0} Description exported to {1}", name, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(null, ex); } } else { filePath = string.Empty; this._iWriteToOutput.WriteToOutput(null, filePathConfiguration); this._iWriteToOutput.WriteToOutput(null, "PluginAssembly {0} Description is empty.", name); } return(filePath); }
private async Task PerformDownloadBinaryContent(Guid pluginAssemblyId, string assemblyName, Func <Task <IOrganizationServiceExtented> > getService) { ToggleControls(false, Properties.WindowStatusStrings.ExportingPluginAssemblyBodyBinaryFormat1, assemblyName); var service = await getService(); if (service != null) { var repository = new PluginAssemblyRepository(service); var assembly = await repository.GetAssemblyByIdRetrieveRequestAsync(pluginAssemblyId, new ColumnSet(PluginAssembly.Schema.Attributes.content)); string fileName = EntityFileNameFormatter.GetPluginAssemblyFileName(service.ConnectionData.Name, assembly.Name, "Content", "dll"); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); var array = Convert.FromBase64String(assembly.Content); File.WriteAllBytes(filePath, array); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, service.ConnectionData.Name, PluginAssembly.Schema.EntityLogicalName, assembly.Name, "Content", filePath); if (File.Exists(filePath)) { if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } } } ToggleControls(true, Properties.WindowStatusStrings.ExportingPluginAssemblyBodyBinaryCompletedFormat1, assemblyName); }
private async Task UpdateWebResourceDependencyXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, WebResource webResource) { { string fieldTitle = WebResource.Schema.Headers.dependencyxml; string dependencyXml = webResource.DependencyXml; if (!string.IsNullOrEmpty(dependencyXml)) { commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string fileNameBackUp = EntityFileNameFormatter.GetWebResourceFileName(service.ConnectionData.Name, webResource.Name, fieldTitle + " BackUp", FileExtension.xml); string filePathBackUp = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileNameBackUp)); try { dependencyXml = ContentComparerHelper.FormatXmlByConfiguration( dependencyXml , commonConfig , XmlOptionsControls.WebResourceDependencyXmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.WebResourceDependencyXmlSchema , webResourceName: webResource.Name ); File.WriteAllText(filePathBackUp, dependencyXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, WebResource.Schema.EntityLogicalName, webResource.Name, fieldTitle, filePathBackUp); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, WebResource.Schema.EntityLogicalName, webResource.Name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); } } var newText = doc.ToString(SaveOptions.DisableFormatting); var updateEntity = new WebResource { Id = webResource.Id }; updateEntity.Attributes[WebResource.Schema.Attributes.dependencyxml] = newText; await service.UpdateAsync(updateEntity); var repositoryPublish = new PublishActionsRepository(service); _iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionPublishingWebResourceFormat2, service.ConnectionData.Name, webResource.Name); await repositoryPublish.PublishWebResourcesAsync(new[] { webResource.Id }); service.TryDispose(); }
private async Task UpdateSiteMapXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SiteMap siteMap) { string fieldTitle = SiteMap.Schema.Headers.sitemapxml; { string siteMapXml = siteMap.SiteMapXml; if (!string.IsNullOrEmpty(siteMapXml)) { commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string fileNameBackUp = EntityFileNameFormatter.GetSiteMapFileName(service.ConnectionData.Name, siteMap.SiteMapNameUnique, siteMap.Id, fieldTitle + " BackUp", FileExtension.xml); string filePathBackUp = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileNameBackUp)); try { siteMapXml = ContentComparerHelper.FormatXmlByConfiguration( siteMapXml , commonConfig , XmlOptionsControls.SiteMapXmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.SiteMapXmlSchema , siteMapUniqueName: siteMap.SiteMapNameUnique ?? string.Empty ); File.WriteAllText(filePathBackUp, siteMapXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMap.SiteMapNameUnique, fieldTitle, filePathBackUp); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SiteMap.Schema.EntityLogicalName, siteMap.SiteMapNameUnique, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); } } var newText = doc.ToString(SaveOptions.DisableFormatting); var updateEntity = new SiteMap { Id = siteMap.Id }; updateEntity.Attributes[SiteMap.Schema.Attributes.sitemapxml] = newText; await service.UpdateAsync(updateEntity); _iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionPublishingSiteMapFormat3, service.ConnectionData.Name, siteMap.SiteMapName, siteMap.Id.ToString()); var repositoryPublish = new PublishActionsRepository(service); await repositoryPublish.PublishSiteMapsAsync(new[] { siteMap.Id }); service.TryDispose(); }
private async Task PerformExportBodyBinary(Guid idReport, Func <Task <IOrganizationServiceExtented> > getService, string fieldName, string fieldTitle) { if (!this.IsControlsEnabled) { return; } ToggleControls(false, Properties.WindowStatusStrings.ExportingBodyBinaryForFieldFormat1, fieldName); var service = await getService(); try { if (service != null) { var repository = new ReportRepository(service); Report reportWithBodyBinary = await repository.GetByIdAsync(idReport, new ColumnSet(true)); if (!string.IsNullOrEmpty(reportWithBodyBinary.BodyBinary)) { string extension = Path.GetExtension(reportWithBodyBinary.FileName); string fileName = EntityFileNameFormatter.GetReportFileName(service.ConnectionData.Name, reportWithBodyBinary.Name, reportWithBodyBinary.Id, fieldTitle, extension); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); var array = Convert.FromBase64String(reportWithBodyBinary.BodyBinary); File.WriteAllBytes(filePath, array); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, service.ConnectionData.Name, Report.Schema.EntityLogicalName, reportWithBodyBinary.Name, fieldTitle, filePath); if (File.Exists(filePath)) { if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } } } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, service.ConnectionData.Name, Report.Schema.EntityLogicalName, reportWithBodyBinary.Name, fieldTitle); this._iWriteToOutput.WriteToOutput(null, Properties.OutputStrings.EntityFieldIsEmptyFormat4, service.ConnectionData.Name, Report.Schema.EntityLogicalName, reportWithBodyBinary.Name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(null); } } ToggleControls(true, Properties.WindowStatusStrings.ExportingBodyBinaryForFieldCompletedFormat1, fieldName); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(true, Properties.WindowStatusStrings.ExportingBodyBinaryForFieldFailedFormat1, fieldName); } }
private async Task PerformExportBodyBinary(string folder, Guid idReport, string name, string filename, string fieldName, string fieldTitle) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.ExportingBodyBinaryForFieldFormat1, fieldName); try { var repository = new ReportRepository(service); Report reportWithBodyBinary = await repository.GetByIdAsync(idReport, new ColumnSet(fieldName)); string extension = Path.GetExtension(filename); string fileName = EntityFileNameFormatter.GetReportFileName(service.ConnectionData.Name, name, idReport, fieldTitle, extension); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var body = reportWithBodyBinary.GetAttributeValue<string>(fieldName); if (!string.IsNullOrEmpty(body)) { var array = Convert.FromBase64String(body); File.WriteAllBytes(filePath, array); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, Report.Schema.EntityLogicalName, name, fieldTitle, filePath); if (File.Exists(filePath)) { if (_commonConfig.DefaultFileAction != FileAction.None) { this._iWriteToOutput.SelectFileInFolder(service.ConnectionData, filePath); } } } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, Report.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); } ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ExportingBodyBinaryForFieldCompletedFormat1, fieldName); } catch (Exception ex) { _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); ToggleControls(service.ConnectionData, true, Properties.OutputStrings.ExportingBodyBinaryForFieldFailedFormat1, fieldName); } }
public virtual string GetFileName(string connectionName, Guid objectId, string fieldTitle, FileExtension extension) { var entity = GetEntity <Entity>(objectId); if (entity != null) { return(EntityFileNameFormatter.GetEntityName(connectionName, entity, fieldTitle, extension)); } return(string.Format("{0}.ComponentType {1} - {2} - {3}.{4}", connectionName, this.ComponentTypeValue, objectId, fieldTitle, extension.ToStr())); }
private async Task ExecuteCreatingApplicationRibbon(Func <Task <IOrganizationServiceExtented> > getService) { if (!this.IsControlsEnabled) { return; } if (string.IsNullOrEmpty(_commonConfig.FolderForExport)) { _iWriteToOutput.WriteToOutput(null, Properties.OutputStrings.FolderForExportIsEmpty); _commonConfig.FolderForExport = FileOperations.GetDefaultFolderForExportFilePath(); } else if (!Directory.Exists(_commonConfig.FolderForExport)) { _iWriteToOutput.WriteToOutput(null, Properties.OutputStrings.FolderForExportDoesNotExistsFormat1, _commonConfig.FolderForExport); _commonConfig.FolderForExport = FileOperations.GetDefaultFolderForExportFilePath(); } var service = await getService(); this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); ToggleControls(false, Properties.WindowStatusStrings.ExportingApplicationRibbon); try { var repository = new RibbonCustomizationRepository(service); string ribbonXml = await repository.ExportApplicationRibbonAsync(); ribbonXml = ContentCoparerHelper.FormatXmlByConfiguration(ribbonXml, _commonConfig, _xmlOptions , ribbonEntityName: string.Empty ); { string fileName = EntityFileNameFormatter.GetApplicationRibbonFileName(service.ConnectionData.Name); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); File.WriteAllText(filePath, ribbonXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.ExportedAppliationRibbonForConnectionFormat2, service.ConnectionData.Name, filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } ToggleControls(true, Properties.WindowStatusStrings.ExportingApplicationRibbonCompleted); this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); }
private string CreateFile(ConnectionData connectionData, string name, string nameUnique, Guid id, string fieldTitle, string siteMapXml) { string fileName = EntityFileNameFormatter.GetSiteMapFileName(connectionData.Name, name, id, fieldTitle, "xml"); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(siteMapXml)) { try { //if (_commonConfig.SetXmlSchemasDuringExport) //{ // var schemasResources = AbstractDynamicCommandXsdSchemas.GetXsdSchemas(AbstractDynamicCommandXsdSchemas.SchemaSiteMapXml); // if (schemasResources != null) // { // siteMapXml = ContentCoparerHelper.SetXsdSchema(siteMapXml, schemasResources); // } //} //if (_commonConfig.SetIntellisenseContext) //{ // siteMapXml = ContentCoparerHelper.SetIntellisenseContextSiteMapNameUnique(siteMapXml, nameUnique); //} //if (_commonConfig.SortXmlAttributes) //{ // siteMapXml = ContentCoparerHelper.SortXmlAttributes(siteMapXml); //} //siteMapXml = ContentCoparerHelper.FormatXml(siteMapXml, _commonConfig.ExportXmlAttributeOnNewLine); siteMapXml = ContentCoparerHelper.FormatXmlByConfiguration(siteMapXml, _commonConfig, _xmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.SchemaSiteMapXml , siteMapUniqueName: nameUnique ?? string.Empty ); File.WriteAllText(filePath, siteMapXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, connectionData.Name, SiteMap.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, connectionData.Name, SiteMap.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private async Task PerformExportPluginTypeDescription(string folder, Guid idPluginType, string name) { var service = await GetService(); if (service == null) { return; } ToggleControls(service.ConnectionData, false, Properties.OutputStrings.CreatingPluginTypeDescriptionFormat1, name); string fileName = EntityFileNameFormatter.GetPluginTypeFileName(service.ConnectionData.Name, name, "Description"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); var repStep = new SdkMessageProcessingStepRepository(service); var repImage = new SdkMessageProcessingStepImageRepository(service); var repSecure = new SdkMessageProcessingStepSecureConfigRepository(service); var allSteps = await repStep.GetAllStepsByPluginTypeAsync(idPluginType); var queryImage = await repImage.GetImagesByPluginTypeAsync(idPluginType); var listSecure = await repSecure.GetAllSdkMessageProcessingStepSecureConfigAsync(); bool hasDescription = await PluginTypeDescriptionHandler.CreateFileWithDescriptionAsync( service.ConnectionData.GetConnectionInfo() , filePath , idPluginType , name , allSteps , queryImage , listSecure ); if (hasDescription) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, PluginType.EntitySchemaName, name, "Description", filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, PluginType.EntitySchemaName, name, "Description"); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); } ToggleControls(service.ConnectionData, true, Properties.OutputStrings.CreatingPluginTypeDescriptionCompletedFormat1, name); }
private async Task ExecuteCreatingApplicationRibbonArchive(Func <Task <IOrganizationServiceExtented> > getService) { if (!this.IsControlsEnabled) { return; } var service = await getService(); if (service == null) { return; } _commonConfig.CheckFolderForExportExists(_iWriteToOutput); this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); ToggleControls(false, Properties.OutputStrings.ExportingApplicationRibbon); try { var repository = new RibbonCustomizationRepository(service); var ribbonBody = await repository.ExportApplicationRibbonByteArrayAsync(); { string fileName = EntityFileNameFormatter.GetApplicationRibbonFileName(service.ConnectionData.Name, FileExtension.zip); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); File.WriteAllBytes(filePath, ribbonBody); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionExportedAppliationRibbonFormat2, service.ConnectionData.Name, filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } ToggleControls(true, Properties.OutputStrings.ExportingApplicationRibbonCompleted); this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); }
private string CreateFile(ConnectionData connectionData, string folder, string name, string fieldTitle, string siteMapXml) { string fileName = EntityFileNameFormatter.GetOrganizationFileName(connectionData.Name, name, fieldTitle, FileExtension.xml); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(siteMapXml)) { try { string schemaName = string.Empty; var xmlOptions = XmlOptionsControls.OrganizationXmlOptions; if (string.Equals(fieldTitle, Organization.Schema.Attributes.sitemapxml, StringComparison.InvariantCultureIgnoreCase) || string.Equals(fieldTitle, Organization.Schema.Attributes.referencesitemapxml, StringComparison.InvariantCultureIgnoreCase) ) { schemaName = AbstractDynamicCommandXsdSchemas.SiteMapXmlSchema; xmlOptions = XmlOptionsControls.SiteMapXmlOptions; } siteMapXml = ContentComparerHelper.FormatXmlByConfiguration( siteMapXml , _commonConfig , xmlOptions , schemaName: schemaName ); File.WriteAllText(filePath, siteMapXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, connectionData.Name, Organization.Schema.EntityLogicalName, name, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, connectionData.Name, Organization.Schema.EntityLogicalName, name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private async Task DifferenceSavedQueryXml(IOrganizationServiceExtented service, CommonConfiguration commonConfig, XDocument doc, string filePath, SavedQuery savedQuery) { string fieldName = SavedQueryRepository.GetFieldNameByXmlRoot(doc.Root.Name.ToString()); string fieldTitle = SavedQueryRepository.GetFieldTitleByXmlRoot(doc.Root.Name.ToString()); string xmlContent = savedQuery.GetAttributeValue <string>(fieldName); string fileTitle2 = EntityFileNameFormatter.GetSavedQueryFileName(service.ConnectionData.Name, savedQuery.ReturnedTypeCode, savedQuery.Name, fieldTitle, FileExtension.xml); string filePath2 = FileOperations.GetNewTempFilePath(Path.GetFileNameWithoutExtension(fileTitle2), Path.GetExtension(fileTitle2)); if (string.IsNullOrEmpty(xmlContent)) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SavedQuery.Schema.EntityLogicalName, savedQuery.Name, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); return; } try { xmlContent = ContentComparerHelper.FormatXmlByConfiguration( xmlContent , commonConfig , XmlOptionsControls.SavedQueryXmlOptions , schemaName: AbstractDynamicCommandXsdSchemas.FetchSchema , savedQueryId: savedQuery.Id , entityName: savedQuery.ReturnedTypeCode ); File.WriteAllText(filePath2, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldExportedToFormat5, service.ConnectionData.Name, SavedQuery.Schema.EntityLogicalName, savedQuery.Name, fieldTitle, filePath2); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } string fileLocalPath = filePath; string fileLocalTitle = Path.GetFileName(filePath); await this._iWriteToOutput.ProcessStartProgramComparerAsync(service.ConnectionData, fileLocalPath, filePath2, fileLocalTitle, fileTitle2); service.TryDispose(); }
private string CreateFile(string folder, string typeName, string fieldTitle, string xmlContent) { ConnectionData connectionData = null; cmBCurrentConnection.Dispatcher.Invoke(() => { connectionData = cmBCurrentConnection.SelectedItem as ConnectionData; }); if (connectionData == null) { return(null); } string fileName = EntityFileNameFormatter.GetPluginTypeFileName(connectionData.Name, typeName, fieldTitle, "xml"); string filePath = Path.Combine(folder, FileOperations.RemoveWrongSymbols(fileName)); if (!string.IsNullOrEmpty(xmlContent)) { try { if (ContentCoparerHelper.TryParseXml(xmlContent, out var doc)) { xmlContent = doc.ToString(); } File.WriteAllText(filePath, xmlContent, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldExportedToFormat5, connectionData.Name, Workflow.Schema.EntityLogicalName, typeName, fieldTitle, filePath); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } } else { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.EntityFieldIsEmptyFormat4, connectionData.Name, Workflow.Schema.EntityLogicalName, typeName, fieldTitle); this._iWriteToOutput.ActivateOutputWindow(connectionData); } return(filePath); }
private async Task PerformExportApplicationRibbon() { if (!this.IsControlsEnabled) { return; } var service = await GetService(); this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.ExportingApplicationRibbon); try { var repository = new RibbonCustomizationRepository(service); string ribbonXml = await repository.ExportApplicationRibbonAsync(); ribbonXml = ContentCoparerHelper.FormatXmlByConfiguration(ribbonXml, _commonConfig, _xmlOptions , ribbonEntityName: string.Empty ); { string fileName = EntityFileNameFormatter.GetApplicationRibbonFileName(service.ConnectionData.Name); string filePath = Path.Combine(_commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); File.WriteAllText(filePath, ribbonXml, new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.ExportedAppliationRibbonForConnectionFormat2, service.ConnectionData.Name, filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.ExportingApplicationRibbonCompleted); this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.ExportingApplicationRibbonFormat1, service.ConnectionData.Name); }