Ejemplo n.º 1
0
 public override string[] Filter(string[] files, ProjectAttributes attributes)
 {
     if (attributes.HasScope)
     {
         return files.Where(x => x.Contains(attributes.Scope.ToString())).ToArray();
     }
     return files;
 }
Ejemplo n.º 2
0
 public override string[] Filter(string[] files, ProjectAttributes attributes)
 {
     if (attributes.Target == Targets.All)
     {
         return files.Where(x => !TargetsEx.GetValuesButAll().Any(y => x.Contains(y.Convert()))).ToArray();
     }
     return files.Where(x => x.ExtractTarget() == attributes.Target).ToArray();
 }
Ejemplo n.º 3
0
 public override string[] Filter(string[] files, ProjectAttributes attributes)
 {
     if (attributes.Target != Targets.All)
     {
         var allOtherTargets = TargetsEx.GetValuesButAll().Where(x => x != attributes.Target).ToArray();
         return files.Where(x => !allOtherTargets.Any(y => x.Contains(y.Convert()))).ToArray();
     }
     return files;
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> AddProject(ProjectAttributes project)
        {
            if (ModelState.IsValid)
            {
                var newProject = new ProjectAttributes();
                var userId     = userManager.GetUserId(HttpContext.User);
                var user       = await userManager.FindByIdAsync(userId);

                project.OwnerId = userId;
                //project.UsersAssigned = "";
                project.OwnerUserName = user.UserName;
                newProject            = _projectRepository.Add(project);
                //var viewModel = new ProjectDetailsAndAssociatedBugs()
                //{
                //    Project = newProject,
                //    ProjectBugs = _bugRepository.GetAllProjectBugs(project.ProjectId),
                //    ProjectId = newProject.ProjectId
                //};

                var claims = await userManager.GetClaimsAsync(user);

                var result = await userManager.RemoveClaimsAsync(user, claims);


                var claimList = new List <Claim>();

                //var currentClaims = claims.ToList();
                for (var i = 0; i < ClaimsStore.AllClaims.Count; i++)
                {
                    if (claims.Count == 4 && claims[i].Value != null)
                    {
                        claimList.Add(new Claim(ClaimsStore.AllClaims[i].Type, claims[i].Value + " " + newProject.ProjectId.ToString()));
                    }
                    else
                    {
                        claimList.Add(new Claim(ClaimsStore.AllClaims[i].Type, newProject.ProjectId.ToString()));
                    }
                }

                GlobalVar.globalCurrentUserClaims = claimList;

                result = await userManager.AddClaimsAsync(user, claimList);

                //only if needed I guess
                //copied from administrationController
                //if (result.Succeeded == false)
                //{
                //    ModelState.AddModelError("", "Cannot add selected claims to user");
                //    return View(model);
                //}

                GlobalVar.ProjectId = newProject.ProjectId;

                return(RedirectToAction("ProjectDetails", newProject.ProjectId));
            }
            return(View());
        }
Ejemplo n.º 5
0
        private ProjectInfo With(
            ProjectAttributes attributes                       = null,
            CompilationOptions compilationOptions              = null,
            ParseOptions parseOptions                          = null,
            IEnumerable <DocumentInfo> documents               = null,
            IEnumerable <ProjectReference> projectReferences   = null,
            IEnumerable <MetadataReference> metadataReferences = null,
            IEnumerable <AnalyzerReference> analyzerReferences = null,
            IEnumerable <DocumentInfo> additionalDocuments     = null,
            IEnumerable <DocumentInfo> analyzerConfigDocuments = null,
            Optional <Type> hostObjectType                     = default)
        {
            var newAttributes              = attributes ?? Attributes;
            var newCompilationOptions      = compilationOptions ?? CompilationOptions;
            var newParseOptions            = parseOptions ?? ParseOptions;
            var newDocuments               = documents ?? Documents;
            var newProjectReferences       = projectReferences ?? ProjectReferences;
            var newMetadataReferences      = metadataReferences ?? MetadataReferences;
            var newAnalyzerReferences      = analyzerReferences ?? AnalyzerReferences;
            var newAdditionalDocuments     = additionalDocuments ?? AdditionalDocuments;
            var newAnalyzerConfigDocuments = analyzerConfigDocuments ?? AnalyzerConfigDocuments;
            var newHostObjectType          = hostObjectType.HasValue ? hostObjectType.Value : HostObjectType;

            if (newAttributes == Attributes &&
                newCompilationOptions == CompilationOptions &&
                newParseOptions == ParseOptions &&
                newDocuments == Documents &&
                newProjectReferences == ProjectReferences &&
                newMetadataReferences == MetadataReferences &&
                newAnalyzerReferences == AnalyzerReferences &&
                newAdditionalDocuments == AdditionalDocuments &&
                newAnalyzerConfigDocuments == AnalyzerConfigDocuments &&
                newHostObjectType == HostObjectType)
            {
                return(this);
            }

            return(new ProjectInfo(
                       newAttributes,
                       newCompilationOptions,
                       newParseOptions,
                       newDocuments,
                       newProjectReferences,
                       newMetadataReferences,
                       newAnalyzerReferences,
                       newAdditionalDocuments,
                       newAnalyzerConfigDocuments,
                       newHostObjectType));
        }
Ejemplo n.º 6
0
        //[Authorize(Policy = "UserPolicy")]
        public async Task <IActionResult> ProjectDetails(int projectId)
        {
            var project = new ProjectAttributes();

            if (projectId > 0)
            {
                project             = _projectRepository.GetProject(projectId);
                GlobalVar.ProjectId = projectId;
            }
            else
            {
                project = _projectRepository.GetProject(GlobalVar.ProjectId);
            }

            GlobalVar.Project = project;

            var userId = userManager.GetUserId(HttpContext.User);
            var user   = await userManager.FindByIdAsync(userId);

            var claims = await userManager.GetClaimsAsync(user);

            GlobalVar.globalCurrentUserClaims = claims.ToList();

            //var UserIsUserLevel = UserClaimsLevel.IsUser(HttpContext.User.Claims.ToList(), projectId);
            var UserIsUserLevel = UserClaimsLevel.IsUser(claims.ToList(), project.ProjectId);

            if (UserIsUserLevel == false)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }


            //var projectOwner = await userManager.FindByIdAsync(project.OwnerId);
            //project.OwnerId = projectOwner.UserName;

            var projectBugs    = _bugRepository.GetAllProjectBugs(projectId);
            var projectHistory = _projectRepository.GetProjectHistories(projectId);
            var viewModel      = new ProjectDetailsAndAssociatedBugs()
            {
                Project          = project,
                ProjectBugs      = projectBugs,
                projectHistories = projectHistory,
                ProjectId        = project.ProjectId
            };

            return(View(viewModel));
        }
Ejemplo n.º 7
0
 private ProjectInfo(
     ProjectAttributes attributes,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     IEnumerable<DocumentInfo> documents,
     IEnumerable<ProjectReference> projectReferences,
     IEnumerable<MetadataReference> metadataReferences,
     IEnumerable<AnalyzerReference> analyzerReferences,
     IEnumerable<DocumentInfo> additionalDocuments,
     Type hostObjectType)
 {
     Attributes = attributes;
     CompilationOptions = compilationOptions;
     ParseOptions = parseOptions;
     Documents = documents.ToImmutableReadOnlyListOrEmpty();
     ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
     MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
     AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
     AdditionalDocuments = additionalDocuments.ToImmutableReadOnlyListOrEmpty();
     HostObjectType = hostObjectType;
 }
Ejemplo n.º 8
0
 private ProjectInfo(
     ProjectAttributes attributes,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     IEnumerable <DocumentInfo> documents,
     IEnumerable <ProjectReference> projectReferences,
     IEnumerable <MetadataReference> metadataReferences,
     IEnumerable <AnalyzerReference> analyzerReferences,
     IEnumerable <DocumentInfo> additionalDocuments,
     Type hostObjectType)
 {
     Attributes          = attributes;
     CompilationOptions  = compilationOptions;
     ParseOptions        = parseOptions;
     Documents           = documents.ToImmutableReadOnlyListOrEmpty();
     ProjectReferences   = projectReferences.ToImmutableReadOnlyListOrEmpty();
     MetadataReferences  = metadataReferences.ToImmutableReadOnlyListOrEmpty();
     AnalyzerReferences  = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
     AdditionalDocuments = additionalDocuments.ToImmutableReadOnlyListOrEmpty();
     HostObjectType      = hostObjectType;
 }
Ejemplo n.º 9
0
 public ProjectCustomAttributeSimple(IProjectCustomAttribute projectCustomAttribute)
 {
     ProjectCustomAttributeTypeID     = projectCustomAttribute.ProjectCustomAttributeTypeID;
     ProjectCustomAttributeDataTypeID = projectCustomAttribute.ProjectCustomAttributeType.ProjectCustomAttributeDataTypeID;
     ProjectCustomAttributeValues     = projectCustomAttribute.Values
                                        .Select(y =>
                                                y.IProjectCustomAttribute.ProjectCustomAttributeType.ProjectCustomAttributeDataType ==
                                                ProjectCustomAttributeDataType.DateTime
                 ? DateTime.Parse(y.AttributeValue).ToShortDateString()
                 : y.AttributeValue)
                                        .ToList();
     if (ProjectCustomAttributeDataTypeID == ProjectCustomAttributeDataType.DateTime.ProjectCustomAttributeDataTypeID)
     {
         ProjectCustomAttributeValueDisplayString = ProjectAttributes.StringToDateStringStatic(projectCustomAttribute.Values.Single().AttributeValue);
     }
     else
     {
         ProjectCustomAttributeValueDisplayString =
             string.Join(", ", projectCustomAttribute.Values.Select(x => x.AttributeValue).OrderBy(x => x));
     }
 }
Ejemplo n.º 10
0
 private ProjectInfo(
     ProjectAttributes attributes,
     CompilationOptions?compilationOptions,
     ParseOptions?parseOptions,
     IReadOnlyList <DocumentInfo> documents,
     IReadOnlyList <ProjectReference> projectReferences,
     IReadOnlyList <MetadataReference> metadataReferences,
     IReadOnlyList <AnalyzerReference> analyzerReferences,
     IReadOnlyList <DocumentInfo> additionalDocuments,
     IReadOnlyList <DocumentInfo> analyzerConfigDocuments,
     Type?hostObjectType)
 {
     Attributes              = attributes;
     CompilationOptions      = compilationOptions;
     ParseOptions            = parseOptions;
     Documents               = documents;
     ProjectReferences       = projectReferences;
     MetadataReferences      = metadataReferences;
     AnalyzerReferences      = analyzerReferences;
     AdditionalDocuments     = additionalDocuments;
     AnalyzerConfigDocuments = analyzerConfigDocuments;
     HostObjectType          = hostObjectType;
 }
Ejemplo n.º 11
0
        private ProjectInfo With(
            ProjectAttributes attributes = null,
            CompilationOptions compilationOptions = null,
            ParseOptions parseOptions = null,
            IEnumerable<DocumentInfo> documents = null,
            IEnumerable<ProjectReference> projectReferences = null,
            IEnumerable<MetadataReference> metadataReferences = null,
            IEnumerable<AnalyzerReference> analyzerReferences = null,
            IEnumerable<DocumentInfo> additionalDocuments = null,
            Optional<Type> hostObjectType = default(Optional<Type>))
        {
            var newAttributes = attributes ?? Attributes;
            var newCompilationOptions = compilationOptions ?? CompilationOptions;
            var newParseOptions = parseOptions ?? ParseOptions;
            var newDocuments = documents ?? Documents;
            var newProjectReferences = projectReferences ?? ProjectReferences;
            var newMetadataReferences = metadataReferences ?? MetadataReferences;
            var newAnalyzerReferences = analyzerReferences ?? AnalyzerReferences;
            var newAdditionalDocuments = additionalDocuments ?? AdditionalDocuments;
            var newHostObjectType = hostObjectType.HasValue ? hostObjectType.Value : HostObjectType;

            if (newAttributes == Attributes &&
                newCompilationOptions == CompilationOptions &&
                newParseOptions == ParseOptions &&
                newDocuments == Documents &&
                newProjectReferences == ProjectReferences &&
                newMetadataReferences == MetadataReferences &&
                newAnalyzerReferences == AnalyzerReferences &&
                newAdditionalDocuments == AdditionalDocuments &&
                newHostObjectType == HostObjectType)
            {
                return this;
            }

            return new ProjectInfo(
                    newAttributes,
                    newCompilationOptions,
                    newParseOptions,
                    newDocuments,
                    newProjectReferences,
                    newMetadataReferences,
                    newAnalyzerReferences,
                    newAdditionalDocuments,
                    newHostObjectType);
        }
Ejemplo n.º 12
0
 public abstract string[] Filter(string[] files, ProjectAttributes attributes);
Ejemplo n.º 13
0
 public override string[] Filter(string[] files, ProjectAttributes attributes)
 {
     return files.Where(x => FilterTest(attributes.IsTest, x)).ToArray();
 }