private AgileSystemUser FindAgileSystemUser(Assignee assignee, string systemId) { AgileSystemUser agileSystemUser = _dataContext.AgileSystemUser.Where(x => x.AgileSystemId == systemId && x.AgileSystemUserName == assignee.ID).FirstOrDefault(); if (agileSystemUser == null) { agileSystemUser = new AgileSystemUser() { AgileSystemId = systemId, AgileSystemUserId = assignee.ID, Active = true }; _dataContext.AgileSystemUser.Add(agileSystemUser); } return(agileSystemUser); }
private void AddAnyMissingUsers(AgileSystem agileSystem, OutPutObject jsonContent) { List <string> userList = FlattenUsers(jsonContent); foreach (var user in userList) { AgileSystemUser asu = _dataContext.AgileSystemUser.Where(x => x.AgileSystemUserName == user && agileSystem.AgileSystemId == x.AgileSystemId).FirstOrDefault(); if (asu == null) { //set em up, they weren't found asu = new AgileSystemUser() { AgileSystemUserId = Guid.NewGuid().ToString(), AgileSystemUserName = user, AgileSystemId = agileSystem.AgileSystemId, Active = true //work values populated upon cross reference (manual) }; _dataContext.AgileSystemUser.Add(asu); } } _dataContext.SaveChanges(); }
private Exception ProcessFile(string file) { Exception ex = null; try { string content = System.IO.File.ReadAllText(file); VSTSComms.Ouput.OutPutObject jsonContent = JsonConvert.DeserializeObject <VSTSComms.Ouput.OutPutObject>(content); WorkTeam workTeam = _dataContext.WorkTeam.Where(x => x.WorkTeamId == jsonContent.TeamID).FirstOrDefault(); AgileSystem agileSystem = _dataContext.AgileSystem.Where(x => x.WorkTeamId == jsonContent.TeamID).FirstOrDefault(); if (agileSystem == null) { agileSystem = new AgileSystem() { AgileSystemId = Guid.NewGuid().ToString(), AgileSystemType = jsonContent.SystemType, AgileSystemName = workTeam.WorkTeamName, WorkTeamId = workTeam.WorkTeamId }; _dataContext.AgileSystem.Add(agileSystem); } AddAnyMissingUsers(agileSystem, jsonContent); //WorkTeam workTeam = _dataContext.WorkTeam.Where(x => x.TeamId == jsonContent.TeamID).FirstOrDefault(); foreach (var sprint in jsonContent.Sprints) { //TODO: fix issue here with finding previous sprint. It's not deleting it. //find sprint //AgileSprint agileSprint = FindSprint(workTeam.TeamId, sprint.ID); AgileSprint agileSprint = FindSprint(agileSystem.AgileSystemId, sprint.ID); if (agileSprint != null) { RemoveStories(agileSprint); } if (agileSprint == null) { agileSprint = new AgileSprint(); _dataContext.AgileSprint.Add(agileSprint); agileSprint.AgileSprintId = Guid.NewGuid().ToString(); } //set properties agileSprint.AgileSprintName = sprint.ID; agileSprint.AgileSystemId = agileSystem.AgileSystemId; agileSprint.SprintDescription = sprint.Name; agileSprint.EndDate = Convert.ToDateTime(sprint.EndDate); agileSprint.StartDate = Convert.ToDateTime(sprint.StartDate); foreach (var story in sprint.Stories) { AgileStory agileStory = new AgileStory() { AgileStoryId = Guid.NewGuid().ToString() }; _dataContext.AgileStory.Add(agileStory); agileStory.AgileStoryName = story.ID; agileStory.AgileSprintId = agileSprint.AgileSprintId; agileStory.StoryDescription = story.ID; agileStory.StoryType = story.Type; agileStory.StoryStatus = story.State; agileStory.StoryPoints = Convert.ToString(story.Points); foreach (var assignee in story.Assignees) { if (assignee.ID != null) { AgileStoryAgileSystemUser agileStoryAgileSystemUser = new AgileStoryAgileSystemUser(); _dataContext.AgileStoryAgileSystemUser.Add(agileStoryAgileSystemUser); agileStoryAgileSystemUser.AgileStoryAgileSystemUserId = Guid.NewGuid().ToString(); agileStoryAgileSystemUser.AgileStoryId = agileStory.AgileStoryId; //TODO get team member AgileSystemUser systemUser = FindAgileSystemUser(assignee, agileSystem.AgileSystemId); agileStoryAgileSystemUser.AgileSystemUserId = systemUser.AgileSystemUserId; agileStoryAgileSystemUser.AgileSystemUserStoryPoints = assignee.Points.ToString(); } } } } } catch (Exception ex1) { ex = ex1; } return(ex); }