Error executing template "Designs/dwdoc/Paragraph/Workitem_List.cshtml"
System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '[0].fields.assignedTo', line 1, position 311.
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at CompiledRazorTemplates.Dynamic.RazorEngine_a7d9fa09624345919158c8d2b726cb56.<GetAllItemsFromWebApiAsync>d__1.MoveNext() in E:\Dynamicweb.net\Solutions\Dynamicweb\doc.dynamicweb-cms.com\Files\Templates\Designs\dwdoc\Paragraph\Workitem_List.cshtml:line 56
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at CompiledRazorTemplates.Dynamic.RazorEngine_a7d9fa09624345919158c8d2b726cb56.Execute() in E:\Dynamicweb.net\Solutions\Dynamicweb\doc.dynamicweb-cms.com\Files\Templates\Designs\dwdoc\Paragraph\Workitem_List.cshtml:line 86
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
---> (Inner Exception #0) Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '[0].fields.assignedTo', line 1, position 311.
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at CompiledRazorTemplates.Dynamic.RazorEngine_a7d9fa09624345919158c8d2b726cb56.<GetAllItemsFromWebApiAsync>d__1.MoveNext() in E:\Dynamicweb.net\Solutions\Dynamicweb\doc.dynamicweb-cms.com\Files\Templates\Designs\dwdoc\Paragraph\Workitem_List.cshtml:line 56<---
1 @using BugList;
2 @using System.Threading.Tasks;
3 @using System.Net.Http
4 @using System.Net.Http.Headers
5 @using System.Threading.Tasks
6 @using System.Collections.Generic
7 @using Newtonsoft.Json
8
9 @{
10 string pat = @GetString("Item.Personal_Access_Token.Value");
11 string project = @GetString("Item.Project.Value");
12 string query = @GetString("Item.Query_ID.Value");
13 string[] states = @GetString("Item.State").Split(',');
14 string build = @GetString("Item.Build");
15 string tag = @GetString("Item.Tag");
16
17 var currentuser = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser();
18
19 }
20
21 @{
22 if (string.IsNullOrWhiteSpace(project))
23 {
24 project = "dynamicweb";
25 }
26
27 if (string.IsNullOrWhiteSpace(query))
28 {
29 query = "6b8fb4d1-fe99-4f0a-9fd4-c554dabc0d66"; //All customer bugs (Non-Rapido)
30 }
31
32 }
33
34 @functions{
35
36 /// <summary>
37 /// Query: Open Bugs (Customer Bugs), all work items
38 /// </summary>
39 /// <returns></returns>
40 async Task<List<WorkItem>> GetAllItemsInQueryAsync(string pat, string projectName, string queryId)
41 {
42 return await GetAllItemsFromWebApiAsync(queryId);
43 }
44
45 async Task<List<WorkItem>> GetAllItemsFromWebApiAsync(string queryId)
46 {
47 using (var client = new HttpClient())
48 {
49 client.BaseAddress = new Uri("https://devopsservice.dynamicweb-cms.com/");
50 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
51
52 var response = await client.GetAsync($"api/workitem/query/{queryId}");
53 response.EnsureSuccessStatusCode();
54
55 var json = await response.Content.ReadAsStringAsync();
56 return JsonConvert.DeserializeObject<List<WorkItem>>(json);
57 }
58 }
59
60 async Task<string> Test(string queryId)
61 {
62 using (var client = new HttpClient())
63 {
64 client.BaseAddress = new Uri("https://devopsservice.dynamicweb-cms.com/");
65 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
66
67 var response = await client.GetAsync($"api/workitem/query/{queryId}");
68
69 response.EnsureSuccessStatusCode();
70
71
72 var json = await response.Content.ReadAsStringAsync();
73 return json;
74 }
75 }
76
77 public class WorkItem
78 {
79 public int id { get; set; }
80 public Dictionary<string, string> fields { get; set; }
81 }
82 }
83
84 @{
85 //Fetches query data
86 List<WorkItem> workitems = GetAllItemsFromWebApiAsync(@query).Result;
87 }
88
89 <div class="col-md-12">
90
91 <table class="table table-responsive">
92 <thead>
93 <tr>
94 <th>ID</th>
95 <th>Type</th>
96 <th>Description</th>
97 <th>State</th>
98
99 <th>Fixed in</th>
100 </tr>
101 </thead>
102 <tbody>
103 @foreach (var workitem in workitems)
104 {
105 if (states.Contains(workitem.fields["state"]))
106 {
107 if (string.IsNullOrWhiteSpace(build) || (workitem.fields.ContainsKey("integratedInBuild") && workitem.fields["integratedInBuild"] == build))
108 {
109
110 if (workitem.fields["tags"].Contains(tag) || string.IsNullOrWhiteSpace(tag))
111 {
112 <tr>
113 <td>@workitem.id</td>
114 <td>@workitem.fields["type"]</td>
115 <td>
116 @workitem.fields["title"]
117 <br />
118 <em><small>@workitem.fields["areaPath"]</small></em>
119 <br />
120 <small style="font-size:80%">Date Created: @workitem.fields["created"]</small>
121 <br />
122 @if (!string.IsNullOrEmpty(workitem.fields["closeddate"]))
123 {
124 var FixedIn = workitem.fields["closeddate"];
125 <small style="font-size:80%">Date Fixed: @FixedIn</small>
126 }
127 @if(workitem.fields.ContainsKey("FoundIn")){<small style="font-size:80%; display:block;">Found in version: @workitem.fields["FoundIn"]</small>}
128 </td>
129 <td>@workitem.fields["state"]</td>
130 @if(@workitem.fields.ContainsKey("integratedInBuild"))
131 {
132 <td>@workitem.fields["integratedInBuild"]</td>
133 }
134 else
135 {
136 <td></td>
137 }
138 </tr>
139 }
140 }
141 }
142 }
143 <tr>
144 <td align="center" colspan="5">
145 @if (currentuser != null)
146 {
147 foreach (var customfield in currentuser.CustomFieldValues)
148 {
149 if (customfield.CustomField.SystemName == "AccessUser_DWEmployee" && customfield.Value.ToString() == "True")
150 {
151 <br />
152 <div>
153 <em>
154 <small>
155 <b>Applied Filters</b>
156 @if (!string.IsNullOrWhiteSpace(states[0]))
157 {
158 <div>
159 States (@foreach (var state in states){<text>@state;</text>})
160 </div>
161 }
162 @if (!string.IsNullOrWhiteSpace(build))
163 {
164 <div> Build (@build)</div>
165 }
166 @if (!string.IsNullOrWhiteSpace(tag))
167 {
168 <div>Tags (@tag)</div>
169 }
170 </small>
171 </em>
172 </div>
173 }
174 }
175 }
176 </td>
177 </tr>
178 </tbody>
179
180 </table>
181
182 </div>
183
184
185
186