/// <summary> /// 组合成对象实体 /// </summary> /// <param name="row">一行数据</param> /// <returns>Model.plugin_feedback</returns> private Model.plugin_feedback DataRowToModel(DataRow row) { Model.plugin_feedback model = new Model.plugin_feedback(); if (row != null) { if (null != row["id"] && "" != row["id"].ToString()) { model.id = int.Parse(row["id"].ToString()); } if (null != row["site_path"]) { model.site_path = row["site_path"].ToString(); } if (null != row["title"]) { model.title = row["title"].ToString(); } if (null != row["content"]) { model.content = row["content"].ToString(); } if (null != row["user_name"]) { model.user_name = row["user_name"].ToString(); } if (null != row["user_tel"]) { model.user_tel = row["user_tel"].ToString(); } if (null != row["user_qq"]) { model.user_qq = row["user_qq"].ToString(); } if (null != row["user_email"]) { model.user_email = row["user_email"].ToString(); } if (null != row["add_time"] && "" != row["add_time"].ToString()) { model.add_time = DateTime.Parse(row["add_time"].ToString()); } if (null != row["reply_content"]) { model.reply_content = row["reply_content"].ToString(); } if (null != row["reply_time"] && "" != row["reply_time"].ToString()) { model.reply_time = DateTime.Parse(row["reply_time"].ToString()); } if (null != row["is_lock"] && "" != row["is_lock"].ToString()) { model.is_lock = int.Parse(row["is_lock"].ToString()); } } return(model); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_feedback", DTEnums.ActionEnum.Reply.ToString()); //检查权限 BLL.plugin_feedback bll = new BLL.plugin_feedback(); model = bll.GetModel(this.id); model.reply_content = Utils.ToHtml(txtReContent.Text); model.reply_time = DateTime.Now; bll.Update(model); AddAdminLog(DTEnums.ActionEnum.Reply.ToString(), "回复留言插件内容:" + model.title); //记录日志 JscriptMsg("留言回复成功!", "index.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_feedback</param> /// <returns>True or False</returns> public bool Update(Model.plugin_feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [" + databaseprefix + "plugin_feedback] set "); strSql.Append("site_path=@site_path,"); strSql.Append("title=@title,"); strSql.Append("content=@content,"); strSql.Append("user_name=@user_name,"); strSql.Append("user_tel=@user_tel,"); strSql.Append("user_qq=@user_qq,"); strSql.Append("user_email=@user_email,"); strSql.Append("add_time=@add_time,"); strSql.Append("reply_content=@reply_content,"); strSql.Append("reply_time=@reply_time,"); strSql.Append("is_lock=@is_lock"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@site_path", SqlDbType.NVarChar, 100), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 50), new SqlParameter("@user_tel", SqlDbType.NVarChar, 30), new SqlParameter("@user_qq", SqlDbType.NVarChar, 30), new SqlParameter("@user_email", SqlDbType.NVarChar, 100), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@reply_content", SqlDbType.NText), new SqlParameter("@reply_time", SqlDbType.DateTime), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.site_path; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.user_name; parameters[4].Value = model.user_tel; parameters[5].Value = model.user_qq; parameters[6].Value = model.user_email; parameters[7].Value = model.add_time; parameters[8].Value = model.reply_content; parameters[9].Value = model.reply_time; parameters[10].Value = model.is_lock; parameters[11].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_feedback</param> /// <returns>ID</returns> public int Add(Model.plugin_feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [" + databaseprefix + "plugin_feedback]("); strSql.Append("site_path,title,content,user_name,user_tel,user_qq,user_email,add_time,reply_content,reply_time,is_lock"); strSql.Append(") values("); strSql.Append("@site_path,@title,@content,@user_name,@user_tel,@user_qq,@user_email,@add_time,@reply_content,@reply_time,@is_lock)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@site_path", SqlDbType.NVarChar, 100), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 50), new SqlParameter("@user_tel", SqlDbType.NVarChar, 30), new SqlParameter("@user_qq", SqlDbType.NVarChar, 30), new SqlParameter("@user_email", SqlDbType.NVarChar, 100), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@reply_content", SqlDbType.NText), new SqlParameter("@reply_time", SqlDbType.DateTime), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.site_path; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.user_name; parameters[4].Value = model.user_tel; parameters[5].Value = model.user_qq; parameters[6].Value = model.user_email; parameters[7].Value = model.add_time; parameters[8].Value = model.reply_content; parameters[9].Value = model.reply_time; parameters[10].Value = model.is_lock; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (null != obj) { return(Convert.ToInt32(obj)); } else { return(0); } }
private void feedback_add(HttpContext context) { StringBuilder strTxt = new StringBuilder(); BLL.plugin_feedback bll = new BLL.plugin_feedback(); Model.plugin_feedback model = new Model.plugin_feedback(); string _site_path = DTRequest.GetQueryString("site"); string _code = DTRequest.GetFormString("txtCode"); string _title = DTRequest.GetFormString("txtTitle"); string _content = DTRequest.GetFormString("txtContent"); string _user_name = DTRequest.GetFormString("txtUserName"); string _user_tel = DTRequest.GetFormString("txtUserTel"); string _user_qq = DTRequest.GetFormString("txtUserQQ"); string _user_email = DTRequest.GetFormString("txtUserEmail"); //检查站点目录 if (string.IsNullOrEmpty(_site_path)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}"); return; } //校检验证码 if (string.IsNullOrEmpty(_code)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入验证码!\"}"); return; } if (context.Session[DTKeys.SESSION_CODE] == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,验证码已过期!\"}"); return; } if (_code.ToLower() != (context.Session[DTKeys.SESSION_CODE].ToString()).ToLower()) { context.Response.Write("{\"status\":0, \"msg\":\"验证码与系统的不一致!\"}"); return; } if (string.IsNullOrEmpty(_content)) { context.Response.Write("{\"status\": 0, \"msg\": \"对不起,请输入留言的内容!\"}"); return; } model.site_path = Utils.DropHTML(_site_path); model.title = Utils.DropHTML(_title); model.content = Utils.ToHtml(_content); model.user_name = Utils.DropHTML(_user_name); model.user_tel = Utils.DropHTML(_user_tel); model.user_qq = Utils.DropHTML(_user_qq); model.user_email = Utils.DropHTML(_user_email); model.add_time = DateTime.Now; model.is_lock = 1; //不需要审核,请改为0 if (bll.Add(model) > 0) { //是否开启通知功能 if (config.bookmsg > 0 && config.receive != "") { switch (config.bookmsg) { case 1: DTcms.Model.sms_template smsModel = new DTcms.BLL.sms_template().GetModel(config.booktemplet); //取得短信内容 if (smsModel != null) { //替换模板内容 string smstxt = smsModel.content; smstxt = smstxt.Replace("{webname}", siteConfig.webname); smstxt = smstxt.Replace("{webtel}", siteConfig.webtel); smstxt = smstxt.Replace("{weburl}", siteConfig.weburl); smstxt = smstxt.Replace("{username}", model.user_name); smstxt = smstxt.Replace("{usertel}", model.user_tel); smstxt = smstxt.Replace("{userqq}", model.user_qq); smstxt = smstxt.Replace("{useremail}", model.user_email); smstxt = smstxt.Replace("{usertitle}", model.title); smstxt = smstxt.Replace("{usercontent}", model.content); //发送短信 string tipMsg = string.Empty; bool result = new DTcms.BLL.sms_message().Send(config.receive, smstxt, 1, out tipMsg); if (!result) { LogHelper.WriteLog("手机信息发送失败!"); } } break; case 2: //获得邮件内容 DTcms.Model.mail_template mailModel = new DTcms.BLL.mail_template().GetModel(config.booktemplet); if (mailModel != null) { //替换模板内容 string titletxt = mailModel.maill_title; string bodytxt = mailModel.content; titletxt = titletxt.Replace("{webname}", siteConfig.webname); titletxt = titletxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{webname}", siteConfig.webname); bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel); bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl); bodytxt = bodytxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{usertel}", model.user_tel); bodytxt = bodytxt.Replace("{userqq}", model.user_qq); bodytxt = bodytxt.Replace("{useremail}", model.user_email); bodytxt = bodytxt.Replace("{usertitle}", model.title); bodytxt = bodytxt.Replace("{usercontent}", model.content); //循环发送 string[] emailArr = config.receive.Split(','); foreach (string email in emailArr) { if (DTcms.Common.Utils.IsValidEmail(email)) { //发送邮件 try { DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailusername, DESEncrypt.Decrypt(siteConfig.emailpassword, siteConfig.sysencryptstring), siteConfig.emailnickname, siteConfig.emailfrom, email, titletxt, bodytxt); } catch { LogHelper.WriteLog("邮件发送失败!"); } } } } break; } } context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,留言提交成功!\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}"); return; }
//赋值操作 private void ShowInfo(int _id) { BLL.plugin_feedback bll = new BLL.plugin_feedback(); model = bll.GetModel(_id); txtReContent.Text = Utils.ToTxt(model.reply_content); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_feedback</param> /// <returns>True Or False</returns> public bool Update(Model.plugin_feedback model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_feedback</param> /// <returns>ID</returns> public int Add(Model.plugin_feedback model) { return(dal.Add(model)); }