Пример #1
0
        private void LoadConfig()
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SMSC));

                if (!File.Exists("smsc.cfg"))
                {
                    using (TextWriter writer = new StreamWriter("smsc.cfg"))
                    {
                        serializer.Serialize(writer, new SMSC("amital", "192.168.0.1", 2776, "test", "test", "test", 0, 0, "", 0));
                    }
                    onLog(new LogEventArgs("Пожалуйста, проверьте настройки подключения в файле smsc.cfg"));
                }
                using (FileStream fs = new FileStream("smsc.cfg", FileMode.Open))
                {
                    SMSC smsc = (SMSC)serializer.Deserialize(fs);
                    smppClient.AddSMSC(smsc);
                }
            }
            catch (Exception ex)
            {
                onLog(new LogEventArgs("Error on loading smsc.cfg : " + ex.Message));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            SMPPClient client = new SMPPClient();
            SMSC       sms    = new SMSC()
            {
                Host       = "smpp.smsc.ru",
                Port       = 3700,
                SystemId   = "SystemId",
                Password   = "******",
                SourceTon  = 5,
                SourceNpi  = 1,
                AddrTon    = 1,
                AddrNpi    = 1,
                SystemType = ""
            };

            client.AddSMSC(sms);

            if (client.Connect())
            {
                int res = client.SendSms("from", "to", "message");
                Console.WriteLine(res);

                client.Disconnect();
                client.ClearSMSC();
            }

            Console.ReadLine();
        }
Пример #3
0
        private void LoadConfig()
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SMSC));

                if (!File.Exists("smsc.cfg"))
                {
                    using (TextWriter writer = new StreamWriter("smsc.cfg"))
                    {
                        serializer.Serialize(writer, new SMSC("example", "127.0.0.1", 12345, "test", "test", "test", 0, 0, "", 0));
                    }
                    onLog(new LogEventArgs("Please edit smsc.cfg and enter your data."));
                }
                using (FileStream fs = new FileStream("smsc.cfg", FileMode.Open))
                {
                    SMSC smsc = (SMSC)serializer.Deserialize(fs);
                    smppClient.AddSMSC(smsc);
                }
            }
            catch (Exception ex)
            {
                onLog(new LogEventArgs("Error on loading smsc.cfg : " + ex.Message));
            }
        }
Пример #4
0
        public SmsClient(string description, string host, int port, string systemId, string password, string systemType, int seqn)
        {
            smppClient = new SMPPClient();

            smppClient.OnDeliverSm    += new DeliverSmEventHandler(onDeliverSm);
            smppClient.OnSubmitSmResp += new SubmitSmRespEventHandler(onSubmitSmResp);

            smppClient.OnLog   += new LogEventHandler(onLog);
            smppClient.LogLevel = LogLevels.LogErrors;
            // smppClient.LogLevel = LogLevels.LogDebug;

            SMSC smsc = new SMSC(description, host, port, systemId, password, systemType, seqn);

            smppClient.AddSMSC(smsc);
        }
Пример #5
0
        private void LoadConfig()
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SMSC));

                if (!File.Exists("smsc.cfg"))
                {
                    /*
                     * using (TextWriter writer = new StreamWriter("smsc.cfg"))
                     * {
                     *      serializer.Serialize(writer, new SMSC("example", "217.23.150.71", 2775, "regplat", "yd2qox45", "test", 1, 1, "+79039531420", 0));
                     * }
                     */
                    onLog(new LogEventArgs("Please edit smsc.cfg and enter your data."));
                }
                using (FileStream fs = new FileStream("smsc.cfg", FileMode.Open))
                {
                    SMSC smsc = (SMSC)serializer.Deserialize(fs);
                    smppClient.AddSMSC(smsc);

                    onLog(new LogEventArgs("Try host " + smsc.Host));
                    IPAddress ip;
                    if (!IPAddress.TryParse(smsc.Host, out ip))
                    {
                        IPHostEntry hostinfo = Dns.GetHostEntry(smsc.Host);
                        IPAddress[] ips      = hostinfo.AddressList;
                        smsc.Host = ips[0].ToString();
                        string msg = string.Format("IP: {0}", smsc.Host);
                    }

                    string desc = string.Format("Description: {0}\r\nHost: {1}\r\nPort: {2}", smsc.Description, smsc.Host, smsc.Port);
                    onLog(new LogEventArgs(desc));
                }
            }
            catch (Exception ex)
            {
                onLog(new LogEventArgs("Error on loading smsc.cfg : " + ex.Message));
            }
        }