예제 #1
0
        private IEnumerable <BuildJob> GetBuildJobs(SqlDataReader reader)
        {
            string filesURL = "https://apsimdev.apsim.info/APSIMClassicFiles/";

            while (reader.Read())
            {
                string baseFileName = Path.GetFileNameWithoutExtension((string)reader["PatchFileName"]);

                BuildJob buildJob = new BuildJob();
                buildJob.ID            = (int)reader["ID"];
                buildJob.PatchFileName = reader["PatchFileName"]?.ToString();
                buildJob.UserName      = (string)reader["UserName"];
                if (!Convert.IsDBNull(reader["RevisionNumber"]))
                {
                    buildJob.Revision = (int)reader["RevisionNumber"];
                }
                buildJob.StartTime      = (DateTime)reader["StartTime"];
                buildJob.TaskID         = (int)reader["BugID"];
                buildJob.Description    = reader["Description"].ToString();
                buildJob.JenkinsID      = (int)reader["JenkinsID"];
                buildJob.BuiltOnJenkins = buildJob.JenkinsID >= 0;
                buildJob.WindowsStatus  = (string)reader["Status"];
                // PullRequestID will be null for the old Bob builds.
                if (!Convert.IsDBNull(reader["PullRequestID"]))
                {
                    buildJob.PullRequestID = Convert.ToInt32(reader["PullRequestID"]);
                }

                if (!Convert.IsDBNull(reader["FinishTime"]))
                {
                    buildJob.Duration = 0;
                    DateTime finishTime = (DateTime)reader["FinishTime"];
                    buildJob.Duration = Convert.ToInt32((finishTime - buildJob.StartTime).TotalMinutes);
                }

                if (buildJob.BuiltOnJenkins /*&& buildJob.Revision != 0*/)
                {
                    buildJob.PatchFileURL        = filesURL + buildJob.PullRequestID + ".zip";
                    buildJob.PatchFileNameShort  = buildJob.PatchFileName;
                    buildJob.WindowsDetailsURL   = $"http://apsimdev.apsim.info:8080/jenkins/job/PullRequestClassic/{buildJob.JenkinsID}/consoleText";
                    buildJob.XmlUrl              = filesURL + buildJob.PullRequestID + ".xml";
                    buildJob.PatchFileURL        = $"https://github.com/APSIMInitiative/APSIMClassic/pull/{buildJob.PullRequestID}";
                    buildJob.IssueURL            = $"https://github.com/APSIMInitiative/APSIMClassic/issues/{buildJob.TaskID}";
                    buildJob.WindowsBinariesURL  = filesURL + buildJob.PullRequestID + ".binaries.zip";
                    buildJob.WindowsBuildTreeURL = filesURL + buildJob.PullRequestID + ".buildtree.zip";
                }
                else
                {
                    buildJob.PatchFileURL        = filesURL + buildJob.PatchFileName;
                    buildJob.PatchFileNameShort  = GetShortPatchFileName((string)reader["PatchFileName"]);
                    buildJob.WindowsDetailsURL   = filesURL + baseFileName + ".txt";
                    buildJob.XmlUrl              = Path.ChangeExtension(buildJob.PatchFileURL, ".xml");
                    buildJob.IssueURL            = $"http://apsimdev.apsim.info/BugTracker/edit_bug.aspx?id={buildJob.TaskID}";
                    buildJob.WindowsBinariesURL  = filesURL + baseFileName + ".binaries.zip";
                    buildJob.WindowsBuildTreeURL = filesURL + baseFileName + ".buildtree.zip";
                }

                if (!Convert.IsDBNull(reader["NumDiffs"]))
                {
                    buildJob.WindowsNumDiffs = (int)reader["NumDiffs"];
                }

                if (buildJob.WindowsNumDiffs > 0)
                {
                    buildJob.WindowsDiffsURL = filesURL + buildJob.PullRequestID + ".diffs.zip";
                }

                string versionString;
                if (buildJob.Revision < 3855)
                {
                    versionString = "Apsim7.7-r";
                }
                else if (buildJob.Revision < 4035)
                {
                    versionString = "Apsim7.8-r";
                }
                else if (buildJob.Revision < 4133)
                {
                    versionString = "Apsim7.9-r";
                }
                else
                {
                    versionString = "Apsim7.10-r";
                }

                buildJob.VersionString = versionString + buildJob.Revision;

                if (buildJob.WindowsNumDiffs == 0 && buildJob.WindowsStatus == "Pass")
                {
                    if (buildJob.BuiltOnJenkins)
                    {
                        if (buildJob.Revision != 0)
                        {
                            // we no longer provide Win32 SFX.
                            buildJob.Win32SFXURL             = null;
                            buildJob.Win64SFXURL             = filesURL + buildJob.PatchFileName + ".binaries.WINDOWS.X86_64.exe";
                            buildJob.WindowsInstallerFullURL = filesURL + buildJob.PatchFileName + ".bootleg.exe";
                            buildJob.WindowsInstallerURL     = filesURL + buildJob.PatchFileName + ".apsimsetup.exe";
                        }
                    }
                    else
                    {
                        buildJob.Win32SFXURL             = filesURL + versionString + buildJob.Revision + ".binaries.WINDOWS.INTEL.exe";
                        buildJob.Win64SFXURL             = filesURL + versionString + buildJob.Revision + ".binaries.WINDOWS.X86_64.exe";
                        buildJob.WindowsInstallerFullURL = filesURL + baseFileName + ".bootleg.exe";
                        buildJob.WindowsInstallerURL     = filesURL + baseFileName + ".apsimsetup.exe";
                    }
                }

                if (buildJob.LinuxStatus == "Pass")
                {
                    buildJob.LinuxBinariesURL = filesURL + versionString + buildJob.Revision + ".LINUX.X86_64.exe";
                    buildJob.LinuxDetailsURL  = filesURL + versionString + buildJob.Revision + ".linux.txt";
                    buildJob.LinuxDiffsURL    = filesURL + versionString + buildJob.Revision + ".linux.txt";
                }

                if (!Convert.IsDBNull(reader["LinuxNumDiffs"]))
                {
                    buildJob.LinuxNumDiffs = (int)reader["LinuxNumDiffs"];
                }
                buildJob.LinuxStatus = (string)reader["LinuxStatus"];

                yield return(buildJob);
            }
        }
        /// <summary>Return a list of build jobs.</summary>
        public BuildJob[] GetJobs(int NumRows, bool PassOnly)
        {
            string sql;
            if (PassOnly)
                sql = "SELECT TOP (" + NumRows.ToString() + ") * " +
                         " FROM Classic " +
                         " WHERE Status = 'Pass'" +
                         " ORDER BY ID DESC";
            else
                sql = "SELECT TOP (" + NumRows.ToString() + ") * " +
                         " FROM Classic " +
                         " ORDER BY ID DESC";

            string filesURL = "http://bob.apsim.info/files/";

            List<BuildJob> buildJobs = new List<BuildJob>();
            using (SqlConnection connection = Open())
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            string baseFileName = Path.GetFileNameWithoutExtension((string)reader["PatchFileName"]);

                            BuildJob buildJob = new BuildJob();
                            buildJob.ID = (int)reader["ID"];
                            buildJob.UserName = (string)reader["UserName"];
                            if (!Convert.IsDBNull(reader["RevisionNumber"]))
                                buildJob.Revision = (int)reader["RevisionNumber"];
                            buildJob.StartTime = (DateTime)reader["StartTime"];
                            buildJob.TaskID = (int)reader["BugID"];
                            buildJob.Description = reader["Description"].ToString();

                            if (!Convert.IsDBNull(reader["FinishTime"]))
                            {
                                buildJob.Duration = 0;
                                DateTime finishTime = (DateTime)reader["FinishTime"];
                                buildJob.Duration = Convert.ToInt32((finishTime - buildJob.StartTime).TotalMinutes);
                            }

                            buildJob.PatchFileURL = "http://www.apsim.info/APSIM.Builds.Portal/Files/" + baseFileName + ".zip";


                            if (!Convert.IsDBNull(reader["NumDiffs"]))
                                buildJob.WindowsNumDiffs = (int)reader["NumDiffs"];

                            if (buildJob.WindowsNumDiffs > 0)
                                buildJob.WindowsDiffsURL = filesURL + baseFileName + ".diffs.zip";

                            buildJob.WindowsBinariesURL = filesURL + baseFileName + ".binaries.zip";
                            buildJob.WindowsBuildTreeURL = filesURL + baseFileName + ".buildtree.zip";
                            buildJob.WindowsDetailsURL = filesURL + baseFileName + ".txt";

                            if (buildJob.WindowsNumDiffs == 0)
                            {
                                buildJob.WindowsInstallerFullURL = filesURL + baseFileName + ".bootleg.exe"; ;
                                buildJob.WindowsInstallerURL = filesURL + baseFileName + ".apsimsetup.exe";
                                buildJob.Win32SFXURL = filesURL + "Apsim7.8-r" + buildJob.Revision + ".binaries.WINDOWS.INTEL.exe";
                                buildJob.Win64SFXURL = filesURL + "Apsim7.8-r" + buildJob.Revision + ".binaries.WINDOWS.X86_64.exe";
                            }

                            buildJob.WindowsStatus = (string)reader["Status"];

                            buildJob.LinuxBinariesURL = filesURL + "Apsim7.8-r" + buildJob.Revision + ".LINUX.X86_64.exe";
                            buildJob.LinuxDetailsURL = filesURL + "Apsim7.8-r" + buildJob.Revision + ".linux.txt";
                            buildJob.LinuxDiffsURL = filesURL + "Apsim7.8-r" + buildJob.Revision + ".linux.txt";
                            if (!Convert.IsDBNull(reader["LinuxNumDiffs"]))
                                buildJob.LinuxNumDiffs = (int)reader["LinuxNumDiffs"];
                            buildJob.LinuxStatus = (string)reader["LinuxStatus"];

                            buildJobs.Add(buildJob);
                        }
                    }
                }
            }
            return buildJobs.ToArray();
        }
예제 #3
0
        /// <summary>Return a list of build jobs.</summary>
        public BuildJob[] GetJobs(int NumRows, bool PassOnly)
        {
            string sql;

            if (PassOnly)
            {
                sql = "SELECT TOP (" + NumRows.ToString() + ") * " +
                      " FROM Classic " +
                      " WHERE Status = 'Pass'" +
                      " ORDER BY ID DESC";
            }
            else
            {
                sql = "SELECT TOP (" + NumRows.ToString() + ") * " +
                      " FROM Classic " +
                      " ORDER BY ID DESC";
            }

            string filesURL = "http://bob.apsim.info/files/";

            List <BuildJob> buildJobs = new List <BuildJob>();

            using (SqlConnection connection = Open())
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            string baseFileName = Path.GetFileNameWithoutExtension((string)reader["PatchFileName"]);

                            BuildJob buildJob = new BuildJob();
                            buildJob.ID       = (int)reader["ID"];
                            buildJob.UserName = (string)reader["UserName"];
                            if (!Convert.IsDBNull(reader["RevisionNumber"]))
                            {
                                buildJob.Revision = (int)reader["RevisionNumber"];
                            }
                            buildJob.StartTime   = (DateTime)reader["StartTime"];
                            buildJob.TaskID      = (int)reader["BugID"];
                            buildJob.Description = reader["Description"].ToString();

                            if (!Convert.IsDBNull(reader["FinishTime"]))
                            {
                                buildJob.Duration = 0;
                                DateTime finishTime = (DateTime)reader["FinishTime"];
                                buildJob.Duration = Convert.ToInt32((finishTime - buildJob.StartTime).TotalMinutes);
                            }

                            buildJob.PatchFileURL = "http://www.apsim.info/APSIM.Builds.Portal/Files/" + baseFileName + ".zip";


                            if (!Convert.IsDBNull(reader["NumDiffs"]))
                            {
                                buildJob.WindowsNumDiffs = (int)reader["NumDiffs"];
                            }

                            if (buildJob.WindowsNumDiffs > 0)
                            {
                                buildJob.WindowsDiffsURL = filesURL + baseFileName + ".diffs.zip";
                            }

                            buildJob.WindowsBinariesURL  = filesURL + baseFileName + ".binaries.zip";
                            buildJob.WindowsBuildTreeURL = filesURL + baseFileName + ".buildtree.zip";
                            buildJob.WindowsDetailsURL   = filesURL + baseFileName + ".txt";

                            string versionString;
                            if (buildJob.Revision < 3855)
                            {
                                versionString = "Apsim7.7-r";
                            }
                            else if (buildJob.Revision < 4035)
                            {
                                versionString = "Apsim7.8-r";
                            }
                            else if (buildJob.Revision < 4133)
                            {
                                versionString = "Apsim7.9-r";
                            }
                            else
                            {
                                versionString = "Apsim7.10-r";
                            }

                            if (buildJob.WindowsNumDiffs == 0)
                            {
                                buildJob.WindowsInstallerFullURL = filesURL + baseFileName + ".bootleg.exe";;
                                buildJob.WindowsInstallerURL     = filesURL + baseFileName + ".apsimsetup.exe";
                                buildJob.Win32SFXURL             = filesURL + versionString + buildJob.Revision + ".binaries.WINDOWS.INTEL.exe";
                                buildJob.Win64SFXURL             = filesURL + versionString + buildJob.Revision + ".binaries.WINDOWS.X86_64.exe";
                            }

                            buildJob.WindowsStatus = (string)reader["Status"];

                            buildJob.LinuxBinariesURL = filesURL + versionString + buildJob.Revision + ".LINUX.X86_64.exe";
                            buildJob.LinuxDetailsURL  = filesURL + versionString + buildJob.Revision + ".linux.txt";
                            buildJob.LinuxDiffsURL    = filesURL + versionString + buildJob.Revision + ".linux.txt";
                            if (!Convert.IsDBNull(reader["LinuxNumDiffs"]))
                            {
                                buildJob.LinuxNumDiffs = (int)reader["LinuxNumDiffs"];
                            }
                            buildJob.LinuxStatus = (string)reader["LinuxStatus"];

                            buildJobs.Add(buildJob);
                        }
                    }
                }
            }
            return(buildJobs.ToArray());
        }