示例#1
0
        /// <summary>
        /// Perform some kind of control action
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public override bool Execute(SshClient client)
        {
            if (Send.Contains("ATD"))
            {
                if (!Send.EndsWith(";"))
                    Send += ";";

                if (Send.Contains("$TESTPHONENUMBER"))
                {
                    if(qForm == null)
                        qForm = new frmQuestionForm {Question = "Please enter the number to dial"};
                    qForm.ShowDialog();

                    Send = Send.Replace("$TESTPHONENUMBER", qForm.Answer);
                }
            }

            bool success = base.Execute(client);
            if (!success)
            {
                if (!string.IsNullOrEmpty(HangUpOnFail))
                {
                    Send = HangUpOnFail;
                    base.Execute(client);
                }
                return false;
            }

            if (Send.Contains("AT+CSQ"))
            {
                if (MinCSQ.HasValue)
                {
                    try
                    {
                        string[] arr =
                            Output.Split(',');
                        int csq = int.Parse(arr[0]);
                        if (csq < MinCSQ)
                        {
                            Logger.Warn("CSQ is too low");
                            Output += " - CSQ too low (<" + MinCSQ + ")";
                            success = false;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Warn("Exception analysing CSQ response: " + e.Message);
                        success = false;

                    }
                }
            }
            return success;
        }
示例#2
0
        /// <summary>
        /// Perform some kind of control action
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public override bool Execute(SshClient client)
        {
            if (Send.Contains("ATD"))
            {
                if (!Send.EndsWith(";"))
                {
                    Send += ";";
                }

                if (Send.Contains("$TESTPHONENUMBER"))
                {
                    if (qForm == null)
                    {
                        qForm = new frmQuestionForm {
                            Question = "Please enter the number to dial"
                        }
                    }
                    ;
                    qForm.ShowDialog();

                    Send = Send.Replace("$TESTPHONENUMBER", qForm.Answer);
                }
            }

            bool success = base.Execute(client);

            if (!success)
            {
                if (!string.IsNullOrEmpty(HangUpOnFail))
                {
                    Send = HangUpOnFail;
                    base.Execute(client);
                }
                return(false);
            }

            if (Send.Contains("AT+CSQ"))
            {
                if (MinCSQ.HasValue)
                {
                    try
                    {
                        string[] arr =
                            Output.Split(',');
                        int csq = int.Parse(arr[0]);
                        if (csq < MinCSQ)
                        {
                            Logger.Warn("CSQ is too low");
                            Output += " - CSQ too low (<" + MinCSQ + ")";
                            success = false;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Warn("Exception analysing CSQ response: " + e.Message);
                        success = false;
                    }
                }
            }
            return(success);
        }
    }