/* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */ package com.hygj.action; import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.DynaActionForm; import org.apache.struts.actions.DispatchAction; import sun.awt.EmbeddedFrame; import com.hygj.bean.EmailBean; import com.hygj.bean.UsersBean; import com.hygj.dao.SendedDAOINF; import com.hygj.dao.impl.SendedDAOImpl; import com.hygj.email.EmailService; import com.hygj.service.InfoServiceINF; import com.hygj.service.impl.InfoServiceImpl; import com.sun.java_cup.internal.emit; /** * MyEclipse Struts * Creation date: 04-30-2009 * * XDoclet definition: * @struts.action parameter="method" validate="true" */ public class InfoAction extends DispatchAction { /* * Generated Methods */ /** * 功能:验证用户 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward checkLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { DynaActionForm dn = (DynaActionForm) form; UsersBean users = new UsersBean(); users.setUsername(dn.get("username").toString()); users.setPassword(dn.get("password").toString()); InfoServiceINF info = new InfoServiceImpl(); UsersBean user = info.checkLogin(users); if(user.getId()>0) { request.getSession().setAttribute("user", user); return mapping.findForward("main"); } else { return new ActionForward("/index.jsp"); } } /****** * 功能:发送Email * @param mapping * @param form * @param request * @param response * @return */ public ActionForward sendedMail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { request.setCharacterEncoding("GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } DynaActionForm dn = (DynaActionForm) form; Calendar cl=Calendar.getInstance(); //获取日期 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String thetime = sdf.format(cl.getTime()); UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); EmailBean email = new EmailBean(); email.setHost("smtp.sohu.com"); email.setUsername(ub.getUsername()); email.setPassword(ub.getPassword()); email.setSender(dn.get("fajianren").toString()); email.setRecipients(dn.get("shoujianren").toString()); email.setTitle(dn.get("title").toString()); email.setContent(dn.get("content").toString()); email.setThetime(thetime); email.setType(3); email.setStatus(0); InfoServiceINF info = new InfoServiceImpl(); int flag = info.sendEmail(email);//存数据库 new EmailService().sendEmail(email);//发邮件 return mapping.findForward("ok"); } /** * 功能:查询已接受邮件 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectGetsEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); info.deleteShou(ub.getUsername(), "1");//删除收件箱邮件 EmailBean email = new EmailBean(); email.setHost("pop3.sohu.com"); email.setUsername(ub.getUsername()); email.setPassword(ub.getPassword()); email.setRecipients(ub.getUsername()+"@sohu.com"); new EmailService().receiveMail(email);//接收邮件 List<EmailBean> list = info.selectGetsEmail(ub.getUsername());//查询数据库 System.out.println(list.size()+"================"); request.setAttribute("list", list); return mapping.findForward("yijie"); } /** * 功能:查询已接受邮件(数量,未读) * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectGetCout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int itt = info.selectGetCount(ub.getUsername());//数量 System.out.println(itt+"数量"); int iss = info.selectGetSCount(ub.getUsername());//未读 request.setAttribute("itt", itt); request.setAttribute("iss", iss); return mapping.findForward("yijiecount"); } /** * 功能:查询已发送邮件 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectSendedEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); List<EmailBean> list = info.selectsendedEmail(ub.getUsername()); request.setAttribute("list", list); return mapping.findForward("yifa"); } /** * 功能:查询已删除邮件 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectDeleteEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); List<EmailBean> list = info.selectdeleteEmail(ub.getUsername()); request.setAttribute("list", list); return mapping.findForward("yishan"); } /** * 功能:查询已发送邮件详细 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectMoreEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String id = request.getParameter("id"); InfoServiceINF info = new InfoServiceImpl(); List<EmailBean> list = info.selectMoreEmail(id); //根据ID查询邮件详细信息 int flag = info.updateDeleteEmail(id); //更新已删除邮件状态 request.setAttribute("list", list); return mapping.findForward("emaillist"); } /** * 功能:查询已发送邮件(数量) * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectSeEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int it = info.selectSendedCount(ub.getUsername()); request.setAttribute("it", it); return mapping.findForward("yifacout"); } /** * 功能:查询已删除邮件(数量) * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectDeleteCout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int it = info.selectDeleteCount(ub.getUsername());//数量 int is = info.selectDeleteUCount(ub.getUsername());//未读 request.setAttribute("it", it); request.setAttribute("is", is); return mapping.findForward("yishancout"); } /** * 功能:查询草稿邮件 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectCao(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); List<EmailBean> list = info.selectCaoEmail(ub.getUsername()); request.setAttribute("list", list); return mapping.findForward("caogao"); } /** * 功能:查询草稿邮件(数量) * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward selectCaoCount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int io = info.selectCaoCount(ub.getUsername());//数量 System.out.println(io+"---!"); request.setAttribute("io", io); return mapping.findForward("caogaocount"); } /**** * 左侧 * @param mapping * @param form * @param request * @param response * @return */ public ActionForward selectCount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int shoujian = info.selectGetCount(ub.getUsername());//收件 int caogao = info.selectCaoCount(ub.getUsername());//草稿 int yifa = info.selectSendedCount(ub.getUsername());//已发 int delete = info.selectDeleteCount(ub.getUsername());//删除 request.setAttribute("shoujian", shoujian); request.setAttribute("caogao", caogao); request.setAttribute("yifa", yifa); request.setAttribute("delete", delete); return mapping.findForward("left"); } /**** * 欢迎页 * @param mapping * @param form * @param request * @param response * @return */ public ActionForward welcome(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); InfoServiceINF info = new InfoServiceImpl(); int wel = info.selectGetCount(ub.getUsername());//数量 int come = info.selectGetSCount(ub.getUsername());//未读 String user = ub.getUsername(); request.setAttribute("user", user); request.setAttribute("wel", wel); request.setAttribute("come", come); return mapping.findForward("welcome"); } /** * 移动到垃圾箱 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward moveAll(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String[] arg = request.getParameterValues("del_id"); InfoServiceINF ss = new InfoServiceImpl(); for (String str : arg) { ss.moveBox(str); } return mapping.findForward("oki"); } /** * 删除邮件 * Method execute * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward deleteEmail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String[] arg = request.getParameterValues("del_id"); InfoServiceINF ss = new InfoServiceImpl(); for (String str : arg) { ss.deleteEmail(str); } UsersBean ub = (UsersBean)(request.getSession().getAttribute("user") != null ? request.getSession().getAttribute("user") : ""); EmailBean email = new EmailBean(); email.setHost("pop3.sohu.com"); email.setUsername(ub.getUsername()); email.setPassword(ub.getPassword()); new EmailService().deleteMail(email); return mapping.findForward("oks"); } }
最近下载更多
Tuxxxxx LV3
2023年1月3日
xmr1003 LV1
2022年8月5日
crosa_Don LV18
2022年7月22日
1272605570 LV1
2022年7月18日
thenyoucan LV2
2022年3月30日
WeiZZZ LV1
2022年3月28日
fangning LV1
2021年11月30日
noronoa LV9
2021年4月6日
linhe27 LV7
2021年3月20日
徐天堂 LV2
2021年2月23日
最近浏览更多
timi123
4月5日
暂无贡献等级
gao123456789 LV6
2月7日
1WQAQW1 LV2
2023年6月12日
Tuxxxxx LV3
2023年1月3日
1358849392 LV21
2022年12月27日
微信网友_6040315240812544 LV8
2022年11月21日
xmr1003 LV1
2022年8月5日
crosa_Don LV18
2022年7月22日
1272605570 LV1
2022年7月18日
Rommel LV27
2022年5月11日