WFProjectAdjust.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:26k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.Inform;
  12. using com.etong.BusinessRule.Zwf;
  13. using com.etong.Model;
  14. using com.etong.DAL.FC;
  15. using System.IO;
  16. using com.etong.Utility;
  17. using com.etong.DBUtility;
  18. using com.etong.DAL;
  19. using DocMergerComponent;
  20. using com.etong.Excel;
  21. public partial class Workflow_WFProjectAdjust : System.Web.UI.Page
  22. {
  23.     protected int userid = -1;
  24.     protected int wfid = -1;
  25.     protected int MustChooseItem = -1;
  26.     protected int ActivityID = -1;
  27.     protected int WFInstanceID = -1;
  28.     protected int ActID = -1;  //活动实例ID
  29.     protected int iEmpID = -1; //当前员工ID
  30.     protected string sEmpName = "";
  31.     protected void Page_Load(object sender, EventArgs e)
  32.     {
  33.         try
  34.         {
  35.             CheckUserInfo RoInfo = (CheckUserInfo)Session["checkuserinfo"];
  36.             userid = RoInfo.UserID;
  37.             iEmpID = RoInfo.EmpID;
  38.             sEmpName = RoInfo.EmpName;
  39.         }
  40.         catch
  41.         {
  42.             this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('系统提示:您尚未登录或您登录已超时,请重新登录!');top.location.href='../login.aspx';", true);
  43.         }
  44.         string WFInstanceIDtxt = Request.QueryString["WFInstanceID"].ToString().Trim();
  45.         string MustChooseItemtxt = Request.QueryString["MustChooseItem"].ToString().Trim();
  46.         MustChooseItem = Convert.ToInt16(MustChooseItemtxt.Trim());
  47.         string ActivityIDtxt = Request.QueryString["ActivityID"].ToString().Trim();
  48.         ActivityID = Convert.ToInt32(ActivityIDtxt.Trim());
  49.         string WFIDtxt = Request.QueryString["WFID"].ToString().Trim();
  50.         ActID = Convert.ToInt32(Request.QueryString["ActID"].ToString().Trim());
  51.         wfid = Convert.ToInt32(WFIDtxt.Trim());
  52.         WFInstanceID = Convert.ToInt32(WFInstanceIDtxt.Trim());
  53.         //if (!IsPostBack)
  54.         //{
  55.         //    PrjGetAll(WFInstanceID);
  56.         //}
  57.         EtongZwf etongzwf = new EtongZwf();
  58.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  59.        
  60.         switch (MustChooseItem)
  61.         {
  62.             case 59:        //基层单位
  63.                 Pn_Zg.Visible = false;
  64.                 Pn_Gcgl.Visible = false;
  65.                 Pn_Fg.Visible = false;
  66.                 Pn_Jc.Visible = false;
  67.                 PrjGetAll(WFInstanceID);
  68.                 break;
  69.             case 60:        //基层单位
  70.                 Pn_Zg.Visible = false;
  71.                 Pn_Gcgl.Visible = false;
  72.                 Pn_Fg.Visible = false;
  73.                 PrjGetAll(WFInstanceID);
  74.               //  TB_JcTransactor.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
  75.                 this.BT_JC.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JcFName').value);");
  76.                 this.BT_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_JcFName2').value);");
  77.              
  78.                 if (!IsPostBack)
  79.                 {
  80.                     string FileName_JC = EtongZwf.GetDocumentFileName(this.ActivityID)[0].ToString();
  81.                     string FileName_JC2 = EtongZwf.GetDocumentFileName(this.ActivityID)[1].ToString();
  82.                     TB_JcFName.Text = EtongZwf.MakeNewFileNameWithDate(FileName_JC);
  83.                     TB_JcFName2.Text = EtongZwf.MakeNewFileNameWithDate(FileName_JC2);
  84.                     if ((!Util.Copyfile(path + "\" + FileName_JC, path + "\DocTemplate\" + this.TB_JcFName.Text.Trim())) || (!Util.Copyfile(path + "\" + FileName_JC2, path + "\DocTemplate\" + this.TB_JcFName2.Text.Trim())))
  85.                     {
  86.                         Common.RunScript(this.Page, "打开模板失败,请检查相关设置!");
  87.                         return;
  88.                     }
  89.                 }
  90.                 break;
  91.             case 63:        //主管部门审批
  92.                 BT_JC.Visible = false;
  93.                 BT_View_JC.Visible = true;
  94.                 BT_JC2.Visible = false;
  95.                 BT_View_JC2.Visible = true;
  96.                 Pn_Gcgl.Visible = false;
  97.                 Pn_Fg.Visible = false;
  98.                 IB_Collect.Visible = true;
  99.                 PrjGetAll(WFInstanceID);
  100.                 break;
  101.             case 61:        //工程管理办公室审批
  102.                 BT_JC.Visible = false;
  103.                 BT_View_JC.Visible = true;
  104.                 Pn_Jc.Visible = false;
  105.                 Pn_Zg.Visible=false;
  106.                 Pn_Fg.Visible = false;
  107.                 IB_Collect.Visible = true;
  108.                 BT_View_ZG2.Visible = true;
  109.                 PrjGetAll(WFInstanceID);
  110.                 break;
  111.             case 62:        //公司分管领导审批
  112.                 Pn_Jc.Visible = false;
  113.                 Pn_Zg.Visible = false;
  114.                 BT_Gcgl.Visible = false;
  115.                 BT_View_Gcgl.Visible = true;
  116.                 BT_Gcgl2.Visible = false;
  117.                 BT_View_Gcgl2.Visible = true;
  118.                 PrjGetAll(WFInstanceID);
  119.                 break;
  120.         }
  121.     }
  122.     protected void PrjGetAll(int wfinstanceid)
  123.     {
  124.         EtongZwf etongzwf = new EtongZwf();
  125.         DataView dv = etongzwf.GetPrjAlert(wfinstanceid);
  126.         if (dv.Count == 0)
  127.          {
  128.            return;
  129.          }
  130.        ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value = dv[0]["AlertID"].ToString();
  131.        TB_ProjectName.Text = dv[0]["AlertName"].ToString();
  132.       // LB_BgFName.Text = dv[0]["BgFName"].ToString();
  133.        EtongWord EWord = new EtongWord();
  134.        EWord.sort = -1;
  135.        // EWord.opSort = "99";
  136.        EWord.XmlNodesNames = "XMLrecord";
  137.        string path = Server.MapPath("doc").Replace("\", "\\");
  138.        EWord.Address = path + "\\DocTemplate\\" + dv[0]["BgFName"].ToString().Trim();
  139.        ArrayList alfn = new ArrayList();
  140.        EtongXml alfn1 = new EtongXml();
  141.        try
  142.        {
  143.            alfn = EWord.ReadXMLFName();
  144.            LB_BgFName.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  145.            LB_BgFName2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  146.        }
  147.        catch
  148.        {
  149.            Common.RunScript(this.Page, "操作失败:未能找到文件!");    
  150.            return;
  151.        }
  152.        if (MustChooseItem != 59 && MustChooseItem != 60)
  153.        {
  154.            alfn.Clear();
  155.            EWord.Address = path + "\\DocTemplate\\" + dv[0]["JcFName"].ToString().Trim();
  156.            try
  157.            {
  158.                alfn = EWord.ReadXMLFName();
  159.                TB_JcFName.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  160.                TB_JcFName2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  161.            }
  162.            catch
  163.            {
  164.                Common.RunScript(this.Page, "操作失败:未能找到文件!");
  165.                return;
  166.            }
  167.        }
  168.        if (MustChooseItem != 59 && MustChooseItem != 60 && MustChooseItem != 63 && MustChooseItem != 61)
  169.        {
  170.            alfn.Clear();
  171.            EWord.Address = path + "\\DocTemplate\\" + dv[0]["GcglIdea"].ToString().Trim();
  172.            try
  173.            {
  174.                alfn = EWord.ReadXMLFName();
  175.                TB_Gcgl.Text = ((EtongXml)alfn[0]).DocFileName.ToString();
  176.                TB_Gcgl2.Text = ((EtongXml)alfn[1]).DocFileName.ToString();
  177.            }
  178.            catch
  179.            {
  180.                Common.RunScript(this.Page, "操作失败:未能找到文件!");
  181.                return;
  182.            }
  183.        }
  184.        this.BT_View_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,false);");
  185.        this.BT_ZG.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG').value,false);");
  186.        this.BT_View_ZG2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG2').value,false);");
  187.        this.BT_ZG2.Attributes.Add("onclick", "javascript:SetLinkUrl('DocTemplate/'+document.all('TB_ZG2').value,false);");
  188.        this.BT_View.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_BgFName').value);");
  189.        this.BT_View2.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_BgFName2').value);");
  190.    
  191.        this.BT_View_JC.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_BgFName').value);");
  192.        this.BT_View_JC2.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_BgFName2').value);");
  193.        this.BT_Gcgl.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_Gcgl').value);");
  194.        this.BT_View_Gcgl.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('LB_BgFName2').value);");
  195.        this.BT_Gcgl2.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_Gcgl2').value);");
  196.        this.BT_View_Gcgl2.Attributes.Add("onclick", "javascript:SetLinkUrl2('DocTemplate/'+document.all('TB_Gcgl2').value);");
  197.        if (MustChooseItem != 62)
  198.        {
  199.            TB_FgIdea.Text = dv[0]["FgIdea"].ToString();
  200.        }
  201.     }
  202.     protected void BT_Pass_Click(object sender, ImageClickEventArgs e)
  203.     {
  204.         int AlertID = Convert.ToInt32(((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value.Trim());
  205.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  206.         EtongZwf etongzwf = new EtongZwf();
  207.         string Opsort = etongzwf.GetEmpType(iEmpID);
  208.         //******************************************************启动*************************************************************
  209.         if (MustChooseItem == 59)
  210.         {
  211.                 WFInstADD();
  212.         }
  213.         //******************************************************基层部门审定*************************************************************
  214.         if (MustChooseItem == 60)
  215.         {
  216.             string JCFName = TB_JcFName.Text;
  217.             string JCFName2 = TB_JcFName2.Text;
  218.             //判断上级活动实例是否产生
  219.             string JCXMLFName = path + "\DocTemplate\";
  220.             bool bl = true;
  221.             bl = etongzwf.CheckUpActCompleteActIns(ActivityID, WFInstanceID, false, "");
  222.             if (bl == false)
  223.             {
  224.                 string NewFName = "";
  225.                 try
  226.                 {
  227.                     NewFName = etongzwf.PrjAlertGetAll(AlertID)[0]["JcFName"].ToString().Trim(); 
  228.                 }
  229.                 catch { NewFName = ""; }
  230.                 if (NewFName == "" || NewFName == null)
  231.                 {
  232.                     NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  233.                     if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  234.                     {
  235.                         Common.RunScript(this.Page, "操作失败,请重试!");
  236.                         return;
  237.                     }
  238.                     etongzwf.PrjAlert_JC(AlertID, "", NewFName, 0);        //.Project_JC(projectid, NewFName, 0);
  239.                 }
  240.                 JCXMLFName = JCXMLFName + NewFName;
  241.                 WFInstADD();
  242.             }
  243.             else
  244.             {
  245.                 try
  246.                 {
  247.                     JCXMLFName = JCXMLFName + etongzwf.PrjAlertGetAll(AlertID)[0]["JcFName"].ToString().Trim(); 
  248.                 }
  249.                 catch
  250.                 {
  251.                     Common.RunScript(this.Page, "操作失败,请重试!");
  252.                     return;
  253.                 }
  254.                 //改变当前活动实例状态
  255.                 etongzwf.WFActInsUpdata(ActID, userid, 1);
  256.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到 主管部门 处理!');top.location.href='../Main.aspx';</script>");
  257.             }
  258.             //写入XML文档
  259.             etongzwf.WriteXML(JCXMLFName, JCFName, sEmpName, Opsort, DateTime.Now.ToShortDateString());
  260.             etongzwf.WriteXML(JCXMLFName, JCFName2, sEmpName, Opsort, DateTime.Now.ToShortDateString());
  261.         }
  262.         //******************************************************主管部门审定*************************************************************
  263.         if (MustChooseItem == 63)
  264.         {
  265.             string ZgTransactor = ""; //sEmpName;    //主管部门提交人和时间
  266.             string ZgFName = ((HtmlInputHidden)this.FindControl("txt_ZgFname")).Value;       
  267.             if (ZgFName == "" || ZgFName == null)
  268.             {
  269.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:请先汇总!');</script>");
  270.                 return;
  271.             }
  272.             bool ReValue_Zg = false;
  273.             etongzwf.PrjAlert_Zg(AlertID, ZgTransactor, ZgFName, 1);
  274.             bool bl = true;
  275.             bl = etongzwf.CheckUpActCompleteActIns(ActivityID, WFInstanceID, false, "");
  276.             if (bl == false)
  277.             {
  278.                 WFInstADD();
  279.             }
  280.             else
  281.             {
  282.                 etongzwf.WFActInsUpdata(ActID, userid, 1);
  283.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到 工程管理办公室处理!');top.location.href='../Main.aspx';</script>");
  284.             }
  285.         }
  286.         //******************************************************工程管理办公室审批*************************************************************
  287.         if (MustChooseItem == 61)
  288.         {
  289.             string GcglTransactor = "";  // sEmpName;
  290.             string GcglFName = ((HtmlInputHidden)this.FindControl("txt_FName")).Value;  // TB_GcglIdea.Text + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";    
  291.             bool ReValue_Gcgl = false;
  292.             ReValue_Gcgl = etongzwf.PrjAlert_Gcgl(AlertID, GcglTransactor, GcglFName, 1);
  293.             if (ReValue_Gcgl == true)
  294.                 WFInstADD();
  295.         }
  296.         //******************************************************分管领导审批*************************************************************
  297.         if (MustChooseItem == 62)
  298.         {
  299.             string FgTransactor = sEmpName;
  300.             string FgIdea = TB_FgIdea.Text + "【" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "】";
  301.            
  302.             bool ReValue_Fg = false;
  303.             ReValue_Fg = etongzwf.PrjAlert_Fg(AlertID, FgTransactor, FgIdea, 2);
  304.            //转到  工程项目实施流程
  305.             string ProjectName= TB_ProjectName.Text;
  306.             DataView dva=etongzwf.GetPrjAlert(WFInstanceID);
  307.             string PrjSort = dva[0]["ConSort"].ToString();   //etongzwf.GetEmpType(iEmpID);
  308.             string documentxml="";
  309.             ConstructInfo constructinfo = new ConstructInfo(ProjectName, PrjSort, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 1, documentxml);
  310.             ProjectImplment projectimplment = new ProjectImplment();
  311.             int revalue = 0;
  312.             revalue= projectimplment.AddConstruct(constructinfo);
  313.             if (revalue != 0)
  314.             {
  315.                 int WorkFlowID = -1;
  316.                 WorkFlowID = etongzwf.GetConWfID();
  317.                 WFInstanceInfo wfinstanceinfo = new WFInstanceInfo(-1, Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  318.                         userid, -1, -1, DateTime.Now,2, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WorkFlowID, revalue);
  319.                 int ReInstanceValue = etongzwf.WFInstanceADD(wfinstanceinfo);
  320.                 //产生下一活动实例
  321.                 if (ReInstanceValue != 0)
  322.                 {
  323.                     WFInstADD();
  324.                     DataView dvCU = etongzwf.ActivityColony_User(4);
  325.                     int actid = Convert.ToInt16(dvCU[0]["ActivityID"].ToString().Trim());
  326.                     int roleid = Convert.ToInt16(dvCU[0]["RoleID"].ToString().Trim());
  327.                     NextColonyRole(actid, roleid, -1, ReInstanceValue);    //转到 项目实施  
  328.                 }
  329.             }
  330.          
  331.         }
  332.     }
  333.     /// <summary>
  334.     /// 改变工作流活动实例状态   
  335.     /// </summary>
  336.     protected void WFInstADD()
  337.     {
  338.         if (WFInstanceID > 0)
  339.         {
  340.             //int ReActInsValue = 0;
  341.             if (MustChooseItem == 0)                                                                     //标记起始活动实例
  342.             {
  343.                 ActID = Convert.ToInt16(((HtmlInputHidden)this.FindControl("txt_ActID")).Value.Trim());  //活动实例
  344.             }
  345.             else
  346.             {
  347.                 string ActIDtxt = Request.QueryString["ActID"].ToString().Trim();
  348.                 ActID = Convert.ToInt32(ActIDtxt);
  349.             }
  350.             EtongZwf etongzwf = new EtongZwf();
  351.             DataView dv = etongzwf.ColonyUserGetByActId(ActivityID);
  352.             int CurrentRoleID = -1;
  353.             int ParentActID = -1;
  354.             int ParentRoleID = -1;
  355.             string ReValueRole = "";
  356.             if (dv.Count > 0)
  357.             {
  358.                 for (int i = 0; i <= dv.Count - 1; i++)
  359.                 {
  360.                     string shuntflag = dv[i]["shuntflag"].ToString().Trim();
  361.                    
  362.                     CurrentRoleID = Convert.ToInt16(dv[i]["CurrentRoleID"].ToString().Trim());
  363.                     ParentActID = Convert.ToInt16(dv[i]["ParentActID"].ToString().Trim());
  364.                     ParentRoleID = Convert.ToInt16(dv[i]["ParentRoleID"].ToString().Trim());          //提交到下一活动  的 角色ID  
  365.                     if (ParentActID != -1)
  366.                     {
  367.                         //产生下一个活动实例并提交到下一个角色的用户申核
  368.                         ReValueRole = ReValueRole + NextColonyRole(ParentActID, ParentRoleID, -1, WFInstanceID) + ",";
  369.                     }
  370.                     else
  371.                     {  //工作流任务完成
  372.                         etongzwf.WFActInsUpdata(ActID, userid, 1);
  373.                         string projectid = ((HtmlInputHidden)this.FindControl("txt_ProjectID")).Value;
  374.                         bool re = etongzwf.WF_End("", "", -1, -1, wfid, 1, Convert.ToInt32(projectid.Trim()));
  375.                         if (re == true)
  376.                         {
  377.                             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:项目申报完成!');top.location.href='../Main.aspx';</script>");
  378.                             return;
  379.                         }
  380.                     }
  381.                 }
  382.                 bool returnvalue = false;
  383.                 //更新当前活动实例状态
  384.                 etongzwf.WFActInsUpdata(ActID, userid, 1);
  385.                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:操作成功,转到:  " + ReValueRole + "  申核处理!');top.location.href='../Main.aspx';</script>");
  386.             }
  387.         }
  388.     }
  389.     /// <summary>
  390.     /// 提交到上级部门用户申核
  391.     /// </summary>
  392.     protected string NextColonyRole(int ParentActID, int ParentRoleID, int ParentEmp, int WFInsID)
  393.     {
  394.         string ReValue = "";
  395.         //获取某业务角色对应的类型
  396.         EtongZwf etongzwf = new EtongZwf();
  397.         string Opsort;
  398.         if (MustChooseItem == 11)      //是否提交到主管                  
  399.             Opsort = etongzwf.GetEmpType(iEmpID);
  400.         else
  401.             Opsort = EtongZwf.GetOpRole(ParentRoleID);
  402.         WFActInsInfo wfactinsinfo = new WFActInsInfo(-1, ParentActID, Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToDateTime(DateTime.Now.ToShortDateString()),
  403.                                                       0, Convert.ToDateTime(DateTime.Now.ToShortDateString()), WFInsID, Opsort, ParentEmp, ParentRoleID);
  404.         int ReActInsValue = etongzwf.WFActInsADD(wfactinsinfo);
  405.         if (ReActInsValue > 0)
  406.         {
  407.             DataView dvRoleName = etongzwf.GetOrgzation(ParentRoleID);
  408.             if (dvRoleName.Count != 0)
  409.             {
  410.                 ReValue = dvRoleName[0][0].ToString();
  411.             }
  412.         }
  413.         else
  414.             ReValue = "";
  415.         return ReValue;
  416.     }
  417.     protected void IB_Collect_Click(object sender, ImageClickEventArgs e)    //汇总
  418.     {
  419.         MyDocMerger objMerger = new MyDocMerger();
  420.         DocMerger docmerger = new DocMerger();
  421.         EtongWord EWord = new EtongWord();
  422.         EtongZwf etongzwf = new EtongZwf();
  423.         string path = Server.MapPath("doc").Replace("\", "\\");      //获取项目所在路径
  424.         int AlertID = Convert.ToInt32(txt_ProjectID.Value.Trim());
  425.         DataView dvprj = etongzwf.PrjAlertGetAll(AlertID);  
  426.         string FName = "";
  427.         string FName1 = "";
  428.         string FName2 = "";
  429.         //string opsort = etongzwf.ActInsSort(ActID)[0]["BlockReason"].ToString();  //类型
  430.         string opsort = etongzwf.GetEmpType(iEmpID);
  431.         //新建要存储汇总文件的XML文档
  432.         FName1 = EtongZwf.MakeNewFileNameWithDate("项目预算表.doc");  //"芜湖供电公司工程项目预算表.doc"
  433.         FName2 = EtongZwf.MakeNewFileNameWithDate("项目计划汇总表.xls");  //项目计划汇总表.xls
  434.         string JCXMLFName = "";          
  435.         string NewFName = "";          
  436.         EtongFlyChouWFPrj etongflychouwfprj = new EtongFlyChouWFPrj();
  437.         etongflychouwfprj.sID = ActID;
  438.         etongflychouwfprj.iStatus = 4;
  439.         etongflychouwfprj.sBlockReason = opsort;    
  440.         etongflychouwfprj.PrjID = AlertID;
  441.         etongflychouwfprj.wID = wfid;
  442.         if (MustChooseItem == 63)    //主管汇总
  443.         {
  444.             EWord.opSort = opsort;
  445.             FName = path + "\DocTemplate\" + dvprj[0]["JcFName"].ToString();               
  446.             //判断同类型的所有活动是否走完
  447.             bool re = etongflychouwfprj.CheckUpActCompleteSort();
  448.             if (re == false)
  449.             {
  450.                 Common.RunScript(this.Page,"系统提示:基层单位同类型电子文档未全部提交,不能汇总!");
  451.                 return;
  452.             }
  453.             TB_ZG.Text = FName1;
  454.             TB_ZG2.Text = FName2;
  455.             try
  456.             {
  457.                 NewFName = etongzwf.PrjAlertGetAll(AlertID)[0]["ZgFName"].ToString().Trim();   
  458.             }
  459.             catch { NewFName = ""; }
  460.             if (NewFName == "" || NewFName == null)
  461.             {
  462.                 NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  463.                 if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  464.                 {
  465.                     Common.RunScript(this.Page, "操作失败,请重试!");
  466.                     return;
  467.                 }
  468.             }
  469.             ((HtmlInputHidden)this.FindControl("txt_ZgFname")).Value = NewFName;
  470.         }
  471.         if (MustChooseItem == 61)    //工程管理办公室汇总 
  472.         {
  473.             //判断所有活动是否走完 
  474.             bool re = etongflychouwfprj.CheckUpActComplete();
  475.             if (re == false)
  476.             {
  477.                 Common.RunScript(this.Page, "系统提示:主管部门电子文档未全部提交,不能汇总!");
  478.                 return;
  479.             }
  480.             FName = path + "\DocTemplate\" + dvprj[0]["ZgFName"].ToString();
  481.             EWord.sort = -1;
  482.             TB_Gcgl.Text = FName1;
  483.             TB_Gcgl2.Text = FName2;
  484.             NewFName = EtongZwf.MakeNewFileNameWithDate("XML.xml");
  485.             ((HtmlInputHidden)this.FindControl("txt_FName")).Value = NewFName;
  486.             if (!Util.Copyfile(path + "\" + "XML.xml", path + "\DocTemplate\" + NewFName))
  487.             {
  488.                 Common.RunScript(this.Page, "操作失败,请重试!");
  489.                 return;
  490.             }
  491.         }
  492.         EWord.XmlNodesNames = "XMLrecord";
  493.         EWord.Address = FName;
  494.         ArrayList alfn = new ArrayList();
  495.         try
  496.         {
  497.             alfn = EWord.ReadXMLFName();
  498.         }
  499.         catch
  500.         {
  501.             Common.RunScript(this.Page, "操作失败:未能找到文件!");
  502.             return;
  503.         }
  504.         int count = alfn.Count;
  505.         string[] fname = new string[count];
  506.         ArrayList aldoc = new ArrayList();
  507.         ArrayList alxls = new ArrayList();
  508.         for (int k = 0; k < count; k++)
  509.         {
  510.             EtongXml alfn1 = new EtongXml();
  511.             alfn1 = alfn[k] as EtongXml;
  512.             fname[k] = path + "\\DocTemplate\\" + alfn1.DocFileName.ToString();
  513.             string[] a = fname[k].ToString().Split('.');
  514.             if (a[1].ToString().Trim() == "doc")
  515.                 aldoc.Add(fname[k]);
  516.             if (a[1].ToString().Trim() == "xls")
  517.                 alxls.Add(fname[k]);
  518.         }
  519.         int count_doc = aldoc.Count;
  520.         string[] Docfname = new string[count_doc];
  521.         for (int i = 0; i < count_doc; i++)
  522.             Docfname[i] = aldoc[i].ToString().Trim();
  523.         if (!Util.Copyfile(path + "\" + "项目预算表.doc", path + "\DocTemplate\" + FName1))
  524.         {
  525.             Common.RunScript(this.Page, "文件拷贝失败,请检查相关设置!");
  526.             return;
  527.         }
  528.         string filename = path + "\\DocTemplate\\" + FName1;
  529.         JCXMLFName = path + "\DocTemplate\" + NewFName;
  530.         try
  531.         {
  532.             objMerger.MergeDocArray(filename, Docfname, filename);      //汇总Doc文档
  533.             EtongExcel EExcel = new EtongExcel(Server.MapPath("doc\\项目计划汇总表.xls"), Server.MapPath("doc\\DocTemplate\\") + FName2);
  534.             EExcel.RangeCellSet(alxls, 3, 10);
  535.             EExcel.SaveAsFile();
  536.             //将汇总的文件写入XML文档中
  537.             etongzwf.WriteXML(JCXMLFName, FName1, sEmpName, opsort, DateTime.Now.ToShortDateString());
  538.             etongzwf.WriteXML(JCXMLFName, FName2, sEmpName, opsort, DateTime.Now.ToShortDateString());
  539.             Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('系统提示:汇总成功!');</script>");
  540.         }
  541.         catch (Exception ex)
  542.         {
  543.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  544.         }
  545.     }
  546. }