Ejemplo n.º 1
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public bool Send(SmsSendDto dto)
        {
            string code       = SmsSender.GetVCode();
            int    sendResult = SmsSender.SendMsgByTXY("", dto.Receiver, code);

            var sendLog = new SmsSendLog()
            {
                UserId     = dto.UserId,
                Type       = dto.Type,
                Code       = code,
                Count      = 1,
                Receiver   = dto.Receiver,
                Sender     = dto.Sender,
                SendPort   = 0,
                SendTime   = DateTime.Now,
                UpdateTime = DateTime.Now,
                Status     = 0,
                SendResult = sendResult
            };

            if (sendResult != 0)
            {
                sendLog.Status = 2;
            }
            else
            {
                sendLog.Status = 1;
            }

            string sql = string.Format(@"INSERT INTO [dbo].[SmsSendLog]
      ([UserId],[Sender],[Receiver],[Type],[Code],[Status],[Count],[SendTime],[SendPort],[SendResult],[UpdateTime])
      VALUES({0},'{1}','{2}',{3},'{4}',{5},{6},GETDATE(),{7},{8},GETDATE())",
                                       sendLog.UserId, sendLog.Sender, sendLog.Receiver, sendLog.Type, sendLog.Code,
                                       sendLog.Status, sendLog.Status, sendLog.SendPort, sendLog.SendResult);

            SqlHelper.ExecuteNonQuery(sql);

            return(sendLog.SendResult == 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 发送模板消息,包含参数
 /// </summary>
 /// <param name="dto"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public bool Send(SmsSendDto dto, Dictionary <string, string> param)
 {
     throw new NotImplementedException();
 }