1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
Imports System.Net Imports Atlassian.Jira Imports Newtonsoft.Json.Linq Public Class MyCustomFieldValueSerializer Implements ICustomFieldValueSerializer Public Function FromJson(json As JToken) As String() Implements ICustomFieldValueSerializer.FromJson Debug.WriteLine(json) End Function Public Function ToJson(values() As String) As JToken Implements ICustomFieldValueSerializer.ToJson ' Dim MySerial As New Newtonsoft.Json.JsonSerializer() Dim token = JToken.Parse("[{""key"" : """ & values(0) & """}]") Return token End Function End Class Public Class Form1 Dim MyJira As Jira = Nothing Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Dim settings = New JiraRestClientSettings() settings.EnableRequestTrace = True settings.CustomFieldSerializers.Add("com.riadalabs.jira.plugins.insight:rlabs-customfield-default-object", New MyCustomFieldValueSerializer()) MyJira = Jira.CreateRestClient("https://jira.FQDN.org", "YourLoginName", "YourLoginPassword", settings) 'Init() CreateAndCloseTicket() End End Sub Public Async Function CreateAndCloseTicket() As Task Try Dim MyFields As New CreateIssueFields("IS") MyFields.ProjectKey = "IT" 'MyFields.ParentIssueKey = "IT" Dim Myissue As Issue = MyJira.CreateIssue(MyFields) Myissue.Type = "User Incident" Myissue.Summary = "test summary" Myissue.Description = "test" 'Myissue.CustomFields("awd") = map[string]String{{"value": "NA"}} Debug.WriteLine(Myissue.CustomFields.Count) 'Myissue.CustomFields.AddById("customfield_12002", "{""key"" : ""TONE-15751""}") 'Myissue.CustomFields.AddArray("Location", {"TONE-15751"}) Myissue.CustomFields.SearchByProjectOnly = True 'Myissue.CustomFields.AddArray("customfield_12002", "[{""key"" : ""TONE-15751""}]") 'Myissue.CustomFields.AddById("customfield_12002", {"[{""key"" : ""TONE-15751""}]"}) Dim MyString As String() = {"TONE-15751"} Myissue.CustomFields.AddArray("Location", MyString) 'Dim MyDictonary = New Dictionary(Of String, Strin 'MyDictonary.Add("key", "[TONE-15751]") 'Dim MyString As New ComparableString("TONE-15751") 'Myissue("Location") = MyString 'Myissue.CustomFields.AddById("Location", {"TONE-15751"}) Myissue.CustomFields.AddById("customfield_10311", "x1234") Myissue.CustomFields.AddById("customfield_10400", "An Account Issue") Myissue.SaveChanges() Catch ex As Exception Debug.WriteLine(ex.Message) Debug.WriteLine(ex.InnerException.Message) 'Response Status Code: 400. Response Content: {"errorMessages":[],"errors":{"customfield_12002":"Location is required.","customfield_10311":"Best Callback Number is required.","customfield_10400":"Type of Issue is required."}} End Try End Function Public Async Function Init() As Task Try 'Dim MyServiceLocator As New ServiceLocator() 'Dim MyJira As New Jira(MyServiceLocator) Dim MyJiraRest As New JiraRestClientSettings Debug.WriteLine(MyJira.RestClient.Url) Dim FetchJQL As Task(Of IPagedQueryResult(Of Issue)) = MyJira.Issues.GetIssuesFromJqlAsync("project = ""IS"" AND (""Assignment Group"" = ""System Administrator"" OR Assignee in MembersOf(""WG System Administrator"")) AND status not in (Closed, Done, ""IS Director Approval"", ""Needs Approval"") AND assignee = ""24556""", 100) Dim Fetch As Task(Of IDictionary(Of String, Issue)) = MyJira.Issues.GetIssuesAsync({"IS-462496"}) Dim MyIssuesJQL As IPagedQueryResult(Of Issue) = Await FetchJQL Dim MyIssues As IDictionary(Of String, Issue) = Await Fetch For Each MyEntry In MyIssues Debug.WriteLine(MyEntry.Key) Next Debug.WriteLine("Found issues count:" & MyIssuesJQL.Count) For Each MyEntry As Issue In MyIssuesJQL Debug.WriteLine(MyEntry.Updated.ToString() & " " & MyEntry.Key.ToString & " " & MyEntry.Summary) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Function End Class |