public IEnumerable <string> FindTickets(string query) { return(issueManagement .GetIssuesBySearch(query) .Cast <dynamic>() .Select(issue => issue.Id + ": " + issue.summary) .Cast <string>()); }
/// <summary> /// Simple query, yields <c>ShortIssue</c> objects. Can drill down later if needed. /// </summary> /// <param name="projectShortName"></param> /// <param name="query"></param> /// <returns></returns> public IList <ShortIssue> Query(string projectShortName, string query) { var im = new IssueManagement(Connection); if (!string.IsNullOrEmpty(projectShortName)) { query = string.Format("project: {0} {1}", projectShortName, query); } var mapper = new IssueToShortIssueMapper(BaseUrl); return(im.GetIssuesBySearch(query, sensibleQueryLimit, 0) .Select(mapper.Map) .ToList()); }
protected override void ProcessRecord() { if (!Force) { var similarIssues = IssueManagement.GetIssuesBySearch(string.Format("project: {0} \"{1}\" \"{2}\"", ProjectShortName, Summary, Description)); var issueList = from si in similarIssues select new { IssueId = si.Id, Summary = si.Summary, Description = si.Description }; if (issueList.Count() > 0) { WriteWarning("Found similar issues. If you still want to create it, use -Force=true"); WriteObject(issueList); return; } } var newIssue = new Issue { Summary = Summary, Description = Description, Priority = Priority, ProjectShortName = ProjectShortName, ReporterName = Connection.GetCurrentAuthenticatedUser().Username, State = "Submitted", Type = Type, Subsystem = Subsystem }; var id = IssueManagement.CreateIssue(newIssue); WriteObject(string.Format("Issue Created with id: {0}", id)); }
protected override void ProcessRecord() { if (!Force) { var similarIssues = IssueManagement.GetIssuesBySearch(string.Format("project: {0} \"{1}\" \"{2}\"", ProjectShortName, Summary, Description)); // TODO: Fix this once issues work again with dynamic type //var issueList = from si in similarIssues // select new {IssueId = si.Id, Summary = si.Summary, Description = si.Description}; //if (issueList.Count() > 0) //{ // WriteWarning("Found similar issues. If you still want to create it, use -Force=true"); // WriteObject(issueList); // return; //} } dynamic newIssue = new Issue(); newIssue.Summary = Summary; newIssue.Description = Description; newIssue.Priority = new[] { Priority }; newIssue.ProjectShortName = ProjectShortName; newIssue.ReporterName = Connection.GetCurrentAuthenticatedUser().Username; newIssue.State = "Submitted"; newIssue.Type = Type; newIssue.Subsystem = Subsystem; var id = IssueManagement.CreateIssue(newIssue); WriteObject(string.Format("Issue Created with id: {0}", id)); }