Пример #1
0
        private static async Task <DateTimeOffset?> GetWorkingStartTime(IssueData issue, HashSet <string> workingLabels, IGitHubClient gitHubClient)
        {
            // No GraphQL API for this :(
            var workingLabelsOnThisIssue =
                issue.Labels
                .Where(label => workingLabels.Contains(label.Name, StringComparer.OrdinalIgnoreCase))
                .Select(label => label.Name);

            if (!workingLabelsOnThisIssue.Any())
            {
                // Item isn't in any Working state, so ignore it
                return(null);
            }

            // Find all "labeled" events for this issue
            var issueEvents = await gitHubClient.Issue.Events.GetAllForIssue(issue.Repository.Owner.Login, issue.Repository.Name, issue.Number);

            var lastApiInfo = gitHubClient.GetLastApiInfo();

            foreach (var workingLabelOnThisIssue in workingLabelsOnThisIssue)
            {
                var labelEvent = issueEvents.LastOrDefault(
                    issueEvent =>
                    issueEvent.Event == EventInfoState.Labeled &&
                    string.Equals(issueEvent.Label.Name, workingLabelOnThisIssue, StringComparison.OrdinalIgnoreCase));

                if (labelEvent != null)
                {
                    // If an event where this label was applied was found, return the date on which it was applied
                    return(labelEvent.CreatedAt);
                }
            }

            return(null);
        }
Пример #2
0
 internal OriginalData(IssueData issueData)
 {
     ExceptionTypeName = issueData.IssueType.ExceptionTypeName;
     Message           = issueData.IssueType.Message;
     StackTrace        = issueData.IssueType.StackTrace;
     Data = issueData.Data;
 }
Пример #3
0
        public static long AddIssue(IssueData Issue)
        {
            long IssueId;

            using (MySqlConnection Connection = new MySqlConnection(SqlConnector.ConnectionString))
            {
                Connection.Open();

                using (MySqlCommand Command = new MySqlCommand("INSERT INTO ugs_db.Issues (Project, Summary, OwnerId, CreatedAt, FixChange) VALUES (@Project, @Summary, @OwnerId, UTC_TIMESTAMP(), 0)", Connection))
                {
                    Command.Parameters.AddWithValue("@Project", Issue.Project);
                    Command.Parameters.AddWithValue("@Summary", SanitizeText(Issue.Summary, IssueSummaryMaxLength));
                    if (Issue.Owner != null)
                    {
                        Command.Parameters.AddWithValue("OwnerId", FindOrAddUserId(Issue.Owner, Connection));
                    }
                    else
                    {
                        Command.Parameters.AddWithValue("OwnerId", null);
                    }
                    Command.ExecuteNonQuery();

                    IssueId = Command.LastInsertedId;
                }
            }
            return(IssueId);
        }
Пример #4
0
        public static long AddIssue(IssueData Issue)
        {
            long IssueId;

            using (SQLiteConnection Connection = new SQLiteConnection(SqlConnector.ConnectionString))
            {
                Connection.Open();

                using (SQLiteCommand Command = new SQLiteCommand("INSERT INTO [Issues] (Project, Summary, Details, OwnerId, CreatedAt, FixChange) VALUES (@Project, @Summary, @Details, @OwnerId, DATETIME('now'), 0)", Connection))
                {
                    Command.Parameters.AddWithValue("@Project", Issue.Project);
                    Command.Parameters.AddWithValue("@Summary", SanitizeText(Issue.Summary, IssueSummaryMaxLength));
                    Command.Parameters.AddWithValue("@Details", SanitizeText(Issue.Details, IssueDetailsMaxLength));
                    if (Issue.Owner != null)
                    {
                        Command.Parameters.AddWithValue("OwnerId", FindOrAddUserId(Issue.Owner, Connection));
                    }
                    else
                    {
                        Command.Parameters.AddWithValue("OwnerId", null);
                    }
                    Command.ExecuteNonQuery();

                    IssueId = Connection.LastInsertRowId;
                }
            }
            return(IssueId);
        }
        public async Task <Exception> UpdateList()
        {
            OnUpdateStatus(LocalizationHelper.GetString("IssuesListLoading"), 0, true);
            try
            {
                var projects = await MantisClient.Instance.GetProjectsForUser();

                List <ProjectDetail> data = new List <ProjectDetail>();

                foreach (var p in projects)
                {
                    var issues = await MantisClient.Instance.GetIssuesForUserByProjet(p.id);

                    data.Add(new ProjectDetail {
                        Project = p, Issues = issues.ToList()
                    });
                }
                lstIssues.DataContext = data.OrderByDescending(p => p.Issues.Count);

                SelectedIssue   = null;
                SelectedIssueId = string.Empty;
                OnUpdateStatus(LocalizationHelper.GetString("IssuesListLoaded", data.Count), 100, false);
            }
            catch (Exception ex)
            {
                OnUpdateStatus(LocalizationHelper.GetString("IssuesListErrorLoading"), 0, false);
                // TODO : log error
                return(ex);
            }
            return(null);
        }
Пример #6
0
        private static IssueData PrepareIssueData(string message, MessageIssueLevel issueLevel, bool?visibleToUser, string userHandle, string userInput, IDictionary <string, string> data)
        {
            var issueType = new IssueType(message, issueLevel.ToIssueLevel());
            var issueData = new IssueData(Guid.NewGuid(), DateTime.UtcNow, Session.GetSessionData(), visibleToUser, data, issueType, Guid.NewGuid(), userHandle, userInput);

            return(issueData);
        }
Пример #7
0
        public IssueResponse RegisterIssue(IssueData issueData)
        {
            var data   = issueData.ToIssueData();
            var result = ExecuteQuery <IssueResponse, RegisterIssueRequest>(data, "issue", "register");

            return(result);
        }
        public async Task <OnchainResponse> IssueAsync(IssueData data)
        {
            var request = new IssueRequest(data.TransactionId, data.Address, data.AssetId, (decimal)data.Amount);

            var response = await _apiClient.ApiEnqueueTransactionIssuePostAsync(request);

            return(PrepareOnchainResult(response));
        }
Пример #9
0
        private static IssueData PrepareIssueData(Exception exception, ExceptionIssueLevel issueLevel, bool?visibleToUser, string userHandle, string userInput)
        {
            var issueThreadGuid = HandleIssueThreadGuid(exception);
            var data            = exception.Data.Cast <DictionaryEntry>().Where(x => x.Value != null).ToDictionary(item => item.Key.ToString(), item => item.Value.ToString());
            var issueType       = new IssueType(exception, issueLevel.ToIssueLevel());
            var issueData       = new IssueData(Guid.NewGuid(), DateTime.UtcNow, Session.GetSessionData(), visibleToUser, data, issueType, issueThreadGuid, userHandle, userInput);

            return(issueData);
        }
Пример #10
0
        public async void IssueData_Test()
        {
            var r      = _cli_mock.GitHubClientMock.RepositoriesData.Data.FirstOrDefault();
            var i      = _cli_mock.GitHubClientMock.RepositoryIssuesData[r.Id].Data.FirstOrDefault();
            var result = await IssueData.Fetch(_cli_mock.GitHubClientMock.MockGitHubClient.Object, r.Id, i.Number);

            Assert.NotNull(result);
            Assert.Equal(i.State.StringValue, result.Issue.State.StringValue);
        }
Пример #11
0
 public void ViewDetail(IssueData new_data)
 {
     issueTitle.text       = new_data.attributes.title;
     issueCreatedBy.text   = new_data.attributes.created_by;
     issueCreatedAt.text   = new_data.attributes.created_at;
     issueDescription.text = new_data.attributes.description;
     issueDetail.SetActive(true);
     issueView.SetActive(false);
 }
Пример #12
0
        /// <summary>
        /// Updates an existing issue.
        /// </summary>
        /// <param name="id">The public issue ID.</param>
        /// <param name="issueData">The modified issue data.</param>
        /// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
        /// <returns>A task that returns the updated issue.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="id"/> is <c>null</c>.</exception>
        public Task <Issue> UpdateAsync(string id, IssueData issueData, CancellationToken cancellationToken)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var requestUri = $"/issues/{Uri.EscapeDataString(id)}";

            return(PatchAsync <IssueData, Issue>(requestUri, issueData, cancellationToken));
        }
 private void lstIssues_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     if (e.NewValue is IssueData)
     {
         SelectedIssueId = (e.NewValue as IssueData).id;
         SelectedIssue   = (e.NewValue as IssueData);
         RoutedPropertyChangedEventArgs <IssueData> ee = new RoutedPropertyChangedEventArgs <IssueData>(e.OldValue as IssueData, e.NewValue as IssueData, IssueSelectionChangedEvent);
         ee.Source = this;
         RaiseEvent(ee);
     }
 }
Пример #14
0
        public XDoc Link(
            [DekiExtParam("bug id")] int id
            )
        {
            IssueData bug    = _service.mc_issue_get(_username, _password, id.ToString());
            XDoc      result = new XDoc("html");

            result.Start("body");
            BuildBugLink(bug, result);
            result.End();
            return(result);
        }
        public static async Task Run([TimerTrigger("0 0 1 */1 * *")] TimerInfo myTimer,
                                     [CosmosDB(
                                          databaseName: "GithubStats",
                                          collectionName: "DocsRepo",
                                          ConnectionStringSetting = "CosmosDBConnection")]  IAsyncCollector <IssueData> outputData,
                                     ILogger log)
        {
            log.LogInformation($"C# DataProcessing_3 function executed at: {DateTime.Now}");

            var client    = new GitHubClient(new ProductHeaderValue("fsharpfunctions"));
            var tokenAuth = new Credentials(Environment.GetEnvironmentVariable("GithubToken")); // NOTE: not real token

            client.Credentials = tokenAuth;

            log.LogInformation("Retrieving Github Issues");

            var request = new SearchIssuesRequest()
            {
                PerPage = 100,
                Page    = 1,
                Type    = IssueTypeQualifier.Issue,
                State   = ItemState.Open
            };

            request.Repos.Add("MicrosoftDocs", "azure-docs");
            var openIssues = await client.Search.SearchIssues(request);

            log.LogInformation($"Retrieved {openIssues.Items.Count()} Issues");;

            log.LogInformation(client.GetLastApiInfo().RateLimit.Remaining.ToString());

            var byPriority = GetIssueCount(openIssues.Items, "Pri")
                             .ToDictionary(g => g.Key.Remove(0, 3), g => g.Count());

            var byService = GetIssueCount(openIssues.Items, "/svc")
                            .ToDictionary(g => g.Key.Substring(0, g.Key.LastIndexOf('/')), g => g.Count());


            var document = new IssueData()
            {
                id              = Guid.NewGuid().ToString(),
                Source          = "CSharp",
                EntryType       = "ByService",
                Timestamp       = DateTime.UtcNow,
                TotalOpenIssues = openIssues.Items.Count(),
                MissingTags     = openIssues.Items.Count(o => o.Labels.Count() == 0),
                CountByPriority = byPriority,
                CountByService  = byService
            };

            await outputData.AddAsync(document);
        }
Пример #16
0
 public static RegisterIssueRequest ToIssueData(this IssueData item)
 {
     return(new RegisterIssueRequest
     {
         Id = item.Id,
         Session = item.Session.ToSessionData(),
         ClientTime = item.ClientTime,
         VisibleToUser = item.VisibleToUser,
         Data = item.Data,
         IssueType = item.IssueType.ToIssueType(),
         IssueThreadGuid = item.IssueThreadGuid,
         UserHandle = item.UserHandle,
         UserInput = item.UserInput,
     });
 }
Пример #17
0
    private void AddButtons()
    {
        for (int i = 0; i < issues.data.Length; i++)
        {
            IssueData  file      = issues.data[i];
            GameObject newButton = fileDirectory.Get_Object();
            newButton.transform.SetParent(contentPanel);

            IssueButton fileButton = newButton.GetComponent <IssueButton>();
            //if (fileButton.FileText == null){
            //   fileButton.FileText = fileButton.GetComponent<Text>();
            // fileButton.FileImage = fileButton.GetComponent<Image>();
            //}
            fileButton.Setup(file, this);
        }
    }
Пример #18
0
        private async Task ProcessIssue(IssueCommand cmd)
        {
            var request = new IssueData
            {
                TransactionId = cmd.TransactionId,
                Address       = cmd.Multisig,
                Amount        = cmd.Amount,
                AssetId       = cmd.AssetId
            };

            var response = await _bitcoinApiClient.IssueAsync(request);

            var reqMsg = $"{BitCoinCommands.Issue}:{request.ToJson()}";

            await ProcessBitcoinApiResponse(reqMsg, BitCoinCommands.Issue, response, cmd.Context);
        }
Пример #19
0
        public IssueResponse RegisterIssue(IssueData issueData)
        {
            var data = issueData.ToIssueData();

            var jsonFormatter = new JsonMediaTypeFormatter();
            var content       = new ObjectContent <RegisterIssueRequest>(data, jsonFormatter);

            var x        = ExecuteQuery <RegisterIssueRequest, RegisterIssueResponse>(content, "issue", "register");
            var response = new IssueResponse
            {
                IssueTypeTicket     = x.IssueTypeTicket,
                IssueInstanceTicket = x.IssueInstanceTicket,
                IsOfficial          = x.IsOfficial,
                ResponseMessage     = x.ResponseMessage,
            };

            return(response);
        }
Пример #20
0
        public void AddNewIssue()
        {
            AccountData account = new AccountData()
            {
                Name     = "administrator",
                Password = "******"
            };
            ProjectData project = new ProjectData()
            {
                Id = "1"
            };
            IssueData issue = new IssueData()
            {
                Summary     = "some text",
                Description = "short text",
                Category    = "1"
            };

            app.API.CreateNewIssue(account, project, issue);
        }
 protected async override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     base.OnPropertyChanged(e);
     if (e.Property == CurrentIssueProperty)
     {
         if (e.NewValue != null && IssueId != (e.NewValue as IssueData).id)
         {
             IssueId = CurrentIssue.id;
         }
         RefreshIssueDetail();
     }
     if (e.Property == IssueIdProperty)
     {
         if (e.NewValue != null && e.NewValue as string != CurrentIssue.id)
         {
             CurrentIssue = await Interfaces.MantisClient.Instance.GetIssueById(e.NewValue.ToString());
         }
         RefreshIssueDetail();
     }
 }
Пример #22
0
        public async void IssueData_Test()
        {
            ReportGithubModel m = new ReportGithubModel("");

            var r = _cli_mock.GitHubClientMock.RepositoriesData.Data.FirstOrDefault();
            var i = _cli_mock.GitHubClientMock.RepositoryIssuesData[r.Id].Data.FirstOrDefault();

            var result = m.issuesModel(new List <IssueData>()
            {
                await IssueData.Fetch(_cli_mock.GitHubClientMock.MockGitHubClient.Object, r.Id, i.Number)
            });

            Assert.NotNull(result);
            Assert.NotEmpty(result.issues);
            var issues = result.issues as IEnumerable <dynamic>;

            Assert.Equal(i.Number.ToString(), issues.ElementAt(0).issueName.ToString());
            Assert.Equal(i.State.StringValue, issues.ElementAt(0).state.ToString());
            Assert.Equal(i.Assignee.Login, issues.ElementAt(0).assignee.ToString());
        }
Пример #23
0
 public void Setup(IssueData current_file, IssueScrollList current_list)
 {
     file = current_file;
     if (NameText != null)
     {
         NameText.text = file.attributes.title;
     }
     else
     {
         Debug.LogWarning("NameText is null");
     }
     if (DateText != null)
     {
         DateText.text = file.attributes.created_at;
     }
     else
     {
         Debug.LogWarning("FileImage is null");
     }
     file_list = current_list;
 }
Пример #24
0
        private static IssueData GetIssueDataFromIssue(Issue issue, RepositoryReference repo)
        {
            var issueData = new IssueData()
            {
                Id        = issue.Number.ToString(CultureInfo.InvariantCulture),
                Url       = issue.HtmlUrl,
                Number    = issue.Number,
                Title     = issue.Title,
                Author    = CreateUserReferenceFromUser(issue.User),
                Milestone = issue.Milestone == null ? null : new Models.Milestone {
                    Title = issue.Milestone.Title
                },
                CreatedAt    = issue.CreatedAt.ToPacificTime(),
                UpdatedAt    = issue.UpdatedAt?.ToPacificTime(),
                CommentCount = issue.Comments,
                Repository   = repo,
            };

            // Load the assignees and labels
            foreach (var assignee in issue.Assignees)
            {
                issueData.Assignees.Add(CreateUserReferenceFromUser(assignee));
            }

            foreach (var label in issue.Labels)
            {
                issueData.Labels.Add(new Models.Label
                {
                    Name      = label.Name,
                    Color     = label.Color,
                    ForeColor = ColorMath.GetHexForeColorForBackColor(label.Color),
                });
            }

            return(issueData);
        }
Пример #25
0
        private static RegisterCompleteEventArgs RegisterEx(IssueData issueData, Action <RegisterCompleteEventArgs> completeAction)
        {
            RegisterCompleteEventArgs registerCompleteEventArgs = null;

            try
            {
                var target  = TargetFactory.Get();
                var reponse = target.RegisterIssue(issueData);

                Session.RegisteredOnServer = true; //TODO: This is true, also if an issue has been returned from the server

                //TODO: Make it possible to append a user comment on an issue (Ither on the initial call, or afterwords as a second call)
                registerCompleteEventArgs = new RegisterCompleteEventArgs(true, reponse, new OriginalData(issueData));
            }
            catch (InvalidOperationException exception)
            {
                registerCompleteEventArgs = new RegisterCompleteEventArgs(false, exception, new OriginalData(issueData));
            }
            catch (Exception exception)
            {
                registerCompleteEventArgs = new RegisterCompleteEventArgs(false, exception, new OriginalData(issueData));
            }
            finally
            {
                InvokeRegisterComplete(registerCompleteEventArgs);
            }

            if (completeAction != null)
            {
                completeAction.Invoke(registerCompleteEventArgs);
            }

            _registerCompleteEventArgs = registerCompleteEventArgs;

            return(registerCompleteEventArgs);
        }
Пример #26
0
        //--- Methods ---
        private XDoc BuildBugLink(IssueData issue, XDoc doc)
        {
            bool strikeThrough = issue.status != null && Array.Exists <string>(STRIKE_THROUGH_STATUSES, delegate(string s) {
                return(StringUtil.EqualsInvariantIgnoreCase(issue.status.name, s));
            });

            string title = string.Format("{0} (Reporter: {1} AssignedTo: {2})",
                                         issue.summary,
                                         issue.reporter != null ? issue.reporter.name : string.Empty,
                                         issue.handler != null ? issue.handler.name : string.Empty);


            doc.Start("a").Attr("href", _uri.At("view.php").With("id", issue.id)).Attr("title", title);
            if (strikeThrough)
            {
                doc.Start("del").Value("#" + issue.id).End();
            }
            else
            {
                doc.Value("#" + issue.id);
            }
            doc.End();
            return(doc);
        }
Пример #27
0
 /// <summary>
 /// Creates a new issue.
 /// </summary>
 /// <param name="issueData">The issue data.</param>
 /// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
 /// <returns>A task that returns the created issue.</returns>
 public Task <Issue> CreateAsync(IssueData issueData, CancellationToken cancellationToken = default)
 {
     return(PostAsync <IssueData, Issue>("/issues", issueData, cancellationToken));
 }
Пример #28
0
        public async Task <IActionResult> PostExport([FromBody] List <Model.IssueListItem> issuesList, [FromQuery] bool generateQr = true)
        {
            User             user   = null;
            List <IssueData> issues = null;
            Dictionary <long, Repository> repo_dict = null;

            ReportModel.Document documentReportModel = null;

            string extension      = "pdf";
            string uid            = Guid.NewGuid().ToString();
            string reportFileName = $"{_configuration.GetValue<string>("Settings:StorageRoot", "clients_github")}/{uid}.{extension}";

            Report.PdfReport pdfReport = null;
            try
            {
                user = await _githubCli.User.Current();

                //Utils.Save2File("07_user.json", user);
                // fetch issues
                issues = (await Task.WhenAll(issuesList.Select(i => IssueData.Fetch(_githubCli, i.RepositoryId, i.IssueNo)))).ToList();
                // fetch repositories
                repo_dict = (await Task.WhenAll(issues.GroupBy(i => i.IssueRepoId).Select(i => _githubCli.Repository.Get(i.Key)))).ToDictionary(r => r.Id, r => r);
                // update issues repositories
                issues.ForEach(i => i.IssueRepo = repo_dict[i.IssueRepoId]);
                ReportGithubModel model = new ReportGithubModel(System.IO.File.ReadAllText(_configuration.GetValue("Templates:ReportIssuesModel", "template/Report-Issues.Mustache")));
                model.GenerateQRCode = generateQr;
                documentReportModel  = model.CreateReportModel(model.issuesModel(issues));
                if (null == documentReportModel.Options)
                {
                    documentReportModel.Options = new ReportModel.DocumentOptions();
                }

                pdfReport = new Report.PdfReport(filePath: reportFileName, storageName: _configuration.GetValue <string>("Settings:StorageName"), debug: _hostEnvironment.IsDevelopment());
                await pdfReport.Configure(_client.PdfApi, _client.BarcodeApi);

                await pdfReport.Report(documentReportModel);

                return(new OkObjectResult(new
                {
                    downloadlink = _basePathReplacement.ReplaceBaseUrl(Url.Link("GetDownload", new { id = uid })),
                    id = uid
                }));
            }catch (Exception ex)
            {
                ZipFileArchive archive = new ZipFileArchive().AddFile("010_request_params.json", new
                {
                    RequestId = _client.RequestId,
                    FileId    = uid,
                    FileName  = reportFileName
                });
                foreach (var f in new Dictionary <string, object> {
                    { "020_user.json", user },
                    { "030_issues.json", issues },
                    { "040_repo_dict.json", repo_dict },
                    { "050_report_model.json", documentReportModel },
                }.ToArray())
                {
                    archive.AddFile(f.Key, f.Value);
                }
                throw new ControllerException($"Error generating {reportFileName}", innerException: ex, customData: await archive.Archive());
            }
            finally
            {
                _client.Stat = pdfReport?.Stat;
            }
        }
Пример #29
0
 internal Issue(IssueData issueData)
 {
     data = issueData;
 }
Пример #30
0
        private XDoc BuildBugListHTMLTable(IssueData[] issues) {
            XDoc ret = new XDoc("div").Attr("class", "DW-table Mantis-table table");
            ret.Start("table").Attr("border", 0).Attr("cellspacing", 0).Attr("cellpadding", 0).Attr("class", "table sortable ").Attr("id", "mantis-table");

            // header
            ret.Start("tr")
                .Elem("th", "Bug#")
                .Elem("th", "Summary")
                .Elem("th", "Status")
                .Elem("th", "Opened By")
                .Elem("th", "Assigned To")
                .Elem("th", "Severity")
            .End();

            // loop over rows, if any
            if(issues != null) {
                int count = 0;
                foreach (IssueData bug in issues) {
                    count++;
                    string status = (bug.status != null) ? bug.status.name : string.Empty;
                    string severity = (bug.severity != null) ? bug.severity.name : string.Empty;
                    string tdClass = string.Format("{0} {1} {2}", (count % 2 == 0) ? "bg1" : "bg2", status, severity);
                    ret.Start("tr").Attr("class", tdClass);
                    ret.Start("td").Attr("class", tdClass);
                    ret = BuildBugLink(bug, ret);
                    ret.End(); //td;
                    ret.Start("td").Attr("class", tdClass).Value(bug.summary).End()
                         .Start("td").Attr("class", tdClass).Value(status).End()
                         .Start("td").Attr("class", tdClass).Value((bug.reporter != null) ? bug.reporter.name : string.Empty).End()
                         .Start("td").Attr("class", tdClass).Value((bug.handler != null) ? bug.handler.name : string.Empty).End()
                         .Start("td").Attr("class", tdClass + " severity").Value(severity).End()
                     .End();
                }
            }
            ret.End(); // table
            return ret;
        }
Пример #31
0
 private XDoc BuildBugListHTML(IssueData[] issues) {
     XUri view = _uri.At("view.php");
     XDoc ret = new XDoc("div").Attr("class", "mantis-list");
     ret.Start("ul");
     foreach (IssueData bug in issues) {
         ret.Start("li")
             .Start("a").Attr("href", view.With("id", bug.id)).Attr("target", "blank")
                 .Value(string.Format("{0}: {1} ({2})", bug.id, bug.summary, (bug.status != null) ? bug.status.name : string.Empty))
             .End() // a
         .End(); // li
     }
     ret.End();
     return ret;
 }
Пример #32
0
        //--- Methods ---
        private XDoc BuildBugLink(IssueData issue, XDoc doc) {
            bool strikeThrough = issue.status != null && Array.Exists<string>(STRIKE_THROUGH_STATUSES, delegate(string s) {
                return StringUtil.EqualsInvariantIgnoreCase(issue.status.name, s);
            });

            string title = string.Format("{0} (Reporter: {1} AssignedTo: {2})",
                issue.summary,
                issue.reporter != null ? issue.reporter.name : string.Empty,
                issue.handler != null ? issue.handler.name : string.Empty);


            doc.Start("a").Attr("href", _uri.At("view.php").With("id", issue.id)).Attr("title", title);
            if(strikeThrough) {
                doc.Start("del").Value("#" + issue.id).End();
            } else {
                doc.Value("#" + issue.id);
            }
            doc.End();
            return doc;
        }
        public object Post(IssueData Issue)
        {
            long IssueId = SqlConnector.AddIssue(Issue);

            return(new { Id = IssueId });
        }
Пример #34
0
        private static List <IssueData> GetIssuesInternal(long IssueId, string UserName, bool IncludeResolved, int NumResults)
        {
            List <IssueData> Issues = new List <IssueData>();

            using (SQLiteConnection Connection = new SQLiteConnection(SqlConnector.ConnectionString))
            {
                Connection.Open();

                long UserId = -1;
                if (UserName != null)
                {
                    UserId = FindOrAddUserId(UserName);
                }

                StringBuilder CommandBuilder = new StringBuilder();
                CommandBuilder.Append("SELECT");
                CommandBuilder.Append(" Issues.Id, Issues.CreatedAt, DATETIME('now'), Issues.Project, Issues.Summary, Issues.Details, OwnerUsers.Name, NominatedByUsers.Name, Issues.AcknowledgedAt, Issues.FixChange, Issues.ResolvedAt");
                if (UserName != null)
                {
                    CommandBuilder.Append(", IssueWatchers.UserId");
                }
                CommandBuilder.Append(" FROM [Issues]");
                CommandBuilder.Append(" LEFT JOIN [Users] AS [OwnerUsers] ON OwnerUsers.Id = Issues.OwnerId");
                CommandBuilder.Append(" LEFT JOIN [Users] AS [NominatedByUsers] ON NominatedByUsers.Id = Issues.NominatedById");
                if (UserName != null)
                {
                    CommandBuilder.Append(" LEFT JOIN [IssueWatchers] ON IssueWatchers.IssueId = Issues.Id AND IssueWatchers.UserId = @UserId");
                }
                if (IssueId != -1)
                {
                    CommandBuilder.Append(" WHERE Issues.Id = @IssueId");
                }
                else if (!IncludeResolved)
                {
                    CommandBuilder.Append(" WHERE Issues.ResolvedAt IS NULL");
                }
                if (NumResults > 0)
                {
                    CommandBuilder.AppendFormat(" ORDER BY Issues.Id DESC LIMIT {0}", NumResults);
                }

                using (SQLiteCommand Command = new SQLiteCommand(CommandBuilder.ToString(), Connection))
                {
                    if (IssueId != -1)
                    {
                        Command.Parameters.AddWithValue("@IssueId", IssueId);
                    }
                    if (UserName != null)
                    {
                        Command.Parameters.AddWithValue("@UserId", UserId);
                    }

                    using (SQLiteDataReader Reader = Command.ExecuteReader())
                    {
                        while (Reader.Read())
                        {
                            IssueData Issue = new IssueData();
                            Issue.Id             = Reader.GetInt64(0);
                            Issue.CreatedAt      = Reader.GetDateTime(1);
                            Issue.RetrievedAt    = Reader.GetDateTime(2);
                            Issue.Project        = Reader.GetString(3);
                            Issue.Summary        = Reader.GetString(4);
                            Issue.Details        = Reader.GetString(5);
                            Issue.Owner          = Reader.IsDBNull(6)? null : Reader.GetString(6);
                            Issue.NominatedBy    = Reader.IsDBNull(7)? null : Reader.GetString(7);
                            Issue.AcknowledgedAt = Reader.IsDBNull(8)? (DateTime?)null : Reader.GetDateTime(8);
                            Issue.FixChange      = Reader.GetInt32(9);
                            Issue.ResolvedAt     = Reader.IsDBNull(10)? (DateTime?)null : Reader.GetDateTime(10);
                            if (UserName != null)
                            {
                                Issue.bNotify = !Reader.IsDBNull(11);
                            }
                            Issues.Add(Issue);
                        }
                    }
                }
            }
            return(Issues);
        }
Пример #35
0
 public Issue(long projectId)
 {
     data = new IssueData {id = projectId.ToString()};
 }