public Project GetProjectTree(IssueManagement issueManagement)
        {
            var issues = issueManagement.GetIssuesBySearch(IssueSearchQuery).ToArray();

            var metaissues = issues.
                Cast<dynamic>().
                ToDictionary(iss => (string)iss.Id, issue => new
                {
                    Id = (string) issue.Id,
                    Summary = (string) issue.Summary,
                    Subtasks = (List<KeyValuePair<string, string>>)GetSubtasks(issue.Links),
                    Type = (string) issue.Type
                });

            var tree = from issue in metaissues
                       where issue.Value.Type == "Requirement"
                       select new Project()
                       {
                           Id = issue.Key,
                           Name = issue.Value.Summary,
                           Childs = GetChilds(issue.Value.Subtasks.Select(sub => sub.Value), metaissues.ToDictionary(x=>x.Key,x=>x.Value.Summary)),
                       };

            return new Project {Childs = tree.ToArray(), Id = "HM", Name = "MarkTime"};
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var connection = new Connection("youtrack.lamione.cz");
            connection.Authenticate("root", "hop,scotch3");
            var issueManagement = new IssueManagement(connection);

            var issues = issueManagement.GetAllIssuesForProject("HM").ToArray();
            var metaissues = issues.
                Cast<dynamic>().
                ToDictionary(iss => (string) iss.Id, issue => new SyncIssue
                {
                    Id = issue.Id,
                    Summary = issue.Summary,
                    Subtasks = GetSubtasks(issue.Links),
                    Type = issue.Type
                });

            var tree = from issue in metaissues
                       where issue.Value.Type == "Requirement"
                       select new SyncIssue
                       {
                           Id = issue.Key,
                           Summary = issue.Value.Summary,
                           Childs = GetChilds(issue.Value.Subtasks.Select(sub => sub.Value), metaissues),
                           Type = issue.Value.Type
                       };

            Console.WriteLine("END");
        }
Exemple #3
0
 /// <summary>
 /// Simple query, yields <c>ShortIssue</c> objects. Can drill down later if needed.
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public IList<ShortIssue> Query(string s)
 {
     var im = new IssueManagement(connection);
       return im.GetIssuesBySearch(s, sensibleQueryLimit, 0)
        .Select((dynamic i) => new ShortIssue(i.Id, i.summary))
        .ToList();
 }
        public ActionResult Update(string id, string status)
        {
            var issueManagement = new IssueManagement(UserSession.Connection);

            issueManagement.ApplyCommand(id, status, "Command applied from SimpleTrack");

            return Json(true, JsonRequestBehavior.AllowGet);
        }
        private IEnumerable<Issue> PerformSearch()
        {
            var connection = this.youTrackServer.Connect();

            var issueManagement = new IssueManagement(connection);

            return issueManagement.GetAllIssuesForProject(this.youTrackServer.Project);
        }
        //
        // GET: /Board/
        public ActionResult Index()
        {
            var issueManagement = new IssueManagement(UserSession.Connection);

            var issueGroups = new IssueGroups
            {
                Backlog = issueManagement.GetIssuesBySearch("for: me #Unresolved -{In Progress}"),
                InProgress = issueManagement.GetIssuesBySearch("for: me #{In Progress}"),
                Completed = issueManagement.GetIssuesBySearch("for: me #Resolved")
            };

            return View(issueGroups);
        }
Exemple #7
0
        private static bool CheckIfIssueExists(IssueManagement issueManagement, string issue)
        {
            bool result;

            try
            {
                result = issueManagement.CheckIfIssueExists(issue);
            }
            catch
            {
                result = false;
            }

            return result;
        }
        public void DeleteAll()
        {
            var conn = new Connection("localhost", 2669);
            conn.Authenticate("root", "10Pounds");

            var issueManagement = new IssueManagement(conn);

            foreach (var issueId in issueManagement.GetAllIssuesForProject("EJ").Select(x => x.Id))
            {
                var conn1 = new Connection("localhost", 2669);
                conn1.Authenticate("root", "10Pounds");
                var issueManagement1 = new IssueManagement(conn1);

                issueManagement1.ApplyCommand(issueId, "remove", string.Empty);
            }
        }
        public ActionResult MonthlyStats(ReportInput reportInput)
        {
            // Refactor this to make it async controller

            var issueManagement = new IssueManagement(UserSession.Connection);

            var statistics = new Cell[reportInput.Months];

            for (int i = 0; i < reportInput.Months; i++)
            {

                var month = i < 10 ? String.Format("0{0}", i + 1) : i + 1.ToString();

                var range = String.Format("{0}-{1}-01 .. {0}-{1}-{2}", reportInput.Year, month, DateTime.DaysInMonth(reportInput.Year, i + 1));
                statistics[i] = new Cell
                            {
                                FilterName1 = // project: resharper #fixed resolved date:
                                    issueManagement.GetIssueCount(
                                        string.Format("{0} {1}", reportInput.FilterExpression1, range)),
                                // project: resharper created by: resharper-developers created:
                                FilterName2 = issueManagement.GetIssueCount(
                                    string.Format("{0} {1}", reportInput.FilterExpression2,
                                                  range)),
                                // project: resharper created by: -resharper-developers created:

                                FilterName3= issueManagement.GetIssueCount(
                                    string.Format("{0} {1}", reportInput.FilterExpression3,
                                                  range)),
                            };

            }

            var stastics = ConvertToArray(statistics, reportInput.Months);

            var reportResult = new ReportResult()
                               {
                                   FilterName1 = reportInput.FilterName1,
                                   FilterName2 = reportInput.FilterName2,
                                   FilterName3 = reportInput.FilterName3,
                                   Statistics = stastics
                               };

            return View(reportResult);
        }
        public void Go()
        {
            var rep = new BugRepository();
            foreach (var issue in rep.GetBugs().Select(bug => new Issue()
                                                                {
                                                                    Summary = bug.Summary,
                                                                    Description = PandocHelper.Convert(bug.Description).Replace("<br />", string.Empty),
                                                                    Assignee = "Unassigned",
                                                                    State = MapBugStatus(bug.Status),
                                                                    Type = "Bug",
                                                                    ProjectShortName = "EJ"
                                                                }))
            {
                var conn = new Connection("localhost", 2669);
                conn.Authenticate("root", "10Pounds");

                var issueManagement = new IssueManagement(conn);

                issueManagement.CreateIssue(issue);
            }
        }
        public ActionResult New(NewIssueModel model)
        {
            if (ModelState.IsValid)
            {

                var issueManagement = new IssueManagement(UserSession.Connection);

                var issue = new Issue()
                              {
                                  Description = model.Description,
                                  ProjectShortName = model.Project,
                                  Summary = model.Summary,
                                  Type = model.Type,
                                  ReporterName = UserSession.Username

                              };
                issueManagement.CreateIssue(issue);

                return RedirectToAction("Index", "Home");
            }
            return View(model);
        }
        public Project GetProjectTree(IssueManagement issueManagement)
        {
            var issues = issueManagement.GetIssuesBySearch(IssueSearchQuery).ToArray();

            var groupBy = issues.
                Cast<dynamic>().
                Select(issue => new
                {
                    Id = (string)issue.Id,
                    Summary = (string)issue.Summary,
                    Project = (string[])issue.SubProject,
                    Type = (string)issue.Type
                }).GroupBy(x => x.Project);

            var projects = from grup in groupBy
                           select new Project
                                      {
                                          Id = grup.Key.First(),
                                          Name = "",
                                          Childs = grup.Select(s=> new Project{Id=s.Id,Name = s.Summary,Childs = Enumerable.Empty<Project>()})
                                      };
            return new Project {Childs = projects, Id = "LM", Name = "Lamione"};
        }
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            IssueManagement = new IssueManagement(Connection);
        }
        /// <summary>
        /// Using YouTrackSharp here. We can't submit
        /// the report as if it were from this person, even if they have an account (well, not without
        /// asking them for credentials, which is just not gonna happen). So we submit with an
        /// account we created just for this purpose, "auto_report_creator".
        /// </summary>
        private bool SubmitToYouTrack()
        {
            try
            {
                ChangeState(State.Submitting);

                _youTrackConnection.Authenticate("auto_report_creator", "thisIsInOpenSourceCode");
                _issueManagement = new IssueManagement(_youTrackConnection);
                _youTrackIssue = new Issue();
                _youTrackIssue.ProjectShortName = _youTrackProjectKey;
                _youTrackIssue.Type = "Awaiting Classification";
                _youTrackIssue.Summary = string.Format(Summary,_name.Text);
                _youTrackIssue.Description = GetFullDescriptionContents(false);
                _youTrackIssueId = _issueManagement.CreateIssue(_youTrackIssue);

                // this could all be done in one go, but I'm doing it in stages so as to increase the
                // chance of success in bad internet situations
                if (_includeScreenshot.Checked)
                {
                    using (var file = TempFile.WithFilenameInTempFolder("screenshot.png"))
                    {
                        SIL.IO.RobustIO.SaveImage(_screenshot, file.Path, ImageFormat.Png);
                        AddAttachment(file.Path);
                    }
                }

                if (Logger.Singleton != null)
                {
                    try
                    {
                        using (var logFile = GetLogFile())
                        {
                            AddAttachment(logFile.Path);
                        }
                    }
                    catch (Exception e)
                    {
                        _youTrackIssue.Description += System.Environment.NewLine + "***Got exception trying to attach log file: " + e.Message;
                        _issueManagement.UpdateIssue(_youTrackIssueId, _youTrackIssue.Summary, _youTrackIssue.Description);
                    }
                }

                if (_includeBook.Visible && _includeBook.Checked) // only Visible if Book is not null
                {
                    ChangeState(State.UploadingBook);
                    using (var bookZip = TempFile.WithFilenameInTempFolder(_youTrackIssueId + ".zip"))
                    {
                        var progress = new StatusProgress();
                        try
                        {
                            var zip = new BloomZipFile(bookZip.Path);
                            zip.AddDirectory(Book.FolderPath);
                            zip.Save();
                        }
                        catch (Exception error)
                        {
                            _youTrackIssue.Description += System.Environment.NewLine + "***Error as ProblemReporterDialog attempted to zip up the book: " + error.Message;
                            _issueManagement.UpdateIssue(_youTrackIssueId, _youTrackIssue.Summary, _youTrackIssue.Description);
                            Logger.WriteEvent("*** Error as ProblemReporterDialog attempted to zip up the book. " + error.Message);
                            // if an error happens in the zipper, the zip file stays locked, so we just leak it
                            bookZip.Detach();
                            _shortErrorHtml += " Error Zipping Book ";
                            throw;
                        }

                        try
                        {
                            string url = ProblemBookUploader.UploadBook(BloomS3Client.ProblemBookUploadsBucketName, bookZip.Path,
                                progress);
                            _youTrackIssue.Description += System.Environment.NewLine + url;
                            _issueManagement.UpdateIssue(_youTrackIssueId, _youTrackIssue.Summary, _youTrackIssue.Description);
                        }
                        catch (Exception error)
                        {
                            Logger.WriteError(progress.LastError, error);
                            _youTrackIssue.Description += System.Environment.NewLine + "***Got exception trying upload book: " + error.Message;
                            _issueManagement.UpdateIssue(_youTrackIssueId, _youTrackIssue.Summary, _youTrackIssue.Description);
                            _shortErrorHtml += " Uploading Book Failed ";
                        }
                    }
                }

                ChangeState(State.Success);
                return true;
            }
            catch (Exception error)
            {
                Debug.Fail(error.Message);
                return false;
            }
        }
Exemple #15
0
        /// <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();
        }
Exemple #16
0
 public void AttachFile(string issueId, string pathToFile)
 {
     var im = new IssueManagement(Connection);
       im.AttachFileToIssue(issueId, pathToFile);
 }
Exemple #17
0
        /// <summary>
        /// Simple query, yields <c>ShortComment</c> objects.
        /// </summary>
        /// <param name="issueId"></param>
        /// <returns></returns>
        public IList<ShortComment> QueryComments(string issueId)
        {
            var im = new IssueManagement(Connection);

              var mapper = new CommentToShortCommentMapper();
              return im.GetCommentsForIssue(issueId)
              .Select(mapper.Map)
              .ToList();
        }
Exemple #18
0
        private static bool RequiredPreconditionsFulfilled(IEnumerable<IEntry<ShortTrackingFormatPayload>> entries,
            IssueManagement issueManagement)
        {
            var @continue = true;

            var entryExistence = entries.Select(e => new { e.Payload.Query, Exists = CheckIfIssueExists(issueManagement, e.Payload.Query) }).ToList();
            if (entryExistence.Any(e => !e.Exists))
            {
                var ticketQueries = string.Join(", ", entryExistence.Where(e => !e.Exists).Select(e => e.Query));
                Interaction.Notice($"ERROR: There are entries that cannot be found: {ticketQueries}");
                @continue = false;
            }

            return @continue;
        }
Exemple #19
0
        private static bool UpdateWorkItems(IConnection connection, IEnumerable<IEntry<ShortTrackingFormatPayload>> entries, FileAppendLogger logger)
        {
            var issueManagement = new IssueManagement(connection);

            var errors = !RequiredPreconditionsFulfilled(entries, issueManagement);
            var warnings = !OptionalPreconditionsFulfilled(entries);

            if (errors)
            {
                if (warnings)
                {
                    Interaction.Acknowledge("There have been errors and warnings. Cannot store entries.");
                    return false;
                }

                Interaction.Acknowledge("There have been errors. Cannot store entries.");
                return false;
            }

            if (warnings && !Interaction.Confirm("There have been warnings. Continue?"))
            {
                return false;
            }

            PrintEntryList(entries, issueManagement);

            if (!Interaction.Confirm("Please review the entries. Continue?"))
            {
                return false;
            }

            foreach (var trakkrEntry in entries)
            {
                var minutes = (int)Math.Round(trakkrEntry.Duration.TotalMinutes);
                System.Console.Write($"Saving: {trakkrEntry.Timestamp.ToShortDateString()} : {trakkrEntry.Payload.Query} ... : {minutes} Minutes ({trakkrEntry.Payload.Descrition}) ... ");

                var doc = "<workItem>"
                          + $"<date>{UnixTime.GetUnixTimestampMilliseconds(trakkrEntry.Timestamp)}</date>"
                          + $"<duration>{minutes}</duration>"
                          + $"<description>{HttpUtility.HtmlEncode(trakkrEntry.Payload.Descrition)}</description>"
                          + "</workItem>";

                var response = connection.PostXml($"issue/{trakkrEntry.Payload.Query}/timetracking/workitem", doc);
                if (response.StatusCode == HttpStatusCode.Created)
                {
                    logger.Log($"Ticket {trakkrEntry.Payload.Query} ({trakkrEntry.Payload.Descrition}) : {minutes}m : {response.Location}");
                    System.Console.Write("SAVED!");
                }
                else
                {
                    System.Console.Write($"ERROR! Response Code: {response.StatusCode}");
                    logger.Log($"Ticket {trakkrEntry.Payload.Query} ({trakkrEntry.Payload.Descrition})" +
                               $" : {minutes}m" +
                               $" : ERROR! Response Code: {response.StatusCode}");
                }

                //POST http://localhost:8081/rest/issue/HBR-63/timetracking/workitem

                System.Console.WriteLine();

                //https://confluence.jetbrains.com/display/YTD6/Get+Available+Work+Items+of+Issue

                // get all workitems
                // GET /rest/issue/{issue}/timetracking/workitem/
                //var result = connection.Get<object>($"issue/{trakkrEntry.Mark}/timetracking/workitem/");

                // add a workitem
                //connection.Post($"issue/{trakkrEntry.Mark}/timetracking/workitem", "<xml/>");
                //POST http://localhost:8081/rest/issue/HBR-63/timetracking/workitem
            }

            return true;
        }
Exemple #20
0
 private static void PrintEntryList(IEnumerable<IEntry<ShortTrackingFormatPayload>> entries, IssueManagement issueManagement)
 {
     foreach (var trakkrEntry in entries)
     {
         var minutes = (int)Math.Round(trakkrEntry.Duration.TotalMinutes);
         dynamic issue = issueManagement.GetIssue(trakkrEntry.Payload.Query);
         string summary = issue.summary;
         Interaction.Notice($"{trakkrEntry.Timestamp.ToShortDateString()} : {trakkrEntry.Payload.Query} {summary} : {minutes} Minutes ({trakkrEntry.Payload.Descrition})");
     }
 }
Exemple #21
0
 public void SubmitComment(string issueId, string text)
 {
     var im = new IssueManagement(Connection);
       im.ApplyCommand(issueId, null, text);
 }