示例#1
0
        public void get_user_info()
        {
            var smsClient = new SmsClient("**", "**");
            var result = smsClient.GetUserInfo(ActionTypes.UserInfo);
            Console.WriteLine(result);

        }
示例#2
0
    //Private Method CheckConnection
    private bool CheckConnection()
    {
        try
        {
            SmsClient.ServerAddress = ServerAddress;
            SmsClient.Port = Convert.ToInt32(ServerPort);
            SmsClient.HttpProxy.ProxyMode = HttpProxyMode.AutoDetect;
            //SmsClient.HttpProxy.Host = ProxyAddress;
            //SmsClient.HttpProxy.Port = Convert.ToInt32(ProxyPort);

            SmsClient sms = new SmsClient(Username, Password);

            if (sms.TestConnection())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception ex)
        {
            return false;
        }
    }
示例#3
0
    //Public Method SendSMS
    public string SendSMS(string mobileno, string message)
    {
        if (CheckConnection())
        {
            try
            {
                SmsClient.ServerAddress = ServerAddress;
                SmsClient.Port = Convert.ToInt32(ServerPort);
                SmsClient.HttpProxy.ProxyMode = HttpProxyMode.AutoDetect;
                //SmsClient.HttpProxy.Host = ProxyAddress;
                //SmsClient.HttpProxy.Port = Convert.ToInt32(ProxyPort);

                SmsClient sms = new SmsClient(Username, Password);
                try
                {
                    SendMessageResult result = sms.SendMessage(mobileno, message);
                    return result.TaskId + "|" + result.MessageId;
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        else
        {
            return "Error";
        }
    }
示例#4
0
        public static void SendMessageAsync(string AccountUsername, string AccountPassword, string mobileNo, string message, DateTime scheduleTime)
        {
            var smsClient = new SmsClient(AccountUsername, AccountPassword);

            var smsLog = new SmsLog
            {
                UserId = Current.User.Id,
                MobileNo = mobileNo,
                Message = message,
                SentTime = DateTime.Now,
                SmsStatus = SmsStatus.Sending,
                MessageId = "",
                TaskId = "",
                ErrorMsg = ""
            };
            smsLog.Id = (int)Current.DB.SmsLogs.Insert(smsLog);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    SendMessageResult result;
                    if (scheduleTime == DateTime.MinValue)
                    {
                        result = smsClient.SendMessage(mobileNo, message);
                    }
                    else
                    {
                        result = smsClient.SendMessage(mobileNo, message, scheduleTime);
                    }
                    Current.DB.Execute(@"update SmsLogs
            set [email protected],
            [email protected],
            [email protected]
            where Id = @id", new
                    {
                        SmsStatus = (int)SmsStatus.Success,
                        MessageId = result.MessageId,
                        TaskId = result.TaskId,
                        id = smsLog.Id
                    });
                }
                catch (GatewayException ge)
                {
                    Current.DB.Execute(@"update SmsLogs
            set [email protected],
            [email protected]
            where Id = @id", new
                    {
                        SmsStatus = (int)SmsStatus.Error,
                        ErrorMsg = ge.Message,
                        id = smsLog.Id
                    });
                }
                catch (Exception ex)
                {
                    Current.DB.Execute(@"update SmsLogs
            set [email protected],
            [email protected]
            where Id = @id", new
                    {
                        SmsStatus = (int)SmsStatus.Error,
                        ErrorMsg = ex.Message,
                        id = smsLog.Id
                    });
                }
            });
        }
示例#5
0
 public void send_sms()
 {
     var smsClient = new SmsClient("*", "*");
     var result = smsClient.Send(ActionTypes.SmsToConcat, "Test mesaj", new List<string> { "*" }, "*");
     Console.WriteLine(result);
 }
 /// <summary>
 /// 发短信
 /// </summary>
 /// <param name="mobile"></param>
 /// <param name="newCode"></param>
 private void SendSms(string[] mobile, string newCode)
 {
     var sms = new SmsClient();
     //string message = "您的验证码是:{0}。请不要把验证码泄露给其他人。";
     string message = new UserMessageSmsService().QueryByID(1).Content;
     message = message.Replace("{0}", newCode);
     var smsModel = new UserMessageSmsService().QueryByID(1);
     sms.SmsSend(mobile, message, "1");
 }