Пример #1
0
        /// <summary>
        ///
        /// </summary>
        private bool Check()
        {
            try
            {
                using (Command command = new CS.CodeSuppressionCommand(_adaptor))
                {
                    ((CS.CodeSuppressionCommand)command).Type = CS.CodeSuppressionType.TransmitCodes;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.CommandEchoCommand(_adaptor))
                {
                    ((CS.CommandEchoCommand)command).Type = CS.CommandEchoType.NoEcho;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.ResponseFormatCommand(_adaptor))
                {
                    ((CS.ResponseFormatCommand)command).Type = CS.ResponseFormatType.Verbose;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.SMS.MessageFormatCommand(_adaptor))
                {
                    ((CS.SMS.MessageFormatCommand)command).FormatType = CS.SMS.MessageFormatType.PDU;
                    if (((CS.SMS.MessageFormatCommand)command).FormatType != CS.SMS.MessageFormatType.PDU)
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.ReportMEErrorCommand(_adaptor))
                {
                    ((CS.ReportMEErrorCommand)command).ReportType = CS.ReportMEErrorType.ReportOK;
                    if (((CS.ReportMEErrorCommand)command).ReportType != CS.ReportMEErrorType.ReportOK)
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.SMS.PreferredMessageStorage(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.SMS.NewMessageIndications(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                using (Command command = new CS.SMS.ServiceCentreAddress(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new Exception();
                    }
                    _SMSC = ((CS.SMS.ServiceCentreAddress)command).Address;
                }

                return(true);
            }
            catch (Exception p)
            {
                logger.Error(p);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        private bool Check()
        {
            try
            {
                OnExecute(new ExecutionEventArgs("Setting Code Suppression..."));
                using (Command command = new CS.CodeSuppressionCommand(_adaptor))
                {
                    ((CS.CodeSuppressionCommand)command).Type = CS.CodeSuppressionType.TransmitCodes;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting Command Echo..."));
                using (Command command = new CS.CommandEchoCommand(_adaptor))
                {
                    ((CS.CommandEchoCommand)command).Type = CS.CommandEchoType.NoEcho;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting Response Format..."));
                using (Command command = new CS.ResponseFormatCommand(_adaptor))
                {
                    ((CS.ResponseFormatCommand)command).Type = CS.ResponseFormatType.Verbose;
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting Message Format..."));
                using (Command command = new CS.SMS.MessageFormatCommand(_adaptor))
                {
                    ((CS.SMS.MessageFormatCommand)command).FormatType = CS.SMS.MessageFormatType.PDU;
                    if (((CS.SMS.MessageFormatCommand)command).FormatType != CS.SMS.MessageFormatType.PDU)
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting Report Error..."));
                using (Command command = new CS.ReportMEErrorCommand(_adaptor))
                {
                    ((CS.ReportMEErrorCommand)command).ReportType = CS.ReportMEErrorType.ReportOK;
                    if (((CS.ReportMEErrorCommand)command).ReportType != CS.ReportMEErrorType.ReportOK)
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting Preferred Message Storage..."));
                using (Command command = new CS.SMS.PreferredMessageStorage(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Setting New Message Indications..."));
                using (Command command = new CS.SMS.NewMessageIndications(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                }

                OnExecute(new ExecutionEventArgs("Fetching Service Centre Address..."));
                using (Command command = new CS.SMS.ServiceCentreAddress(_adaptor))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }
                    _SMSC = ((CS.SMS.ServiceCentreAddress)command).Address;
                }

                OnExecute(new ExecutionEventArgs("Clearing Incoming Message Queue..."));
                using (Command command = new CS.SMS.ListMessageCommand(_adaptor, CS.SMS.MessageStateType.All, CS.SMS.MessageFormatType.PDU))
                {
                    if (!command.Execute())
                    {
                        throw new ModemException();
                    }

                    foreach (CS.SMS.ShortMessage item in ((CS.SMS.ListMessageCommand)command).MessageCollection)
                    {
                        CS.SMS.DeleteMessageCommand dmc = new CS.SMS.DeleteMessageCommand(_adaptor, item.Index);
                        if (!dmc.Execute())
                        {
                            throw new ModemException("DeleteMessageCommand Execute Failed.");
                        }
                        if (_Stopped)
                        {
                            break;
                        }
                    }
                }

                OnExecute(new ExecutionEventArgs("Initializing Completed."));

                return(true);
            }
            catch (Exception p)
            {
                logger.Error(p);
                return(false);
            }
        }