Exemple #1
0
 internal static Task <TResult> ExecuteAsync <TOptions, TResult>(SmsAccount account, TOptions smsOptions, Func <SmsAccount, TOptions, Task <TResult> > proxy) where TOptions : SmsOptions where TResult : SmsResult
 {
     if (account == null)
     {
         throw new EZNEWException("No sms account specified");
     }
     return(proxy(account, smsOptions));
 }
Exemple #2
0
 /// <summary>
 /// Send sms
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="content">Content</param>
 /// <param name="parameters">Parameters</param>
 /// <param name="mobiles">Mobile numbers</param>
 /// <returns>Return send result</returns>
 public static async Task <SendSmsResult> SendAsync(SmsAccount smsAccount, string content, object parameters, bool asynchronously = true, params string[] mobiles)
 {
     return(await SendAsync(smsAccount, new SendSmsOptions()
     {
         Content = content,
         Parameters = parameters?.ObjectToStringDcitionary(),
         Asynchronously = asynchronously,
         Mobiles = mobiles
     }).ConfigureAwait(false));
 }
Exemple #3
0
 internal SendSmsResult Clone()
 {
     return(new SendSmsResult()
     {
         RequestId = RequestId,
         Result = Result,
         Code = Code,
         Description = Description,
         Success = Success,
         MessageId = MessageId,
         BizId = BizId,
         FailMobiles = FailMobiles?.Select(c => c).ToList() ?? new List <string>(0),
         SmsAccount = SmsAccount?.Clone(),
         SmsOptions = SmsOptions?.Clone()
     });
 }
Exemple #4
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));
     }
 }
Exemple #5
0
        /// <summary>
        /// Receive sms
        /// </summary>
        /// <param name="account">Sms account</param>
        /// <param name="receiveSmsOptions">Receive sms options</param>
        /// <returns>Return receive sms result</returns>
        public static async Task <ReceiveSmsResult> ReceiveAsync(SmsAccount account, ReceiveSmsOptions receiveSmsOptions)
        {
            var smsProvider = GetSmsProvider();

            return(await ExecuteAsync(account, receiveSmsOptions, smsProvider.ReceiveAsync).ConfigureAwait(false));
        }
Exemple #6
0
 /// <summary>
 /// Check keyword
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="checkKeywordOptions">Check keyword options</param>
 /// <returns>Return check keyword result</returns>
 public static CheckKeywordResult CheckKeyword(SmsAccount account, CheckKeywordOptions checkKeywordOptions)
 {
     return(CheckKeywordAsync(account, checkKeywordOptions).Result);
 }
Exemple #7
0
        /// <summary>
        /// Check keyword
        /// </summary>
        /// <param name="account">Sms account</param>
        /// <param name="checkKeywordOptions">Check keyword options</param>
        /// <returns>Return check keyword result</returns>
        public static async Task <CheckKeywordResult> CheckKeywordAsync(SmsAccount account, CheckKeywordOptions checkKeywordOptions)
        {
            var smsProvider = GetSmsProvider();

            return(await ExecuteAsync(account, checkKeywordOptions, smsProvider.CheckKeywordAsync).ConfigureAwait(false));
        }
Exemple #8
0
 /// <summary>
 /// Check black
 /// </summary>
 /// <param name="account">Sms acount</param>
 /// <param name="checkBlackOptions">Check black options</param>
 /// <returns>Return check black result</returns>
 public static CheckBlackResult CheckBlack(SmsAccount account, CheckBlackOptions checkBlackOptions)
 {
     return(CheckBlackAsync(account, checkBlackOptions).Result);
 }
Exemple #9
0
 /// <summary>
 /// Query balance
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="queryBalanceOptions">Query balance options</param>
 /// <returns>Return query balance result</returns>
 public static QuerySmsBalanceResult QueryBalance(SmsAccount account, QueryBalanceOptions queryBalanceOptions)
 {
     return(QueryBalanceAsync(account, queryBalanceOptions).Result);
 }
Exemple #10
0
        /// <summary>
        /// Query balance
        /// </summary>
        /// <param name="account">Sms account</param>
        /// <param name="queryBalanceOptions">Query balance options</param>
        /// <returns>Return query balance result</returns>
        public static async Task <QuerySmsBalanceResult> QueryBalanceAsync(SmsAccount account, QueryBalanceOptions queryBalanceOptions)
        {
            var smsProvider = GetSmsProvider();

            return(await ExecuteAsync(account, queryBalanceOptions, smsProvider.QueryBalanceAsync).ConfigureAwait(false));
        }
Exemple #11
0
 /// <summary>
 /// Get sms report
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="getSmsReportOptions">Get sms report options</param>
 /// <returns>Return sms report result</returns>
 public static GetSmsReportResult GetSmsReport(SmsAccount account, GetSmsReportOptions getSmsReportOptions)
 {
     return(GetSmsReportAsync(account, getSmsReportOptions).Result);
 }
Exemple #12
0
        /// <summary>
        /// Get sms report
        /// </summary>
        /// <param name="account">Sms account</param>
        /// <param name="getSmsReportOptions">Get sms report options</param>
        /// <returns>Return sms report result</returns>
        public static async Task <GetSmsReportResult> GetSmsReportAsync(SmsAccount account, GetSmsReportOptions getSmsReportOptions)
        {
            var smsProvider = GetSmsProvider();

            return(await ExecuteAsync(account, getSmsReportOptions, smsProvider.GetSmsReportAsync).ConfigureAwait(false));
        }
Exemple #13
0
 /// <summary>
 /// Send sms
 /// </summary>
 /// <param name="smsAccount">Sms account</param>
 /// <param name="content">Content</param>
 /// <param name="parameters">Parameters</param>
 /// <param name="mobiles">Mobile numbers</param>
 /// <returns>Return send result</returns>
 public static SendSmsResult Send(SmsAccount smsAccount, string content, object parameters, bool asynchronously = true, params string[] mobiles)
 {
     return(SendAsync(smsAccount, content, parameters, asynchronously, mobiles).Result);
 }
Exemple #14
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);
 }
Exemple #15
0
 /// <summary>
 /// Receive sms
 /// </summary>
 /// <param name="account">Sms account</param>
 /// <param name="receiveSmsOptions">Receive sms options</param>
 /// <returns>Return receive sms result</returns>
 public static ReceiveSmsResult Receive(SmsAccount account, ReceiveSmsOptions receiveSmsOptions)
 {
     return(ReceiveAsync(account, receiveSmsOptions).Result);
 }