コード例 #1
0
ファイル: SMSDB.cs プロジェクト: aspdotnetmvc/mvc
        /// <summary>
        /// 插入记录到ReviewMT 中
        /// </summary>
        /// <param name="sms"></param>
        /// <param name="Numbers"></param>
        /// <param name="tran"></param>
        private static void AddReviewMT(SMSMessage sms, SMSNumber Numbers, IDbTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ReviewMT(");
            strSql.Append("SMSID,AccountID,Phones,SMSContent,StatusReport,SMSLevel,SendTime,Audit,ContentFilter,PhoneCount,SendGateway,PriorityDate,AuditResult,Signature,SPNumber,@WapURL,SMSTimer,Source)");
            strSql.Append(" values (");
            strSql.Append("@SMSID,@AccountID,@Phones,@SMSContent,@StatusReport,@SMSLevel,@SendTime,@Audit,@ContentFilter,@PhoneCount,@SendGateway,@PriorityDate,@AuditResult,@Signature,@SPNumber,@WapURL,@SMSTimer,@Source)");

            DBHelper.Instance.Execute(strSql.ToString(),
                                      new
            {
                SMSID         = Numbers.ID,
                AccountID     = sms.AccountID,
                Phones        = Numbers.Numbers,
                SMSContent    = sms.Content,
                StatusReport  = (ushort)sms.StatusReportType,
                SMSLevel      = (ushort)sms.SMSLevel,
                SendTime      = sms.SendTime,
                Audit         = (ushort)(sms.AuditType == AuditType.Template ? AuditType.Manual : sms.AuditType),
                ContentFilter = 0,
                PhoneCount    = Numbers.NumberCount,
                SendGateway   = sms.Channel,
                PriorityDate  = sms.SendTime,
                AuditResult   = sms.AuditType == AuditType.Manual ? 0 : 1,
                Signature     = sms.Signature,
                SPNumber      = sms.SPNumber,
                WapURL        = sms.WapURL,
                SMSTimer      = sms.SMSTimer,
                Source        = sms.Source
            }, tran);
        }
コード例 #2
0
ファイル: SMSDB.cs プロジェクト: aspdotnetmvc/mvc
        /// <summary>
        /// 增加一条短信号码
        /// </summary>
        public static void AddSMSNumber(SMSNumber smsnumber, IDbTransaction tran = null)
        {
            string sql = @"insert into SMSNumber(ID,SMSID,Numbers,NumberCount,Operator,SendTime)
                       values(@ID,@SMSID,@Numbers,@NumberCount,@Operator,@SendTime)";

            DBHelper.EnsureID(smsnumber);

            DBHelper.Instance.Execute(sql, smsnumber, tran);
        }
コード例 #3
0
ファイル: TwilioController.cs プロジェクト: davidbwire/bvcms
        public ActionResult NumberAdd(int groupID, string newNumber)
        {
            var n = new SMSNumber();

            n.LastUpdated = DateTime.Now;
            n.GroupID     = groupID;
            n.Number      = newNumber;

            DbUtil.Db.SMSNumbers.InsertOnSubmit(n);
            DbUtil.Db.SubmitChanges();

            return(RedirectToAction("Index"));
        }
コード例 #4
0
ファイル: TwilioHelper.cs プロジェクト: rastographics/bvcms
        public static string SendSmsReplyIncoming(CMSDataContext db, int receivedId,
                                                  Person p, string toNumber, SMSNumber fromNumber, string title, string message)
        {
            string sSid   = GetSid(db);
            string sToken = GetToken(db);

            var list = new SMSList
            {
                Created     = DateTime.Now,
                SendAt      = DateTime.Now,
                SenderID    = db.UserPeopleId ?? 1,
                SendGroupID = fromNumber.GroupID,
                Title       = title,
                Message     = message,
                ReplyToId   = receivedId
            };
            var item = new SMSItem
            {
                ListID   = list.Id,
                PeopleID = p?.PeopleId,
                Number   = toNumber,
            };

            list.SMSItems.Add(item);

            var r = new TextReplacements(db, message);

            if (item.PeopleID != null)
            {
                message = r.DoReplacements(item);
            }
            var response = SendSmsInternal(sSid, sToken, fromNumber.Number, toNumber, message);

            var succeeded = !IsSmsFailed(response);

            if (succeeded)
            {
                list.SentSMS = 1;
                item.Sent    = true;
            }
            db.SMSLists.InsertOnSubmit(list);
            db.SubmitChanges();
            if (succeeded)
            {
                db.Connection.Execute(
                    "update dbo.SmsReceived set RepliedTo = @replied where id = @id",
                    new { replied = true, id = receivedId });
            }
            return(ResultMessage(response, toNumber));
        }
コード例 #5
0
        public static bool IsConfigured(CMSDataContext db)
        {
            bool   isConfigured = false;
            string sSID         = GetSid(db);
            string sToken       = GetToken(db);

            if (sSID.HasValue() && sToken.HasValue())
            {
                SMSNumber smsNumber = db.SMSNumbers.FirstOrDefault();
                if (smsNumber != null)
                {
                    isConfigured = true;
                }
            }

            return(isConfigured);
        }
コード例 #6
0
        public static bool SendSMS(CMSDataContext db, string toNumber, SMSNumber fromNumber, string message)
        {
            bool   success = false;
            string sSID    = GetSid(db);
            string sToken  = GetToken(db);

            if (sSID.HasValue() && sToken.HasValue())
            {
                SMSNumber smsNumber = fromNumber ?? db.SMSNumbers.FirstOrDefault();
                if (smsNumber != null)
                {
                    var response = SendSmsInternal(sSID, sToken, smsNumber.Number, toNumber, message);
                    success = new[] {
                        MessageResource.StatusEnum.Accepted,
                        MessageResource.StatusEnum.Queued,
                        MessageResource.StatusEnum.Sending
                    }.Contains(response.Status);
                }
            }
            return(success);
        }