using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Text;
|
using System.Web;
|
|
namespace IStation.Server
|
{
|
/// <summary>
|
/// sms短消息辅助类
|
/// </summary>
|
public class DataDockingSmsHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public static bool Send(Model.DataDockingProblem problem, Model.DataDockingProblem.SmsHandleParameters handleParas)
|
{
|
try
|
{
|
|
string content = $"【智慧泵站】{problem.Name},中断时长超过 {problem.Interruption} 秒, 数据出现问题! ";
|
string signName = "【智慧泵站】";
|
string productId = "676767";
|
foreach (var tele in handleParas.Telephones)
|
{
|
string strURL = "http://www.ztsms.cn:8800/sendXSms.do?username={0}&password={1}&mobile={2}&content={3}&dstime=&productid={4}&xh=";
|
strURL = string.Format(strURL, handleParas.Account.UserName, handleParas.Account.Password, tele, HttpUtility.UrlEncode(content + signName), productId);
|
WebRequest wRequest = WebRequest.Create(strURL);
|
WebResponse wResponse = wRequest.GetResponse();
|
Stream stream = wResponse.GetResponseStream();
|
StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default);
|
string result = reader.ReadToEnd();
|
wResponse.Close();
|
|
if (!result.Contains("1,"))
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
catch //(Exception)
|
{
|
return default;
|
//throw;
|
}
|
}
|
|
|
|
}
|
}
|