/// <summary> /// 创建文件及路径参数 /// </summary> public void CreateMdAndFilePaht(HttpPostedFile hpf) { //string wordMd = Request.PhysicalApplicationPath.Replace(HttpRuntime.AppDomainAppVirtualPath.Replace("/", "") + "\\", ""); string upPaht = "upload"; string createPaht = "\\Messge"; string fileSaveMd = createPaht + ul.LoginID + "\\"; fileDirectory = Request.PhysicalApplicationPath + upPaht + createPaht; if (Tunnel.Common.Common.CreateMd(fileDirectory) == 0) { fileDirectory = fileDirectory + fileSaveMd; if (Tunnel.Common.Common.CreateMd(fileDirectory) == 0) { upDbFilePaht = upPaht + createPaht + fileSaveMd; fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff"); } } if (hpf.ContentLength > 0) { if (!string.IsNullOrEmpty(hpf.FileName)) { fileName = fileName + System.IO.Path.GetExtension(hpf.FileName); } else { fileName = fileName + hpf.ContentType; } filePaht = upDbFilePaht + fileName; fileDirectory = fileDirectory + fileName; hpf.SaveAs(fileDirectory); } else { if (classid == 2) { Tunnel.Model.Tunnel_mail model = new Tunnel.Model.Tunnel_mail(); Tunnel.BLL.Tunnel_mail mbll = new Tunnel.BLL.Tunnel_mail(); model = mbll.GetModel(Convert.ToInt64(Id)); if (model.m_file.Trim().Equals("")) { filePaht = string.Empty; } else { filePaht = upDbFilePaht + fileName + model.m_file.Substring(model.m_file.LastIndexOf('.')); File.Copy(Request.PhysicalApplicationPath + model.m_file, fileDirectory + fileName + model.m_file.Substring(model.m_file.LastIndexOf('.'))); } } else { filePaht = string.Empty; } } }
private void PageBind2(int mailId) { Tunnel.BLL.Tunnel_mail mail = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail model = new Tunnel.Model.Tunnel_mail(); model = mail.GetModel(mailId); tb_Title.Text = "转发:" + model.m_title; tb_content.Text = "原信息内容:\n" + model.m_content.Replace(@"<br \>", "\n") + "\n" + model.m_time.ToString() + "\n-------------------------------\n"; if (!model.m_file.Trim().Equals("")) { Label1.Text += model.m_file.Substring(model.m_file.LastIndexOf('\\')); Label1.Visible = true; Label2.Visible = true; } }
private void PageBind(int mailId) { Tunnel.BLL.Tunnel_mail mail = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail model = new Tunnel.Model.Tunnel_mail(); model = mail.GetModel(mailId); tb_Title.Text = "回复:" + model.m_title; tb_content.Text = "原信息内容:\n" + model.m_content.Replace(@"<br \>", "\n") + "\n" + model.m_time.ToString() + "\n-------------------------------\n"; Tunnel.BLL.Tunnel_menber menb = new Tunnel.BLL.Tunnel_menber(); Tunnel.Model.Tunnel_menber mmol = new Tunnel.Model.Tunnel_menber(); mmol = menb.GetModel(model.m_from); tb_toname.Text = mmol.m_name + ","; id_toValue.Value = model.m_from.ToString() + ","; string priv_name = mmol.m_name; long priv_id = mmol.m_id; char d = '"'; td_tomail.InnerHtml = priv_name + "<IMG id=" + priv_name + priv_id + " onclick=" + "'" + "removeimg(" + d + priv_name + d + "," + d + priv_id + d + ");" + "'" + " src=" + d + "../../image/remove.png" + d + ">,"; }
/// <summary> /// 发送邮件并保存到服务器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { //获得所需参数 string strTo = tb_toname.Text.Trim(); strToIds = id_toValue.Value.Trim(); string strTitle = tb_Title.Text.Trim(); string strContent = tb_content.Text.Trim().Replace("\r\n", @"<br \>").Replace("原信息内容:", ""); HttpPostedFile hpf = file1.PostedFile; if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10) { Response.Write("<script>alert('附件大小不能大于10MB');</script>"); return; } else { CreateMdAndFilePaht(hpf); } //写入数据库 Tunnel.BLL.Tunnel_mail rbll = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail model = new Tunnel.Model.Tunnel_mail(); model.m_title = strTitle; model.m_content = strContent; model.m_file = filePaht; model.m_time = DateTime.Now; model.m_from = ul.LoginID; model.m_sort = 0; // 0未删除、1删除 model.m_state = 0; // 0未读、1已读 model.m_Ip = Tunnel.Common.Common.GetIp(); if (strToIds.LastIndexOf(',') > 0) { strToIds = strToIds.Remove(strToIds.LastIndexOf(','), 1); } string[] arr = strToIds.Split(','); int relt1 = -1; foreach (string s in arr) { bool state = true; for (int i = 1; i <= 2; i++) { if (i == 1) { model.m_Main = 1; //标记是自己发的 model.m_to = Convert.ToInt32(s); relt1 = rbll.Add(model); } else { model.m_Main = 0; //标记是发给别人的 model.m_to = Convert.ToInt32(s); relt1 = rbll.Add(model); //-------添加消息提示-------- Tunnel.Model.Tunnel_Remind remindmodel = new Tunnel.Model.Tunnel_Remind(); remindmodel.m_isread = 0; remindmodel.m_time = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); remindmodel.m_title = "新的站内消息,发件人:" + ul.getUserModel(model.m_from).m_name + "。时间:" + DateTime.Now + "<font color=red>(未读)</font>"; remindmodel.m_touser = model.m_to; remindmodel.m_url = "N_Exchange/N_Message/N_MessageView.aspx?Id=" + relt1; remindmodel.m_type = 2; remindmodel.m_typeid = relt1; remindmodel.m_callTime = Convert.ToDateTime("1800-01-01"); Tunnel.BLL.Tunnel_Remind rd = new Tunnel.BLL.Tunnel_Remind(); rd.Add(remindmodel); } if (relt1 == 0) { state = false; break; } } if (state == false) { break; } } string str = "站内信息发送"; string url = "N_MessageOld.aspx"; if (relt1 > 0) { str += "成功!"; } else { str += "失败!"; } MessageBox(str, url); }
public void NewSh() { if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); int i_hit = 0; string str1 = ""; if (RadioButton2.Checked) { i_hit = 1; str1 = "已通过审核"; } if (RadioButton1.Checked) { i_hit = 2; str1 = "审核已被驳回"; } string strsql = "update tunnel_information set i_hit=" + i_hit.ToString() + " where i_id=" + id.ToString(); int result = Tunnel.Data.DbHelperSQL.ExecuteSql(strsql); string str = ""; if (result > 0) { str = "提交成功"; PageBind(); } else { str = "提交失败"; } string strsql2 = "delete tunnel_remind where m_typeid=" + id.ToString() + " and m_type=4"; Tunnel.Data.DbHelperSQL.ExecuteSql(strsql2); Tunnel.Common.Message.Show(str); Tunnel_log model = new Tunnel_log(); model.l_content = "系统管理>>新闻管理>>审核新闻新闻,id:" + id; model.l_ip = Tunnel.Common.Common.GetIp(); model.l_time = DateTime.Now; model.l_user = ul.LoginID; model.l_sort = 3; Tunnel.BLL.Tunnel_log log = new Tunnel.BLL.Tunnel_log(); log.Add(model); strsql = "select * from tunnel_information where i_id=" + id; SqlDataReader reader = Tunnel.Data.DbHelperSQL.ExecuteReader(strsql); int touserId = 0; string titles = ""; if (reader.Read()) { touserId = Convert.ToInt32(reader["i_user"]); titles = reader["i_title"].ToString(); } if (touserId > 0 && touserId != ul.LoginID) { Tunnel.BLL.Tunnel_mail rbll = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail modelm = new Tunnel.Model.Tunnel_mail(); modelm.m_title = "新闻" + str1; modelm.m_content = "您发布的新闻:" + titles + "。" + str1; modelm.m_file = ""; modelm.m_time = DateTime.Now; modelm.m_from = ul.LoginID; modelm.m_sort = 0; // 0未删除、1删除 modelm.m_state = 0; // 0未读、1已读 modelm.m_Ip = Tunnel.Common.Common.GetIp(); int relt1 = -1; for (int i = 1; i <= 2; i++) { if (i == 1) { modelm.m_Main = 1; //标记是自己发的 modelm.m_to = Convert.ToInt32(touserId); relt1 = rbll.Add(modelm); } else { modelm.m_Main = 0; //标记是发给别人的 modelm.m_to = Convert.ToInt32(touserId); relt1 = rbll.Add(modelm); } } } } }