Пример #1
0
        public static List <CommittedBuildData> GetCommitedBuildList(ConnectionData connData, DatabaseList dbList)
        {
            string startingDb = connData.DatabaseName;
            string sql        = @"SELECT BuildFileName, count(ScriptFileName) as ScriptCount, commitDate, '' as [database] 
                    FROM SqlBuild_Logging GROUP BY BuildFileName,commitDate ORDER BY commitDate DESC";

            List <CommittedBuildData> data = new List <CommittedBuildData>();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (dbList[i].IsManuallyEntered)
                {
                    continue;
                }

                connData.DatabaseName = dbList[i].DatabaseName;
                SqlConnection conn = SqlSync.Connection.ConnectionHelper.GetConnection(connData);
                try
                {
                    SqlCommand cmd = new SqlCommand(sql, conn);
                    conn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        bool filled;
                        while (!reader.IsClosed)
                        {
                            CommittedBuildData dat = new CommittedBuildData();
                            filled = dat.Fill(reader, false);
                            if (filled)
                            {
                                dat.Database = dbList[i].DatabaseName;
                                data.Add(dat);
                            }
                        }
                        conn.Close();
                    }
                }
                catch (SqlException)
                {
                    //ignore
                }
                catch (Exception)
                {
                    return(new List <CommittedBuildData>());
                }
                finally
                {
                    connData.DatabaseName = startingDb;
                }
            }
            return(MergeServerResults(data));;
        }
Пример #2
0
        public static List <CommittedBuildData> GetCommitedBuildList(ConnectionData connData, string databaseName)
        {
            string startingDb = connData.DatabaseName;
            string sql        = @"SELECT BuildFileName, count(ScriptFileName) as ScriptCount, commitDate, '' as [database] 
                    FROM SqlBuild_Logging GROUP BY BuildFileName,commitDate ORDER BY commitDate DESC";

            List <CommittedBuildData> data = new List <CommittedBuildData>();

            connData.DatabaseName = databaseName;
            SqlConnection conn = SqlSync.Connection.ConnectionHelper.GetConnection(connData);

            try
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    bool filled;
                    while (!reader.IsClosed)
                    {
                        CommittedBuildData dat = new CommittedBuildData();
                        filled = dat.Fill(reader, false);
                        if (filled)
                        {
                            dat.Database = databaseName;
                            data.Add(dat);
                        }
                    }
                    conn.Close();
                }
            }
            catch (SqlException sExe)
            {
                log.LogError(sExe, $"Unable to get committed SBM package list from {connData.SQLServerName}.{databaseName}");
            }
            catch (Exception exe)
            {
                log.LogError(exe, $"Unable to get committed SBM package list from {connData.SQLServerName}.{databaseName}");
            }
            finally
            {
                connData.DatabaseName = startingDb;
            }

            return(data);
        }