示例#1
0
        // CreateIssue
        public static bool CreateIssue(BearerTokenConnection connection, Issue issue)
        {
            // Create new YoutrackSharp Issue and Set Standard Fields
            var newIssue = new YouTrackSharp.Issues.Issue()
            {
                Summary     = issue.Summary,
                Description = issue.Description,
            };

            // Set CustomFields
            foreach (var customField in issue.CustomFields)
            {
                newIssue.SetField(customField.Name, customField.Value);
            }

            try
            {
                connection.CreateIssuesService().CreateIssue("OTHER", newIssue).Wait();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        private Issue CreateIssue(YouTrackSharp.Issues.Issue issue)
        {
            var workItems = timeService.GetWorkItemsForIssue(issue.Id).Result;

            return(new Issue(
                       issue.Id,
                       issue.Summary,
                       issue.GetField("Estimate")?.AsInt32() / 60,
                       issue.GetField("Spent time")?.AsInt32() / 60,
                       issue.GetField("reporterFullName").Value.ToString(),
                       ((List <YouTrackSharp.Issues.Assignee>)issue.GetField("Assignee")?.Value)?.FirstOrDefault()?.UserName,
                       issue.GetField("projectShortName").AsString(),
                       serverUrl + @"/issue/" + issue.Id,
                       workItems?
                       .Select(w => new WorkItem()
            {
                UserName = w.Author.Login,
                SpentTime = (int)w.Duration.TotalHours
            })
                       .ToList()));
        }