public void Save(ScoreBoard scoreBoard) { var context = new LINQtoCSV.CsvContext(); var playersToWrite = scoreBoard.Players.Select(p => new CSVModel.Player(p)); context.Write(playersToWrite, Path.Combine(fileLocation, DateTime.Now.ToString(DateTimeFormat) + ".csv")); }
private static void WriteFiles(IList <Project> projects, IList <ProjectMember> commits) { LINQtoCSV.CsvContext csv = new LINQtoCSV.CsvContext(); //File 1: projects and their build counts csv.Write( (from p in projects select new { Project = p.Name, p.BuildCount }).OrderBy(x => x.Project), "ProjectBuilds.csv"); //File 2: project members and their count of commits csv.Write( //returns commits even if member has left the team since committing code ( from commit in commits group commit by new { commit.Project, commit.Name } into gc select new { Project = gc.First().Project, Member = gc.First().Name, gc.First().Email, Commits = gc.Sum(c => c.Commits) } //gets the members that did not commit any code ).Union( from projectmembers in projects.SelectMany(x => x.Members) where !(from commit in commits select commit.Id).Contains(projectmembers.Id) select new { Project = projectmembers.Project, Member = projectmembers.Name, projectmembers.Email, Commits = 0 } ).OrderBy(x => x.Project).ThenByDescending(x => x.Commits), "MemberCommits.csv"); }
/// <summary> /// returns all students as CSV /// </summary> /// <returns>students as CSV</returns> public string AsCSV() { var items = this.getStudents(); var results = items.Select(i => new { Mail = i.Properties["mail"][0], Vorname = i.Properties["msDS-PhoneticFirstName"][0], Nachname = i.Properties["msDS-PhoneticLastName"][0], Username = i.Properties["name"][0], ErstellungsDatum = DateTime.Parse(i.Properties["whenCreated"][0].ToString()), Studiengang = getProgramFromTree(i.Properties["memberOf"][0].ToString()) }); var csvContext = new LINQtoCSV.CsvContext(); var writer = new System.IO.StringWriter(); csvContext.Write(results, writer); writer.Close(); return(writer.ToString()); }
/// <summary> /// returns all students as CSV /// </summary> /// <returns>students as CSV</returns> public string AsCSV() { var items = this.getStudents(); var results = items.Select(i => new { Mail = i.Properties["mail"][0], Vorname = i.Properties["msDS-PhoneticFirstName"][0], Nachname = i.Properties["msDS-PhoneticLastName"][0], Username = i.Properties["name"][0], ErstellungsDatum = DateTime.Parse(i.Properties["whenCreated"][0].ToString()), Studiengang = getProgramFromTree(i.Properties["memberOf"][0].ToString()) }); var csvContext = new LINQtoCSV.CsvContext(); var writer = new System.IO.StringWriter(); csvContext.Write(results, writer); writer.Close(); return writer.ToString(); }
private static void WriteFiles(IList<Project> projects, IList<ProjectMember> commits) { LINQtoCSV.CsvContext csv = new LINQtoCSV.CsvContext(); //File 1: projects and their build counts csv.Write( (from p in projects select new { Project = p.Name, p.BuildCount }).OrderBy(x => x.Project), "ProjectBuilds.csv"); //File 2: project members and their count of commits csv.Write( //returns commits even if member has left the team since committing code ( from commit in commits group commit by new { commit.Project, commit.Name } into gc select new { Project = gc.First().Project, Member = gc.First().Name, gc.First().Email, Commits = gc.Sum(c => c.Commits) } //gets the members that did not commit any code ).Union( from projectmembers in projects.SelectMany(x => x.Members) where !(from commit in commits select commit.Id).Contains(projectmembers.Id) select new { Project = projectmembers.Project, Member = projectmembers.Name, projectmembers.Email, Commits = 0 } ).OrderBy(x => x.Project).ThenByDescending(x => x.Commits), "MemberCommits.csv"); }