예제 #1
0
        /// <summary>
        /// Send sms
        /// </summary>
        /// <param name="sendSmsOptions">Sms options</param>
        /// <returns>Return send result</returns>
        public static async Task <SendSmsResult> SendAsync(SendSmsOptions sendSmsOptions)
        {
            if (sendSmsOptions == null)
            {
                throw new ArgumentNullException(nameof(sendSmsOptions));
            }
            //Set additions
            SetAdditions(sendSmsOptions);
            if (sendSmsOptions.Asynchronously)
            {
                InternalQueueSendSmsItem smsInternalMessageCommand = new InternalQueueSendSmsItem()
                {
                    SmsOptions = sendSmsOptions
                };
                InternalQueueManager.GetQueue(EZNEWConstants.InternalQueueNames.Message).Enqueue(smsInternalMessageCommand);
                return(SmsResult.SendSuccess <SendSmsResult>());
            }
            else
            {
                var smsProvider = GetSmsProvider();
                var sendResult  = await ExecuteAsync(sendSmsOptions, smsProvider.SendAsync).ConfigureAwait(false);

                //callback
                ThreadPool.QueueUserWorkItem(s =>
                {
                    SmsSentCallback?.Invoke(new SendSmsResult[1] {
                        sendResult.Clone()
                    });
                });
                return(sendResult);
            }
        }
예제 #2
0
 /// <summary>
 /// Send sms
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="sendSmsOptions">Send sms options</param>
 /// <returns>Return send sms result</returns>
 public static async Task <SendSmsResult> SendAsync(SmsAccount account, SendSmsOptions sendSmsOptions)
 {
     if (sendSmsOptions == null)
     {
         throw new ArgumentNullException(nameof(sendSmsOptions));
     }
     if (sendSmsOptions.Asynchronously)
     {
         InternalQueueSendSmsItem smsInternalMessageCommand = new InternalQueueSendSmsItem()
         {
             SmsOptions = sendSmsOptions,
             SmsAccount = account
         };
         InternalQueueManager.GetQueue(EZNEWConstants.InternalQueueNames.Message).Enqueue(smsInternalMessageCommand);
         return(SmsResult.SendSuccess <SendSmsResult>());
     }
     else
     {
         var smsProvider = GetSmsProvider();
         return(await ExecuteAsync(account, sendSmsOptions, smsProvider.SendAsync).ConfigureAwait(false));
     }
 }
예제 #3
0
 /// <summary>
 /// Send sms
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="sendSmsOptions">Send sms options</param>
 /// <returns>Return send sms result</returns>
 public static SendSmsResult Send(SmsAccount account, SendSmsOptions sendSmsOptions)
 {
     return(SendAsync(account, sendSmsOptions).Result);
 }
예제 #4
0
 /// <summary>
 /// Send sms
 /// </summary>
 /// <param name="sendSmsOptions">Send sms options</param>
 /// <returns>Return send sms result</returns>
 public static SendSmsResult Send(SendSmsOptions sendSmsOptions)
 {
     return(SendAsync(sendSmsOptions).Result);
 }