Esempio n. 1
0
        public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus)
        {
            var idEntity = await _service.UpsertAsync(entity);

            var systemForm = await GetByIdAsync(idEntity, new ColumnSet(SystemForm.Schema.Attributes.objecttypecode, SystemForm.Schema.Attributes.name));

            var repositoryPublish = new PublishActionsRepository(_service);

            updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingSystemFormFormat3, _service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name));

            await repositoryPublish.PublishDashboardsAsync(new[] { idEntity });

            updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingSystemFormCompletedFormat3, _service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name));

            if (systemForm.ObjectTypeCode.IsValidEntityName())
            {
                updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, _service.ConnectionData.Name, systemForm.ObjectTypeCode));

                await repositoryPublish.PublishEntitiesAsync(new[] { systemForm.ObjectTypeCode });

                updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, systemForm.ObjectTypeCode));
            }

            return(idEntity);
        }
        public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus)
        {
            var idEntity = await _service.UpsertAsync(entity);

            var webResource = await GetByIdAsync(idEntity, new ColumnSet(WebResource.Schema.Attributes.name));

            var repositoryPublish = new PublishActionsRepository(_service);

            updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingWebResourceFormat2, _service.ConnectionData.Name, webResource.Name));

            await repositoryPublish.PublishWebResourcesAsync(new[] { idEntity });

            updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingWebResourceCompletedFormat2, _service.ConnectionData.Name, webResource.Name));

            return(idEntity);
        }
        public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus)
        {
            var idEntity = await _service.UpsertAsync(entity);

            var siteMap = await GetByIdAsync(idEntity, new ColumnSet(SiteMap.Schema.Attributes.sitemapname));

            var repositoryPublish = new PublishActionsRepository(_service);

            updateStatus(string.Format(Properties.WindowStatusStrings.PublishingSiteMapFormat3, _service.ConnectionData.Name, siteMap.SiteMapName, idEntity.ToString()));

            await repositoryPublish.PublishSiteMapsAsync(new[] { idEntity });

            updateStatus(string.Format(Properties.WindowStatusStrings.PublishingSiteMapCompletedFormat3, _service.ConnectionData.Name, siteMap.SiteMapName, idEntity.ToString()));

            return(idEntity);
        }
Esempio n. 4
0
        public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus)
        {
            var idEntity = await _service.UpsertAsync(entity);

            var savedQuery = await GetByIdAsync(idEntity, new ColumnSet(SavedQuery.Schema.Attributes.returnedtypecode));

            if (savedQuery.ReturnedTypeCode.IsValidEntityName())
            {
                updateStatus(string.Format(Properties.WindowStatusStrings.PublishingEntitiesFormat2, _service.ConnectionData.Name, savedQuery.ReturnedTypeCode));

                var repositoryPublish = new PublishActionsRepository(_service);

                await repositoryPublish.PublishEntitiesAsync(new[] { savedQuery.ReturnedTypeCode });

                updateStatus(string.Format(Properties.WindowStatusStrings.PublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, savedQuery.ReturnedTypeCode));
            }

            return(idEntity);
        }
        public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus)
        {
            var idEntity = await _service.UpsertAsync(entity);

            var chart = await GetByIdAsync(idEntity, new ColumnSet(SavedQueryVisualization.Schema.Attributes.primaryentitytypecode));

            if (chart.PrimaryEntityTypeCode.IsValidEntityName())
            {
                updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, _service.ConnectionData.Name, chart.PrimaryEntityTypeCode));

                var repositoryPublish = new PublishActionsRepository(_service);

                await repositoryPublish.PublishEntitiesAsync(new[] { chart.PrimaryEntityTypeCode });

                updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, chart.PrimaryEntityTypeCode));
            }

            return(idEntity);
        }
Esempio n. 6
0
        public async Task PerformUpdateRibbonDiffXml(IWriteToOutput iWriteToOutput, CommonConfiguration commonConfig, XDocument doc, EntityMetadata entityMetadata, RibbonCustomization ribbonCustomization)
        {
            if (entityMetadata == null && ribbonCustomization == null)
            {
                throw new ArgumentException("entityMetadata or ribbonCustomization");
            }

            ContentComparerHelper.ClearRoot(doc);

            Publisher publisherDefault = null;

            {
                var repositoryPublisher = new PublisherRepository(_service);
                publisherDefault = await repositoryPublisher.GetDefaultPublisherAsync();

                if (publisherDefault == null)
                {
                    iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.NotFoundedDefaultPublisher);
                    iWriteToOutput.ActivateOutputWindow(_service.ConnectionData);
                    return;
                }
            }

            var idSolution = Guid.NewGuid();

            var solutionUniqueName = string.Format("RibbonDiffXml_{0}", idSolution);

            solutionUniqueName = solutionUniqueName.Replace("-", "_");

            var solution = new Solution()
            {
                UniqueName   = solutionUniqueName,
                FriendlyName = solutionUniqueName,

                SolutionId = idSolution,

                Description = "Temporary solution for exporting RibbonDiffXml.",

                PublisherId = publisherDefault.ToEntityReference(),

                Version = "1.0.0.0",
            };

            iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.CreatingNewSolutionFormat1, solutionUniqueName);

            solution.Id = await _service.CreateAsync(solution);

            iWriteToOutput.WriteToOutputSolutionUri(_service.ConnectionData, solution.UniqueName, solution.Id);

            try
            {
                if (entityMetadata != null)
                {
                    iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.InConnectionAddingInSolutionEntityFormat3, _service.ConnectionData.Name, solutionUniqueName, entityMetadata.LogicalName);

                    {
                        var repositorySolutionComponent = new SolutionComponentRepository(_service);

                        await repositorySolutionComponent.AddSolutionComponentsAsync(solutionUniqueName, new[] { new SolutionComponent()
                                                                                                                 {
                                                                                                                     ComponentType             = new OptionSetValue((int)ComponentType.Entity),
                                                                                                                     ObjectId                  = entityMetadata.MetadataId.Value,
                                                                                                                     RootComponentBehaviorEnum = SolutionComponent.Schema.OptionSets.rootcomponentbehavior.Include_Subcomponents_0,
                                                                                                                 } });
                    }

                    iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.ExportingSolutionAndExtractingRibbonDiffXmlForEntityFormat2, solutionUniqueName, entityMetadata.LogicalName);
                }
                else if (ribbonCustomization != null)
                {
                    iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.InConnectionAddingInSolutionApplicationRibbonFormat2, _service.ConnectionData.Name, solutionUniqueName);

                    {
                        var repositorySolutionComponent = new SolutionComponentRepository(_service);

                        await repositorySolutionComponent.AddSolutionComponentsAsync(solutionUniqueName, new[] { new SolutionComponent()
                                                                                                                 {
                                                                                                                     ComponentType             = new OptionSetValue((int)ComponentType.RibbonCustomization),
                                                                                                                     ObjectId                  = ribbonCustomization.Id,
                                                                                                                     RootComponentBehaviorEnum = SolutionComponent.Schema.OptionSets.rootcomponentbehavior.Include_Subcomponents_0,
                                                                                                                 } });
                    }

                    iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.ExportingSolutionAndExtractingApplicationRibbonDiffXmlFormat1, solutionUniqueName);
                }

                string header = (entityMetadata != null) ? entityMetadata.LogicalName : "ApplicationRibbon";

                var repository = new ExportSolutionHelper(_service);

                var solutionBodyBinary = await repository.ExportSolutionAndGetBodyBinaryAsync(solutionUniqueName);

                {
                    string fileName = EntityFileNameFormatter.GetSolutionFileName(_service.ConnectionData.Name, solution.UniqueName, $"{header} Solution Backup", FileExtension.zip);

                    string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

                    File.WriteAllBytes(filePath, solutionBodyBinary);

                    iWriteToOutput.WriteToOutput(_service.ConnectionData, "Solution {0} Backup exported to {1}", solution.UniqueName, filePath);

                    iWriteToOutput.WriteToOutputFilePathUri(_service.ConnectionData, filePath);
                }

                string ribbonDiffXml = string.Empty;

                if (entityMetadata != null)
                {
                    ribbonDiffXml = ExportSolutionHelper.GetRibbonDiffXmlForEntityFromSolutionBody(entityMetadata.LogicalName, solutionBodyBinary);
                }
                else if (ribbonCustomization != null)
                {
                    ribbonDiffXml = ExportSolutionHelper.GetApplicationRibbonDiffXmlFromSolutionBody(solutionBodyBinary);
                }

                ribbonDiffXml = ContentComparerHelper.FormatXmlByConfiguration(
                    ribbonDiffXml
                    , commonConfig
                    , XmlOptionsControls.RibbonXmlOptions
                    , schemaName: AbstractDynamicCommandXsdSchemas.RibbonSchema
                    , entityName: entityMetadata?.LogicalName ?? string.Empty
                    );

                {
                    string filePath = string.Empty;

                    if (entityMetadata != null)
                    {
                        string fileName = EntityFileNameFormatter.GetEntityRibbonDiffXmlFileName(_service.ConnectionData.Name, entityMetadata.LogicalName, "BackUp", FileExtension.xml);
                        filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));
                        iWriteToOutput.WriteToOutput(_service.ConnectionData, "{0} RibbonDiffXml BackUp exported to {1}", entityMetadata.LogicalName, filePath);
                    }
                    else if (ribbonCustomization != null)
                    {
                        string fileName = EntityFileNameFormatter.GetApplicationRibbonDiffXmlFileName(_service.ConnectionData.Name, "BackUp", FileExtension.xml);
                        filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));
                        iWriteToOutput.WriteToOutput(_service.ConnectionData, "Application RibbonDiffXml BackUp exported to {0}", filePath);
                    }

                    File.WriteAllText(filePath, ribbonDiffXml, new UTF8Encoding(false));

                    iWriteToOutput.WriteToOutputFilePathUri(_service.ConnectionData, filePath);
                }

                if (entityMetadata != null)
                {
                    solutionBodyBinary = ExportSolutionHelper.ReplaceRibbonDiffXmlForEntityInSolutionBody(entityMetadata.LogicalName, solutionBodyBinary, doc.Root);
                }
                else if (ribbonCustomization != null)
                {
                    solutionBodyBinary = ExportSolutionHelper.ReplaceApplicationRibbonDiffXmlInSolutionBody(solutionBodyBinary, doc.Root);
                }

                {
                    string fileName = EntityFileNameFormatter.GetSolutionFileName(_service.ConnectionData.Name, solution.UniqueName, $"{header} Changed Solution Backup", FileExtension.zip);

                    string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName));

                    File.WriteAllBytes(filePath, solutionBodyBinary);

                    iWriteToOutput.WriteToOutput(_service.ConnectionData, "Changed Solution {0} Backup exported to {1}", solution.UniqueName, filePath);

                    iWriteToOutput.WriteToOutputFilePathUri(_service.ConnectionData, filePath);
                }

                iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.ImportingSolutionFormat1, solutionUniqueName);

                await repository.ImportSolutionAsync(solutionBodyBinary);

                await DeleteSolution(iWriteToOutput, solution);

                {
                    var repositoryPublish = new PublishActionsRepository(_service);

                    if (entityMetadata != null)
                    {
                        iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, _service.ConnectionData.Name, entityMetadata.LogicalName);

                        await repositoryPublish.PublishEntitiesAsync(new[] { entityMetadata.LogicalName });
                    }
                    else if (ribbonCustomization != null)
                    {
                        iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.OutputStrings.InConnectionPublishingApplicationRibbonFormat1, _service.ConnectionData.Name);

                        await repositoryPublish.PublishApplicationRibbonAsync();
                    }
                }
            }
            finally
            {
                var task = DeleteSolution(iWriteToOutput, solution);
            }
        }