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)); }
/// <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)); }
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() }); }
/// <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)); } }
/// <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)); }
/// <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); }
/// <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)); }
/// <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); }
/// <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); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }