示例#1
0
        private static IEnumerable <IssueId> GetIssueIdsFromSource(string sourceName, IEnumerable <IssueId> source)
        {
            IssueId leastIssueId = null;
            IssueId maxIssueId   = null;
            int     issueIdCount = 0;

            foreach (var issueId in source)
            {
                if (leastIssueId == null || leastIssueId > issueId)
                {
                    leastIssueId = issueId;
                }

                if (maxIssueId == null || maxIssueId < issueId)
                {
                    maxIssueId = issueId;
                }

                issueIdCount++;
                yield return(issueId);
            }

            Logger.Debug($"issue ids from {sourceName}: {{cachedIds}}",
                         new { min = leastIssueId, max = maxIssueId, count = issueIdCount });
        }
        public void IssuesByProject(
            ExportOptions exportOptions,
            [Option(Description = "Resumes export after this issue")]
            IssueId resumeAfter,
            [Option(Description = "Specify if the issue list should come from Jira, Cache or Both. " +
                                  "Use Jira when there are unknown updates or issues have been exported out of order by id. " +
                                  "Use Cache for speed when you only need to updates. " +
                                  "Using Both starts with Cache and then queries Jira for issue keys " +
                                  "greater than what have been cached per project.")]
            IssueSource?issueListSource = null,
            [Operand(Description = "The keys of the projects to export. If none are specified, all projects are exported")]
            List <string> projects = null)
        {
            if (_jiraApiSettings.JiraOffline &&
                issueListSource.HasValue &&
                issueListSource.Value.HasFlag(IssueSource.Jira))
            {
                throw new ArgumentException(
                          $"--{nameof(issueListSource)} cannot include {nameof(IssueSource.Jira)} " +
                          $"when --{nameof(_jiraApiSettings.JiraOffline)} is specified.");
            }

            if (!_jiraApiSettings.JiraOffline)
            {
                ((CacheJiraApi)_jiraApi).IssueListSource = issueListSource.GetValueOrDefault(IssueSource.Both);
            }

            var projectFilter = new ProjectFilter {
                Projects = projects
            };
            var issueIds = _jiraContext.Api.GetIssueIds(projectFilter, out int totalCount, resumeAfter);

            issueIds.EnumerateOperation(totalCount, "Export Issue", exportOptions.FailFile, _cancellationToken, ExportIssue);
        }
示例#3
0
        public IEnumerable <IssueId> GetIssueIdsByProject(string projectId,
                                                          IssueId resumeAfterId = null,
                                                          int?batchSize         = null)
        {
            Logger.Debug("Begin JiraRestApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId, batchSize });

            batchSize = batchSize ?? 100;

            var jql = BuildSearchJql(new[] { projectId }, resumeAfterId);

            var            currentStart = 0;
            var            pageCount    = 0;
            List <IssueId> ids;

            do
            {
                var page = _jiraClient.Issues.GetIssuesFromJqlAsync(jql, startAt: currentStart, maxIssues: batchSize, token: _cancellationToken).Result;
                ids = page.Select(p => new IssueId(p.Key.Value)).ToList();
                ids.Sort();

                pageCount++;
                var totalPages = (page.TotalItems / batchSize) + 1; // plus 1 because it's unlikely the remainder is 0

                Logger.Debug($"Fetched page {pageCount} of {totalPages}");
                Logger.Trace("Returned ids: {ids}", ids);

                foreach (var id in ids)
                {
                    yield return(id);
                }

                currentStart += batchSize.Value;
            } while (ids.Count >= batchSize && !_cancellationToken.IsCancellationRequested);
        }
示例#4
0
        public Task <int> GetTotalIssueCount(ICollection <string> projectIds, IssueId resumeAfterId = null)
        {
            var filteredProjects = _issuesByProject.Where(kvp => projectIds.Contains(kvp.Key));

            int totalIssueCount = 0;

            if (resumeAfterId == null)
            {
                totalIssueCount = filteredProjects.Sum(kvp => kvp.Value.Count);
            }
            else
            {
                foreach (var project in filteredProjects)
                {
                    var comparison = string.Compare(project.Key, resumeAfterId.Project, StringComparison.Ordinal);
                    if (comparison == 0)
                    {
                        totalIssueCount += project.Value.Count(id => id > resumeAfterId);
                    }
                    else if (comparison > 0)
                    {
                        totalIssueCount += project.Value.Count;
                    }
                }
            }

            return(Task.FromResult(totalIssueCount));
        }
 public IssueAssociatedWithNewBacklogItem(TenantId tenantId, ProductId productId, IssueId issueId)
 {
     TenantId = tenantId;
     ProductId = productId;
     IssueId = issueId;
     OccurredOn = DateTime.Now;
 }
示例#6
0
        public async Task <int> GetTotalIssueCount(ICollection <string> projectIds, IssueId resumeAfterId = null)
        {
            var jql  = BuildSearchJql(projectIds, resumeAfterId);
            var page = await _jiraClient.Issues.GetIssuesFromJqlAsync(jql, startAt : 0, maxIssues : 1, token : _cancellationToken);

            return(page.TotalItems);
        }
示例#7
0
        public IssueMigration Get(IssueId issueId)
        {
            var migration = _migrationRepository.GetOrCreate(issueId);

            UpdateMigrationMetaData(migration);
            return(migration);
        }
示例#8
0
 void MustBeActive(TenantId tenant = null, ProductId product = null, IssueId ticket = null,IssueAssignerId assigner=null)
 {
     if (tenant != null) Guard.That(Queries.IsActive(tenant), "This is an inactive tenant");
     if (product != null) Guard.That(Queries.IsActive(tenant,product), "This is an inactive product");
     if (ticket != null) Guard.That(Queries.IsActive(tenant, product, ticket), "This is an inactive ticket");
     if (assigner != null) Guard.That(Queries.IsActive(tenant, assigner), "This is an inactive assigner");
 }
示例#9
0
        public WorkItem GetWorkItem(IssueId jiraId)
        {
            Logger.Debug("Get work item by jira id {jiraId}", jiraId);
            var wiql = $@"select * from  workitems where {_adoApiSettings.JiraIdField} = '{jiraId}'";

            return(_workItemStore.Query(wiql).OfType <WorkItem>().FirstOrDefault());
        }
示例#10
0
        public void SaveIssue(IssueId issueId, JObject issue)
        {
            var file = _localDirs.GetIssueJsonFile(issueId);

            Logger.Trace("Save issue to file: {file}", file.FullName);
            File.WriteAllText(file.FullName, issue.ToString());
        }
示例#11
0
        public Task <JObject> GetIssue(IssueId issueId)
        {
            var file = _localDirs.GetIssueJsonFile(issueId);

            Logger.Trace("Get issue from file: {file}", file.FullName);
            return(LoadJsonFromFile <JObject>(file));
        }
示例#12
0
        public Issue GetById(IssueId id)
        {
            var dto = _issueRepository.GetAll()
                      .First(x => x.Id == id);

            return(ConvertFromDto(dto));
        }
示例#13
0
        public IEnumerable <IssueId> GetIssueIdsByProject(string projectId, IssueId resumeAfterId = null)
        {
            Logger.Debug("Begin JiraCacheApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId });

            if (IssueListSource.HasFlag(IssueSource.Cache))
            {
                foreach (var issueId in GetIssueIdsFromSource("cache-by-project", _cacheApi.GetIssueIdsByProject(projectId, resumeAfterId)))
                {
                    if (resumeAfterId == null || resumeAfterId < issueId)
                    {
                        resumeAfterId = issueId;
                    }

                    yield return(issueId);
                }
            }

            if (IssueListSource.HasFlag(IssueSource.Jira))
            {
                foreach (var issueId in GetIssueIdsFromSource("jira-by-project", _sourceApi.GetIssueIdsByProject(projectId, resumeAfterId)))
                {
                    yield return(issueId);
                }
            }
        }
示例#14
0
            public void WithNull_False()
            {
                IssueId vo = Freeze.GuidOne;

                var actually = vo.Equals(null);

                actually.Should().BeFalse();
            }
示例#15
0
            public void ObjectWithUnderlyingDifferentValue_True()
            {
                IssueId vo = Freeze.GuidOne;

                var actually = vo != Freeze.GuidTwo;

                actually.Should().BeTrue();
            }
示例#16
0
 private CompileIssue(IssueLocation location, IssueType type, IssueId id)
 {
     this._id        = id;
     this._issueType = type;
     _desc           = id.GetDescription();
     _msg            = _desc;
     _location       = location;
 }
示例#17
0
            public void UnderlyingWithObjectDifferentValue_False()
            {
                IssueId vo = Freeze.GuidOne;

                var actually = Freeze.GuidTwo == vo;

                actually.Should().BeFalse();
            }
示例#18
0
        public async Task <JObject> GetIssue(IssueId issueId)
        {
            // TODO: check the page properties for comments and changelogs. Fetch and merge remaining pages when available.
            Logger.Debug("Fetching issue {issueId}", issueId);
            var url = $"{_apiUrl}/issue/{issueId}?fields=*all&expand=changelog,renderedFields";

            return((JObject)await _restClient.ExecuteRequestAsync(Method.GET, url, token : _cancellationToken).ConfigureAwait(false));
        }
示例#19
0
            public void ObjectWithUnderlyingSameValue_False()
            {
                IssueId vo = Freeze.GuidOne;

                var actually = vo != Freeze.GuidOne;

                actually.Should().BeFalse();
            }
示例#20
0
            public void UnderlyingWithObjectSameValue_False()
            {
                IssueId vo = Freeze.GuidOne;

                var actually = Freeze.GuidOne != vo;

                actually.Should().BeFalse();
            }
示例#21
0
 public async Task <JObject> GetIssue(IssueId issueId)
 {
     return(await CallAndCache(
                "issue",
                issueId.ToString(),
                api => api.GetIssue(issueId),
                onSetCache : result => _cacheApi.SaveIssue(issueId, result)));
 }
示例#22
0
 private CompileIssue(IssueLocation location, IssueType type, IssueId id)
 {
     this._id = id;
     this._issueType = type;
     _desc = id.GetDescription();
     _msg = _desc;
     _location = location;
 }
示例#23
0
        public void ToStringTestCases()
        {
            IssueId vo = Freeze.GuidFortyTwo;

            var actually = vo.ToString();

            actually.Should().Be(Freeze.GuidFortyTwo.ToString());
        }
示例#24
0
            public void OneObject_UniqueHash()
            {
                IssueId vo = Freeze.GuidOne;

                var hash = vo.GetHashCode();

                hash.Should().Be(-92871782);
            }
示例#25
0
        public IEnumerable <IssueId> GetIssueIdsByProject(string projectId,
                                                          IssueId resumeAfterId = null)
        {
            Logger.Debug("Begin LocalDirJiraApi.GetIssueIds {params}", new { projectIds = projectId.ToOrderedCsv(), resumeAfterId });

            return(_issuesByProject.GetOrAdd(projectId, new HashSet <IssueId>())
                   .OrderBy(id => id)
                   .SkipWhile(id => resumeAfterId != null && id <= resumeAfterId));
        }
示例#26
0
            public void DifferentObjectsSameValue_False()
            {
                IssueId vo1 = Freeze.GuidOne;
                IssueId vo2 = Freeze.GuidOne;

                var actually = vo1 != vo2;

                actually.Should().BeFalse();
            }
示例#27
0
            public void DifferentObjectsAndValues_True()
            {
                IssueId vo1 = Freeze.GuidOne;
                IssueId vo2 = Freeze.GuidTwo;

                var actually = vo1 != vo2;

                actually.Should().BeTrue();
            }
示例#28
0
 public void EmptyGuid_ArgumentException()
 {
     this.Invoking(_ =>
     {
         IssueId __ = Freeze.GuidEmpty.ToString();
     })
     .Should().ThrowExactly <ArgumentException>()
     .WithMessage("The IssueId must be a valid guid.");
 }
示例#29
0
            public void WithSomethingDifferent_False()
            {
                IssueId vo = Freeze.GuidOne;

                // ReSharper disable once SuspiciousTypeConversion.Global
                var actually = vo.Equals(DateTime.UtcNow);

                actually.Should().BeFalse();
            }
示例#30
0
            public void WithEmptyObject_False()
            {
                IssueId vo    = Freeze.GuidOne;
                var     empty = new IssueId();

                var actually = vo.Equals(empty);

                actually.Should().BeFalse();
            }
示例#31
0
            public void WithSameObject_True()
            {
                IssueId vo  = Freeze.GuidOne;
                var     one = new IssueId(Freeze.GuidOne);

                var actually = vo.Equals(one);

                actually.Should().BeTrue();
            }
示例#32
0
            public void ValidGuid_WithValue()
            {
                IssueId vo = Freeze.GuidFortyTwo.ToString();

                using (new AssertionScope())
                {
                    vo.HasValue.Should().BeTrue();
                    vo.Value.Should().Be(Freeze.GuidFortyTwo);
                }
            }
        public IssueMigration Get(IssueId issueId)
        {
            var file = _localDirs.GetIssueMigrationStatusFile(issueId);

            if (!file.Exists)
            {
                return(null);
            }
            return(LoadFromFile(file));
        }
示例#34
0
文件: Rewriter.cs 项目: rexzh/SharpJs
 private void AppendCompileIssue(SyntaxToken token, IssueType type, IssueId id, params object[] args)
 {
     var issue = CompileIssue.Create(this._semanticModel.SyntaxTree, token, type, id, args);
     _aggregator.AppendIssue(issue);
 }
示例#35
0
 public void CloseIssue(TenantId Tenant, ProductId Product, IssueId Id)
 {
     MustBeActive(Tenant, Product, Id);
     Changes.IssueClosed(Tenant, Product, Id);
 }
示例#36
0
 public void ReportDefect(TenantId Tenant, ProductId Product, IssueId Id, string Name, string Description,IssueAssignerId Assigner)
 {
     MustBeActive(Tenant, Product);
     Changes.IssueRegistered(Tenant, Product, Id, Name, Description,IssueType.Defect,Assigner);
 }
示例#37
0
 public void RequestFeature(TenantId Tenant, ProductId Product, IssueId Id, string Name, string Description,IssueAssignerId Assigner)
 {
     MustBeActive(Tenant,Product);
     MustBeActive(Tenant,assigner:Assigner);
     Changes.IssueRegistered(Tenant,Product,Id, Name, Description,IssueType.Feature,Assigner);
 }
示例#38
0
 private CompileIssue(IssueLocation location, IssueType type, IssueId id, params object[] args)
     : this(location, type, id)
 {
     _msg = _desc.TryFormat(args);
 }
示例#39
0
 public static CompileIssue CreateNoLocationIssue(IssueType type, IssueId id, params object[] args)
 {
     CompileIssue issue = new CompileIssue(IssueLocation.NA, type, id, args);
     return issue;
 }
示例#40
0
 public static CompileIssue Create(SyntaxTree tree, SyntaxToken token, IssueType type, IssueId id, params object[] args)
 {
     IssueLocation loc = new IssueLocation(tree, token);
     CompileIssue issue = new CompileIssue(loc, type, id, args);
     return issue;
 }