//add Rio public string AddEmailInfor(EmailEntity _EmailEntity) { DbParameter[] pramsInsert = { MakeInParam("@UserID",(DbType)SqlDbType.VarChar,50,_EmailEntity.UserID), MakeInParam("@SenderID",(DbType)SqlDbType.VarChar,2000,_EmailEntity.SenderID), MakeInParam("@ReceiverID",(DbType)SqlDbType.VarChar,2000,_EmailEntity.ReceiverID), MakeInParam("@MailTitle",(DbType)SqlDbType.VarChar,50,_EmailEntity.MailTitle), MakeInParam("@MailContent",(DbType)SqlDbType.VarChar,20000,_EmailEntity.MailContent), MakeInParam("@AttachmentID",(DbType)SqlDbType.VarChar,50,_EmailEntity.AttachID), MakeInParam("@ReceiveTime",(DbType)SqlDbType.DateTime,20,_EmailEntity.ReceiveTime), MakeInParam("@SendTime",(DbType)SqlDbType.DateTime,20,_EmailEntity.SendTime), MakeInParam("@ISRead",(DbType)SqlDbType.Int,4,_EmailEntity.ISRead ), MakeInParam("@UserMasterID",(DbType)SqlDbType.Int,4,_EmailEntity.UserMasterID ), MakeInParam("@SecretSenderID",(DbType)SqlDbType.VarChar,2000,_EmailEntity.SecretSenderID ), MakeInParam("@ISSecret",(DbType)SqlDbType.Int,4,_EmailEntity.IsScret ), }; StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO [dbo].[UserEmail]"); sb.Append("([UserID]"); sb.Append(",[SenderID]"); sb.Append(",[ReceiverID]"); sb.Append(",[MailTitle]"); sb.Append(",[MailContent]"); sb.Append(",[AttachmentID]"); sb.Append(",[ReceiveTime]"); sb.Append(",[ISRead]"); sb.Append(",[SendTime]"); sb.Append(",[UserMasterID]"); sb.Append(",[SecretSenderID]"); sb.Append(",[ISSecret]"); sb.Append(")"); sb.Append("VALUES"); sb.Append("(@UserID"); sb.Append(",@SenderID"); sb.Append(",@ReceiverID"); sb.Append(",@MailTitle"); sb.Append(",@MailContent"); sb.Append(",@AttachmentID"); sb.Append(",@ReceiveTime"); sb.Append(",@ISRead"); sb.Append(",@SendTime"); sb.Append(",@UserMasterID"); sb.Append(",@SecretSenderID"); sb.Append(",@ISSecret"); sb.Append(")"); sb.Append(" select @@identity;"); return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString(); }
protected void btnSendMail_Click(object sender, EventArgs e) { string szResult =""; string szUserSerialID = ""; // string szFileName = lblHideMessage.Text; string szAllName = ""; string szAllSecret = ""; string savePath = ".."; DataTable dtValue = (DataTable)FileUploadEmail.dtAttach; szAllName = txtSendTo.Text; szAllSecret = txtlblScret.Text; EmailEntity _EmailEntity = new EmailEntity(); _EmailEntity.UserID = userEntity.UserID; _EmailEntity.SenderID = szAllName; _EmailEntity.ReceiverID = ""; _EmailEntity.SendTime = DateTime.Now; _EmailEntity.ReceiveTime = DateTime.Now; _EmailEntity.MailTitle = txtTitle.Text; _EmailEntity.MailContent = FreeTextBox1.Text; _EmailEntity.ISRead = 0; if (szAllSecret == "") _EmailEntity.SecretSenderID = ""; else _EmailEntity.SecretSenderID = szAllSecret; if (dtValue.Rows.Count > 0) _EmailEntity.AttachID ="" ; else _EmailEntity.AttachID = ""; _EmailEntity.UserMasterID = 0; szUserSerialID = DbHelper.GetInstance().AddEmailInfor(_EmailEntity); if (dtValue.Rows.Count > 0) { for (int jj = 0; jj < dtValue.Rows.Count; jj++) { EmailAttachEntity _EmailAttachEntity = new EmailAttachEntity(); _EmailAttachEntity.AttachSize = Convert.ToSingle(dtValue.Rows[jj]["AttachSize"].ToString()); _EmailAttachEntity.AttachType = dtValue.Rows[jj]["AttachType"].ToString(); ; _EmailAttachEntity.AttachClientName = dtValue.Rows[jj]["AttachClientName"].ToString(); _EmailAttachEntity.AttachmentName = dtValue.Rows[jj]["AttachmentName"].ToString() ; _EmailAttachEntity.AttachmentUrl = Server.MapPath(savePath) + "\\" + dtValue.Rows[jj]["AttachmentName"].ToString(); _EmailAttachEntity.EmailSerialID = Int32.Parse(szUserSerialID); szResult = DbHelper.GetInstance().AddEmailAttachmentInfor(_EmailAttachEntity); } } int iCount = 0; string[] szOneAllName = szAllName.Split(';'); foreach (string szOneName in szOneAllName) { if (szOneName != "") { string[] szName = szOneName.Split('('); foreach (string szUserName in szName) { iCount++; if (iCount == 1) { _EmailEntity = new EmailEntity(); _EmailEntity.UserID = szUserName; _EmailEntity.SenderID = ""; _EmailEntity.ReceiverID = userEntity.UserID; _EmailEntity.SendTime = DateTime.Now; _EmailEntity.ReceiveTime = DateTime.Now; _EmailEntity.MailTitle = txtTitle.Text; _EmailEntity.MailContent = FreeTextBox1.Text; _EmailEntity.ISRead = 0; //0: 未读 1: 已读 2:删除(非彻底删除) _EmailEntity.SecretSenderID = ""; _EmailEntity.IsScret = 0; if (dtValue.Rows.Count > 0) _EmailEntity.AttachID = ""; else _EmailEntity.AttachID = ""; _EmailEntity.UserMasterID = Int32.Parse(szUserSerialID); szResult = DbHelper.GetInstance().AddEmailInfor(_EmailEntity); } else iCount = 0; } } } iCount = 0; string[] szOneSecretName = szAllSecret.Split(';'); foreach (string szOneName in szOneSecretName) { if (szOneName != "") { string[] szName = szOneName.Split('('); foreach (string szUserName in szName) { iCount++; if (iCount == 1) { _EmailEntity = new EmailEntity(); _EmailEntity.UserID = szUserName; _EmailEntity.SenderID = ""; _EmailEntity.ReceiverID = userEntity.UserID; _EmailEntity.SendTime = DateTime.Now; _EmailEntity.ReceiveTime = DateTime.Now; _EmailEntity.MailTitle = txtTitle.Text; _EmailEntity.MailContent = FreeTextBox1.Text; _EmailEntity.ISRead = 0; //0: 未读 1: 已读 2:删除(非彻底删除) _EmailEntity.SecretSenderID = ""; _EmailEntity.IsScret = 1; //1:密件 if (dtValue.Rows.Count > 0) _EmailEntity.AttachID = "" ; else _EmailEntity.AttachID = ""; _EmailEntity.UserMasterID = Int32.Parse(szUserSerialID); szResult = DbHelper.GetInstance().AddEmailInfor(_EmailEntity); } else iCount = 0; } } } Response.Redirect("Success.aspx"); }
public void ProcessRequest(HttpContext context) { string myaction = context.Request.Params["action"]; string temp = ""; if (myaction.ToLower() == "add") { string Title = context.Request.Params["TxtTitle"]; string Content = context.Request.Params["TxtContent"]; string Type = context.Request.Params["drType"]; string BeginTime = context.Request.Params["TxtBeginTime"]; string EndTime = context.Request.Params["TxtEndTime"]; string Invite = context.Request.Params["TxtInvite"]; string ckRemind = context.Request.Params["ckTiXing"]; //是否提醒 string Remind = context.Request.Params["drTiXing"]; //多久提醒 string ckRepeat = context.Request.Params["ckRepeat"]; //是否重复 string RepeatRate = context.Request.Params["drRepeatRate"]; //重复频率 string ckEmailNote = context.Request.Params["ckEmailNote"]; //是否邮件提醒 CalendarEventEntity _CalendarEvent = new CalendarEventEntity(); _CalendarEvent.Content = Content; _CalendarEvent.EmailNote = ckEmailNote; _CalendarEvent.EndTime = DateTime.Parse(EndTime); _CalendarEvent.Invite = Invite; _CalendarEvent.Note = ckRemind; _CalendarEvent.NoteBefore = Int16.Parse(Remind); _CalendarEvent.Repeat = ckRepeat; _CalendarEvent.RepeatRate = Int16.Parse(RepeatRate); _CalendarEvent.StartTime = DateTime.Parse(BeginTime); _CalendarEvent.Title = Title; _CalendarEvent.Type = Int16.Parse(Type); _CalendarEvent.UserID = Int32.Parse(context.Session["UserID"].ToString()); int id = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEvent); string[] UserList = Invite.Split(','); foreach(string UserID in UserList) { if (UserID != "") { if (ckEmailNote == "true") //发邮件提醒 { EmailEntity _EmailEntity = new EmailEntity(); _EmailEntity.UserID = context.Session["UserID"].ToString(); _EmailEntity.SenderID = UserID; _EmailEntity.ReceiverID = context.Session["UserID"].ToString(); _EmailEntity.SendTime = DateTime.Now; _EmailEntity.ReceiveTime = DateTime.Now; _EmailEntity.MailTitle = "[提醒]" + Title; _EmailEntity.MailContent = Content; _EmailEntity.ISRead = 0; //0: 未读 1: 已读 2:删除(非彻底删除) _EmailEntity.SecretSenderID = ""; _EmailEntity.IsScret = 0; _EmailEntity.AttachID = ""; _EmailEntity.UserMasterID = 0; string szResult = DbHelper.GetInstance().AddEmailInfor(_EmailEntity); } //添加到提醒好友的事件中 _CalendarEvent.Content = Content; _CalendarEvent.EmailNote = ckEmailNote; _CalendarEvent.EndTime = DateTime.Parse(EndTime); _CalendarEvent.Invite = Invite; _CalendarEvent.Note = ckRemind; _CalendarEvent.NoteBefore = Int16.Parse(Remind); _CalendarEvent.Repeat = ckRepeat; _CalendarEvent.RepeatRate = Int16.Parse(RepeatRate); _CalendarEvent.StartTime = DateTime.Parse(BeginTime); _CalendarEvent.Title = Title; _CalendarEvent.Type = Int16.Parse(Type); _CalendarEvent.UserID = Int32.Parse( UserID); int idd = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEvent); } } if (ckRemind=="true") //提醒 {} if (ckRepeat == "true") //重复 { } Global.CalendarNote(); //提醒定时器 } else if (myaction.ToLower() == "show") { int UserID = Int32.Parse(context.Session["UserID"].ToString()); int id = Int32.Parse(context.Request.Params["activity.id"].ToString()); StringBuilder jsonBuilder = new StringBuilder(); DataTable dtCalendar = DbHelper.GetInstance().GetCalenderEventByID(id); if (dtCalendar.Rows.Count > 0) { if (dtCalendar.Rows.Count > 0) { jsonBuilder.Append("{\""); jsonBuilder.Append(dtCalendar.TableName); jsonBuilder.Append("\":["); for (int i = 0; i < dtCalendar.Rows.Count; i++) { jsonBuilder.Append("{"); for (int j = 0; j < dtCalendar.Columns.Count; j++) { jsonBuilder.Append("\""); jsonBuilder.Append(dtCalendar.Columns[j].ColumnName); jsonBuilder.Append("\":\""); jsonBuilder.Append(dtCalendar.Rows[i][j].ToString()); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilder.Append("}"); } } context.Response.Write(jsonBuilder); } else if (myaction.ToLower() == "delete") { } else if (myaction.ToLower() == "update") { int id = Int32.Parse(context.Request.Form["activity.id"].ToString()); CalendarEventEntity _CalendarEventEntity = DbHelper.GetInstance().GetCalendarEntityByID(id); string Title = context.Request.Params["TxtTitle"]; string Content = context.Request.Params["TxtContent"]; string Type = context.Request.Params["drType"]; string BeginTime = context.Request.Params["TxtBeginTime"]; string EndTime = context.Request.Params["TxtEndTime"]; string Invite = context.Request.Params["TxtInvite"]; string ckRemind = context.Request.Params["ckTiXing"]; //是否提醒 string Remind = context.Request.Params["drTiXing"]; //多久提醒 string ckRepeat = context.Request.Params["ckRepeat"]; //是否重复 string RepeatRate = context.Request.Params["drRepeatRate"]; //重复频率 string ckEmailNote = context.Request.Params["ckEmailNote"]; //是否邮件提醒 _CalendarEventEntity.Content = Content; _CalendarEventEntity.EmailNote = ckEmailNote; _CalendarEventEntity.EndTime = DateTime.Parse(EndTime); _CalendarEventEntity.Invite = Invite; _CalendarEventEntity.Note = ckRemind; _CalendarEventEntity.NoteBefore = Int16.Parse(Remind); _CalendarEventEntity.Repeat = ckRepeat; _CalendarEventEntity.RepeatRate = Int16.Parse(RepeatRate); _CalendarEventEntity.StartTime = DateTime.Parse(BeginTime); _CalendarEventEntity.Title = Title; _CalendarEventEntity.Type = Int16.Parse(Type); int id_update = DbHelper.GetInstance().UpDateCalendarEvnetByID(_CalendarEventEntity); Global.CalendarNote(); //提醒定时器 } else if (myaction.ToLower() == "save") { string title = context.Request.Form["activity.title"]; DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]); DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]); CalendarEventEntity _CalendarEventEntity = new CalendarEventEntity(); _CalendarEventEntity.UserID = Int32.Parse(context.Session["UserID"].ToString()); _CalendarEventEntity.Type = 0; _CalendarEventEntity.Title = title; _CalendarEventEntity.StartTime = startTime; _CalendarEventEntity.RepeatRate = 0; _CalendarEventEntity.Repeat = ""; _CalendarEventEntity.NoteBefore = 0; _CalendarEventEntity.Note = ""; _CalendarEventEntity.Invite = ""; _CalendarEventEntity.EndTime = endTime; _CalendarEventEntity.EmailNote = ""; _CalendarEventEntity.Content = ""; int id = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEventEntity); if (id != 0) { SortedDictionary<string, object> values = new SortedDictionary<string, object>(); values.Add("returnStr", "success"); values.Add("id", id); context.Response.Write(new JavaScriptSerializer().Serialize(values)); } Global.CalendarNote(); //提醒定时器 } else if (myaction.ToLower() == "loadmonth") { DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]); DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]); int PermissionUserID = Int32.Parse(context.Request.Params["PerssionUserID"].ToString()); int UserID; if (PermissionUserID == 0) UserID = Int32.Parse(context.Session["UserID"].ToString()); else UserID = PermissionUserID; ////本月第一天时间 //DateTime dt_First = startTime.AddDays(-(startTime.Day) + 1); ////将本月月数+1 //DateTime dt2 = startTime.AddMonths(1); ////本月最后一天时间 //DateTime dt_Last = dt2.AddDays(-(startTime.Day)); DataTable dtMonth = DbHelper.GetInstance().GetCalendarByDate(startTime, endTime, UserID); StringBuilder jsonBuilder = new StringBuilder(); if (dtMonth.Rows.Count > 0) { if (dtMonth.Rows.Count > 0) { jsonBuilder.Append("{\""); jsonBuilder.Append(dtMonth.TableName); jsonBuilder.Append("\":["); for (int i = 0; i < dtMonth.Rows.Count; i++) { jsonBuilder.Append("{"); for (int j = 0; j < dtMonth.Columns.Count; j++) { jsonBuilder.Append("\""); jsonBuilder.Append(dtMonth.Columns[j].ColumnName); jsonBuilder.Append("\":\""); jsonBuilder.Append(dtMonth.Rows[i][j].ToString()); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilder.Append("}"); } } context.Response.Write(jsonBuilder); } else if (myaction.ToLower() == "loadweek") { DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]); DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]); int PermissionUserID = Int32.Parse( context.Request.Params["PerssionUserID"].ToString()); int UserID; if(PermissionUserID==0) UserID = Int32.Parse(context.Session["UserID"].ToString()); else UserID = PermissionUserID; //int weeknow = Convert.ToInt32(startTime.DayOfWeek); ////星期日 获取weeknow为0 //weeknow = weeknow == 0 ? 7 : weeknow; //int daydiff = (-1) * weeknow + 1; //int dayadd = 7 - weeknow; ////本周第一天 //DateTime datebegin = startTime.AddDays(daydiff); ////本周最后一天 //DateTime dateend = startTime.AddDays(dayadd); DataTable dtWeek = DbHelper.GetInstance().GetCalendarByDate(startTime, endTime, UserID); StringBuilder jsonBuilder = new StringBuilder(); if (dtWeek.Rows.Count > 0) { if (dtWeek.Rows.Count > 0) { jsonBuilder.Append("{\""); jsonBuilder.Append(dtWeek.TableName); jsonBuilder.Append("\":["); for (int i = 0; i < dtWeek.Rows.Count; i++) { jsonBuilder.Append("{"); for (int j = 0; j < dtWeek.Columns.Count; j++) { jsonBuilder.Append("\""); jsonBuilder.Append(dtWeek.Columns[j].ColumnName); jsonBuilder.Append("\":\""); jsonBuilder.Append(dtWeek.Rows[i][j].ToString()); jsonBuilder.Append("\","); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("},"); } jsonBuilder.Remove(jsonBuilder.Length - 1, 1); jsonBuilder.Append("]"); jsonBuilder.Append("}"); } context.Response.Write(jsonBuilder); } } }