static async System.Threading.Tasks.Task Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                Console.WriteLine();
                Console.WriteLine("Commits der letzten 4 Wochen");
                Console.WriteLine("----------------------------");
                var weeks = unitOfWork.CommitRepository
                            .Commits4Weeks();
                WriteCommit(weeks);
                Console.WriteLine();

                Console.WriteLine("Commit mit Id 4");
                Console.WriteLine("----------------------------");
                Console.WriteLine();
                var id = unitOfWork.CommitRepository
                         .CommitWithId4();
                Console.WriteLine(id.ToString());
                Console.WriteLine();

                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("----------------------------");
                Console.WriteLine();
                var statistik = unitOfWork.DeveloperRepository
                                .CommitAndDev();
                WriteStatistik(statistik);
                Console.WriteLine();
            }

            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
Exemple #2
0
 static void Main()
 {
     Console.WriteLine("Import der Commits in die Datenbank");
     using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
     {
         Console.WriteLine("Datenbank löschen");
         unitOfWorkImport.DeleteDatabase();
         Console.WriteLine("Datenbank migrieren");
         unitOfWorkImport.MigrateDatabase();
         Console.WriteLine("Commits werden von commits.txt eingelesen");
         var commits = ImportController.ReadFromCsv();
         if (commits.Length == 0)
         {
             Console.WriteLine("!!! Es wurden keine Commits eingelesen");
             return;
         }
         Console.WriteLine(
             $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
         unitOfWorkImport.CommitRepository.AddRange(commits);
         int countDevelopers = commits.GroupBy(c => c.Developer).Count();
         int savedRows       = unitOfWorkImport.SaveChanges();
         Console.WriteLine(
             $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
         Console.WriteLine();
         var csvCommits = commits.Select(c =>
                                         $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
         File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
     }
     Console.WriteLine("Datenbankabfragen");
     Console.WriteLine("=================");
     using (IUnitOfWork unitOfWork = new UnitOfWork())
     {
         var g     = unitOfWork.CommitRepository.GetAllCommitsGroupedByDevoloper();
         var group = g.GroupBy(g => g.Developer).OrderByDescending(g => g.Key.Commits.Count());
         Console.WriteLine("Statistik der Commits der Developer");
         Console.WriteLine("-----------------------------------");
         Console.WriteLine($"Developer	Commits	FileChanges	Insertions	Deletions");
         foreach (var pair in group)
         {
             Console.WriteLine($"{pair.Key.Name, -16} " +
                               $"{pair.Key.Commits.Count(), 4} " +
                               $"{pair.Key.Commits.Sum(s => s.FilesChanges), 12} " +
                               $"{ pair.Key.Commits.Sum(s => s.Insertions), 13} " +
                               $"{ pair.Key.Commits.Sum(s => s.Deletions), 14}");
         }
         var v = unitOfWork.CommitRepository.GetCommitByDeveloperID(4);
         Console.WriteLine("Commit mit ID 4");
         Console.WriteLine("-----------------------------------");
         Console.WriteLine($"{v.Developer.Name,-16} {v.Date.ToShortDateString(),4} {v.FilesChanges}\t {v.Insertions}\t {v.Deletions}");
         var s = unitOfWork.CommitRepository.GetCommitsByDate();
         Console.WriteLine("Commit der letzten 4 Wochen");
         Console.WriteLine("---------------------------");
         foreach (var item in s)
         {
             Console.WriteLine($"{item.Developer.Name,-16} {item.Date.ToShortDateString(),4} {item.FilesChanges}\t {item.Insertions}\t {item.Deletions}");
         }
     }
     Console.Write("Beenden mit Eingabetaste ...");
     Console.ReadLine();
 }
Exemple #3
0
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                var commits = unitOfWork.CommitRepository.GetCommitsFromLast4Wekks();
                Console.WriteLine("Commits der letzten 4 Wochen");
                Console.WriteLine("----------------------------");
                WriteCommits(commits);
                Console.WriteLine();

                Console.WriteLine("Commit mit Id 4");
                Console.WriteLine("---------------");
                var commit = unitOfWork.CommitRepository.GetCommitById(4);
                Console.WriteLine(commit.ToString());
                Console.WriteLine();

                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");
                var stats = unitOfWork.DeveloperRepository.GetDevOpStats();
                foreach (var item in stats)
                {
                    Console.WriteLine($"{item.Name,-20} {item.Commits,-15} {item.Changes,-15}" +
                                      $"{item.Inserts,-15}{item.Deletes}");
                }
                Console.WriteLine();
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
Exemple #4
0
 static void Main()
 {
     Console.WriteLine("Import der Commits in die Datenbank");
     using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
     {
         Console.WriteLine("Datenbank löschen");
         unitOfWorkImport.DeleteDatabase();
         Console.WriteLine("Datenbank migrieren");
         unitOfWorkImport.MigrateDatabase();
         Console.WriteLine("Commits werden von commits.txt eingelesen");
         var commits = ImportController.ReadFromTxt();
         if (commits.Length == 0)
         {
             Console.WriteLine("!!! Es wurden keine Commits eingelesen");
             return;
         }
         Console.WriteLine(
             $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
         unitOfWorkImport.CommitRepository.AddRange(commits);
         int countDevelopers = commits.GroupBy(c => c.Developer).Count();
         int savedRows       = unitOfWorkImport.SaveChanges();
         Console.WriteLine(
             $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
         Console.WriteLine();
         var csvCommits = commits.Select(c =>
                                         $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
         File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
     }
     Console.WriteLine("Datenbankabfragen");
     Console.WriteLine("=================");
     using (IUnitOfWork unitOfWork = new UnitOfWork())
     {
         PrintFristQuery(unitOfWork);
         PrintSecondQuery(unitOfWork);
         PrintThirdQuery(unitOfWork);
     }
     Console.Write("Beenden mit Eingabetaste ...");
     Console.ReadLine();
 }
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");

            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                List <Commit> commitsOf2019 = unitOfWork.CommitRepository.GetCommitsOf2019().ToList();

                Console.WriteLine("Commits von 2019!");
                Console.WriteLine();

                ConsoleTableBuilder.From(commitsOf2019
                                         .Select(o => new object[]
                {
                    o.Developer.Name,
                    o.Date,
                    o.FilesChanges,
                    o.Insertions,
                    o.Deletions
                })
                                         .ToList())
                .WithColumn(
                    "Name",
                    "Date",
                    "FileChanges",
                    "Insertions",
                    "Deletions"
                    )
                .WithFormat(ConsoleTableBuilderFormat.Minimal)
                .WithOptions(new ConsoleTableBuilderOption {
                    DividerString = ""
                })
                .ExportAndWrite();

                Console.WriteLine();
                Console.WriteLine("____________________________________________");
                Console.WriteLine();

                Commit commit = unitOfWork.CommitRepository.GetCommitByID(4);
                Console.WriteLine("Commit mit ID 4");
                Console.WriteLine();
                Console.WriteLine(commit.ToString());
                Console.WriteLine();

                List <Developer> devops = unitOfWork.DeveloperRepository.GetDevopsAndCommits().OrderBy(d => d.Commits.Count()).ToList();

                Console.WriteLine("Statistik der Developer");
                Console.WriteLine("____________________________________________");

                ConsoleTableBuilder.From(devops
                                         .Select(o => new object[]
                {
                    o.Name,
                    o.Commits.Count(),
                    o.Commits.Select(c => c.FilesChanges).Sum(),
                    o.Commits.Select(c => c.Insertions).Sum(),
                    o.Commits.Select(c => c.Deletions).Sum()
                })
                                         .ToList())
                .WithColumn(
                    "Name",
                    "FileChanges",
                    "Insertions",
                    "Deletions"
                    )
                .WithFormat(ConsoleTableBuilderFormat.Minimal)
                .WithOptions(new ConsoleTableBuilderOption {
                    DividerString = ""
                })
                .ExportAndWrite();

                Console.WriteLine();
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                //var commits = ImportController.ReadFromTxt();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();

                /*var csvCommits = commits.Select(c =>
                 *  $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}"); //Auskommentiert für Testzwecke bezüglich der .csv und der .txt Dateien
                 * File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);*///da diese unterschiedliche Daten beinhalten
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                MyLogger.InitializeLogger();
                Console.WriteLine("Commits der letzten 4 Wochen ab dem letzten Commit");
                Console.WriteLine("--------------------------------------------------");

                DateTime lastCommit = unitOfWork.CommitRepository.GetLatestCommit().Date;
                DateTime lowerBound = lastCommit.AddDays(-28);

                var commits = unitOfWork.CommitRepository.GetCommitsForTimePeriod(lowerBound, lastCommit);

                Console.WriteLine($"{"Developer", -18}{"Date", -10} FileChanges Insertions  Deletions ");
                foreach (var item in commits)
                {
                    Console.WriteLine($"{item.Developer.Name, -18}{item.Date.Date.ToShortDateString(), 10} {item.FilesChanges, 11} {item.Insertions, 10} {item.Deletions, 10} ");
                }

                Console.WriteLine("");
                Console.WriteLine("Commit mit Id 4");
                Console.WriteLine("---------------");

                var commit = unitOfWork.CommitRepository.GetCommitById(4);
                Console.WriteLine($"{commit.Developer.Name, -18}{commit.Date.Date.ToShortDateString(),10} {commit.FilesChanges,11} {commit.Insertions,10} {commit.Deletions,10} ");
                Console.WriteLine("");
                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");

                var statistics = unitOfWork.DeveloperRepository.GetDeveloperStatistics();

                Console.WriteLine($"{"Developer", -18}{"Commits", 10} {"FileChanges", 11} {"Insertions", 10}  {"Deletions", 10}");
                foreach (var stat in statistics)
                {
                    Console.WriteLine($"{stat.Item1, -18}{stat.Item2, 10} {stat.Item3, 11} {stat.Item4, 10} {stat.Item5, 11}");
                }
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
Exemple #7
0
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.csv eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
            }


            Console.WriteLine("\nDatenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                //Commits der letzten Vier Wochen vor dem letzten Commit
                int days          = 28;
                var latestCommits = unitOfWork.CommitRepository.GetLatestCommits(days); //GetDevStats(28) => days since last commit

                Console.WriteLine($"\nCommits der letzten {days} Tage vor dem letzten Commit");
                Console.WriteLine($"---------------------------------------------------");
                Console.WriteLine($"{"Developer",-15}{"Date",-11}{"FileChanges", -13}{"Insertions", -12}{"Deletions", -11}");

                foreach (var item in latestCommits)
                {
                    Console.WriteLine($"{item.Developer.Name,-15}{item.Date.ToShortDateString(),-11}{item.FilesChanges, -13}{item.Insertions,-12}{item.Deletions,-11}");
                }

                //Commit mit id
                int id       = 4;
                var IdCommit = unitOfWork.CommitRepository.GetCommitById(id);

                Console.WriteLine($"\nCommits mit ID {id}");
                Console.WriteLine($"----------------");
                Console.WriteLine($"{IdCommit.Developer.Name,-15}{IdCommit.Date.ToShortDateString(),-11}{IdCommit.FilesChanges,-13}{IdCommit.Insertions,-12}{IdCommit.Deletions,-11}");

                //Statistik der Commits der Developer
                var devStats = unitOfWork.DeveloperRepository.GetDevStats();

                Console.WriteLine("\nStatistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");
                Console.WriteLine($"{"Developer",-15}{"Commits",-11}{"FileChanges",-13}{"Insertions",-12}{"Deletions",-11}");

                foreach (var item in devStats)
                {
                    Console.WriteLine($"{item.Item1,-15}{item.Item2,-11}{item.Item3,-13}{item.Item4,-12}{item.Item5,-11}");
                }
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                var commits         = unitOfWork.CommitRepository.GetAllCommits();
                var commitsWithSums = commits
                                      .GroupBy(d => d.Developer.Name)
                                      .Select(g => new
                {
                    Name         = g.Key,
                    Commit       = g.Select(c => c.Developer.Commits).Count(),
                    FilesChanges = g.Sum(fc => fc.FilesChanges),
                    Insertions   = g.Sum(i => i.Insertions),
                    Deletions    = g.Sum(d => d.Deletions)
                }).OrderByDescending(o => o.Commit).ToList();

                Console.WriteLine("");
                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");

                foreach (var item in commitsWithSums)
                {
                    Console.WriteLine("Developer: {0} | Commits: {1} | FileChanges: {2} | Insertions: {3} | Deletions: {4}", item.Name, item.Commit, item.FilesChanges, item.Insertions, item.Deletions);
                }


                Console.WriteLine("");
                Console.WriteLine("Commit mit Id 4");
                Console.WriteLine("-----------------------------------");
                var commitByID = unitOfWork.CommitRepository.GetCommitById(4);

                Console.WriteLine("Developer: {0} | Date: {1} | FileChanges: {2} | Insertions: {3} | Deletions: {4}", commitByID.Developer.Name, commitByID.Date, commitByID.FilesChanges, commitByID.Insertions, commitByID.Deletions);

                Console.WriteLine("");
                Console.WriteLine("Commits der letzten 4 Wochen");
                Console.WriteLine("-----------------------------------");
                DateTime help        = commits.OrderBy(s => s.Date).Last().Date.AddDays(-28);
                var      lastCommits = commits.Where(c => c.Date >= help).OrderBy(s => s.Date);

                foreach (var item in lastCommits)
                {
                    Console.WriteLine("Developer: {0} | Date: {1} | FileChanges: {2} | Insertions: {3} | Deletions: {4}", item.Developer.Name, item.Date, item.FilesChanges, item.Insertions, item.Deletions);
                }
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }
        static void Main()
        {
            Console.WriteLine("Import der Commits in die Datenbank");
            using (IUnitOfWork unitOfWorkImport = new UnitOfWork())
            {
                Console.WriteLine("Datenbank löschen");
                unitOfWorkImport.DeleteDatabase();
                Console.WriteLine("Datenbank migrieren");
                unitOfWorkImport.MigrateDatabase();
                Console.WriteLine("Commits werden von commits.txt eingelesen");
                var commits = ImportController.ReadFromCsv();
                if (commits.Length == 0)
                {
                    Console.WriteLine("!!! Es wurden keine Commits eingelesen");
                    return;
                }
                Console.WriteLine(
                    $"  Es wurden {commits.Count()} Commits eingelesen, werden in Datenbank gespeichert ...");
                unitOfWorkImport.CommitRepository.AddRange(commits);
                int countDevelopers = commits.GroupBy(c => c.Developer).Count();
                int savedRows       = unitOfWorkImport.SaveChanges();
                Console.WriteLine(
                    $"{countDevelopers} Developers und {savedRows - countDevelopers} Commits wurden in Datenbank gespeichert!");
                Console.WriteLine();
                var csvCommits = commits.Select(c =>
                                                $"{c.Developer.Name};{c.Date};{c.Message};{c.HashCode};{c.FilesChanges};{c.Insertions};{c.Deletions}");
                File.WriteAllLines("commits.csv", csvCommits, Encoding.UTF8);


                var developerStatitic = commits
                                        .GroupBy(c => c.Developer)
                                        .Select(d => new
                {
                    Name        = d.Key.Name,
                    Commits     = d.Count(),
                    FileChanges = d.Sum(d => d.FilesChanges),
                    Insertions  = d.Sum(d => d.Insertions),
                    Deletions   = d.Sum(d => d.Deletions)
                })
                                        .OrderByDescending(_ => _.Commits);

                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");
                Console.WriteLine($"{"Developer",-20}{"Commits",-20}{"FileChanges",-20}{"Insertions",-20}{"Deletions"}");
                foreach (var developer in developerStatitic)
                {
                    Console.WriteLine($"{developer.Name, -20}{developer.Commits, -20}{developer.FileChanges, -20}{developer.Insertions, -20}{developer.Deletions, -20}");
                }
            }
            Console.WriteLine("Datenbankabfragen");
            Console.WriteLine("=================");
            using (IUnitOfWork unitOfWork = new UnitOfWork())
            {
                Console.WriteLine("Commits der letzten 4 Wochen");
                Console.WriteLine("----------------------------");
                Console.WriteLine($"{"Developer",-20}{"Date",-20}{"Commits",-20}{"FileChanges",-20}{"Insertions",-20}{"Deletions"}");
                var commits = unitOfWork.CommitRepository.GetCommitYoungerEqualThen(DateTime.Parse("2019, 03, 01"));
                foreach (var commit in commits)
                {
                    Console.WriteLine($"{commit.Name,-20}{commit.Date.ToShortDateString(),-20}{commit.FilesChanges,-20}{commit.Insertions,-20}{commit.Deletions,-20}");
                }
                Console.WriteLine();

                Console.WriteLine("Commmit mit Id 4");
                Console.WriteLine("----------------");
                var commitWithId4 = unitOfWork.CommitRepository.GetCommitWithId(4);
                Console.WriteLine($"{commitWithId4.Name,-20}{commitWithId4.Date,-20}{commitWithId4.FileChanges,-20}{commitWithId4.Insertions,-20}{commitWithId4.Deletions,-20}");
                Console.WriteLine();

                Console.WriteLine("Statistik der Commits der Developer");
                Console.WriteLine("-----------------------------------");
                Console.WriteLine($"{"Developer",-20}{"Commits",-20}{"FileChanges",-20}{"Insertions",-20}{"Deletions"}");

                var developers = unitOfWork.DeveloperRepository.GetDeveloperStatistik();
                foreach (var developer in developers)
                {
                    Console.WriteLine($"{developer.Name,-20}{developer.Commits,-20}{developer.FileChanges,-20}{developer.Insertions,-20}{developer.Deletions,-20}");
                }
            }
            Console.Write("Beenden mit Eingabetaste ...");
            Console.ReadLine();
        }