Exemplo n.º 1
0
        /// <summary>
        /// Aggregates the Messaging Objects that have been given a rating.
        /// </summary>
        /// <param name="application">The target application.</param>
        private static void RollupConversionRatings(TargetApplication application)
        {
            var validResources  = 0;
            var conversionTotal = 0;

            application.Application.Channels.Where(c => (int)c.Rating > 0).ToList().ForEach(c =>
            {
                validResources++;
                conversionTotal += (int)c.Rating;
            });

            application.Application.Intermediaries.Where(c => (int)c.Rating > 0).ToList().ForEach(c =>
            {
                validResources++;
                conversionTotal += (int)c.Rating;
            });

            application.Application.Endpoints.Where(c => (int)c.Rating > 0).ToList().ForEach(c =>
            {
                validResources++;
                conversionTotal += (int)c.Rating;
            });

            application.Application.Messages.Where(c => (int)c.Rating > 0).ToList().ForEach(c =>
            {
                validResources++;
                conversionTotal += (int)c.Rating;
            });

            // Aggregate - note the enum scores out of 5 so multiply by 20 to get a percentage.
            if (validResources > 0)
            {
                application.AverageConversionRating = 20.0M * conversionTotal / validResources;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the summary information for the target application.
        /// </summary>
        /// <param name="containerNode">The HTML container to render into.</param>
        /// <param name="application">The target application</param>
        public static void RenderApplicationSummary(HtmlNode containerNode, TargetApplication application)
        {
            _ = containerNode ?? throw new ArgumentNullException(nameof(containerNode));
            _ = application ?? throw new ArgumentNullException(nameof(application));

            // Create a header entry
            var sectionNode = HtmlNode.CreateNode(HtmlResources.SnippetEmptyDiv);

            sectionNode.InnerHtml = HtmlResources.TargetApplicationSummaryHeading;
            containerNode.AppendChild(sectionNode);

            // Create header for the application
            var snippet = HtmlResources.TargetApplicationSnippetSummary;
            var refId   = Guid.NewGuid().ToString();

            snippet = snippet.Replace("{refId}", refId);

            // Build the description rows.
            var descriptionBuilder = new StringBuilder();

            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberOfMessages, application.Application.Messages.Count));
            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberOfEndpoints, application.Application.Endpoints.Count));
            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberofChannels, application.Application.Channels.Count));
            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberOfIntermediaries, application.Application.Intermediaries.Count));
            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberOfScenarios, application.Scenarios.Count));
            descriptionBuilder.Append(string.Format(CultureInfo.CurrentCulture, HtmlResources.TargetApplicationSnippetPropertyRow, HtmlResources.TargetApplicationPropertyNumberOfResources, application.Resources.Count));
            snippet = snippet.Replace("{description}", descriptionBuilder.ToString());

            var node = CreateNodeWithSnippetContent(snippet);

            containerNode.AppendChild(node);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Rolls up the resources in the target application.
 /// </summary>
 /// <param name="application">The target application.</param>
 private static void RollupResources(TargetApplication application)
 {
     application.Application.Resources.ToList().ForEach(r => application.Resources.Add(r));
     application.Application.Channels.ToList().ForEach(m => m.Resources.ToList().ForEach(r => application.Resources.Add(r)));
     application.Application.Endpoints.ToList().ForEach(m => m.Resources.ToList().ForEach(r => application.Resources.Add(r)));
     application.Application.Intermediaries.ToList().ForEach(m => m.Resources.ToList().ForEach(r => application.Resources.Add(r)));
     application.Application.Messages.ToList().ForEach(m => m.Resources.ToList().ForEach(r => application.Resources.Add(r)));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Decodes the scenarios for the application.
        /// </summary>
        /// <param name="application">The application being decoded.</param>
        /// <param name="target">The whole target model, should references to other applications be required.</param>
        private static void DecodeScenarios(TargetApplication application, AzureIntegrationServicesMigrationTarget target)
        {
            // Create a list of scenarios based on the activator flag
            var scenarios = new List <TargetScenario>();

            application.Application.Endpoints.Where(e => e.Activator && e.Properties.ContainsKey(ModelConstants.ScenarioName)).ToList().ForEach(e => scenarios.Add(e.CreateScenario()));
            application.Application.Endpoints.Where(e => e.MessageExchangePattern == MessageExchangePattern.RequestReply && e.Properties.ContainsKey(ModelConstants.ScenarioName)).ToList().ForEach(e => scenarios.Add(e.CreateScenario()));
            application.Application.Intermediaries.Where(e => e.Activator).ToList().ForEach(i => scenarios.Add(i.CreateScenario()));

            // Recurse through the scenarios to find subsequent stages.
            scenarios.ForEach(s => RecurseScenarioStage(s.Activator, target));

            // Append to output.
            scenarios.ForEach(s => application.Scenarios.Add(s));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Decodes the scenarios from the target model
        /// </summary>
        /// <param name="target">The target model.</param>
        /// <returns>A list of decoded applications with scenarios.</returns>
        public static IList <TargetApplication> DecodeTargetModel(AzureIntegrationServicesMigrationTarget target)
        {
            _ = target ?? throw new ArgumentNullException(nameof(target));

            var applications = new List <TargetApplication>();

            // Loop through each application on the message bus to initialize the applications.
            foreach (var application in target.MessageBus.Applications)
            {
                var targetApplication = new TargetApplication()
                {
                    Application = application
                };
                DecodeScenarios(targetApplication, target);
                RollupConversionRatings(targetApplication);
                RollupResources(targetApplication);
                applications.Add(targetApplication);
            }

            return(applications);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Renders the heading for the target application.
        /// </summary>
        /// <param name="containerNode">The HTML container to render into.</param>
        /// <param name="application">The target application</param>
        public static HtmlNode RenderTargetApplicationHeading(HtmlNode containerNode, TargetApplication application)
        {
            _ = containerNode ?? throw new ArgumentNullException(nameof(containerNode));
            _ = application ?? throw new ArgumentNullException(nameof(application));

            var snippet = HtmlResources.TargetApplicationSnippetNewSection;
            var refId   = Guid.NewGuid().ToString();

            snippet = snippet.Replace("{refId}", refId);
            snippet = snippet.Replace("{name}", application.Application.Name);
            snippet = snippet.Replace("{stars}", BuildApplicationStarsSnippet(application.AverageConversionRating));
            snippet = snippet.Replace("{description}", string.IsNullOrEmpty(application.Application.Description) ? HtmlResources.ApplicationDefaultDescription : application.Application.Description);
            var node = CreateNodeWithSnippetContent(snippet);

            containerNode.AppendChild(node);

            // Return the node container.
            return(node.SelectSingleNode(string.Format(CultureInfo.CurrentCulture, HtmlResources.ApplicationSectionChildJQuery, refId)));
        }