private void MergeUsers(Users first, Users second) { if (second.Name.Split(' ').Length > 1) { first.Name = second.Name; } first.BugsClosed += second.BugsClosed; first.MailingListMessages += second.MailingListMessages; foreach (Projects secondproject in second.projects) { bool found = false; foreach (Projects firstproject in first.projects) { if (firstproject.name == secondproject.name) { found = true; firstproject.CodeAdded += secondproject.CodeAdded; firstproject.CodeCurved += secondproject.CodeCurved; firstproject.CodeRemoved += secondproject.CodeRemoved; foreach (string commit in secondproject.commits) { firstproject.commits.Add(commit); } } } if (!found) { Projects project = new Projects(secondproject.name); first.projects.Add(project); project.CodeAdded = secondproject.CodeAdded; project.CodeCurved = secondproject.CodeCurved; project.CodeRemoved = secondproject.CodeRemoved; foreach (string commit in secondproject.commits) { project.commits.Add(commit); } } } users.Remove(second); }
/// <summary> /// Find the Project, else create the project. /// </summary> public Projects GetProject(string project) { foreach (Projects proj in projects) { if (proj.name == project) { return proj; } } Projects temp = new Projects(project); projects.Add(temp); return temp; }
private void AddProject(Projects project, int userid) { SqliteCommand addProject = db.CreateCommand(); addProject.CommandText = "INSERT INTO Project VALUES(\"" + project.name + "\", " + project.CodeCurved + ", " + project.CodeAdded + ", " + project.CodeRemoved + ", " + userid + ")"; addProject.ExecuteNonQuery(); int id = GetID("Project", "UserID=" + userid + " AND ProjName=\"" + project.name + "\""); AddData(project, id); }
public List<Users> RetrieveUsers() { List<Users> users = new List<Users>(); Users user; SqliteCommand retrieveUsers = db.CreateCommand(); retrieveUsers.CommandText = "SELECT rowid, UserName, MailingListMessage, ResolvedBugs FROM User"; SqliteDataReader reader = retrieveUsers.ExecuteReader(); while(reader.Read()) { user = new Users(); users.Add(user); SqliteCommand retrieveEmails = db.CreateCommand(); retrieveEmails.CommandText = "SELECT Email, UserID FROM Address WHERE UserID=" + reader["rowid"].ToString(); SqliteDataReader addressReader = retrieveEmails.ExecuteReader(); while(addressReader.Read()) { user.email.Add(addressReader["Email"].ToString()); } user.Name = reader["UserName"].ToString(); user.MailingListMessages = int.Parse(reader["MailingListMessage"].ToString()); user.BugsClosed = int.Parse(reader["ResolvedBugs"].ToString()); SqliteCommand retrieveProjects = db.CreateCommand(); retrieveProjects.CommandText = "SELECT rowid, ProjName, CodeCurved, CodeAdded, CodeRemoved, UserID FROM Project WHERE UserID=" + reader["rowid"].ToString(); SqliteDataReader projectReader = retrieveProjects.ExecuteReader(); while(projectReader.Read()) { Projects project = new Projects(projectReader["ProjName"].ToString()); user.projects.Add(project); project.CodeCurved = int.Parse(projectReader["CodeCurved"].ToString()); project.CodeAdded = int.Parse(projectReader["CodeAdded"].ToString()); project.CodeRemoved = int.Parse(projectReader["CodeRemoved"].ToString()); SqliteCommand retrieveData = db.CreateCommand(); retrieveData.CommandText = "SELECT * FROM Data WHERE ProjID=" + projectReader["rowid"].ToString(); SqliteDataReader dataReader = retrieveData.ExecuteReader(); while(dataReader.Read()) { project.commits.Add(dataReader["CommitID"].ToString()); } } } return users; }
private void AddData(Projects project, int projid) { foreach (string commit in project.commits) { SqliteCommand addData = db.CreateCommand(); addData.CommandText = "INSERT INTO Data VALUES(\"" + commit + "\", " + projid + ")"; addData.ExecuteNonQuery(); } }