示例#1
0
        //-------------------------------------------------------------------------------------------------//

        public ResultReport RetrieveResult(int experimentId, string sbName)
        {
            ResultReport resultReport = null;

            //
            // Try loading the experiment result from file
            //
            resultReport = this.experimentResults.Load(experimentId, sbName);
            if (resultReport.statusCode == (int)StatusCodes.Unknown)
            {
                //
                // No results found for the experiment, check the queue table to see if it ever existed
                //
                StatusCodes statusCode = this.experimentQueue.GetExperimentStatus(experimentId, sbName);
                resultReport.statusCode = (int)statusCode;
            }

            return(resultReport);
        }
示例#2
0
        //---------------------------------------------------------------------------------------//

        public ResultReport Load(int experimentId, string sbName)
        {
            const string STRLOG_MethodName = "Load";

            string logMessage = STRLOG_experimentId + experimentId.ToString() +
                                Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + sbName + Logfile.STRLOG_Quote;

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);


            //
            // Create a ResultReport to return (not nullable)
            //
            ResultReport resultReport       = new ResultReport();
            string       xmlWarningMessages = string.Empty;

            //
            // Catch all exceptions so that a valid result report can be returned
            //
            lock (this.resultsLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveResults, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_ExperimentId, experimentId));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_SbName, sbName));

                    try
                    {
                        this.sqlConnection.Open();

                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        while (sqlDataReader.Read() == true)
                        {
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_Status]) != System.DBNull.Value)
                            {
                                StatusCodes status = (StatusCodes)Enum.Parse(typeof(StatusCodes), (string)sdrObject);
                                resultReport.statusCode = (int)status;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_XmlExperimentResult]) != System.DBNull.Value)
                            {
                                resultReport.experimentResults = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_XmlResultExtension]) != System.DBNull.Value)
                            {
                                resultReport.xmlResultExtension = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_XmlBlobExtension]) != System.DBNull.Value)
                            {
                                resultReport.xmlBlobExtension = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_WarningMessages]) != System.DBNull.Value)
                            {
                                xmlWarningMessages = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_ErrorMessage]) != System.DBNull.Value)
                            {
                                resultReport.errorMessage = (string)sdrObject;
                            }
                        }
                        sqlDataReader.Close();
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }

                    //
                    // Convert warning messages from XML format to string array
                    //
                    if (xmlWarningMessages != null && xmlWarningMessages.Length > 0)
                    {
                        try
                        {
                            XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(xmlWarningMessages);
                            XmlNode     xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_warningMessages);
                            resultReport.warningMessages = XmlUtilities.GetXmlValues(xmlRootNode, STRXML_warningMessage, true);
                        }
                        catch
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Place the exception message in the result report
                    resultReport.errorMessage = ex.Message;

                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_statusCode + ((StatusCodes)resultReport.statusCode).ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(resultReport);
        }
示例#3
0
        //-------------------------------------------------------------------------------------------------//

        public LabExperimentStatus GetExperimentStatus(int experimentId, string sbName)
        {
            const string STRLOG_MethodName = "GetExperimentStatus";

            LabExperimentStatus labExperimentStatus = null;

            lock (this.managerLock)
            {
                string logMessage = STRLOG_experimentId + experimentId.ToString() +
                                    Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + sbName + Logfile.STRLOG_Quote;

                Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

                labExperimentStatus = new LabExperimentStatus();
                logMessage          = string.Empty;

                //
                // Get the status of the experiment from the queue table
                //
                StatusCodes status = this.experimentQueue.GetExperimentStatus(experimentId, sbName);
                if (status == StatusCodes.Unknown)
                {
                    //
                    // The experiment never existed
                    //
                }
                else if (status == StatusCodes.Waiting)
                {
                    //
                    // Experiment is waiting on the queue
                    //
                    QueuedExperimentInfo queuedExperimentInfo = this.experimentQueue.GetQueuedExperimentInfo(experimentId, sbName);
                    if (queuedExperimentInfo != null && queuedExperimentInfo.position > 0)
                    {
                        // Set the experiment status
                        labExperimentStatus.statusReport.statusCode = (int)queuedExperimentInfo.status;

                        // Get the queue position and wait time
                        labExperimentStatus.statusReport.wait =
                            new WaitEstimate(queuedExperimentInfo.position, queuedExperimentInfo.waitTime);

                        // Add in time for any currently running experiment ????
                        labExperimentStatus.statusReport.wait.estWait += GetMinRemainingRuntime();

                        // Get the time it takes to run the experiment
                        labExperimentStatus.statusReport.estRuntime          = queuedExperimentInfo.estExecutionTime;
                        labExperimentStatus.statusReport.estRemainingRuntime = queuedExperimentInfo.estExecutionTime;

                        logMessage =
                            Logfile.STRLOG_Spacer + STRLOG_QueuePosition + labExperimentStatus.statusReport.wait.effectiveQueueLength.ToString() +
                            Logfile.STRLOG_Spacer + STRLOG_QueueWaitTime + labExperimentStatus.statusReport.wait.estWait.ToString() +
                            Logfile.STRLOG_Spacer + STRLOG_estRuntime + labExperimentStatus.statusReport.estRuntime.ToString() +
                            Logfile.STRLOG_Spacer + STRLOG_remainingRuntime + labExperimentStatus.statusReport.estRemainingRuntime.ToString();
                    }
                }
                else if (status == StatusCodes.Running)
                {
                    //
                    // Experiment is currently running
                    //
                    labExperimentStatus = this.GetLabExperimentStatus(experimentId, sbName);
                }
                else
                {
                    //
                    // Experiment has completed, cancelled or failed
                    //
                    ResultReport resultReport = this.experimentResults.Load(experimentId, sbName);

                    // Set the experiment status
                    labExperimentStatus.statusReport.statusCode = resultReport.statusCode;
                }

                logMessage = STRLOG_statusCode + ((StatusCodes)labExperimentStatus.statusReport.statusCode).ToString() +
                             Logfile.STRLOG_Spacer + logMessage;

                Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);
            }

            return(labExperimentStatus);
        }