示例#1
0
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            if (solution.Settings.MinSolutionFormatVersion != null &&
                solution.FormatVersion < solution.Settings.MinSolutionFormatVersion)
            {
                yield return
                    (Issue.Create(
                         Issue.WrongSolutionFormatVersion,
                         solution,
                         "Solution format version {0} is less than {1}",
                         solution.FormatVersion,
                         solution.Settings.MinSolutionFormatVersion));
            }

            if (solution.Settings.MaxSolutionFormatVersion != null &&
                solution.FormatVersion > solution.Settings.MaxSolutionFormatVersion)
            {
                yield return
                    (Issue.Create(
                         Issue.WrongSolutionFormatVersion,
                         solution,
                         "Solution format version {0} is greater than {1}",
                         solution.FormatVersion,
                         solution.Settings.MaxSolutionFormatVersion));
            }
        }
示例#2
0
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.Properties == null || project.Settings.Properties.Count() == 0)
                {
                    continue;
                }

                Dictionary <string, IEnumerable <string> > projectProperties = project.Properties.ToDictionary(GetPropertyKey, y => y.Values);

                foreach (IProjectProperty property in project.Settings.Properties)
                {
                    string key      = GetPropertyKey(property);
                    string flatList = string.Join(";", property.Values);

                    if (!projectProperties.ContainsKey(key))
                    {
                        yield return(Issue.Create(Issue.ProjectPropertyMissing, project, "Required Property {0}={1} is missing", key, flatList));

                        continue;
                    }

                    List <string> actualValues = projectProperties[key].ToList();
                    if (!actualValues.SequenceEqual(property.Values))
                    {
                        yield return(Issue.Create(Issue.ProjectPropertyMismatch, project, "Property {0} value mismatch, expected: {1}", key, flatList));
                    }
                }
            }
        }
 public IEnumerable <IIssue> Apply(ISolution solution)
 {
     if (solution.Settings.ProjectNameIsFileName ?? false)
     {
         foreach (IProject project in solution.Projects)
         {
             if (project.Name != Path.GetFileNameWithoutExtension(project.File))
             {
                 yield return(Issue.Create(Issue.ProjectVsFileNameMismatch, project, "Project name {0} is not matching its filename", project.Name));
             }
         }
     }
 }
示例#4
0
        protected virtual async Task OnIssueCreated(IssueCreatedEventArgs args, CancellationToken token)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (string.IsNullOrWhiteSpace(args.ReferenceId))
            {
                throw new ArgumentException("ReferenceId cannot be empty");
            }

            using (LogContext.PushProperty("IssueId", args.ReferenceId))
            {
                int?userId;
                try
                {
                    userId = string.IsNullOrWhiteSpace(args.RequestorEmail)
                    ? null : await GetOrCreateUserIdAsync(args.RequestorEmail, args.RequestorGivenName, args.RequestorSurnName, args.RequestorTelephone);
                }
                catch (Exception err)
                {
                    userId = null;
                    _logger.Warning(err, "Error retrieving user details for {EmailAddress}", args.RequestorEmail);
                }

                int ownerPersonId = userId.GetValueOrDefault();

                Issue oldIssue = null;
                oldIssue = await GetIssueByIncidentId(args.ReferenceId);

                if (oldIssue != null)
                {
                    _logger.Information("Found Issue {IssueId} in database, old status {IssueStatus}, new status {newIssueStatus}", args.ReferenceId, oldIssue.RemedyStatus, args.RemedyStatus);
                    await _issueRepository.DeleteIssueAsync(oldIssue, token);
                }

                try
                {
                    var issue = Issue.Create(args.Title, args.Description, args.ReferenceId, args.RemedyStatus, args.RequestorDisplayName, args.AssigneeEmail, args.AssigneeGroup, args.CreatedDate, args.Urgency, ownerPersonId);
                    _logger.Information("Saving Issue {IssueId} to database", args.ReferenceId);
                    await _issueRepository.AddIssueAsync(issue, token);
                }
                catch (Exception err)
                {
                    _logger.Error(err, "Unable to set work item id to Issue. Will retry later. Error was: {ErrorMessage}",
                                  err.Message);
                    throw;
                }
            }
        }
示例#5
0
        public async Task <IActionResult> AddIssue(Issue issue)
        {
            //获取节点名称
            if (!string.IsNullOrEmpty(issue.ScheduleId))
            {
                var temp = await _scheduleBll.GetAsync(issue.ScheduleId);

                if (temp != null)
                {
                    issue.ScheduleName = temp.Name;
                }
                else
                {
                    return(new JsonResult(new { success = false, message = "未发现该节点" }));
                }
            }
            //获取负责人名称
            if (!string.IsNullOrEmpty(issue.PrincipalId))
            {
                var temp = await _userBll.GetAsync(issue.PrincipalId);

                if (temp != null)
                {
                    issue.PrincipalName = temp.UserName;
                }
                else
                {
                    return(new JsonResult(new { success = false, message = "未发现该负责人" }));
                }
            }

            issue.Create(Request.RequestUser().UserId);
            issue.CreateName = Request.RequestUser().UserName;

            await _issueBll.AddAsync(issue);

            //日志
            await _logBll.AddAsync(
                Request.RequestUser().UserId,
                Request.RequestUser().UserName + "添加了问题:" + issue.Summary,
                Json.Serialize(issue),
                issue.ProjectId
                );

            return(new JsonResult(new { success = true }));
        }
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.RequiredImports == null)
                {
                    continue;
                }

                foreach (string requiredImport in project.Settings.RequiredImports)
                {
                    if (project.Imports.All(x => Path.GetFileName(x) != requiredImport))
                    {
                        yield return(Issue.Create(Issue.MissingRequiredImport, project, "Project has missing target import: {0}", requiredImport));
                    }
                }
            }
        }
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.AllowBuildEvents ?? true)
                {
                    continue;
                }

                if (project.Properties.Any(p => p.Name == "PreBuildEvent"))
                {
                    yield return(Issue.Create(Issue.NoBuildEventsAllowed, project, "Project {0} is not allowed to have PreBuildEvent", project.Name));
                }

                if (project.Properties.Any(p => p.Name == "PostBuildEvent"))
                {
                    yield return(Issue.Create(Issue.NoBuildEventsAllowed, project, "Project {0} is not allowed to have PostBuildEvent", project.Name));
                }
            }
        }
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.AssemblyNameIsProjectName ?? false)
                {
                    IProjectProperty assemblyNameProperty = project.Properties.FirstOrDefault(p => p.Name == "AssemblyName");
                    if (assemblyNameProperty == null)
                    {
                        continue;
                    }

                    string assemblyName = assemblyNameProperty.Values.FirstOrDefault() ?? string.Empty;
                    if (assemblyName != project.Name)
                    {
                        yield return(Issue.Create(Issue.AssemblyVsProjectNameMismatch, project, "AssemblyName {0} is not matching Project name {1}", assemblyName, project.Name));
                    }
                }
            }
        }
示例#9
0
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            if (solution.Settings.ProjectNamePrefix == null)
            {
                yield break;
            }

            foreach (IProject project in solution.Projects)
            {
                if (!project.Name.StartsWith(solution.Settings.ProjectNamePrefix))
                {
                    yield return
                        (Issue.Create(
                             Issue.ProjectNamePrefixMismatch,
                             project,
                             "Project name {0} is not following pattern: {1}",
                             project.Name,
                             solution.Settings.ProjectNamePrefix));
                }
            }
        }
示例#10
0
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            if (solution.Settings.DetectMissingFiles ?? false)
            {
                string directory = Path.GetDirectoryName(solution.File);
                foreach (string file in CheckFiles(directory, solution.Files))
                {
                    yield return(Issue.Create(Issue.MissingFileDetected, solution, "Solution references missing file: {0}", file));
                }
            }

            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.DetectMissingFiles ?? false)
                {
                    string directory = Path.GetDirectoryName(project.File);
                    foreach (string file in CheckFiles(directory, project.Files))
                    {
                        yield return(Issue.Create(Issue.MissingFileDetected, project, "Project references missing file: {0}", file));
                    }
                }
            }
        }
示例#11
0
        public IEnumerable <IIssue> Apply(ISolution solution)
        {
            if (solution.Settings.IgnoredDuplicateFiles != null)
            {
                foreach (string file in solution.Settings.IgnoredDuplicateFiles)
                {
                    ignoredDuplicates += file + System.Environment.NewLine;
                }
                System.Console.WriteLine("Ignored duplicate files from SolutionInspector.xml are: " + System.Environment.NewLine + ignoredDuplicates);
            }
            else
            {
                ignoredDuplicates = "";
            }

            if (solution.Settings.DetectDuplicateFiles ?? false)
            {
                string directory = Path.GetDirectoryName(solution.File);
                foreach (var duplicateName in CheckDuplicates(directory, solution.Files))
                {
                    yield return(Issue.Create(Issue.DuplicateFileDetected, solution, "Solution references Duplicate file: {0}", duplicateName.FirstOrDefault()));
                }
            }

            foreach (IProject project in solution.Projects)
            {
                if (project.Settings.DetectDuplicateFiles ?? false)
                {
                    string directory = Path.GetDirectoryName(project.File);
                    foreach (var duplicateName in CheckDuplicates(directory, project.Files))
                    {
                        yield return(Issue.Create(Issue.DuplicateFileDetected, project, "Project references Duplicate file: {0}", duplicateName.FirstOrDefault()));
                    }
                }
            }
        }