コード例 #1
0
ファイル: VstsApiWrapper.cs プロジェクト: chrisglein/kanban4u
 public static void Fixup(VstsWorkItem workItem)
 {
     // The description is stored as HTML, so we want to strip the HTML tags and unescape everything.
     if (workItem.Fields.Description != null)
     {
         workItem.Fields.Description = System.Net.WebUtility.HtmlDecode(workItem.Fields.Description);
         string description = System.Text.RegularExpressions.Regex.Replace(workItem.Fields.Description, @"<.*?>", string.Empty);
         workItem.Fields.Description = description;
     }
 }
コード例 #2
0
ファイル: VstsApiWrapper.cs プロジェクト: chrisglein/kanban4u
        public static async Task CommitUpdatesAsync(this VstsWorkItem workItem)
        {
            string jsonUpdateString = string.Empty;

            foreach (var workItemJsonObject in JObject.FromObject(workItem.Fields))
            {
                if (jsonUpdateString.Length > 0)
                {
                    jsonUpdateString += $",{Environment.NewLine}";
                }

                var workItemString = workItemJsonObject.Value.ToString().Replace(@"\", @"\\").Replace("\"", "\\\"");
                jsonUpdateString += $"    {{ \"op\": \"add\", \"path\": \"/fields/{workItemJsonObject.Key}\", \"value\": \"{workItemString}\" }}";
            }

            jsonUpdateString = $"[{Environment.NewLine}{jsonUpdateString}{Environment.NewLine}]";
            await InvokeRestMethodAsync <VstsWorkItem>(string.Empty, GetUpdateWorkItemRestApiUri(workItem.Id), HttpMethod.Patch, CreateHttpContentFromString(jsonUpdateString, HttpMethod.Patch));
        }