| | |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Net.Http.Headers; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using CoreCms.Net.Configuration; |
| | | using CoreCms.Net.IRepository; |
| | |
| | | using CoreCms.Net.Utility.Helper; |
| | | using Flurl.Http; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Options; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using SqlSugar; |
| | | using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionResponse.Types; |
| | | using static SKIT.FlurlHttpClient.Wechat.Api.Models.WxaApiUserLogSearchResponse.Types.Data.Types.RealtimeLog.Types; |
| | | |
| | | |
| | |
| | | switch (type) |
| | | { |
| | | case "login": |
| | | oldLog.contentBody = "您本次登陆的验证码是:" + codeNumber + ",请不要将验证码泄露给他人!"; |
| | | oldLog.contentBody = "您正在登陆账号,验证码是" + codeNumber + ",请勿告诉他人。";//您本次登陆的验证码是:" + codeNumber + ",请不要将验证码泄露给他人!" |
| | | oldLog.parameters = JsonConvert.SerializeObject(obj); |
| | | break; |
| | | default: |
| | | oldLog.contentBody = "您验证码是:" + codeNumber + ",请不要将验证码泄露给他人!"; |
| | | oldLog.contentBody = "您的验证码是" + codeNumber + ",请勿告诉他人。"; //"您验证码是:" + codeNumber + ",请不要将验证码泄露给他人!"; |
| | | oldLog.parameters = JsonConvert.SerializeObject(obj); |
| | | break; |
| | | } |
| | |
| | | { |
| | | if (smsOptions.Enabled) |
| | | { |
| | | var result = await smsOptions.ApiUrl.PostUrlEncodedAsync(new |
| | | var result = new SMSReturnData() |
| | | { |
| | | action = "send", |
| | | userid = smsOptions.UserId, |
| | | account = smsOptions.Account, |
| | | password = smsOptions.Password, |
| | | mobile, |
| | | content = "【" + smsOptions.Signature + "】" + contentBody, |
| | | rt = "json" |
| | | }).ReceiveJson<SMSReturnData>(); |
| | | result.IsSuccess = result.ReturnStatus.ToLowerInvariant() == "success"; |
| | | ReturnStatus = "faild", |
| | | Message = "短信发送失败", |
| | | RemainPoint = 0, |
| | | TaskID = 0, |
| | | SuccessCounts = 0 |
| | | }; |
| | | |
| | | string url = smsOptions.ApiUrl; |
| | | string data = "CorpID="+ smsOptions.Account + "&Pwd="+ smsOptions.Password + "&Mobile=" + mobile + "&Content=" + contentBody + "【川印文化集团股份有限公司】&SendTime="; //退订回N |
| | | string ssss = await HttpClientPostGB2312Async(url, "POST", data); |
| | | int aaaa = 0; |
| | | if (int.TryParse(ssss, out aaaa) && aaaa > 0) |
| | | { |
| | | result = new SMSReturnData() |
| | | { |
| | | ReturnStatus = "success", |
| | | Message = "短信发送成功", |
| | | RemainPoint = 0, |
| | | TaskID = 0, |
| | | SuccessCounts = 1, |
| | | IsSuccess = true, |
| | | }; |
| | | } |
| | | |
| | | |
| | | //var result = await smsOptions.ApiUrl.PostUrlEncodedAsync(new |
| | | //{ |
| | | // action = "send", |
| | | // userid = smsOptions.UserId, |
| | | // account = smsOptions.Account, |
| | | // password = smsOptions.Password, |
| | | // mobile, |
| | | // content = "【" + smsOptions.Signature + "】" + contentBody, |
| | | // rt = "json" |
| | | //}).ReceiveJson<SMSReturnData>(); |
| | | //result.IsSuccess = result.ReturnStatus.ToLowerInvariant() == "success"; |
| | | return result; |
| | | } |
| | | else |
| | |
| | | } |
| | | #endregion |
| | | |
| | | public async Task<string> HttpClientPostGB2312Async(string url, string Method, string data = "") |
| | | { |
| | | string _url = url;// "http://localhost:65022/login/getaa"; |
| | | string jsonParam = data;// "{\"a\":\"aa\",\"b\":\"bb\",\"c\":\"cc\"}"; |
| | | var request = (HttpWebRequest)WebRequest.Create(_url); |
| | | request.Method = Method;//"POST"; |
| | | request.ContentType = "application/x-www-form-urlencoded;charset=GB2312"; |
| | | var byteData = Encoding.GetEncoding("GB2312").GetBytes(jsonParam); |
| | | var length = byteData.Length; |
| | | request.ContentLength = length; |
| | | request.ServicePoint.Expect100Continue = false; |
| | | //ServicePointManager.Expect100Continue = false; |
| | | request.Timeout = 5000; //是进行后续同步请求时使用 GetResponse 方法等待响应以及 GetRequestStream 方法等待流所允许的毫秒数 |
| | | var writer = request.GetRequestStream(); |
| | | await writer.WriteAsync(byteData, 0, length); |
| | | writer.Close(); |
| | | |
| | | //接收响应内容 |
| | | var response = (HttpWebResponse)request.GetResponse(); |
| | | var responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")).ReadToEnd(); |
| | | return responseString.ToString(); |
| | | } |
| | | } |
| | | } |