protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SendMailFacade.sendEmail(CommonMethodFacade.GetConfigValue("NoticeEmail"), "系统报错,页面:" + CommonMethod.FinalString(Request["aspxerrorpath"]), "系统报错,页面:" + CommonMethod.FinalString(Request["aspxerrorpath"])); } }
protected void btnSave_Click(object sender, EventArgs e) { RetrieveCriteria rc = new RetrieveCriteria(typeof(XiHuan_UserInfoEntity)); Condition c = rc.GetNewCondition(); c.AddEqualTo(XiHuan_UserInfoEntity.__USERNAME, txtName.Text.Trim()); rc.AddSelect(XiHuan_UserInfoEntity.__USERNAME); rc.AddSelect(XiHuan_UserInfoEntity.__ORIGNALPWD); rc.AddSelect(XiHuan_UserInfoEntity.__QUESTION); rc.AddSelect(XiHuan_UserInfoEntity.__ANSWER); XiHuan_UserInfoEntity user = rc.AsEntity() as XiHuan_UserInfoEntity; if (user != null) { if (user.Question == txtQuestion.Text.Trim() && user.Answer == txtAnswer.Text.Trim()) { try { SendMailFacade.sendEmail(txtEmail.Text.Trim(), "喜换网-找回密码", "<strong>" + txtName.Text.Trim() + "</strong>您好,<br/>您在喜换网注册的账号密码为" + user.OrignalPwd + ",请妥善保管,此邮件为系统邮件,请勿回复!"); Alert("您的密码已成功发送到您的邮箱,请注意查收!"); ExecScript("parent.ymPrompt.close();"); } catch { Alert("抱歉:邮件发送出现错误!"); return; } } else { Alert("很抱歉:您输入的安全提问问题和答案不符合,我们不能为您提供找回密码的服务!"); return; } } else { Alert("不存在换客名为" + txtName.Text + "的用户!"); return; } }
public void Execute(JobExecutionContext context) { SendMailFacade.sendEmail(CommonMethodFacade.GetConfigValue("NoticeEmail"), " 进行了自动触发程序执行操作!", "进行了自动触发程序执行操作"); HttpWebRequest wr = WebRequest.Create(CommonMethodFacade.GetConfigValue("GenerateUrl")) as HttpWebRequest; wr.Timeout = 30 * 1000 * 60; //超时时间30分钟 wr.ReadWriteTimeout = 30 * 1000 * 60; //超时时间30分钟 WebResponse ws = wr.GetResponse(); string response = string.Empty; using (System.IO.StreamReader reader = new System.IO.StreamReader( ws.GetResponseStream() , System.Text.Encoding.GetEncoding("GBK"))) { response = reader.ReadToEnd(); if (response.Equals("1") && CommonMethodFacade.GetConfigValue("SendSysTriggerEmail").Equals("true")) { SendMailFacade.sendEmail(CommonMethodFacade.GetConfigValue("NoticeEmail"), "网站半小时自动执行程序触发", " 执行成功,进行了更新明星换客和换品浏览次数,更新幻灯操作,留言自动审核,更新首页操作!"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!IsUserAlreadyLogin) { MemberCenterPageRedirect("", "goodsadd.aspx" + (IsEdit ? "?id=" + CommonMethod.FinalString(Request["id"]) : "")); } else { #region 务器端验证 以后完善 #endregion #region 保存换品信息 Transaction t = new Transaction(); XiHuan_UserGoodsEntity newgoods = null; if (IsEdit) { newgoods = XiHuan_UserGoodsEntityAction.RetrieveAXiHuan_UserGoodsEntity(CommonMethod.ConvertToInt(Request["id"], 0)); } else { newgoods = new XiHuan_UserGoodsEntity(); } newgoods.OwnerId = CurrentUserId; newgoods.OwnerName = CurrentUserName; newgoods.Name = txtGoodName.Text.Trim(); newgoods.IsTJ = chkTJ.Checked ? (byte)1 : (byte)0; newgoods.TypeId = CommonMethod.ConvertToInt(ddlGoodType.SelectedValue, 0); newgoods.ChildId = CommonMethod.ConvertToInt(ddlGoodChildType.SelectedValue, 0); newgoods.IsHavePhoto = rbtYes.Checked ? (byte)XiHuan_UserGoodsFacade.IsGoodHavePhoto. : (byte)XiHuan_UserGoodsFacade.IsGoodHavePhoto.无; newgoods.Description = txtGoodDesc.Value.Trim(); newgoods.NewDeep = byte.Parse(ddlNewOldDeep.SelectedValue.Trim()); newgoods.OnlyCityChange = chkValidCity.Checked ? (byte)1 : (byte)0; newgoods.OnlySchoolChange = chkValidSchool.Checked ? (byte)1 : (byte)0; newgoods.HopeToChangeTypeId = CommonMethod.ConvertToInt(ddlGoodType1.SelectedValue, 0); newgoods.HopeToChangeChildTypeId = CommonMethod.ConvertToInt(ddlGoodChildType1.SelectedValue, 0); newgoods.HopeToChangeDesc = txtHopeToChangeDesc.Text.Trim(); newgoods.ProvinceId = CurrentUser.ProvinceId; newgoods.ProvinceName = CurrentUser.ProvinceName; newgoods.CityId = CurrentUser.CityId; newgoods.CityName = CurrentUser.CityName; newgoods.AreaId = CurrentUser.AreaId; newgoods.AreaName = CurrentUser.AreaName; newgoods.SchoolId = CurrentUser.SchoolId; newgoods.SchoolName = CurrentUser.SchoolName; if (!IsEdit) { newgoods.CreateDate = DateTime.Now; newgoods.ViewCount = new Random().Next(10, 30); newgoods.GoodState = (byte)XiHuan_UserGoodsFacade.GoodsState.新登记; } newgoods.IsChecked = (byte)(SystemConfigFacade.Instance().IsGoodsAddNeedCheck ? 0 : 1); t.DoSaveObject(newgoods); if (!IsEdit) { #region 换品图片上传 string gooddefaultphoto = string.Empty; if (rbtYes.Checked) { string extention = string.Empty; int filesize = 0; string filepath = string.Empty; string savepath = string.Empty; string filename = string.Empty; HttpFileCollection goodimages = HttpContext.Current.Request.Files; for (int i = 0; i < goodimages.Count; i++) { HttpPostedFile currentfile = goodimages[i]; extention = Path.GetExtension(currentfile.FileName); filesize = currentfile.ContentLength; filepath = "images/userupload/goodsimage/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/"; //不符合条件的直接跳过,不进行保存 if (!(currentfile.FileName.Length > 0) || filesize == 0 || !CommonMethod.IsUploadImageValid("", extention) || filesize > 500 * 1024) { continue; } else { if (!Directory.Exists(Server.MapPath(filepath))) { Directory.CreateDirectory(Server.MapPath(filepath)); } filename = newgoods.Id.ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssfff"); currentfile.SaveAs(Server.MapPath(filepath + filename + extention)); XiHuan_GoodsImageEntity newgoodimage = new XiHuan_GoodsImageEntity(); newgoodimage.GoodsId = newgoods.Id; newgoodimage.GoodsName = newgoods.Name; newgoodimage.ImgSrc = filepath + filename + extention; newgoodimage.CreateDate = DateTime.Now; if (i == 0) { gooddefaultphoto = filepath + filename + GlobalVar.DefaultPhotoSize + extention; newgoodimage.IsDefaultPhoto = 1; //生成不同规格的图片 PicHelper.MakeThumbnail(Server.MapPath(filepath + filename + extention), Server.MapPath(filepath + filename + GlobalVar.DefaultPhotoSize + extention), 85, 85); PicHelper.MakeThumbnail(Server.MapPath(filepath + filename + extention), Server.MapPath(filepath + filename + GlobalVar.BigPhotoSize + extention), 200, 220); } t.DoSaveObject(newgoodimage); } } } #endregion #region 默认图片保存 string sql = string.Format("update XiHuan_UserGoods set DefaultPhoto='{0}' where Id={1} ", gooddefaultphoto.Length > 0 ? gooddefaultphoto : "images/none.jpg", newgoods.Id); t.DoSqlNonQueryString(sql, GlobalVar.DataBase_Name); #endregion #region 更新用户换品数量和积分,换币 string updategoodsnumber = string.Format(@"update XiHuan_UserInfo set GoodsNumber=GoodsNumber+1, Score=Score+{0},HuanBi=HuanBi+{1} where Id={2}" , SystemConfigFacade.Instance().AddScoreByAddGoods(), SystemConfigFacade.Instance().AddHBByAddGoods(), CurrentUser.ID); t.DoSqlNonQueryString(updategoodsnumber, GlobalVar.DataBase_Name); #endregion #region 浏览人 XiHuan_GoodsViewUserEntity view = new XiHuan_GoodsViewUserEntity(); view.GoodsId = newgoods.Id; view.Type = 0; view.VisitDate = DateTime.Now; view.VisitorName = "喜换网"; view.VisitorId = 1; view.VisitorHeadImage = "images/userupload/20092113032102_1.png"; t.DoSaveObject(view); #endregion } try { string detailurl = "goods/" + newgoods.CreateDate.Year + "/" + newgoods.CreateDate.Month + "/" + newgoods.CreateDate.Day + "/goods" + newgoods.Id + ".html"; t.DoSqlNonQueryString("update XiHuan_UserGoods set DetailUrl='" + detailurl + "' where Id=" + newgoods.Id, GlobalVar.DataBase_Name); t.Commit(); if (!SystemConfigFacade.Instance().IsGoodsAddNeedCheck) { DataTable dt = Query.ProcessSql("select Id,DetailUrl,GoodState from XiHuan_UserGoods with(nolock) where OwnerId= " + CurrentUserId + " and IsChecked=1 ", GlobalVar.DataBase_Name); foreach (DataRow dr in dt.Rows) { CommonMethod.readAspxAndWriteHtmlSoruce("showdetail.aspx?id=" + dr["Id"], dr["DetailUrl"].ToString()); } } if (IsEdit) { Alert("恭喜:换品信息保存成功" + (SystemConfigFacade.Instance().IsGoodsAddNeedCheck ? ",我们会尽快进行审核" : string.Empty) + "^_^!"); } else { Alert("恭喜:换品登记成功" + (SystemConfigFacade.Instance().IsGoodsAddNeedCheck ? ",我们会尽快进行审核" : string.Empty) + "^_^!"); SendMailFacade.sendEmail("[email protected],[email protected]", "有人在喜换网发换品了", "有人在喜换网发换品:" + txtGoodName.Text); } ExecScript("window.location='goodlist.aspx?s='+Math.random();"); } catch (Exception ex) { t.RollBack(); Alert("抱歉:换品保存出错," + ex.Message); return; } #endregion } }
protected void lnkSubmit_Click(object sender, EventArgs e) { #region 务器端验证 int provinceid = CommonMethod.ConvertToInt(ddlProvince.SelectedValue, 0); int cityid = CommonMethod.ConvertToInt(ddlCity.SelectedValue, 0); int areaid = CommonMethod.ConvertToInt(ddlArea.SelectedValue, 0); int schoolid = CommonMethod.ConvertToInt(ddlSchool.SelectedValue, 0); if (txtUserName.Text.Trim().Length == 0) { Alert(" 请您填写换客名!"); Select(txtUserName); return; } else if (XiHuan_UserFacade.IsUserNameAlreayUse(txtUserName.Text)) { Alert("您填写的换客名已经被占用,请您换个换客名重试!"); Select(txtUserName); return; } if (txtPassWord.Text.Trim().Length == 0) { Alert("请您填写密码!"); Select(txtPassWord); return; } if (txtPassWord2.Text.Trim().Length == 0) { Alert("请您再次输入密码!"); Select(txtPassWord2); return; } if (!txtPassWord.Text.Trim().Equals(txtPassWord2.Text.Trim())) { Alert("两次密码输入不一致,请重新输入!"); Select(txtPassWord2); return; } if (txtEmail.Text.Trim().Length > 0) { Regex reg = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); if (!reg.IsMatch(txtEmail.Text.Trim())) { Alert("您的邮箱格式填写不正确!"); Select(txtEmail); return; } } if (provinceid == 0) { Alert("请您选择省份!"); return; } if (cityid == 0) { Alert("请您选择城市!"); return; } if (txtQuestion.Text.Trim().Length == 0) { Alert("请您填写安全提问问题!"); Select(txtQuestion); return; } if (txtAnswer.Text.Trim().Length == 0) { Alert("请您填写安全提问答案!"); Select(txtAnswer); return; } #endregion #region 用户基本信息 Transaction t = new Transaction(); XiHuan_UserInfoEntity NewUser = new XiHuan_UserInfoEntity(); NewUser.UserType = (int)XiHuan_UserFacade.UserType.个人注册; NewUser.UserName = txtUserName.Text.Trim(); NewUser.OrignalPwd = txtPassWord.Text.Trim(); NewUser.Md5Pwd = CommonMethod.MD5Encrypt(txtPassWord.Text.Trim()); NewUser.Email = txtEmail.Text.Trim(); NewUser.Gender = Rad_sex_0.Checked ? (byte)1 : (byte)0; NewUser.ProvinceId = provinceid; NewUser.ProvinceName = ddlProvince.SelectedItem.Text; NewUser.CityId = cityid; if (cityid > 0) { NewUser.CityName = CommonMethodFacade.GetCityNameById(cityid.ToString()); } NewUser.AreaId = areaid; if (areaid > 0) { NewUser.AreaName = CommonMethodFacade.GetAreaNameById(areaid.ToString()); } if (schoolid > 0) { NewUser.SchoolId = schoolid; NewUser.SchoolName = CommonMethodFacade.GetSchoolNameById(provinceid.ToString(), cityid.ToString(), schoolid.ToString()); } NewUser.HuanBi = SystemConfigFacade.Instance().RegisterAddHuanBi(); NewUser.Score = SystemConfigFacade.Instance().RegisterAddScore(); NewUser.RegisterDate = NewUser.LastLoginTime = DateTime.Now; NewUser.Question = txtQuestion.Text.Trim(); NewUser.Answer = txtAnswer.Text.Trim(); NewUser.HeadImage = "images/nophoto.gif"; t.DoSaveObject(NewUser); #endregion #region 推荐人积分换币更新 if (txtTuiJianMember.Text.Trim().Length > 0) { string updateTJ = string.Format("update XiHuan_UserInfo set Score=Score+{0},HuanBi=HuanBi+{1} where UserName='******' ", SystemConfigFacade.Instance().TuiJianAddScore(), SystemConfigFacade.Instance().TuiJianAddHuanBi(), txtTuiJianMember.Text.Trim()); t.DoSqlNonQueryString(updateTJ, GlobalVar.DataBase_Name); } #endregion #region 给新注册用户发送短消息 XiHuan_MessageFacade.SendNewMessage(1, NewUser.ID, "喜换网", NewUser.UserName, "尊敬的会员" + NewUser.UserName + "," + SystemConfigFacade.Instance().RegMesContent(), t, true); #endregion try { t.Commit(); #region 注册完成后自动登陆调转到个人管理中心 Alert("恭喜:您的注册信息已成功提交!"); CommonMethod.AddLoginCookie(NewUser.ID, NewUser.UserName, DateTime.MinValue); SendMailFacade.sendEmail(CommonMethodFacade.GetConfigValue("NoticeEmail"), "有人在喜换网注册了", "有人在喜换网注册了:" + txtUserName.Text); Response.Redirect("membercenter.aspx?action=" + Server.UrlEncode("membermanageindex.aspx")); #endregion } catch (Exception ex) { t.RollBack(); Alert("抱歉:注册信息提交失败," + ex.Message + "请重试!"); return; } }
private void AddNotes() { #region 验证 string username = CommonMethod.FinalString(Request["username"]); string userpass = CommonMethod.FinalString(Request["pwd"]); if (!IsUserAlreadyLogin) { if (username.Length == 0) { CommonMethod.ResponseAjaxContent(this.Page, "needusername"); return; } if (userpass.Length == 0) { CommonMethod.ResponseAjaxContent(this.Page, "needpwd"); return; } } #endregion #region 留言提交 XiHuan_GuestBookEntity newguest = new XiHuan_GuestBookEntity(); newguest.ToId = CommonMethod.ConvertToInt(Request["oid"], 0); newguest.ToName = GlobalObject.unescape(CommonMethod.FinalString(Request["oname"])); newguest.GoodsId = CommonMethod.ConvertToInt(Request["gid"], 0);; newguest.GoodsName = GlobalObject.unescape(CommonMethod.FinalString(Request["gname"])); if (IsUserAlreadyLogin) { newguest.FromId = CurrentUserId; newguest.FromName = CurrentUserName; } else { if (XiHuan_UserFacade.IsUserValid(username, userpass)) { CommonMethod.AddLoginCookie(XiHuan_UserFacade.GetIdByName(username), username, DateTime.MinValue); newguest.FromName = username; newguest.FromId = XiHuan_UserFacade.GetIdByName(username); } else { CommonMethod.ResponseAjaxContent(this.Page, "notvaliduser"); return; } } newguest.Content = GlobalObject.unescape(CommonMethod.FinalString(Request["content"])); newguest.IsScerect = CommonMethod.FinalString(Request["issceret"]) == "true" ? (byte)1 : (byte)0; newguest.CreateDate = DateTime.Now; newguest.IsChecked = 0; newguest.Save(); SendMailFacade.sendEmail(CommonMethodFacade.GetConfigValue("NoticeEmail"), "有人在喜换网留言了", "有人在喜换网留言了,快去审核吧!"); if (CommonMethod.FinalString(Request["type"]).Equals("1")) { CommonMethod.readAspxAndWriteHtmlSoruce("showdetail.aspx?id=" + newguest.GoodsId, CommonMethod.FinalString(Request["url"])); } CommonMethod.ResponseAjaxContent(this.Page, "ok"); #endregion }
protected void btnSendMaiil_Click(object sender, EventArgs e) { string mailcontent = " <table style=\"width:98%;border: #ccc 1px solid;padding-right: 10px;padding-left: 10px;padding-bottom: 10px;padding-top: 10px;background-color: #f7f7f7; font-size:14px; color:black;\">"; RetrieveCriteria rcGoodsPics = new RetrieveCriteria(typeof(XiHuan_UserGoodsEntity)); rcGoodsPics.AddSelect(XiHuan_UserGoodsEntity.__DEFAULTPHOTO); rcGoodsPics.AddSelect(XiHuan_UserGoodsEntity.__NAME); rcGoodsPics.AddSelect(XiHuan_UserGoodsEntity.__DETAILURL); Condition c = rcGoodsPics.GetNewCondition(); c.AddEqualTo(XiHuan_UserGoodsEntity.__ISCHECKED, 1); c.AddNotEqualTo(XiHuan_UserGoodsEntity.__DEFAULTPHOTO, "images/none.jpg"); rcGoodsPics.OrderBy(XiHuan_UserGoodsEntity.__CREATEDATE, false); rcGoodsPics.Top = 70; EntityContainer ecGoods = rcGoodsPics.AsEntityContainer(); for (int i = 0; i < ecGoods.Count; i++) { int rem; XiHuan_UserGoodsEntity goods = ecGoods[i] as XiHuan_UserGoodsEntity; Math.DivRem(i, 7, out rem); if (rem == 0) { mailcontent += "<tr>"; } else { mailcontent += string.Format("<td style=\"border: solid 1px #CCCCCC;height: 30px;text-align:center;padding: 2px 5px;\"> <a title=\"{0}\" href=\"{1}\" target=\"_blank\"><img style=\"width: 85px;height: 85px;border: solid 1px #CCCCCC;\" title=\"{0}\" src=\"{2}\" /><br/><br/>{3}</a></td>", goods.Name, "http://www.tsc8.com/" + goods.DetailUrl + "?from=email", "http://www.tsc8.com/" + goods.DefaultPhoto, CommonMethod.GetSubString(goods.Name, 6, "...")); } if (rem == 0) { mailcontent += "</tr>"; } } mailcontent += "</table>"; DataTable dt = PersistenceLayer.Query.ProcessSql("select Id,UserName,Email,QQ,Msn from XiHuan_UserInfo with(nolock) where LastLoginTime<='" + DateTime.Now.AddDays(-Math.Abs(Convert.ToDouble(txtDays.Text))).ToString("yyyy-MM-dd") + "' and (Email>'' or QQ >'' or Msn >'')", GlobalVar.DataBase_Name); string strMailAdd = string.Empty; string email = string.Empty; string qq = string.Empty; string msn = string.Empty; foreach (DataRow dr in dt.Rows) { strMailAdd = string.Empty; email = CommonMethod.FinalString(dr[XiHuan_UserInfoEntity.__EMAIL]).ToLower(); qq = GetFinalQQ(CommonMethod.FinalString(dr[XiHuan_UserInfoEntity.__QQ])); msn = CommonMethod.FinalString(dr[XiHuan_UserInfoEntity.__MSN]); if (IsEmail(email)) { strMailAdd += email + ","; } if (IsInt(qq)) { strMailAdd += qq + "@qq.com,"; } if (IsEmail(msn)) { strMailAdd += msn + ","; } if (strMailAdd.Length > 0) { SendMailFacade.sendEmail(strMailAdd.TrimEnd(','), "喜换网-物品交换,节约,时尚,好玩,精彩不容错过!", "<span style=\"color:blue;font-weight:bold;\">尊敬的换友<a href=\"http://www.tsc8.com/xh.aspx?id=" + dr[XiHuan_UserInfoEntity.__ID] + "&from=email\" target=\"_blank\" style=\"color:red;\">" + dr[XiHuan_UserInfoEntity.__USERNAME] + "</a>,我们注意到你有段时间没来<a href=\"http://www.tsc8.com/?from=eamil&id=" + dr[XiHuan_UserInfoEntity.__ID] + "\" target=\"_blank\" style=\"color:red;\">喜换网</a>逛逛了啊,<br/><br/>你不在的这段时间里好多朋友发布了很多好玩的换品:</span><br/><br/>" + mailcontent + "<br/><br/>现在快<a href=\"http://www.tsc8.com/?from=eamil\" target=\"_blank\">去看看</a>吧!"); } } Alert("恭喜:邮件已经成功发送!"); }