Example #1
0
 protected YxMsg GetPageParameter()
 {
     YxMsg yxmsg = new YxMsg();
     yxmsg.BeginTime = this.txtStartTime.Value.Trim();
     yxmsg.EndTime = this.txtEndTime.Value.Trim();
     yxmsg.PageIndex = AspNetPager1.CurrentPageIndex;
     yxmsg.PageSize = AspNetPager1.PageSize;
     yxmsg.ClsID = int.Parse(this.txtSelectTime.SelectedValue);
     yxmsg.Message = this.txtMessage.Text.Trim();
     yxmsg.SeqNo = this.seqno;
     return yxmsg;
 }
Example #2
0
        /// <summary>
        /// 提交营销记录
        /// </summary>
        /// <param name="msg"></param>
        public static void Send(YxMsg msg)
        {
            using (SqlConnection cn = new SqlConnection(SqlHelper.ConnectionStringServer))
            {
                cn.Open();
                SqlTransaction tran = cn.BeginTransaction();
                SqlCommand cmd = new SqlCommand();

                try
                {
                    List<string> messages = SplitMessage(msg.Message,msg.SeqNo);
                    string msgitem = string.Empty;
                    foreach (string mess in messages)
                    {

                        SqlParameter[] param = new SqlParameter[] {
                            new SqlParameter(PARAM_SEQNO,SqlDbType.Int),
                            new SqlParameter(PARAM_MESSAGE,SqlDbType.VarChar),
                            new SqlParameter(PARAM_SENDTIME,SqlDbType.DateTime),
                            new SqlParameter(PARAM_SENDCOUNTS,SqlDbType.Int),
                            new SqlParameter(PARAM_STARTID,SqlDbType.Int),
                            new SqlParameter(PARAM_ENDID,SqlDbType.Int)
                        };
                        param[0].Value = msg.SeqNo;
                        param[1].Value = mess;
                        param[2].Value = msg.SendTime;
                        param[3].Value = msg.SendCounts;
                        param[4].Value = msg.StartID;
                        param[5].Value = msg.EndID;

                        Int64 SmsID = Convert.ToInt64(SqlHelper.ExecuteScalar(tran, CommandType.Text, SQL_SMS_SEND_ADD, param).ToString());

                        string[] str1 = msg.AreaIndustry.Split(';');
                        string[] str2 = null;

                        foreach (string str in str1)
                        {
                            str2 = str.Split('|');
                            if (str2.Length < 3)
                            {
                                continue;
                            }
                            cmd = new SqlCommand();
                            param = new SqlParameter[] {
                            new SqlParameter(PARAM_SMSID,SqlDbType.BigInt),
                            new SqlParameter(PARAM_PROVINCEID,SqlDbType.Int),
                            new SqlParameter(PARAM_AREAID,SqlDbType.Int),
                            new SqlParameter(PARAM_INDUSTRY,SqlDbType.Int)
                        };
                            param[0].Value = SmsID;
                            param[1].Value = str2[0];
                            param[2].Value = str2[1];
                            param[3].Value = str2[2];

                            SqlHelper.ExecuteNonQuery(tran, CommandType.Text, SQL_AREA_INDUSTRY_ADD, param);
                        }
                    }
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                }
            }
        }
Example #3
0
        public static DataSet GetSendList(YxMsg msg, out string totalRows)
        {
            string where = " 1 = 1";
            if (msg.SeqNo > -1)
            {
                where += string.Format(" and SeqNo = {0}", msg.SeqNo);
            }
            if (msg.ClsID == 1)//当天
            {
                where += string.Format(" and SubmitTime > '{0} 00:00:00'", DateTime.Now.ToString("yyyy-MM-dd"));
            }
            else if (msg.ClsID == 2)//一周内
            {
                where += string.Format(" and SubmitTime > '{0} 00:00:00'", DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd"));
            }
            else if (msg.ClsID == 3)//一个月以内
            {
                where += string.Format(" and SubmitTime > '{0} 00:00:00'", DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
            }
            else if (msg.ClsID == 4)
            {
                if (msg.BeginTime.Length > 0)
                {
                    where += string.Format(" and SubmitTime > '{0} 00:00:00'", msg.BeginTime);
                }
                if (msg.EndTime.Length > 0)
                {
                    if (where.Length > 0)
                    {
                        where += string.Format(" and SubmitTime < '{0} 23:59:59'", msg.EndTime);
                    }
                    else
                    {
                        where += string.Format(" and SubmitTime < '{0} 23:59:59'", msg.EndTime);
                    }
                }
            }
            if (msg.Message.Length > 0)
            {
                where += string.Format(" and Message like '%{0}%'", msg.Message);
            }
            string orderby = " order by ID desc";

            try
            {
                string sql = string.Format("select count(1) from YX_Sms_Send where {0}", where);
                totalRows = SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringServer, CommandType.Text, sql, null).ToString();

                sql = string.Format("SELECT * FROM (SELECT ROW_NUMBER() OVER ({0}) rowid, ID,SendTime,[Message],SendStatus,SuccessCounts,FailedCounts,SendCounts,cast(UsedValue as decimal(10,2)) as UsedValue FROM YX_Sms_Send Where {1}) AS TEMP WHERE rowid BETWEEN {2} AND {3}", orderby, where, (msg.PageIndex - 1) * msg.PageSize + 1, msg.PageIndex * msg.PageSize);

                DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringServer, CommandType.Text, sql, null);
                return ds;
            }
            catch
            {
                totalRows = "0";
                return null;
            }
        }
Example #4
0
    //发送按钮的单击事件
    protected void bt_Send_Click(object sender, EventArgs e)
    {
        this.btnSend.Enabled = false;
        int start = int.Parse(Request.Form["txtStart"].ToString().Trim());
        int end = int.Parse(Request.Form["txtEnd"].ToString().Trim());
        int num = end - start + 1;
        string area = this.Hidmg.Value;//Request.Form["Hidmg"].ToString();

        List<string> list = Send.SplitMessage(this.txtContent.Value.ToString(),0);
        int count = list.Count * num;
        if (!BalanceIsFull(count))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('发送失败,您的余额不足,请充值!');</script>");
            this.btnSend.Enabled = true;
            Refresh();
            return;
        }

        DateTime sendTime;
        if (string.IsNullOrEmpty(this.txtSendTime.Value))
        {
            sendTime = DateTime.Now;
        }
        else
        {
            sendTime = DateTime.Parse(this.txtSendTime.Value);
            switch (CheckTime(sendTime))
            {
                case SendTimeType.EqualToNow:
                    sendTime = DateTime.Now;
                    break;
                case SendTimeType.AMonthAfterNow:
                case SendTimeType.PriorToNow:
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('发送时间不能早于当前时间,不能晚于一个月');</script>");
                    this.btnSend.Enabled = true;
                    return;
                case SendTimeType.WithinAMonthAfterNow:
                    break;
            }
        }

        TimeSpan TimeSend = sendTime.TimeOfDay;
        TimeSpan TimeBegin = TimeSpan.Parse(Public.BeginTime);
        TimeSpan TimeEnd = TimeSpan.Parse(Public.EndTime);
        if (!(TimeSend >= TimeBegin && TimeSend < TimeEnd))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "time", string.Format("<script>alert('可以正常发送的时间段为{0}—{1}');</script>", TimeBegin.ToString(), TimeEnd.ToString()));
            this.btnSend.Enabled = true;
            return;
        }

        YxMsg msg = new YxMsg();
        msg.SeqNo = this.seqNo;
        msg.SendTime = sendTime;
        msg.Message = this.txtContent.Value;
        if (this.ddlSignatrue.SelectedItem.Value != "0")
        {
            msg.Message += "【" + this.ddlSignatrue.SelectedItem.Value + "】";
        }
        else
        {
            msg.Message = msg.Message.Replace('[', '【');
            msg.Message = msg.Message.Replace(']', '】');
        }
        msg.Message = msg.Message.Replace('#', '#');
        msg.Message = msg.Message.Replace("'", "''");
        msg.AreaIndustry = area;
        msg.StartID = start;
        msg.EndID = end;
        msg.SendCounts = num;
        YxSms.Send(msg);
        this.btnSend.Enabled = true;
        Response.Redirect("Sendok.htm", false);
    }