package zr.zrpower.flowengine.web.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import zr.zrpower.web.bean.MessageBox;
import zr.zrpower.flowengine.service.FlowMonitor;

public class ActionFlowEntrusCarry
    extends MessageBox {

  public void init() throws ServletException {
  }

  //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException
  {
    request.setCharacterEncoding("GBK");
    response.setContentType("text/html; charset=GBK");
    String strAction = request.getParameter("Act");
    if (strAction.equals("edit")){
        EditPro(request, response);
    }
    if (strAction.equals("edit1")) {
        EditPro1(request, response);
    }
  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    doGet(request, response);
  }

  //Clean up resources
  public void destroy() {
  }

  //流程委托处理
  private void EditPro(HttpServletRequest request,HttpServletResponse response) throws IOException{
    String strDOPSN=request.getParameter("DOPSN");
    String strUserID=request.getParameter("UserID");
    String strUNIT=request.getParameter("UNIT");
    String strID=request.getParameter("ID");
    try {
      FlowMonitor FMManage = new FlowMonitor();
      if (FMManage.FlowEntrustManage(strID,strDOPSN,strUserID,strUNIT)){
         FMManage = null;
         response.sendRedirect("ZrWorkFlow/FlowMonitor/FlowToTurn/List.jsp");
      }
    }
    catch (Exception ex) {
      this.Msg = "连接中间件服务器失败，请稍后再试！";
    }
  }

//流程任务重分配处理
private void EditPro1(HttpServletRequest request,HttpServletResponse response) throws IOException{
  String strDOPSN=request.getParameter("DOPSN");
  String strUserID=request.getParameter("UserID");
  String strUNIT=request.getParameter("UNIT");
  String strID=request.getParameter("ID");

  try {
    FlowMonitor FMManage = new FlowMonitor();
    if (FMManage.FlowAnewManage(strID,strDOPSN,strUserID,strUNIT)){
       FMManage = null;
       response.sendRedirect("ZrWorkFlow/FlowMonitor/FlowAllotment/List.jsp");
    }
  }
  catch (Exception ex){
      this.Msg = "连接中间件服务器失败，请稍后再试！";
  }
}

}
