lixiaojun
2022-08-24 902c72c963c2acc23aac04c2beef256cf68d2757
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
            }
        }
 
 
 
    }
}