Beispiel #1
0
 /// <summary>
 /// Send sms message
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="messageTemplate">Message template</param>
 /// <param name="smsTag">Sms tag</param>
 /// <param name="parameters">Parameters</param>
 /// <param name="mobile">Mobiles</param>
 /// <param name="asynchronously">Whether send by asynchronously</param>
 /// <returns>Return send result</returns>
 public static async Task <SendMessageResult> SendSmsMessageAsync(SmsAccount smsAccount, MessageTemplate messageTemplate, string smsTag, object parameters, IEnumerable <string> mobiles, bool asynchronously = true)
 {
     return(await SendSmsMessageAsync(smsAccount, messageTemplate, new MessageInfo()
     {
         Parameters = parameters
     }, smsTag, mobiles, asynchronously).ConfigureAwait(false));
 }
Beispiel #2
0
        /// <summary>
        /// Send sms message
        /// </summary>
        /// <param name="smsAccount">Sms account</param>
        /// <param name="messageTemplate">Message template</param>
        /// <param name="message">Message</param>
        /// <param name="smsTag">Sms tag</param>
        /// <param name="mobiles">Mobiles</param>
        /// <param name="asynchronously">Whether send by asynchronously</param>
        /// <returns>Return send result</returns>
        public static async Task <SendMessageResult> SendSmsMessageAsync(SmsAccount smsAccount, MessageTemplate messageTemplate, MessageInfo message, string smsTag, IEnumerable <string> mobiles, bool asynchronously = true)
        {
            var msgResult = GetSmsOptions(messageTemplate, message, smsTag, mobiles, asynchronously, out var smsOptions);

            if (!msgResult.Success || smsOptions == null)
            {
                return(msgResult);
            }
            SendSmsResult smsSendResult = await SmsManager.SendAsync(smsAccount, smsOptions).ConfigureAwait(false);

            return(smsSendResult.Success ? SendMessageResult.SendSuccess() : SendMessageResult.SendFailed(smsSendResult.Description));
        }
        public static SmsAccount ConverToViewModel(this bx_sms_account smsAccount)
        {
            SmsAccount vm = new SmsAccount();

            if (smsAccount != null)
            {
                vm = new SmsAccount
                {
                    id           = smsAccount.id,
                    agent_id     = smsAccount.agent_id,
                    sms_account  = smsAccount.sms_account,
                    sms_password = smsAccount.sms_password,
                    total_times  = smsAccount.total_times,
                    avail_times  = smsAccount.avail_times,
                    status       = smsAccount.status,
                    create_time  = smsAccount.create_time
                }
            }
            ;
            return(vm);
        }
    }
 /// <summary>
 /// Create or Update account
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='update'>
 /// Account
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SmsAccount> CreateOrUpdateAccountAsync(this ISmsOperations operations, string apiVersion, SmsAccount update, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateAccountWithHttpMessagesAsync(apiVersion, update, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create or Update account
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='apiVersion'>
 /// </param>
 /// <param name='update'>
 /// Account
 /// </param>
 public static SmsAccount CreateOrUpdateAccount(this ISmsOperations operations, string apiVersion, SmsAccount update)
 {
     return(operations.CreateOrUpdateAccountAsync(apiVersion, update).GetAwaiter().GetResult());
 }
Beispiel #6
0
 /// <summary>
 /// Send sms message
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="messageTemplate">Message template</param>
 /// <param name="smsTag">Sms tag</param>
 /// <param name="parameters">Parameters</param>
 /// <param name="mobile">Mobile</param>
 /// <param name="asynchronously">Whether send by asynchronously</param>
 /// <returns>Return send result</returns>
 public static SendMessageResult SendSmsMessage(SmsAccount smsAccount, MessageTemplate messageTemplate, string smsTag, object parameters, string mobile, bool asynchronously = true)
 {
     return(SendSmsMessageAsync(smsAccount, messageTemplate, smsTag, parameters, mobile, asynchronously).Result);
 }
Beispiel #7
0
 /// <summary>
 /// Send sms message
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="messageTemplate">Message template</param>
 /// <param name="smsTag">Sms tag</param>
 /// <param name="parameters">Parameters</param>
 /// <param name="mobile">Mobile</param>
 /// <param name="asynchronously">Whether send by asynchronously</param>
 /// <returns>Return send result</returns>
 public static async Task <SendMessageResult> SendSmsMessageAsync(SmsAccount smsAccount, MessageTemplate messageTemplate, string smsTag, object parameters, string mobile, bool asynchronously = true)
 {
     return(await SendSmsMessageAsync(smsAccount, messageTemplate, smsTag, parameters, new string[1] {
         mobile
     }, asynchronously).ConfigureAwait(false));
 }
Beispiel #8
0
 /// <summary>
 /// Send sms message
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="messageTemplate">Message template</param>
 /// <param name="message">Message</param>
 /// <param name="smsTag">Sms tag</param>
 /// <param name="mobiles">Mobiles</param>
 /// <param name="asynchronously">Whether send by asynchronously</param>
 /// <returns>Return send result</returns>
 public static SendMessageResult SendSmsMessage(SmsAccount smsAccount, MessageTemplate messageTemplate, MessageInfo message, string smsTag, IEnumerable <string> mobiles, bool asynchronously = true)
 {
     return(SendSmsMessageAsync(smsAccount, messageTemplate, message, smsTag, mobiles, asynchronously).Result);
 }