示例#1
0
 public void FillRepoDataBaseList()
 {
     // Alle Infos aus der db besorgen
     // Ist das Repo neu ?
     // Hat sich das Repo vberändert / gelöscht
     try
     {
         connection.Open();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "SELECT * FROM repositories";
         var reader = command.ExecuteReader();
         repoDataBaseList = new List <RepositoryInfoForDataBase>();
         while (reader.Read())
         {
             RepositoryInfoForDataBase repoInfoObj = new RepositoryInfoForDataBase();
             repoInfoObj.RepoID             = reader.GetValue(0).ToString();
             repoInfoObj.NameOfRepository   = reader.GetValue(1).ToString();
             repoInfoObj.Description        = reader.GetValue(2).ToString();
             repoInfoObj.LinkFromReposetory = reader.GetValue(3).ToString();
             repoInfoObj.Commits            = GetCommitsOfRepo(Convert.ToInt32(repoInfoObj.RepoID));
             repoDataBaseList.Add(repoInfoObj);
         }
     }
     catch (Exception e)
     {
     }
     CheckIfRepoIsNew();
 }
示例#2
0
 public void RemoveOldRepository(RepositoryInfoForDataBase repInfo)
 {
     try
     {
         connection.Open();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "DELETE  FROM `commits` WHERE RepoID = '" + repInfo.RepoID + "'";
         command.ExecuteNonQuery();
         command.CommandText = "DELETE  FROM `repositories` WHERE RepoID = '" + repInfo.RepoID + "'";
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         Logger.LogMessage(e.ToString(), "AddNewGitHubEntrysToDB", "Fehler beim Hinzufügen von neuen Datensätzen in die DB");
         connection.Close();
     }
 }
示例#3
0
        private void CheckForChangesInRepo(RepositoryInfo repo, RepositoryInfoForDataBase repoInfoDataBase)
        {
            if (repo.Description != repoInfoDataBase.Description)
            {
                try
                {
                    connection.Open();
                    MySqlCommand command = connection.CreateCommand();
                    command.CommandText = "UPDATE  `repositories` SET RepoDescription = '" + repo.Description + "' WHERE RepoID = '" + repo.RepoID + "'";
                    command.ExecuteNonQuery();
                    connection.Close();
                }

                catch (Exception e)

                {
                    Console.WriteLine(e);
                    Logger.LogMessage(e.ToString(), "CheckForNewCommitGitHubEntrys", "Verbindung zu der DB konnte nicht aufgebaut werden");
                }
                repoChangesCounter++;
            }
            if (repo.LinkFromReposetory != repoInfoDataBase.LinkFromReposetory)
            {
                try
                {
                    connection.Open();
                    MySqlCommand command = connection.CreateCommand();
                    command.CommandText = "UPDATE  `repositories` SET RepoLink = '" + repo.LinkFromReposetory + "' WHERE RepoID = '" + repo.RepoID + "'";
                    command.ExecuteNonQuery();
                    connection.Close();
                }

                catch (Exception e)

                {
                    Console.WriteLine(e);
                    Logger.LogMessage(e.ToString(), "CheckForNewCommitGitHubEntrys", "Verbindung zu der DB konnte nicht aufgebaut werden");
                }
                repoChangesCounter++;
            }
        }