⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 archivecategoryservlet.java

📁 一个简单的公文管理系统
💻 JAVA
字号:
package com.jasson.presentation.archive;

import com.jasson.integration.agentflow.*;
import com.jasson.integration.agentflow.Task;
import com.flowring.struts.webapp.User;
import com.jasson.business.document.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import si.wfinterface.WFCI; 
import java.util.Vector; 
import com.jasson.common.*;
import com.jasson.business.archive.*;
/**
 * <p>Title: ArchiveCategoryServlet</p>
 * <p>Description: borrow archive </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Wingroup Network Software Corporation </p>
 * @author eastern || x_fisher@sohu.com
 * @version 1.0
 */
public class ArchiveCategoryServlet extends HttpServlet {
    /** forward error page or archive list */
    String strForwardError = "/workflow/errorpage.jsp";
    String strForwardArchiveCategorycList = "/WebAgenda/DMS/archive/ArchiveCategoryList.jsp"; 
    /***/    
    WFCI wfci;
    public void service (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

        //System.out.println("Begin of Servlet");
        request.setCharacterEncoding("ISO8859-1"); 
        HttpSession session = (HttpSession)request.getSession(); 
        /**controler variable*/
	String sign=request.getParameter("sign"); 
	String act=(String)request.getParameter("act"); 
	
	System.out.println("sign:"+sign);
	System.out.println("act:"+act);
	
	if(sign==null)
		sign="one";
	session.setAttribute("sign",sign);
	/***/
	String detailNO=request.getParameter("DetailNO");
	String parentNO_One=request.getParameter("ParentNO_One");
	String parentNO_Two=request.getParameter("ParentNO_Two");
	
	session.setAttribute("DetailNO",detailNO);
	session.setAttribute("ParentNO_One",parentNO_One);
	session.setAttribute("ParentNO_Two",parentNO_Two);
	
	System.out.println("detailNO:"+detailNO);
	System.out.println("parentNO_One:"+parentNO_One);
	System.out.println("parentNO_Two:"+parentNO_Two); 
	 
	/**
	 * archive category list
	 * if archiveID is empty then to enter category list
	 * if archiveID is not empty ,and delete is not empty too,or add is not empty too, or modify is not empty too
	 * inluding active or inactive status
	 */
	/**variable*/  
	String DetailNO_Access=request.getParameter("DetailNO_Access");
	String detailName="";
	if(request.getParameter("DetailName")!=null)
		 detailName=new String(request.getParameter("DetailName").getBytes("ISO8859-1"));
	String parentNO=request.getParameter("ParentNO");
	if((parentNO!=null&&parentNO.equals(""))||parentNO==null)
		parentNO="0"; 
				
	/**DetailTag=1,2,3,4*/
	String detailTag=request.getParameter("DetailTag"); 
	String activateTag=request.getParameter("ActivateTag"); 
	
	//System.out.println("DetailNO_Access:"+DetailNO_Access);
	//System.out.println("detailName:"+detailName);
	//System.out.println("parentNO:"+parentNO);
	//System.out.println("detailTag:"+detailTag); 
	//System.out.println("activateTag:"+activateTag);  
	
	/**define archive category DAO*/ 
	if(act==null){  
		ArchiveCategoryDAO [] archiveCategoryDAOTemp=null;
		if(sign.equals("one")) 
			archiveCategoryDAOTemp =ArchiveCategoryDAO.findAllKind();
		if(sign.equals("two")) 
			archiveCategoryDAOTemp =ArchiveCategoryDAO.findByKindNO(detailNO);		 
		if(sign.equals("three")) 
			archiveCategoryDAOTemp =ArchiveCategoryDAO.findByKindAndKeyNO(parentNO_One,detailNO);	 
		if(sign.equals("four")) 
			archiveCategoryDAOTemp =ArchiveCategoryDAO.findByKindKeyAndItemNO(parentNO_Two,parentNO_One,detailNO);	
		if(archiveCategoryDAOTemp!=null){//unempty redirect archive category list
			session.setAttribute("archiveCategoryDAO",archiveCategoryDAOTemp);
			clientForward1(strForwardArchiveCategorycList,request,response);
		} 
	}
	else{
		//System.out.println("test:");
		/**add archive category*/
		ArchiveCategoryDAO  categoryDAO=new ArchiveCategoryDAO();
		ArchiveCategoryDAO [] categoryDAOTemp=null; 
		boolean isSuccess=false;
		categoryDAO.setDetailNO(DetailNO_Access);
		categoryDAO.setDetailName(detailName); 
		categoryDAO.setParentNO(parentNO); 
		
		System.out.println("DetailNO_Access:"+DetailNO_Access);
		System.out.println("detailName:"+detailName);
		System.out.println("parentNO:"+parentNO);
		System.out.println("detailTag:"+detailTag); 
		
		//System.out.println("categoryDAO.getParentNO:"+categoryDAO.getParentNO());	
		categoryDAO.setDetailTag(detailTag); 
		categoryDAO.setActiveTag(activateTag);  
		//System.out.println("categoryDAO.getActiveTag:"+categoryDAO.getActiveTag());
		if(act.equals("add")){  
			if(categoryDAO.insert()!=-1){  
				isSuccess=true; 
				//System.out.println("test1:");
			}
		}
		/**modify archive category*/
		if(act.equals("modify")){  
			//System.out.println("test2:");
			String oldDetailNO=request.getParameter("OldDetailNO"); 
			//System.out.println("oldDetailNO:"+oldDetailNO);
			//System.out.println("categoryDAO.update:"+categoryDAO.update(oldDetailNO));
			if(categoryDAO.update(oldDetailNO)){ 
				isSuccess=true; 
				//System.out.println("test3:");
			}
		}
		/**activate*/ 
		if(act.equals("activate")){  
			if(categoryDAO.configCateogyActive()){ 
				isSuccess=true; 
			}
		} 
		/**inactivate*/ 
		if(act.equals("inActivate")){  
			if(categoryDAO.configCateogyActive()){ 
				isSuccess=true; 
			}
		}
		/**delete archive category*/
		if(act.equals("delete")){  
			//System.out.println("categoryDAO.delete:"+categoryDAO.delete());
			if(categoryDAO.delete()){ 
				isSuccess=true; 
			}
		} 
		if(isSuccess){ 
			if(sign.equals("one")) 
				categoryDAOTemp =ArchiveCategoryDAO.findAllKind();
			if(sign.equals("two")) 
				categoryDAOTemp =ArchiveCategoryDAO.findByKindNO(detailNO);		 
			if(sign.equals("three")) 
				categoryDAOTemp =ArchiveCategoryDAO.findByKindAndKeyNO(parentNO_One,detailNO);	 
			if(sign.equals("four")) 
				categoryDAOTemp =ArchiveCategoryDAO.findByKindKeyAndItemNO(parentNO_Two,parentNO_One,detailNO);	
			if(categoryDAOTemp!=null){
				session.setAttribute("archiveCategoryDAO",categoryDAOTemp);
				clientForward1(strForwardArchiveCategorycList,request,response);	 
			}
		}
	}
    }//sevice 

	private void clientForward1(String strForward, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException	{
		forward("/DMS/document/ClientForward.jsp?Forward=" + strForward, request, response);
		return;
	}
    
    /**
     * refresh basefrm function
     */	
    private void clientForward(String strForward, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		/***/
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<html>");
		out.println("	<head>");
		out.println("		<script language=\"JavaScript\">");
		out.println("			function window_onLoad () {");
		out.println("				this.parent.frames.basefrm.location.href = \"" + strForward + "\";");
		out.println("			}");
		out.println("		</script>");
		out.println("	</head>");
		out.println("	<body onLoad=\"window_onLoad()\">");
		out.println("	</body>");
		out.println("</html>");
		out.close();

     }//clientforward

     /**
      * function refresh
      * @param strForward
      * @param request
      * @param response
      * @throws IOException
      * @throws ServletException
      */
     private void forward(String strForward, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        /***/
	RequestDispatcher dispatcher = request.getRequestDispatcher(strForward);
	dispatcher.forward((ServletRequest)request, (ServletResponse)response); 
     }
     /***/
     private String StrToStr(String str){
     		if(str.indexOf("-")==-1)
     		return str;
     		String year=str.substring(0,str.indexOf("-"));
     		String month=str.substring(str.indexOf("-")+1,str.lastIndexOf("-"));
     		String day=str.substring(str.lastIndexOf("-")+1);
    		return (year+"/"+month+"/"+day);
     }
}//ArchiveCategoryServlet 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -