Example #1
0
        /// <summary>
        /// 获取特定子号的所有回复(只能获取一次,回复获取后服务器将删除)
        /// </summary>
        /// <returns></returns>
        public static ManDaoSMS[] ReceiveSMS()
        {
            string sn       = (string)ConfigurationManager.AppSettings["sn"];
            string pwd      = (string)ConfigurationManager.AppSettings["pwd"];
            string password = (string)ConfigurationManager.AppSettings["password"];

            cn.entinfo.sdk3.WebService ws = new cn.entinfo.sdk3.WebService();
            cn.entinfo.sdk3.MOBody[]   msgs;
            msgs = ws.RECSMSEx(sn, pwd, "1");
            ManDaoSMS[] msg = new ManDaoSMS[msgs.Length];
            return(msg);
        }
Example #2
0
        /// <summary>
        /// 获取剩余短信
        /// </summary>
        /// <returns></returns>
        public static int GetLeftSmsNum()
        {
            string sn  = (string)ConfigurationManager.AppSettings["sn"];
            string pwd = (string)ConfigurationManager.AppSettings["pwd"];

            cn.entinfo.sdk3.WebService ws = new cn.entinfo.sdk3.WebService();
            //检验余额
            string Overage = ws.GetBalance(sn, pwd);
            int    money   = Utils.StrToInt(Overage, 0);

            return(money);
        }
Example #3
0
        /// <summary>
        /// 发送短信息
        /// </summary>
        /// <param name="mobile">手机号,多个用","间隔</param>
        /// <param name="content">短信内容,字数不限,短信服务接口自动处理;内容字符无限制;70个字符为一条短信</param>
        /// <returns>"1"-余额不足,"0"-成功,串码-失败</returns>
        public static string SendSMS(string mobile, string content)
        {
            //Common.FileOperate.WriteFile("C:\\sms.txt", mobile + "-" + content);
            string sn       = (string)ConfigurationManager.AppSettings["sn"];
            string pwd      = (string)ConfigurationManager.AppSettings["pwd"];
            string password = (string)ConfigurationManager.AppSettings["password"];

            cn.entinfo.sdk3.WebService ws = new cn.entinfo.sdk3.WebService();
            string[] count = mobile.Split(',');
            //检验余额
            string Overage = ws.GetBalance(sn, pwd);
            int    money   = Utils.StrToInt(Overage, 0);

            if (money < count.Length)
            {
                return("1"); //余额不足
            }
            int    rnd      = new Random(DateTime.Now.Millisecond).Next();
            String sendTime = "(" + DateTime.Now.ToString("MM-dd HH:mm") + ")";
            string result   = "";

            //多于500人后需要分批发送
            if (count.Length <= 500)
            {
                //result = ws.SendSMSEx(sn, pwd, mobile, content + SIGNATRUE, "1");
                result = ws.mt(sn, password, mobile, content + sendTime + SIGNATRUE, EXT, "", rnd.ToString());
            }
            else
            {
                //分批发送
                for (int i = 0; i < (count.Length / 500) + ((count.Length % 500 == 0) ? 0 : 1); i++)
                {
                    string mobilestr = "";
                    for (int j = i * 500; j < count.Length; j++)
                    {
                        mobilestr += count[j] + ",";
                    }
                    result = ws.mt(sn, password, mobile, content + sendTime + SIGNATRUE, EXT, "", rnd.ToString());
                }
            }
            //Common.FileOperate.WriteFile("C:\\sms.txt",  " result-" + result);
            if (result == rnd.ToString())
            {
                return(RESULT_SUCCESS);
            }
            return("error");
        }