邮箱找回密码:
ForgetPass.aspx.cs
Admins admin = new Admins()[u.AdminID];string key = Shove._Security.Encrypt.EncryptString(PublicFunction.GetCallCert(), u.ID + "," + DateTime.Now.ToString());//key进行md5加密后转成16进制后得到一个32位的密文MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();string sign = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(key))).Replace("-", "");key = sign.Substring(0, 16) + key + sign.Substring(16, 16);string url = Shove._Web.Utility.GetUrl() + "/Users/ResetPass.aspx?key=" + key;
ResetPass.aspx.cs
string sign = key.Substring(0, 16) + key.Substring(key.Length – 16, 16);key = key.Substring(16, key.Length – 32);try{if (sign != BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(key))).Replace("-", "")){tb1.Visible = false;tb2.Visible = true;return;}key = Shove._Security.Encrypt.UnEncryptString(PublicFunction.GetCallCert(), key);long userID = Shove._Convert.StrToLong(key.Split(',')[0], 0);hfId.Value = userID.ToString();DateTime time = Convert.ToDateTime(key.Split(',')[1]);}catch { }
上传附件:
<asp:FileUpload ID="hfImageUrl" runat="server" Width="400px" />
protected void lbSave_Click(object sender, EventArgs e){ string ImageUrl = GetImageName();if (ImageUrl==""){ImageUrl =hfImg.Value;} UpLoadImage(ImageUrl); }//获取文件名private string GetImageName(){string ImageUrl = "";if (hfImageUrl.HasFile){string Extension = System.IO.Path.GetExtension(hfImageUrl.FileName).ToLower();if (".gif.png.jpeg.jpg".IndexOf(Extension) < 0){Shove._Web.JavaScript.Alert(this.Page, "图片后缀名错误!");return "";}ImageUrl = DateTime.Now.Ticks + new Random().Next().ToString() + Extension;}return ImageUrl;}/// <summary>/// 上传图片/// </summary>/// <param name="ImageUrl"></param>private void UpLoadImage(string ImageUrl){string NewsImagePath = Server.MapPath("../Users/Images/Users/");if (ImageUrl != hfImg.Value){if (System.IO.File.Exists(NewsImagePath + hfImg.Value)){System.IO.File.Delete(NewsImagePath + hfImg.Value);}hfImageUrl.PostedFile.SaveAs(NewsImagePath + ImageUrl);}}
Post方式传值:
JonPublish.aspx
<form id="form2" method="post" action="JobPreview.aspx" target="_blank"><input type="hidden" id="hfJobName" name="hfJobName" /><input type="hidden" id="hfWorkAddress" name="hfWorkAddress" /></form>function View() {document.getElementById("hfJobName").value = document.getElementById("<%=tbJName.ClientID %>").value;if (document.getElementById("<%=ddlJobs.ClientID %>").value != "-1") {document.getElementById("hfJobName").value += "(" + document.getElementById("<%=ddlJobs.ClientID %>").options[document.getElementById("<%=ddlJobs.ClientID %>").selectedIndex].text + ")";}form2.submit();}
JobPreview.aspx:
<input type="hidden" id="hfJobName" name="hfJobName" runat="server" /><input type="hidden" id="hfWorkAddress" public void BindData(){lblAdress.Text = PublicFunction.ToString(this.Request["hfWorkAddress"]);lblDateTime.Text = DateTime.Now.ToString();}
xls数据导入:
using System.Data.SqlClient; using System.Data.OleDb;protected void btnImport_Click(object sender, EventArgs e){string xlsPath = Server.MapPath("~/app_data/1.xls"); // 绝对物理路径string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Extended Properties=Excel 8.0;" +"data source=" + xlsPath;// 查询语句string sql = "SELECT * FROM [Sheet1$]";DataSet ds = new DataSet();OleDbDataAdapter da = new OleDbDataAdapter(sql, connStr);da.Fill(ds);string CompanyName = "";int CityID = -1;string Country = "";int IndustryID = -1;string Address = "";string Intro = "";string Url = "";Companys com = null;string ReturnMsg = "";foreach (DataRow r in ds.Tables[0].Rows){if (r[0].ToString() == ""){continue;}CompanyName = r[0].ToString();CityID = Shove._Convert.StrToInt(DAL.Functions.F_GetCityIDByName(r[1].ToString()),-1);Country = r[2].ToString();IndustryID = DAL.Functions.F_GetIndustryTypeIDByName(r[3].ToString(), true);Address = r[4].ToString();Intro = r[5].ToString();Url = r[6].ToString();com = new Companys();com.CompanyName = CompanyName;com.Source = 3;//管理员填写com.CityID = CityID;com.Country = Country;com.IndustryID = IndustryID;com.Address = Address;com.AdminID = 1;com.Address = Address;com.Intro = Intro;com.Url = Url;com.Add(ref ReturnMsg);}}
邮件发送:
Mail.cs
public void SendMail(string MailFrom,string Name,string MailTo,string Subject,string Body,string MailServer,string MailUserName,string MailPassWord){MailMessage mm = new MailMessage();//发件人mm.From = new MailAddress(MailFrom, Name);//收件人(可以是多个)mm.To.Add(new MailAddress(MailTo));//mm.To.Add(new MailAddress("aierong@163.com"));//抄送 (CC)(可以是多个)//mm.CC.Add(new MailAddress("aierong@qq.com"));//mm.CC.Add(new MailAddress("aierong@qq.com"));//密件抄送 (BCC)(可以是多个)//mm.Bcc.Add(new MailAddress("114298@qq.com"));//mm.Bcc.Add(new MailAddress("10249102@qq.com"));//主题mm.Subject = Subject;//邮件正文mm.IsBodyHtml = true;mm.Body = Body;//附件(可以是多个)//mm.Attachments.Add(new Attachment(@"D:/Access.zip"));//mm.Attachments.Add(new Attachment(@"D:/SetupReport.msi"));SmtpClient sc = new SmtpClient();//设置SMTP主机的名称或IP地址sc.Host = MailServer;string User = MailUserName;string PassWord = MailPassWord;//设置用于验证发件人身份的凭据sc.Credentials = new System.Net.NetworkCredential(User, PassWord);sc.Send(mm);}
InterView.aspx.cs
Mail mail = new Mail();try{mail.SendMail(admin.EmailServer_From, tbMail.Value, Mail, MailTitle, EmailBody, admin.EmailServer_EmailServer, admin.EmailServer_UserName, admin.EmailServer_Password);}catch (Exception eee){Shove._Web.JavaScript.Alert(this, "发送失败,请再次验证双方Email地址有效性!");return;}System.Threading.Thread.Sleep(10);