//private static int GetNewItemNumber() //{ // try // { // using (var context = new DatabaseContext()) // { // var count = context.Items.Count(); // if (count == 0) // return 1; // return count + 1; // } // } // catch (Exception e) // { // SharedManager.Log(e, "GetNewItemNumber"); // return -1; // } //} public static List <Item> GetItemsFromSprint(string items) { if (items == null) { return new List <Item>() { } } ; try { using (var context = new DatabaseContext()) { var itemList = SharedManager.SplitString(items); var itemRet = (from item in context.Items where itemList.Contains(item.ItemID.ToString()) select item).ToList(); itemRet = itemRet.OrderBy(d => itemList.IndexOf(d.ItemID.ToString())).ToList(); return(itemRet); } } catch (Exception e) { SharedManager.Log(e, "GetItemsFromSprint"); return(new List <Item>() { }); } }
public static void DailyScrumMeeting(Project project, Sprint sprint, bool timeTrigger = true) { if (sprint.StartDate.Date > DateTime.Now.Date) { return; } if (!timeTrigger && RepeatMethod) { return; } var meetings = MeetingManager.GetMeetingsByEmail(project.ScrumMaster, sprint.SprintID); foreach (var member in SharedManager.SplitString(project.DevTeam)) { var tomorrow = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0).AddDays(1); if (meetings.Count( m => m.Time == tomorrow && m.Developer == member) != 0) { continue; } var meeting = new Meeting { MeetingType = "Scrum Meeting", Developer = member, Location = sprint.MeetingLocation, Time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0).AddDays(1), ScrumMaster = project.ScrumMaster, SprintID = sprint.SprintID, ProjectID = project.ProjectID }; MeetingManager.AddMeeting(meeting, sprint.SprintID); } RepeatMethod = true; }
public static string AddProject(Project project, string scrumMaster, out Project pr) { pr = new Project(); if (project == null) { return("Error when adding. Please try again"); } try { using (var context = new DatabaseContext()) { var proj = (from p in context.Projects where p.Name == project.Name select p).FirstOrDefault(); if (proj != null) { return(project.Name + " is already being used"); } scrumMaster = project.ScrumMaster ?? scrumMaster; var insertProject = new Project { Name = project.Name, ScrumMaster = scrumMaster, DevTeam = project.DevTeam, Description = project.Description }; if (!UserManager.CheckExistingEmail(insertProject.ScrumMaster)) { return(insertProject.ScrumMaster + " does not exist"); } insertProject.DevTeam = String.Join(",", project.DevTeamList.Where(s => !String.IsNullOrWhiteSpace(s))); foreach (var dev in SharedManager.SplitString(insertProject.DevTeam)) { //if (String.IsNullOrEmpty(dev)) continue; if (scrumMaster == dev) { return(dev + " is the Scrum Master"); } if (!UserManager.CheckExistingEmail(dev)) { return(dev + " does not exist"); } } context.Projects.Add(insertProject); context.SaveChanges(); pr = insertProject; return(""); } } catch (Exception e) { SharedManager.Log(e, "AddProject"); return(SharedManager.DatabaseError); } }
public static string ChangeItem(Sprint sprint, Item item) { if (item == null) { return("Error when adding. Please try again"); } else { using (var context = new DatabaseContext()) { using (var dbTransaction = context.Database.BeginTransaction()) { try { item = context.Items.Where(m => m.ItemID == item.ItemID).First(); item.SprintlessProjectID = 0; context.SaveChanges(); //FIXME sprintID is attributed when Add() if (sprint != null) { var number = (sprint.Items == null) ? 1 : (SharedManager.SplitString(sprint.Items)).Count() + 1; if (number == -1) { return(SharedManager.DatabaseError); } //check assignedto member of sprint item.ItemNumber = number; if (AddItemToSprint(sprint.SprintID, item.ItemID) != "") { throw new Exception(); } } dbTransaction.Commit(); return(""); } catch (Exception e) { dbTransaction.Rollback(); SharedManager.Log(e, "AddItem"); return(SharedManager.DatabaseError); } } } } }
//if memeber exists or differnet public static string AddMember(string member, int projectID) { try { if (member == null) { return("Email cannot be null"); } using (var context = new DatabaseContext()) { var proj = (from project in context.Projects where project.ProjectID == projectID select project).First(); if (proj == null) { return("Project not found"); } if (SharedManager.SplitString(proj.DevTeam).Contains(member) || proj.ScrumMaster == member) { return("Member already exists"); } if (!UserManager.CheckExistingEmail(member)) { return(member + " does not exist"); } if (UserManager.GetUserByEmail(member).Role == "ScrumMaster") { return(member + " is a Scrum Master"); } proj.DevTeam += "," + member; context.SaveChanges(); return(""); } } catch (Exception e) { SharedManager.Log(e, "GetSprintFromProject"); return(SharedManager.DatabaseError); } }
public static List <Project> GetProjectsByEmail(string userEmail) { try { using (var context = new DatabaseContext()) { var projects = (from proj in context.Projects select proj).ToList(); return(projects.Where(m => SharedManager.SplitString(m.DevTeam).Contains(userEmail) || m.ScrumMaster == userEmail).ToList()); } } catch (Exception e) { SharedManager.Log(e, "GetProjectsByEmail"); return(new List <Project>()); } }
public static string ChangeSprintInItem(List <SprintItem> item, int projectID) { try { using (var context = new DatabaseContext()) { foreach (var i in item) { var p = (from proj in context.Projects where proj.ProjectID == projectID select proj).FirstOrDefault(); var s = (from sprint in context.Sprints where sprint.SprintName == i.Sprint && p.Sprints.Contains(sprint.SprintID + ",") select sprint).FirstOrDefault(); if (s == null) { continue; } if (!SharedManager.SplitString(s.Items).Contains(i.Item)) { var it = SprintManager.GetItemFromID(Convert.ToInt32(i.Item)); if (it.SprintlessProjectID == 0) { SprintManager.AddItem(s, it); } else { SprintManager.ChangeItem(s, it); } } } context.SaveChanges(); return(""); } } catch (Exception e) { SharedManager.Log(e, "ChangeSprintInItem"); return(SharedManager.DatabaseError); } }
public static List <Sprint> GetSprintFromProject(string sprintString) { try { if (sprintString == null) { return(new List <Sprint>()); } var sprints = SharedManager.SplitString(sprintString); using (var context = new DatabaseContext()) { var sprintList = context.Sprints.Where(m => sprints.Any(m2 => m2 == m.SprintID.ToString())).ToList(); return(sprintList); } } catch (Exception e) { SharedManager.Log(e, "GetSprintFromProject"); return(new List <Sprint>()); } }
public static string AddSprint(Sprint sprint, Project proj) { if (sprint == null) { return("Error when adding. Please try again"); } using (var context = new DatabaseContext()) { using (var dbTransaction = context.Database.BeginTransaction()) { try { var b = (from s in context.Sprints where sprint.SprintName == s.SprintName select s).FirstOrDefault(); if (b != null) { return("A Sprint already exists with that name"); } var number = (proj.Sprints == null) ? 1 : (SharedManager.SplitString(proj.Sprints)).Count() + 1; sprint.SprintNumber = number; context.Sprints.Add(sprint); context.SaveChanges(); AddSprintToProject(proj.ProjectID, sprint.SprintID); dbTransaction.Commit(); return(""); } catch (Exception e) { dbTransaction.Rollback(); SharedManager.Log(e, "AddSprint"); return(SharedManager.DatabaseError); } } } }