Esempio n. 1
0
        public void RemoveByElementName(string elementName)
        {
            ProjectTag[] values = new ProjectTag[templateTags.Values.Count];
            templateTags.Values.CopyTo(values, 0);
            foreach (ProjectTag tag in values)
            {
                if (tag.TemplateElement == elementName)
                {
                    templateTags.Remove(tag.TemplateElement);
                    TagPath basePath = new TagPath(tag.Path);
                    if (basePath.Location == TagLocation.Project)
                    {
                        string relativePath = basePath.ToPath(PathFormat.Relative);
                        templateTagHierarchy.RemoveFile(relativePath);
                    }
                    OnFileRemoved(tag.Path, elementName);

                    TemplateTag templateTag = GetTemplateTag(elementName);
                    if (templateTag != null)
                    {
                        // Generate the FileAdded event with the default filename - this is so that the
                        // ProjectExplorer can update it's Essential Tags list.
                        // This is kind of hackish, because the ProjectFile shouldn't be worrying
                        // about the PE at all.  A more appropriate place to put this functionality would
                        // be in the ProjectNodeSource, but that would complicate some things and would
                        // force me to write additional code.  And we all know how lazy I am! :D
                        TagPath path = new TagPath(templateTag.DefaultFile + "." + templateTag.FileType,
                                                   "", TagLocation.Archive);
                        OnFileAdded(path.ToPath(PathFormat.ExplicitLocation), templateTag.Name);
                    }
                }
            }
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectTag projecttag = db.ProjectTags.Find(id);

            db.ProjectTags.Remove(projecttag);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        //
        // GET: /ProjectTags/Edit/5

        public ActionResult Edit(int id)
        {
            ProjectTag projecttag = db.ProjectTags.Find(id);

            ViewBag.ProjectID = new SelectList(db.Projects, "ProjectID", "alias", projecttag.ProjectID);
            ViewBag.TagID     = new SelectList(db.Tags, "TagID", "name", projecttag.TagID);
            return(View(projecttag));
        }
Esempio n. 4
0
        public async void UnassignProjectTag(int projectId, int tagId)
        {
            ProjectTag projectTag = await FindByProjectIdAndTagId(projectId, tagId);

            if (projectTag != null)
            {
                Remove(projectTag);
            }
        }
Esempio n. 5
0
 public DatabaseProject(int id, string projectname, string description, DatabaseUser owner, ProjectType type, ProjectStatus status, ProjectTag tag)
 {
     ID          = id;
     Projectname = projectname;
     Description = description;
     this.owner  = owner;
     Type        = type;
     Status      = status;
     Tag         = tag;
 }
Esempio n. 6
0
        /// <summary>
        /// Adds the the specified template element/path combination to the list.
        /// </summary>
        public void Add(string templateElement, TagPath tagPath)
        {
            // Make sure that the template element that is attempting to be added exists in
            // the related Template for this list.
            bool validTemplate = false;

            foreach (TemplateTag templateTag in baseTemplate.TagSet)
            {
                if (templateTag.Name == templateElement)
                {
                    validTemplate = true;
                    break;
                }
            }

            if (validTemplate)
            {
                // Get the explicit location and add that path to the elements
                // (Or update an existing path if the named element already exists.)
                string     path = tagPath.ToPath(PathFormat.ExplicitLocation);
                ProjectTag tag  = new ProjectTag(templateElement, path);
                if (!templateTags.ContainsKey(templateElement))
                {
                    templateTags.Add(templateElement, tag);
                }
                else
                {
                    templateTags[templateElement].Path = path;
                }

                // If the tag is from the project, store the relative path
                // (no "p:\" prefix) to the templateTagHierarchy.
                if (tagPath.Location == TagLocation.Project)
                {
                    templateTagHierarchy.Add(tagPath.ToPath(PathFormat.Relative));
                    // We added a new file yar!!
                    OnFileAdded(path, templateElement);

                    TemplateTag templateTag = GetTemplateTag(templateElement);
                    if (templateTag != null)
                    {
                        // Again, haxzorzz!!
                        TagPath lePath = new TagPath(templateTag.DefaultFile + "." + templateTag.FileType,
                                                     "", TagLocation.Archive);
                        OnFileRemoved(lePath.ToPath(PathFormat.ExplicitLocation), templateTag.Name);
                    }
                }
            }
            else
            {
                throw new Exception("The specified element '" + templateElement + "' does not exist in the template '" +
                                    baseTemplate.Name + "'");
            }
        }
Esempio n. 7
0
 public ActionResult Edit(ProjectTag projecttag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projecttag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectID = new SelectList(db.Projects, "ProjectID", "alias", projecttag.ProjectID);
     ViewBag.TagID     = new SelectList(db.Tags, "TagID", "name", projecttag.TagID);
     return(View(projecttag));
 }
Esempio n. 8
0
 public void RemoveByTagPath(string path)
 {
     ProjectTag[] values = new ProjectTag[templateTags.Values.Count];
     templateTags.Values.CopyTo(values, 0);
     foreach (ProjectTag tag in values)
     {
         if (tag.Path == path)
         {
             RemoveByElementName(tag.TemplateElement);
         }
     }
 }
Esempio n. 9
0
        public async Task AssignProjectTag(int projectId, int tagId)
        {
            ProjectTag projectTag = await FindByProjectIdAndTagId(projectId, tagId);

            if (projectTag == null)
            {
                projectTag = new ProjectTag {
                    ProjectId = projectId, TagId = tagId
                };
                await AddAsync(projectTag);
            }
        }
Esempio n. 10
0
        public ActionResult Create(ProjectTag projecttag)
        {
            if (ModelState.IsValid)
            {
                db.ProjectTags.Add(projecttag);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(db.Projects, "ProjectID", "alias", projecttag.ProjectID);
            ViewBag.TagID     = new SelectList(db.Tags, "TagID", "name", projecttag.TagID);
            return(View(projecttag));
        }
Esempio n. 11
0
 public void CreateProjectTagsForProject(int projectId, List <int> tagsId)
 {
     foreach (var id in tagsId)
     {
         ProjectTag projectSprint = new ProjectTag()
         {
             ProjectId = projectId,
             TagId     = id
         };
         this.Db.ProjectTags.Add(projectSprint);
     }
     this.Db.SaveChanges();
 }
Esempio n. 12
0
        public async Task <ProjectTag> AddProjectTag(ProjectTag projectTag)
        {
            try
            {
                _context.ProjectTag.Add(projectTag);
                await _context.SaveChangesAsync();

                return(projectTag);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 13
0
 public ProjectTag this[string templateElement]
 {
     get
     {
         ProjectTag tag = templateTags[templateElement];
         if (tag.Path.StartsWith("p:\\"))
         {
             return(tag);
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 14
0
        /// <summary>
        /// Update the path that corresponds to the specified element.
        /// </summary>
        public void UpdateElementPath(string element, string newPath)
        {
            if (templateTags.ContainsKey(element))
            {
                if (templateTags[element].Path != newPath)
                {
                    ProjectTag tag = templateTags[element];
                    templateTags.Remove(element);
                    OnFileRemoved(tag.Path, element);

                    tag.Path = newPath;
                    templateTags.Add(element, tag);
                    OnFileAdded(newPath, element);
                }
            }
        }
    public void DisplayProjectsWithTag(ProjectTag tag)
    {
        List <ProjectData> filteredList = new List <ProjectData>();

        foreach (ProjectData pd in allProjectDatas)
        {
            foreach (ProjectTag t in pd.tags)
            {
                if (t == tag)
                {
                    filteredList.Add(pd);
                }
            }
        }
        displayProjects(filteredList.ToArray());
    }
Esempio n. 16
0
        public void AddTagsToProject(int projectId, List <int> tagsIds)
        {
            List <ProjectTag> updList = new List <ProjectTag>();

            foreach (var id in tagsIds)
            {
                var projectTag = new ProjectTag()
                {
                    ProjectId = projectId,
                    TagId     = id
                };
                updList.Add(projectTag);
            }
            this.Db.ProjectTags.AddRange(updList);
            this.Db.SaveChanges();
        }
Esempio n. 17
0
        public async Task <ProjectTagResponse> UnassignProjectTagAsync(int projectId, int tagId)
        {
            try
            {
                ProjectTag projectTag = await _projectTagRepository.FindByProjectIdAndTagId(projectId, tagId);

                _projectTagRepository.Remove(projectTag);
                await _unitOfWork.CompleteAsync();

                return(new ProjectTagResponse(projectTag));
            }
            catch (Exception ex)
            {
                return(new ProjectTagResponse($"An error ocurred while assigning Tag to Project: {ex.Message}"));
            }
        }
Esempio n. 18
0
        public List <DatabaseProject> getProjectsOfUser(int userID)
        {
            try
            {
                OleDbCommand command = new OleDbCommand();
                command.Connection = connection;

                command.CommandText = "SELECT Project.* FROM[Project] project" +
                                      " Inner join [UsersInProjects] uip" +
                                      " On uip.ProjectID = project.ID " +
                                      " WHERE uip.UserID = " + userID;

                OleDbDataReader reader = command.ExecuteReader();

                List <DatabaseProject> result = new List <DatabaseProject>();

                while (reader.Read())
                {
                    int           id          = 1;
                    string        projectName = "";
                    string        description = "";
                    ProjectType   type        = ProjectType.Game;
                    ProjectStatus status      = ProjectStatus.Completed;
                    ProjectTag    tag         = ProjectTag.Game;

                    id          = reader.GetInt32(0);
                    projectName = reader.GetString(1);
                    Enum.TryParse <ProjectType>(reader.GetString(2), out type);
                    description = reader.GetString(3);
                    Enum.TryParse <ProjectTag>(reader.GetString(5), out tag);
                    Enum.TryParse <ProjectStatus>(reader.GetString(6), out status);

                    result.Add(new DatabaseProject(id, projectName, description, null, type, status, tag));
                }

                return(result);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine();

            return(null);
        }
Esempio n. 19
0
        //[Authorize(Policy = "RequireLoggedIn")]
        public async Task <IActionResult> AddTag([FromForm] ProjectTagVM formdata)
        {
            // Find Tag In Database
            Tag tag = _dbContext.Tag.SingleOrDefault(t => t.Name == formdata.TagName);

            if (tag == null)
            {
                // Create Tag
                tag = new Tag
                {
                    Name = formdata.TagName,
                };

                // Add Tag To Database
                await _dbContext.Tag.AddAsync(tag);

                await _dbContext.SaveChangesAsync();
            }

            // Find ProjectTag In Database
            ProjectTag projectTag = _dbContext.ProjectTags.SingleOrDefault(pt => pt.ProjectID == formdata.ProjectID && pt.TagID == tag.TagID);

            if (projectTag != null)
            {
                return(Conflict(new { message = "Project Tag Already Exist" }));
            }


            // Add Project Tag To Project
            projectTag = new ProjectTag
            {
                ProjectID = formdata.ProjectID,
                TagID     = tag.TagID
            };

            // Add Tag to Project And Save
            await _dbContext.ProjectTags.AddAsync(projectTag);

            await _dbContext.SaveChangesAsync();

            // Return Ok Status
            return(Ok(new
            {
                result = projectTag,
                message = "Project Tag Added"
            }));
        }
Esempio n. 20
0
        public async Task <IActionResult> RemoveTag([FromRoute] int projectID, [FromRoute] int tagID)
        {
            // Find ProjectTag In Database
            ProjectTag projectTag = _dbContext.ProjectTags
                                    .Include(pt => pt.Tag)
                                    .SingleOrDefault(pt => pt.ProjectID == projectID && pt.TagID == tagID);

            if (projectTag == null)
            {
                return(NotFound(new { message = "Project Tag Not Found" }));
            }

            // Remove Project Tag
            _dbContext.ProjectTags.Remove(projectTag);

            // Save Change
            await _dbContext.SaveChangesAsync();

            // Check If Last Tag
            var projectTagList = _dbContext.ProjectTags.Where(pt => pt.TagID == tagID).ToList();

            // Delete Tag If No Connection Exist
            if (projectTagList.Count == 0)
            {
                // Find Tag
                var tag = await _dbContext.Tag.FindAsync(tagID);

                if (tag == null)
                {
                    return(NotFound(new { message = "Tag Not Found" }));
                }

                // Remove Tag
                _dbContext.Tag.Remove(tag);
            }

            // Save Change
            await _dbContext.SaveChangesAsync();

            // Return Ok Status
            return(Ok(new
            {
                result = projectTag,
                message = projectTag.Tag.Name + " tag has been removed"
            }));
        }
        public IActionResult AddTagToproject([FromBody] ProjectTag projectTag, [FromQuery] string action)
        {
            var lang          = Request.Headers["language"].ToString();
            var errorMessages = new List <string>();

            try
            {
                var project     = _projectRepository.FindById(projectTag.ProjectId);
                var projectTags = project.ProjectTags;

                if (action == "add")
                {
                    var newTag        = _tagRepository.FindById(projectTag.TagId);
                    var newProjectTag = new ProjectTag()
                    {
                        ProjectId = projectTag.ProjectId,
                        Project   = project,
                        TagId     = projectTag.TagId,
                        Tag       = newTag
                    };
                    projectTags.Add(newProjectTag);
                }
                else if (action == "remove")
                {
                    var currentProjectTag = projectTags
                                            .SingleOrDefault(x => x.TagId == projectTag.TagId && x.ProjectId == projectTag.ProjectId);

                    projectTags.Remove(currentProjectTag);
                }
                project.ProjectTags = projectTags;

                var updatedproject = _projectRepository.Update(project);

                var response = ResponseGenerator.GenerateProjectResponse(updatedproject);

                return(Ok(new { updatedProject = response }));
            }
            catch (Exception ex)
            {
                errorMessages.Add(_translator.GetTranslation("ERROR", lang));
                errorMessages.Add(ex.Message);
                return(BadRequest(new { errors = errorMessages }));
            }
        }
Esempio n. 22
0
        public static ProjectTagViewModel ToViewModel(this ProjectTag projectTag)
        {
            try
            {
                if (projectTag == null)
                {
                    return(null);
                }

                return(new ProjectTagViewModel
                {
                    Id = projectTag.Id,
                    Name = projectTag?.Tag?.Name ?? string.Empty
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 23
0
        public DatabaseProject getProject(int projectID)
        {
            try
            {
                OleDbCommand command = new OleDbCommand();
                command.Connection  = connection;
                command.CommandText = "SELECT Project.* FROM[Project] ";

                OleDbDataReader reader = command.ExecuteReader();

                string        projectName = "";
                string        description = "";
                int           ownerID     = 1;
                ProjectType   type        = ProjectType.Game;
                ProjectStatus status      = ProjectStatus.Completed;
                ProjectTag    tag         = ProjectTag.Game;

                while (reader.Read())
                {
                    projectName = reader.GetString(1);
                    Enum.TryParse <ProjectType>(reader.GetString(2), out type);
                    description = reader.GetString(3);
                    ownerID     = reader.GetInt32(4);
                    Enum.TryParse <ProjectTag>(reader.GetString(5), out tag);
                    Enum.TryParse <ProjectStatus>(reader.GetString(6), out status);
                }

                DatabaseUser owner = GetUser(ownerID);

                return(new DatabaseProject(projectID, projectName, description, owner, type, status, tag));
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine();

            return(null);
        }
Esempio n. 24
0
 public void Remove(ProjectTag projectTag)
 {
     _context.ProjectTags.Remove(projectTag);
 }
Esempio n. 25
0
 public async Task AddAsync(ProjectTag projectTag)
 {
     await _context.ProjectTags.AddAsync(projectTag);
 }
Esempio n. 26
0
        //
        // GET: /ProjectTags/Delete/5

        public ActionResult Delete(int id)
        {
            ProjectTag projecttag = db.ProjectTags.Find(id);

            return(View(projecttag));
        }
Esempio n. 27
0
        /// <summary>
        /// Changes the Tag of the project
        /// </summary>
        /// <param name="projectname">The name of the project</param>
        /// <param name="newValue">New tag of the project</param>
        public void ChangeProjectTag(string projectname, ProjectTag newValue)
        {
            string commandText = "UPDATE [Project] SET Tag = '" + newValue + "' WHERE Projectname = '" + projectname + "'";

            ExecuteCommand(commandText);
        }
Esempio n. 28
0
 public ProjectTag[] GetTemplateList()
 {
     ProjectTag[] tags = new ProjectTag[templateTags.Values.Count];
     templateTags.Values.CopyTo(tags, 0);
     return(tags);
 }
Esempio n. 29
0
        /// <summary>
        /// Adds an project to the database
        /// </summary>
        /// <param name="name">The name of the project</param>
        /// <param name="type">The type of the project</param>
        /// <param name="description">Description for the project</param>
        /// <param name="owner">The ID of the project owner</param>
        /// <param name="tag">Tag for the project</param>
        /// <param name="status">The current status of the project</param>
        public void AddProject(string name, ProjectType type, string description, int owner, ProjectTag tag, ProjectStatus status)
        {
            string commandText = "INSERT INTO Project ( Projectname, Type, Description, Owner, Tag, Status ) VALUES " +
                                 "('" + name + "','" + type + "','" + description + "','" + owner + "','" + tag + "','" + status + "')";

            ExecuteCommand(commandText);
        }
Esempio n. 30
0
        public List <DatabaseProject> SearchProject(String name = null, ProjectType typeSearch = ProjectType.Null, ProjectTag tagSearch = ProjectTag.Null, ProjectStatus statusSearch = ProjectStatus.Null)
        {
            try
            {
                List <DatabaseProject> result = new List <DatabaseProject>();

                OleDbCommand command = new OleDbCommand();
                command.Connection = connection;

                string commandtext = "SELECT Project.* FROM[Project] ";

                if (name != null || typeSearch != ProjectType.Null || tagSearch != ProjectTag.Null || statusSearch != ProjectStatus.Null)
                {
                    commandtext += "WHERE ";
                    bool added = false;


                    if (name != null)
                    {
                        commandtext += "UCase(Projectname) like UCase('%" + name + "%') ";
                        added        = true;
                    }
                    if (typeSearch != ProjectType.Null && !added)
                    {
                        commandtext += "Type = '" + typeSearch + "' ";
                        added        = true;
                    }
                    else if (typeSearch != ProjectType.Null)
                    {
                        commandtext += "AND Type = '" + typeSearch + "' ";
                    }
                    if (tagSearch != ProjectTag.Null && !added)
                    {
                        commandtext += "Tag = '" + tagSearch + "' ";
                        added        = true;
                    }
                    else if (tagSearch != ProjectTag.Null)
                    {
                        commandtext += "AND Tag = '" + tagSearch + "' ";
                    }
                    if (statusSearch != ProjectStatus.Null && !added)
                    {
                        commandtext += "Status = '" + statusSearch + "' ";
                    }
                    else if (statusSearch != ProjectStatus.Null)
                    {
                        commandtext += "AND Status = '" + statusSearch + "' ";
                    }
                }

                command.CommandText = commandtext;

                OleDbDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int           id          = reader.GetInt32(0);
                    string        projectname = reader.GetString(1);
                    ProjectType   type;
                    ProjectTag    tag;
                    ProjectStatus status;

                    Enum.TryParse <ProjectType>(reader.GetString(2), out type);
                    string description = reader.GetString(3);
                    int    ownerID     = reader.GetInt32(4);
                    Enum.TryParse <ProjectTag>(reader.GetString(5), out tag);
                    Enum.TryParse <ProjectStatus>(reader.GetString(6), out status);

                    DatabaseUser owner = GetUser(ownerID);

                    result.Add(new DatabaseProject(id, projectname, description, owner, type, status, tag));
                }

                return(result);
            }


            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine();

            return(null);
        }