]> git.somenet.org - pub/jan/aic18.git/blob - service-reporting/Utility/TemplateGenerator.cs
Merge branch 'master' into 32-camunda-reporting-input-format
[pub/jan/aic18.git] / service-reporting / Utility / TemplateGenerator.cs
1 using System.Text;
2 using PdfService.Models;
3
4 namespace PdfService.Utility
5 {
6     public static class TemplateGenerator
7     {
8         public static string GetHTMLString(Term[] terms)
9         {
10             var sb = new StringBuilder();
11             sb.Append(@"
12                         <html>
13                             <head>
14                             </head>
15                             <body>
16                                 <section class='hero is-info'>
17                                 <div class='hero-body' style='padding-left:3em'>
18                                     <div class='container'>
19                                     <h1 class='title'>
20                                         Tweet Sentiment Analysis
21                                     </h1>
22                                     <h2 class='subtitle'>
23                                         Results for the terms
24                                     </h2>
25                                     </div>
26                                 </div>
27                                 </section>
28                                 <div class='container' style='margin-left:3em; margin-right:3em'>
29
30                                 ");
31  
32             foreach (Term term in terms)
33             {
34                 string color = "";
35                 if(term.Sentiment < 0.33)
36                     color = "is-danger";
37                 else if(term.Sentiment < 0.66)
38                     color = "is-warning";
39                 else 
40                     color = "is-success";
41
42                 sb.AppendFormat(@"<div class='container' style='margin-top:3em;'>  
43                             <p class='title is-5'>{0}</p>
44                     <div class='content'>
45                     Sentiment Analysis Result:
46                         <div class='column'><progress class='progress {2}' value='{1}' max='100'>{1}%</progress></div>
47                     
48                     </div>
49                 </div>", term.Name, System.Math.Ceiling(term.Sentiment*100), color);
50             }
51  
52             sb.Append(@" </div>
53                             </body>
54                         </html>");
55  
56             return sb.ToString();
57         }
58     }
59 }