Esempio n. 1
0
        //---------------------------------------------------------------------------------------//

        /// <summary>
        /// Update the status of the specified experiment.
        /// </summary>
        /// <returns></returns>
        public bool UpdateStatus(int experimentId, string sbName, StatusCodes statusCode)
        {
            const string STRLOG_MethodName = "UpdateStatus";

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

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            //
            // Catch all exceptions thrown and return false if an error occurred.
            //
            bool success = false;

            lock (this.queueLock)
            {
                try
                {
                    //
                    // Update queued experiment status
                    //
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_UpdateQueueStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

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

                    try
                    {
                        this.sqlConnection.Open();

                        success = (sqlCommand.ExecuteNonQuery() != 0);
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_success + success.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(success);
        }
Esempio n. 2
0
        private void BuildOrigPage()
        {
            AccountProperty property = new AccountProperty(appEnv.GetConnection());

            DataRow dr = dt.Rows[0];

            lbContentID.Text = dr["ContentID"].ToString();
            lbVersion.Text   = dr["Version"].ToString();
            tbHeadline.Text  = dr["Headline"].ToString();
            tbSource.Text    = dr["Source"].ToString();
            lbBylineNum.Text = dr["Byline"].ToString();
            lbByline.Text    = property.GetValue(Convert.ToInt32(dr["Byline"]),
                                                 "UserName").Trim();
            tbTeaser.Text    = dr["Teaser"].ToString();
            tbBody.Text      = dr["Body"].ToString();
            tbTagline.Text   = dr["Tagline"].ToString();
            lbEditorNum.Text = dr["Editor"].ToString();
            lbEditor.Text    = property.GetValue(Convert.ToInt32(dr["Editor"]),
                                                 "UserName").Trim();
            lbApproverNum.Text = dr["Approver"].ToString();
            lbApprover.Text    = property.GetValue(Convert.ToInt32(dr["Approver"]),
                                                   "UserName").Trim();
            lbStatusNum.Text    = dr["Status"].ToString();
            lbStatus.Text       = StatusCodes.ToString(Convert.ToInt32(dr["Status"]));
            lbModifiedDate.Text = dr["ModifiedDate"].ToString();
            lbCreationDate.Text = dr["CreationDate"].ToString();
        }
        internal async Task SendCloseHandshakeAsync(Stream tcpStream, StatusCodes statusCode)
        {
            var closeFrameBodyCode = BitConverter.GetBytes((ushort)statusCode);
            var reason             = Encoding.UTF8.GetBytes(statusCode.ToString());

            await ComposeFrameAndSendAsync(tcpStream, closeFrameBodyCode.Concat(reason).ToArray(),
                                           FrameType.CloseControlFrame);
        }
        internal async Task SendCloseHandshakeAsync(
            StatusCodes statusCode)
        {
            var closeFrameBodyCode = BitConverter.GetBytes((ushort)statusCode);
            var reason             = Encoding.UTF8.GetBytes(statusCode.ToString());

            await ComposeFrameAndSendAsync(
                closeFrameBodyCode.Concat(reason).ToArray(),
                OpcodeKind.Close,
                FragmentKind.None,
                default);
        }
        private void BuildPage(int cver)
        {
            AccountProperty property = new AccountProperty(appEnv.GetConnection());

            DataRow dr = dt.Rows[cver];

            lbContentID.Text = dr["ContentID"].ToString();
            lbVersion.Text   = dr["Version"].ToString();
            lbHeadline.Text  = dr["Headline"].ToString();
            lbSource.Text    = dr["Source"].ToString() + "&nbsp;";
            lbByline.Text    = property.GetValue(Convert.ToInt32(dr["Byline"]),
                                                 "UserName").Trim();
            lbTeaser.Text  = dr["Teaser"].ToString() + "&nbsp;";
            lbBody.Text    = dr["Body"].ToString();
            lbTagline.Text = dr["Tagline"].ToString() + "&nbsp;";
            lbStatus.Text  = StatusCodes.ToString(Convert.ToInt32(dr["Status"]));
            lbEditor.Text  = property.GetValue(Convert.ToInt32(dr["Editor"]),
                                               "UserName").Trim();
            lbApprover.Text = property.GetValue(Convert.ToInt32(dr["Approver"]),
                                                "UserName").Trim();
            lbUpdateUser.Text = property.GetValue(Convert.ToInt32(dr["UpdateUserID"]),
                                                  "UserName").Trim();
            lbModifiedDate.Text = dr["ModifiedDate"].ToString();
            lbCreationDate.Text = dr["CreationDate"].ToString();

            if (cver > 0)
            {
                bnNext.Enabled = true;
                int tmp = cver - 1;
                bnNext.CommandArgument = tmp.ToString();
            }
            else
            {
                bnNext.Enabled = false;
            }

            if (cver < dt.Rows.Count - 1)
            {
                bnPrevious.Enabled = true;
                int tmp = cver + 1;
                bnPrevious.CommandArgument = tmp.ToString();
            }
            else
            {
                bnPrevious.Enabled = false;
            }

            bnUpdate.Visible = (cver == 0 && StatusCodes.isCreating(dr["Status"].ToString()));
            bnRemove.Visible = (cver == 0 && StatusCodes.isCreating(dr["Status"].ToString()));
        }
        //-------------------------------------------------------------------------------------------------//

        public LabStatus GetLabStatus()
        {
            const string STRLOG_MethodName = "GetLabStatus";

            string logMessage = STRLOG_unitId + unitId.ToString();

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            LabStatus labStatus;

            //
            // Check if there is an equipment service
            //
            if (this.equipmentServiceProxy == null)
            {
                //
                // No equipment service, just get the status of this engine
                //
                StatusCodes status = (this.IsRunningExperiment == true) ? StatusCodes.Running : StatusCodes.Ready;
                labStatus = new LabStatus(true, status.ToString());
            }
            else
            {
                //
                // Get the status of the equipment service
                //
                try
                {
                    LabEquipmentStatus labEquipmentStatus = this.equipmentServiceProxy.GetLabEquipmentStatus();
                    labStatus = new LabStatus(labEquipmentStatus.online, labEquipmentStatus.statusMessage);
                }
                catch (Exception ex)
                {
                    labStatus = new LabStatus(false, ex.Message);
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_online + labStatus.online.ToString() +
                         Logfile.STRLOG_Spacer + STRLOG_labStatusMessage + Logfile.STRLOG_Quote + labStatus.labStatusMessage + Logfile.STRLOG_Quote;

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(labStatus);
        }
Esempio n. 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            account = new Account(appEnv.GetConnection());
            content = new MyContent(appEnv.GetConnection());
            notes   = new ContentNotes(appEnv.GetConnection());

            DataTable dt;
            int       accountNo = account.GetAccountID(User.Identity.Name);

            if (accountNo == 1)  // Admin sees all
            {
                dt = content.GetHeadlines();
            }
            else
            {
                dt = content.GetHeadlinesForAuth(accountNo);
            }

            LiteralControl lit;
            TableCell      cell;
            int            prv = -1;
            int            cur;

            foreach (DataRow dr in dt.Rows)
            {
                cur = Convert.ToInt32(dr["ContentID"]);

                if (cur != prv)
                {
                    prv = cur;

                    if (IsTypeRequested(dr["Status"].ToString()))
                    {
                        TableRow row = new TableRow();
                        tblView.Rows.Add(row);

                        lit  = new LiteralControl(dr["ContentID"].ToString());
                        cell = new TableCell();
                        cell.Controls.Add(lit);
                        cell.HorizontalAlign = HorizontalAlign.Center;
                        row.Cells.Add(cell);

                        lit  = new LiteralControl(dr["Version"].ToString());
                        cell = new TableCell();
                        cell.Controls.Add(lit);
                        cell.HorizontalAlign = HorizontalAlign.Center;
                        row.Cells.Add(cell);

                        lit  = new LiteralControl(dr["Headline"].ToString());
                        cell = new TableCell();
                        cell.Controls.Add(lit);
                        row.Cells.Add(cell);

                        lit = new LiteralControl(StatusCodes.ToString(
                                                     Convert.ToInt32(dr["Status"])));
                        cell                 = new TableCell();
                        cell.Font.Size       = new FontUnit(FontSize.XSmall);
                        cell.HorizontalAlign = HorizontalAlign.Center;
                        cell.Controls.Add(lit);
                        row.Cells.Add(cell);

                        BuildImageButton(row, "AutView.aspx?ContentID=" + dr["ContentID"].ToString(), -1);
                        BuildImageButton(row, "../Note/NoteList.aspx?ContentID=" + dr["ContentID"].ToString() + "&Origin=Author",
                                         notes.CountNotesForID(Convert.ToInt32(dr["ContentID"])));

                        if (StatusCodes.isCreating(dr["Status"].ToString()))
                        {
                            BuildImageButton(row, "AutUpdate.aspx?ContentID=" + dr["ContentID"].ToString(), -1);
                            BuildImageButton(row, "AutSubmit.aspx?ContentID=" + dr["ContentID"].ToString(), -1);
                            BuildImageButton(row, "AutRemove.aspx?ContentID=" + dr["ContentID"].ToString(), -1);
                        }
                        else
                        {
                            BuildImageButton(row, null, -1);
                            BuildImageButton(row, null, -1);
                            BuildImageButton(row, null, -1);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        //---------------------------------------------------------------------------------------//

        public bool Save(ExperimentInfo experimentInfo)
        {
            const string STRLOG_MethodName = "Save";

            string logMessage = null;

            if (experimentInfo != null)
            {
                logMessage = STRLOG_experimentId + experimentInfo.experimentId.ToString() +
                             Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + experimentInfo.sbName + Logfile.STRLOG_Quote;
            }

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            //
            // Catch all exceptions thrown and return false if an error occurred.
            //
            bool success = false;

            lock (this.resultsLock)
            {
                try
                {
                    //
                    // Check that the experiment info exists
                    //
                    if (experimentInfo == null)
                    {
                        throw new ArgumentNullException(STRERR_ExperimentInfoIsNull);
                    }

                    //
                    // Check for null strings and change to empty strings if necessary
                    //
                    string errorMessage       = (experimentInfo.resultReport.errorMessage == null) ? string.Empty : experimentInfo.resultReport.errorMessage;
                    string xmlBlobExtension   = (experimentInfo.resultReport.xmlBlobExtension == null) ? string.Empty : experimentInfo.resultReport.xmlBlobExtension;
                    string xmlResultExtension = (experimentInfo.resultReport.xmlResultExtension == null) ? string.Empty : experimentInfo.resultReport.xmlResultExtension;
                    string experimentResults  = (experimentInfo.resultReport.experimentResults == null) ? string.Empty : experimentInfo.resultReport.experimentResults;
                    string userGroup          = (experimentInfo.userGroup == null) ? string.Empty : experimentInfo.userGroup;

                    //
                    // Convert warning messages to XML format
                    //
                    string xmlWarningMessages = string.Empty;
                    if (experimentInfo.resultReport.warningMessages != null)
                    {
                        XmlDocument xmlDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_WarningMessagesTemplate);
                        XmlNode     xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_warningMessages);
                        XmlUtilities.SetXmlValues(xmlRootNode, STRXML_warningMessage, experimentInfo.resultReport.warningMessages, true);
                        xmlWarningMessages = xmlDocument.OuterXml;
                    }

                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_StoreResults, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_ExperimentId, experimentInfo.experimentId));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_SbName, experimentInfo.sbName));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_UserGroup, userGroup));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_PriorityHint, experimentInfo.priorityHint));
                    StatusCodes status = (StatusCodes)experimentInfo.resultReport.statusCode;
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_Status, status.ToString()));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_XmlExperimentResult, experimentResults));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_XmlResultExtension, xmlResultExtension));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_XmlBlobExtension, xmlBlobExtension));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_WarningMessages, xmlWarningMessages));
                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_ErrorMessage, errorMessage));

                    try
                    {
                        this.sqlConnection.Open();

                        if (sqlCommand.ExecuteNonQuery() == 0)
                        {
                            throw new Exception(STRERR_FailedToSaveResults);
                        }
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }

                    // Information saved successfully
                    success = true;
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_success + success.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(success);
        }
Esempio n. 9
0
        public static ByteArrayPart GetReason(this StatusCodes statusCode)
        {
            switch (statusCode)
            {
            case StatusCodes.Trying:
                return(Trying);

            case StatusCodes.Ringing:
                return(Ringing);

            case StatusCodes.CallIsBeingForwarded:
                return(CallIsBeingForwarded);

            case StatusCodes.Queued:
                return(Queued);

            case StatusCodes.SessionProgress:
                return(SessionProgress);

            case StatusCodes.OK:
                return(OK);

            case StatusCodes.MultipleChoices:
                return(MultipleChoices);

            case StatusCodes.MovedPermanently:
                return(MovedPermanently);

            case StatusCodes.MovedTemporarily:
                return(MovedTemporarily);

            case StatusCodes.UseProxy:
                return(UseProxy);

            case StatusCodes.AlternativeService:
                return(AlternativeService);

            case StatusCodes.BadRequest:
                return(BadRequest);

            case StatusCodes.Unauthorized:
                return(Unauthorized);

            case StatusCodes.PaymentRequired:
                return(PaymentRequired);

            case StatusCodes.Forbidden:
                return(Forbidden);

            case StatusCodes.NotFound:
                return(NotFound);

            case StatusCodes.MethodNotAllowed:
                return(MethodNotAllowed);

            case StatusCodes.NotAcceptable:
                return(NotAcceptable);

            case StatusCodes.ProxyAuthenticationRequired:
                return(ProxyAuthenticationRequired);

            case StatusCodes.RequestTimeout:
                return(RequestTimeout);

            case StatusCodes.Gone:
                return(Gone);

            case StatusCodes.RequestEntityTooLarge:
                return(RequestEntityTooLarge);

            case StatusCodes.RequestURITooLarge:
                return(RequestURITooLarge);

            case StatusCodes.UnsupportedMediaType:
                return(UnsupportedMediaType);

            case StatusCodes.UnsupportedURIScheme:
                return(UnsupportedURIScheme);

            case StatusCodes.BadExtension:
                return(BadExtension);

            case StatusCodes.ExtensionRequired:
                return(ExtensionRequired);

            case StatusCodes.IntervalTooBrief:
                return(IntervalTooBrief);

            case StatusCodes.TemporarilyUnavailable:
                return(TemporarilyUnavailable);

            case StatusCodes.CallLegTransactionDoesNotExist:
                return(CallLegTransactionDoesNotExist);

            case StatusCodes.LoopDetected:
                return(LoopDetected);

            case StatusCodes.TooManyHops:
                return(TooManyHops);

            case StatusCodes.AddressIncomplete:
                return(AddressIncomplete);

            case StatusCodes.Ambiguous:
                return(Ambiguous);

            case StatusCodes.BusyHere:
                return(BusyHere);

            case StatusCodes.RequestTerminated:
                return(RequestTerminated);

            case StatusCodes.NotAcceptableHere:
                return(NotAcceptableHere);

            case StatusCodes.RequestPending:
                return(RequestPending);

            case StatusCodes.Undecipherable:
                return(Undecipherable);

            case StatusCodes.InternalServerError:
                return(InternalServerError);

            case StatusCodes.NotImplemented:
                return(NotImplemented);

            case StatusCodes.BadGateway:
                return(BadGateway);

            case StatusCodes.ServiceUnavailable:
                return(ServiceUnavailable);

            case StatusCodes.ServerTimeOut:
                return(ServerTimeOut);

            case StatusCodes.SipVersionNotSupported:
                return(SipVersionNotSupported);

            case StatusCodes.MessageTooLarge:
                return(MessageTooLarge);

            case StatusCodes.BusyEverywhere:
                return(BusyEverywhere);

            case StatusCodes.Decline:
                return(Decline);

            case StatusCodes.DoesNotExistAnywhere:
                return(DoesNotExistAnywhere);

            case StatusCodes.None:
                throw new ArgumentOutOfRangeException(@"statusCode: " + statusCode.ToString());

            default:
                return(NoReason);
            }
        }
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// Update the status of the specified experiment.
        /// </summary>
        /// <returns></returns>
        public bool UpdateStatus(int experimentId, string sbName, StatusCodes statusCode)
        {
            const string STRLOG_MethodName = "UpdateStatus";

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

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            //
            // Catch all exceptions thrown and return false if an error occurred.
            //
            bool success = false;

            lock (this.queueLock)
            {
                try
                {
                    //
                    // Update queued experiment status
                    //
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_UpdateQueueStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

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

                    try
                    {
                        this.sqlConnection.Open();

                        success = (sqlCommand.ExecuteNonQuery() != 0);
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_success + success.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return success;
        }
        //---------------------------------------------------------------------------------------//
        public ExperimentInfo[] RetrieveAllWithStatus(StatusCodes status)
        {
            const string STRLOG_MethodName = "RetrieveAllWithStatus";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            List<ExperimentInfo> experimentInfoList = new List<ExperimentInfo>();

            lock (this.queueLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveQueueAllWithStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_Status, status.ToString()));

                    try
                    {
                        this.sqlConnection.Open();

                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        while (sqlDataReader.Read() == true)
                        {
                            ExperimentInfo experimentInfo = new ExperimentInfo(0, null);

                            //
                            // Get the experiment information from waiting experiment
                            //
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value)
                                experimentInfo.experimentId = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value)
                                experimentInfo.sbName = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value)
                                experimentInfo.userGroup = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value)
                                experimentInfo.priorityHint = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_XmlSpecification]) != System.DBNull.Value)
                                experimentInfo.xmlSpecification = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_EstimatedExecTime]) != System.DBNull.Value)
                                experimentInfo.estExecutionTime = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_Cancelled]) != System.DBNull.Value)
                                experimentInfo.cancelled = (bool)sdrObject;

                            //
                            // Add the experiment info to the list
                            //
                            experimentInfoList.Add(experimentInfo);
                        }
                        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();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            string logMessage = STRLOG_count + experimentInfoList.Count.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return experimentInfoList.ToArray();
        }
Esempio n. 12
0
        //---------------------------------------------------------------------------------------//

        public ExperimentInfo[] RetrieveAllWithStatus(StatusCodes status)
        {
            const string STRLOG_MethodName = "RetrieveAllWithStatus";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            List <ExperimentInfo> experimentInfoList = new List <ExperimentInfo>();

            lock (this.queueLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveQueueAllWithStatus, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add(new SqlParameter(STRSQLPRM_Status, status.ToString()));

                    try
                    {
                        this.sqlConnection.Open();

                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        while (sqlDataReader.Read() == true)
                        {
                            ExperimentInfo experimentInfo = new ExperimentInfo(0, null);

                            //
                            // Get the experiment information from waiting experiment
                            //
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value)
                            {
                                experimentInfo.experimentId = (int)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value)
                            {
                                experimentInfo.sbName = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value)
                            {
                                experimentInfo.userGroup = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value)
                            {
                                experimentInfo.priorityHint = (int)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_XmlSpecification]) != System.DBNull.Value)
                            {
                                experimentInfo.xmlSpecification = (string)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_EstimatedExecTime]) != System.DBNull.Value)
                            {
                                experimentInfo.estExecutionTime = (int)sdrObject;
                            }
                            if ((sdrObject = sqlDataReader[STRSQL_Cancelled]) != System.DBNull.Value)
                            {
                                experimentInfo.cancelled = (bool)sdrObject;
                            }

                            //
                            // Add the experiment info to the list
                            //
                            experimentInfoList.Add(experimentInfo);
                        }
                        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();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            string logMessage = STRLOG_count + experimentInfoList.Count.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(experimentInfoList.ToArray());
        }
Esempio n. 13
0
        //---------------------------------------------------------------------------------------//

        /// <summary>
        /// Get the status of the specified experiment. If the experiment is not found then the
        /// status of 'Unknown' will be returned.
        /// </summary>
        /// <param name="experimentId"></param>
        /// <param name="sbName"></param>
        /// <returns></returns>
        public StatusCodes GetExperimentStatus(int experimentId, string sbName)
        {
            const string STRLOG_MethodName = "GetExperimentStatus";

            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);

            StatusCodes status = StatusCodes.Unknown;

            lock (this.queueLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveQueue, 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();
                        if (sqlDataReader.Read() == true)
                        {
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_Status]) != System.DBNull.Value)
                            {
                                status = (StatusCodes)Enum.Parse(typeof(StatusCodes), (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();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            logMessage = STRLOG_status + status.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return(status);
        }
 private static int ToStatusCode(StatusCodes arg) => int.Parse(arg.ToString().Trim('_'));
Esempio n. 15
0
        public static ByteArrayPart GetReason(this StatusCodes statusCode)
        {
            if (statusCode <= StatusCodes.OK)
            {
                if (statusCode <= StatusCodes.Trying)
                {
                    if (statusCode == StatusCodes.None)
                    {
                        throw new ArgumentOutOfRangeException("statusCode: " + statusCode.ToString());
                    }
                    if (statusCode == StatusCodes.Trying)
                    {
                        return(StatusCodesConverter.Trying);
                    }
                }
                else
                {
                    switch (statusCode)
                    {
                    case StatusCodes.Ringing:
                        return(StatusCodesConverter.Ringing);

                    case StatusCodes.CallIsBeingForwarded:
                        return(StatusCodesConverter.CallIsBeingForwarded);

                    case StatusCodes.Queued:
                        return(StatusCodesConverter.Queued);

                    case StatusCodes.SessionProgress:
                        return(StatusCodesConverter.SessionProgress);

                    default:
                        if (statusCode == StatusCodes.OK)
                        {
                            return(StatusCodesConverter.OK);
                        }
                        break;
                    }
                }
            }
            else if (statusCode <= StatusCodes.AlternativeService)
            {
                switch (statusCode)
                {
                case StatusCodes.MultipleChoices:
                    return(StatusCodesConverter.MultipleChoices);

                case StatusCodes.MovedPermanently:
                    return(StatusCodesConverter.MovedPermanently);

                case StatusCodes.MovedTemporarily:
                    return(StatusCodesConverter.MovedTemporarily);

                case (StatusCodes)303:
                case (StatusCodes)304:
                    break;

                case StatusCodes.UseProxy:
                    return(StatusCodesConverter.UseProxy);

                default:
                    if (statusCode == StatusCodes.AlternativeService)
                    {
                        return(StatusCodesConverter.AlternativeService);
                    }
                    break;
                }
            }
            else
            {
                switch (statusCode)
                {
                case StatusCodes.BadRequest:
                    return(StatusCodesConverter.BadRequest);

                case StatusCodes.Unauthorized:
                    return(StatusCodesConverter.Unauthorized);

                case StatusCodes.PaymentRequired:
                    return(StatusCodesConverter.PaymentRequired);

                case StatusCodes.Forbidden:
                    return(StatusCodesConverter.Forbidden);

                case StatusCodes.NotFound:
                    return(StatusCodesConverter.NotFound);

                case StatusCodes.MethodNotAllowed:
                    return(StatusCodesConverter.MethodNotAllowed);

                case StatusCodes.NotAcceptable:
                    return(StatusCodesConverter.NotAcceptable);

                case StatusCodes.ProxyAuthenticationRequired:
                    return(StatusCodesConverter.ProxyAuthenticationRequired);

                case StatusCodes.RequestTimeout:
                    return(StatusCodesConverter.RequestTimeout);

                case (StatusCodes)409:
                case (StatusCodes)411:
                case (StatusCodes)412:
                case (StatusCodes)417:
                case (StatusCodes)418:
                case (StatusCodes)419:
                case (StatusCodes)422:
                    break;

                case StatusCodes.Gone:
                    return(StatusCodesConverter.Gone);

                case StatusCodes.RequestEntityTooLarge:
                    return(StatusCodesConverter.RequestEntityTooLarge);

                case StatusCodes.RequestURITooLarge:
                    return(StatusCodesConverter.RequestURITooLarge);

                case StatusCodes.UnsupportedMediaType:
                    return(StatusCodesConverter.UnsupportedMediaType);

                case StatusCodes.UnsupportedURIScheme:
                    return(StatusCodesConverter.UnsupportedURIScheme);

                case StatusCodes.BadExtension:
                    return(StatusCodesConverter.BadExtension);

                case StatusCodes.ExtensionRequired:
                    return(StatusCodesConverter.ExtensionRequired);

                case StatusCodes.IntervalTooBrief:
                    return(StatusCodesConverter.IntervalTooBrief);

                default:
                    switch (statusCode)
                    {
                    case StatusCodes.TemporarilyUnavailable:
                        return(StatusCodesConverter.TemporarilyUnavailable);

                    case StatusCodes.CallLegTransactionDoesNotExist:
                        return(StatusCodesConverter.CallLegTransactionDoesNotExist);

                    case StatusCodes.LoopDetected:
                        return(StatusCodesConverter.LoopDetected);

                    case StatusCodes.TooManyHops:
                        return(StatusCodesConverter.TooManyHops);

                    case StatusCodes.AddressIncomplete:
                        return(StatusCodesConverter.AddressIncomplete);

                    case StatusCodes.Ambiguous:
                        return(StatusCodesConverter.Ambiguous);

                    case StatusCodes.BusyHere:
                        return(StatusCodesConverter.BusyHere);

                    case StatusCodes.RequestTerminated:
                        return(StatusCodesConverter.RequestTerminated);

                    case StatusCodes.NotAcceptableHere:
                        return(StatusCodesConverter.NotAcceptableHere);

                    case (StatusCodes)489:
                    case (StatusCodes)490:
                    case (StatusCodes)492:
                    case (StatusCodes)494:
                    case (StatusCodes)495:
                    case (StatusCodes)496:
                    case (StatusCodes)497:
                    case (StatusCodes)498:
                    case (StatusCodes)499:
                    case (StatusCodes)506:
                    case (StatusCodes)507:
                    case (StatusCodes)508:
                    case (StatusCodes)509:
                    case (StatusCodes)510:
                    case (StatusCodes)511:
                    case (StatusCodes)512:
                        break;

                    case StatusCodes.RequestPending:
                        return(StatusCodesConverter.RequestPending);

                    case StatusCodes.Undecipherable:
                        return(StatusCodesConverter.Undecipherable);

                    case StatusCodes.InternalServerError:
                        return(StatusCodesConverter.InternalServerError);

                    case StatusCodes.NotImplemented:
                        return(StatusCodesConverter.NotImplemented);

                    case StatusCodes.BadGateway:
                        return(StatusCodesConverter.BadGateway);

                    case StatusCodes.ServiceUnavailable:
                        return(StatusCodesConverter.ServiceUnavailable);

                    case StatusCodes.ServerTimeOut:
                        return(StatusCodesConverter.ServerTimeOut);

                    case StatusCodes.SipVersionNotSupported:
                        return(StatusCodesConverter.SipVersionNotSupported);

                    case StatusCodes.MessageTooLarge:
                        return(StatusCodesConverter.MessageTooLarge);

                    default:
                        switch (statusCode)
                        {
                        case StatusCodes.BusyEverywhere:
                            return(StatusCodesConverter.BusyEverywhere);

                        case StatusCodes.Decline:
                            return(StatusCodesConverter.Decline);

                        case StatusCodes.DoesNotExistAnywhere:
                            return(StatusCodesConverter.DoesNotExistAnywhere);
                        }
                        break;
                    }
                    break;
                }
            }
            return(StatusCodesConverter.NoReason);
        }