
package com.trs.web2frame.tool.tyjyh.common;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.jdom.CDATA;
import org.jdom.Document;
import org.jdom.Element;
import org.jsoup.Jsoup;

import com.trs.infra.util.CMyException;
import com.trs.infra.util.CMyFile;
import com.trs.infra.util.CMyString;
import com.trs.infra.util.CMyXMLDoc;
import com.trs.infra.util.CMyZip;
import com.trs.web2frame.WCMServiceCaller;
import com.trs.web2frame.dispatch.Dispatch;
import com.trs.web2frame.tool.tyjyh.Log_Exception;
import com.trs.web2frame.tool.tyjyh.wcmhy06_szf.ServiceImplWcm;

import net.sf.json.JSONObject;
/**
 * Title: TRS 内容协作平台（TRS WCM）<BR>
 * Description:<BR>
 * TODO <BR>
 * Copyright: Copyright (c) 2004-2005 TRS信息技术有限公司<BR>
 * Company: TRS信息技术有限公司(www.trs.com.cn)<BR>
 * @author TRS信息技术有限公司
 * @version 1.0
 */

public class WriteWcmXML {

    /**
     * 根据文档信息生成WCM52规范的XML文件并打ZIP包
     */
    public WriteWcmXML() {
        super();
    }
    
    public static int writeXml(ArticleInfo ai, int count) {
    	
    	ServiceImplWcm wcm=new ServiceImplWcm();
    	
    	int nCount = count%1000;
        String sTempPath = Common.TEMP_PATH;
        
        String sToChannel = ai.getColumnID();
        
        try {
        
	        String sZipFileName = Common.XML_PATH + "import_" + nCount + ".zip";
	        CMyZip oZip = new CMyZip();
	        try {
	            oZip.setZipFileName(sZipFileName);
	        } catch (CMyException e1) {
	            e1.printStackTrace();
	        }
	        
	        //开始生成一篇XML文档
	        Document doc = new Document(new Element("MetaViewDataS"));
	        Element ele = new Element("MetaViewData");
	        ele.setAttribute("Version","6.0");
	        doc.getRootElement().addContent(ele);
	        
	        ele.addContent(new Element("PROPERTIES"));
	        
	        ele = (Element)ele.getChildren().get(0);
	        
	        //DOCTYPE
	        String sDocType = CMyString.showEmpty(ai.getDocType(), "20");
	        Element tempEle = new Element("DOCTYPE");
	        tempEle.addContent(sDocType);
	        ele.addContent(tempEle);
	        
	        //频道ID
	        sToChannel = CMyString.showNull(sToChannel, "10");
	        tempEle = new Element("CHANNELID");
	        tempEle.addContent(sToChannel);
	        ele.addContent(tempEle);
	        
	        //文章标题（加入了去除HTML代码的功能）
	        tempEle = new Element("DOCTITLE");
	        String sDocTitle = clearHtmlCode(CMyString.showNull(ai.getTitle(),"无标题"));
	        tempEle.addContent(new CDATA(sDocTitle));
	        ele.addContent(tempEle);
	        
	        //副标题（加入了去除HTML代码的功能）
	        tempEle = new Element("SUBDOCTITLE");
	        String sSubDocTitle = clearHtmlCode(CMyString.showNull(ai.getSubTitle(),""));
	        tempEle.addContent(new CDATA(sSubDocTitle));
	        ele.addContent(tempEle);
	        
	        //首页标题（加入了去除HTML代码的功能）
	        tempEle = new Element("SHORTTITLE");
	        String sDocPeople = clearHtmlCode(CMyString.showNull(ai.getDocPeople(),""));
	        tempEle.addContent(new CDATA(sDocPeople));
	        ele.addContent(tempEle);
	        
	        //作者
	        tempEle = new Element("DOCAUTHOR");
	        tempEle.addContent(new CDATA(CMyString.showNull(ai.getAuthor())));
	        ele.addContent(tempEle);
	        
	        //撰写时间，保留原创建时间为撰写时间
	        tempEle = new Element("DOCRELTIME");
	        tempEle.addContent(ai.getCreateDate().toString());
	        ele.addContent(tempEle);
	        
	        //创建时间
	        tempEle = new Element("CRTIME");
	        tempEle.addContent(ai.getCreateDate().toString());
	        ele.addContent(tempEle);
	        
	        //摘要
	        tempEle = new Element("DOCABSTRACT");
	        tempEle.addContent(new CDATA(CMyString.showNull(ai.getAbscract())));
	        ele.addContent(tempEle);
	        
	        //来源
	        tempEle = new Element("DOCSOURCENAME");
	        tempEle.addContent(new CDATA(CMyString.showNull(ai.getDocSource())));
	        ele.addContent(tempEle);
	        
	        //原文章ID
	        tempEle = new Element("oldDocid");
	        tempEle.addContent(new CDATA(CMyString.showNull(ai.getID())));
	        ele.addContent(tempEle);
	        
	        if (sDocType.equals("20")) {
	        
		        //文档正文（正文比较容易引起XML解析错误，所以能过filterForJDOM进行转换）
		        String sContent = ai.getContent();
		        if (CMyString.isEmpty(sContent)) {
		        	sContent = "&nbsp";
		        }
		        
		        sContent = CMyString.filterForJDOM(sContent);
		        tempEle = new Element("DOCHTMLCON");
		        tempEle.addContent(new CDATA(sContent));
		        ele.addContent(tempEle);
		        
		        //去除HTML格式的正文
		        tempEle = new Element("DOCCONTENT");
		        tempEle.addContent(new CDATA(getTextFromTHML(sContent)));
		        ele.addContent(tempEle);
	        }
	        
	        if (sDocType.equals("30")) {
	        	tempEle = new Element("DOCLINK");
		        tempEle.addContent(ai.getDocLink());
		        ele.addContent(tempEle);
	        }
	        
	        if (sDocType.equals("40")) {
	        	tempEle = new Element("DOCFILENAME");
		        tempEle.addContent(ai.getDocFileName());
		        ele.addContent(tempEle);
		        try {
                    oZip.addToZip(ai.getDocFilePath() + ai.getDocFileName(), false);
                } catch (CMyException e2) {
                    // TODO Auto-generated catch block
                    e2.printStackTrace();
                }
	        }
	        
	        //如果需要导其它信息，按上面格式继续即可
	        //tempEle = new Element("OLDDOCORDER");
	        //tempEle.addContent(new CDATA(CMyString.showNull(ai.getProperty("OLDDOCORDER"))));
	        //ele.addContent(tempEle);
	        
	        //处理附件
	        if (ai.getApp().size() > 0){
	            ele = ele.getParent();
	            tempEle = new Element("WCMAPPENDIXS");
	            ele.addContent(tempEle);
	            
	            Element appElement = tempEle;
	            
	            //ele = (Element)ele.getChildren().get(0);
	            
	            for (int i=0; i<ai.getApp().size(); i++){
	            	
	            	Appendix app = (Appendix)ai.getApp().get(i);
	                
		            Element tempEle2 = new Element("WCMAPPENDIX");
		            tempEle2.setAttribute("Version", "6.0");
		            appElement.addContent(tempEle2);
		            
		            //ele = tempEle2;
		            
		            tempEle = new Element("PROPERTIES");
		            tempEle2.addContent(tempEle);
		            
		            tempEle2 = (Element)tempEle2.getChildren().get(0);
		            
		            tempEle = new Element("APPSERN");
		            tempEle.addContent(Integer.toString(i+1));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPDESC");
		            tempEle.addContent(new CDATA(app.getAPPDESC()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFILETYPE");
		            tempEle.addContent("0");
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("OTHEROPERATION");
		            tempEle.addContent("0");
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFLAG");
		            tempEle.addContent(app.getAPPTYPE());
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("FILEEXT");
		            tempEle.addContent(new CDATA(app.getFILEEXT()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPLINKALT");
		            tempEle.addContent(new CDATA(app.getAPPLINKALT()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("SRCFILE");
		            tempEle.addContent(new CDATA(app.getSRCFILE()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("CRUSER");
		            tempEle.addContent(new CDATA("admin"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFILE");
		            tempEle.addContent(new CDATA(app.getAPPFILE()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPDOCID");
		            tempEle.addContent(new CDATA("0"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPENDIXID");
		            tempEle.addContent(new CDATA("0"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("USEDVERSIONS");
		            tempEle.addContent(new CDATA("1"));
		            tempEle2.addContent(tempEle);
		            
		            try {
	                    oZip.addToZip(app.getAPPPATH() + app.getAPPFILE(), false);
	                } catch (Exception e2) {
	                    // TODO Auto-generated catch block
	                    e2.printStackTrace();
	                }
	            }
	            
	        }
	                
	        try {
	            CMyXMLDoc.toXMLFile(doc, sTempPath + "import.xml", "UTF-8");
	            oZip.addToZip(sTempPath + "import.xml", false);
	            oZip.done();
	            //System.out.println("生成ZIP文件：" + bDone);
	        } catch (Exception ex) {
	            System.out.println("文档[" + ai.getID() + "]生成ZIP文件失败，跳过");
	            return 1;
	        }
	        
	        Dispatch upDispatch = WCMServiceCaller.UploadFile(sZipFileName);
			// 获取上传后返回的文件名
			String fileName = upDispatch.getUploadShowName();
			//System.out.println(fileName);
			
			String wcmRecId = ai.getProperty("RECID");
        	String wcmDocId = ai.getID();
        	String docTitle = ai.getTitle();
			
			Map<String,Object> oPostData=new HashMap<>();
            oPostData.put("XMLSOURCE", 0);
            oPostData.put("ChannelId", Integer.parseInt(sToChannel));// 目标栏目id
            oPostData.put("CurrUserName", "dev");
            oPostData.put("FileName", fileName);
            oPostData.put("JumpRepeat", 1);
            
            try {
                Dispatch result = WCMServiceCaller.Call("gov_webdocument", "importDocument", oPostData, true);
                if(result!=null){
                	
                    JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                    System.out.println(result.getResponseText().toString());
                    if (rObject.get("ISSUCCESS").toString().equals("true")){
                    	
                        System.out.println("迁移第"+count+"条，成功！wcmRecId:"+wcmRecId+";wcmdocid:"+wcmDocId);
                        JSONObject dataObject=Common.getRecIdFromHy(wcmDocId, sToChannel);
                        String hyRecId=dataObject.getString("RECID");
                        String hyDocId=dataObject.getString("DOCID");
                        
                        //记录原始文章的docorder
                        int res = wcm.updateChnldoc(hyRecId, ai.getProperty("OLDDOCORDER"));
                        if(res<1){
                            Log_Exception.Logger_txt("chnldoc更新失败,海云recid:"+hyRecId+",wcm排序字段:"+ai.getProperty("OLDDOCORDER"));
                        }
                        
                        Map<String,Object> resultMap=new HashMap<>();
                        resultMap=wcm.GetResultInfo(wcmRecId);//
                        
                        //存在更新，不存在插入
                        if(resultMap!=null&&resultMap.size()>0){
                            Boolean isSuc=false;
                            isSuc=wcm.UpdateResult(Integer.valueOf(wcmRecId), Integer.valueOf(hyRecId), Integer.valueOf(wcmDocId),Integer.valueOf(hyDocId));
                            if(!isSuc){
                                Log_Exception.Logger_txt("结果表 "+wcmRecId+" :更新失败！");
                            }
                        }else{
                            Boolean isSuc=false;
                            isSuc=wcm.InsertResult(Integer.valueOf(wcmRecId), Integer.valueOf(hyRecId), Integer.valueOf(wcmDocId),Integer.valueOf(hyDocId), "", ai.getCreateDate().toString());
                            if(!isSuc){
                                Log_Exception.Logger_txt("结果表 "+wcmRecId+" :插入失败！");
                            }
                        }
                    }else{
                        System.out.println("迁移第"+count+"条，失败！");
                        String messageInfo=rObject.getString("MSG");
                        Log_Exception.Logger_txt("失败！RecID："+wcmRecId+" 标题："+docTitle+"错误信息："+messageInfo);

                        //记录文档失败信息
                        Boolean isSuc=false;
                        Map<String,Object> Messagemap=wcm.GetLogMessageInfo(Integer.valueOf(wcmRecId));
                        if(Messagemap!=null&&Messagemap.size()>0){
                            isSuc=wcm.UpdateLogMessageInfo(Integer.valueOf(wcmRecId), messageInfo);
                        }else{
                            isSuc=wcm.InsertLogMessageInfo(Integer.valueOf(wcmRecId), "", messageInfo);
                        }
                        if(!isSuc){
                            Log_Exception.Logger_txt("错误信息表 "+wcmRecId+" :插入/更新失败！");
                        }
                    }
                }
                
            } catch(Exception e) {
            	Boolean isSuc=false;
            	wcm.InsertLogMessageInfo(Integer.valueOf(wcmRecId), docTitle, "网络连接失败");
                if(!isSuc){
                    Log_Exception.Logger_txt("错误信息表 "+wcmRecId+" :插入失败！");
                }
				e.printStackTrace();
            }
			
	        //String sResult = SoapImport.importDoc(sZipFileName);
	        //record(ai.getID(), ai.getColumnID(), getWCMDocId(sResult));
	        return 10;
        } catch(Exception ex) {
            try {
                CMyFile.writeFile(Common.TEMP_PATH + ai.getID() + ".txt", ex.getMessage(), "GBK");
            } catch (CMyException e1) {
                e1.printStackTrace();
            }
            return 0;
        }
        
    }
    
    public static String clearHtmlCode(String htmlCode)
    {
            htmlCode = htmlCode.replaceAll("\t" , "").replaceAll("\n" , "").replaceAll(" " , "");
            //System.out.println(htmlCode);
            htmlCode = htmlCode.replaceAll("<script(.[^(</script>)]*)</script>" , "");
            //System.out.println(htmlCode);
            htmlCode = htmlCode.replaceAll("<(.[^>]*)>" , "");
            //System.out.println(htmlCode);
            return htmlCode;
    }
    
    public static String getTextFromTHML(String htmlStr) {
    	org.jsoup.nodes.Document doc = Jsoup.parse(htmlStr);
    	String text = doc.text();
    	// remove extra white space
    	StringBuilder builder = new StringBuilder(text);
    	int index = 0;
    	while(builder.length()>index){
    		char tmp = builder.charAt(index);
    		if(Character.isSpaceChar(tmp) || Character.isWhitespace(tmp)){
    			builder.setCharAt(index, ' ');
    		}
    		index++;
    	}
    	text = builder.toString().replaceAll(" +", " ").trim();
    	return text;
    }

    public static void main(String[] args) {
    	String s = "<p>adfasdf</p><font color=\"aaa\">4444444</font>";
    	System.out.println(clearHtmlCode(s));
    }
    
    
    
    /**
     * 
     * 市政府信息公开
     * @param ai
     * @param count
     * @return
     */
    public static int writeXmlSzf(ArticleInfo ai, int count) {
    	
    	ServiceImplWcm wcm=new ServiceImplWcm();
    	
    	int nCount = count%1000;
        String sTempPath = Common.TEMP_PATH;
        
        String sToChannel = ai.getColumnID();
        
        try {
        
	        String sZipFileName = Common.XML_PATH + "import_" + nCount + ".zip";
	        CMyZip oZip = new CMyZip();
	        try {
	            oZip.setZipFileName(sZipFileName);
	        } catch (CMyException e1) {
	            e1.printStackTrace();
	        }
	        
	        //开始生成一篇XML文档
	        Document doc = new Document(new Element("MetaViewDataS"));
	        Element ele = new Element("MetaViewData");
	        ele.setAttribute("Version","6.0");
	        doc.getRootElement().addContent(ele);
	        
	        ele.addContent(new Element("PROPERTIES"));
	        
	        ele = (Element)ele.getChildren().get(0);
	        
	        
	        Element tempEle = null;
	        Map<String, Object> properties = ai.getProperties();
	        
	        for(Entry<String, Object> mydoc : properties.entrySet()) {
	        	String key = mydoc.getKey();
	        	String value = ""+mydoc.getValue();
	        	tempEle = new Element(key);
	        	tempEle.addContent(new CDATA(value));
		        ele.addContent(tempEle);
	        }
	        
	        //如果需要导其它信息，按上面格式继续即可
	        //tempEle = new Element("OLDDOCORDER");
	        //tempEle.addContent(new CDATA(CMyString.showNull(ai.getProperty("OLDDOCORDER"))));
	        //ele.addContent(tempEle);
	        
	        //处理附件
	        if (ai.getApp().size() > 0){
	            ele = ele.getParent();
	            tempEle = new Element("WCMAPPENDIXS");
	            ele.addContent(tempEle);
	            
	            Element appElement = tempEle;
	            
	            //ele = (Element)ele.getChildren().get(0);
	            
	            for (int i=0; i<ai.getApp().size(); i++){
	            	
	            	Appendix app = (Appendix)ai.getApp().get(i);
	                
		            Element tempEle2 = new Element("WCMAPPENDIX");
		            tempEle2.setAttribute("Version", "6.0");
		            appElement.addContent(tempEle2);
		            
		            //ele = tempEle2;
		            
		            tempEle = new Element("PROPERTIES");
		            tempEle2.addContent(tempEle);
		            
		            tempEle2 = (Element)tempEle2.getChildren().get(0);
		            
		            tempEle = new Element("APPSERN");
		            tempEle.addContent(Integer.toString(i+1));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPDESC");
		            tempEle.addContent(new CDATA(app.getAPPDESC()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFILETYPE");
		            tempEle.addContent("0");
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("OTHEROPERATION");
		            tempEle.addContent("0");
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFLAG");
		            tempEle.addContent(app.getAPPTYPE());
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("FILEEXT");
		            tempEle.addContent(new CDATA(app.getFILEEXT()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPLINKALT");
		            tempEle.addContent(new CDATA(app.getAPPLINKALT()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("SRCFILE");
		            tempEle.addContent(new CDATA(app.getSRCFILE()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("CRUSER");
		            tempEle.addContent(new CDATA("admin"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPFILE");
		            tempEle.addContent(new CDATA(app.getAPPFILE()));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPDOCID");
		            tempEle.addContent(new CDATA("0"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("APPENDIXID");
		            tempEle.addContent(new CDATA("0"));
		            tempEle2.addContent(tempEle);
		            
		            tempEle = new Element("USEDVERSIONS");
		            tempEle.addContent(new CDATA("1"));
		            tempEle2.addContent(tempEle);
		            
		            try {
	                    oZip.addToZip(app.getAPPPATH() + app.getAPPFILE(), false);
	                } catch (Exception e2) {
	                    // TODO Auto-generated catch block
	                    e2.printStackTrace();
	                }
	            }
	            
	        }
	                
	        try {
	            CMyXMLDoc.toXMLFile(doc, sTempPath + "import.xml", "UTF-8");
	            oZip.addToZip(sTempPath + "import.xml", false);
	            oZip.done();
	            //System.out.println("生成ZIP文件：" + bDone);
	        } catch (Exception ex) {
	            System.out.println("文档[" + ai.getID() + "]生成ZIP文件失败，跳过");
	            return 1;
	        }
	        
	        Dispatch upDispatch = WCMServiceCaller.UploadFile(sZipFileName);
			// 获取上传后返回的文件名
			String fileName = upDispatch.getUploadShowName();
			//System.out.println(fileName);
			
			String wcmRecId = ai.getProperty("RECID");
        	String wcmDocId = ai.getID();
        	String docTitle = ai.getTitle();
			
			Map<String,Object> oPostData=new HashMap<>();
            oPostData.put("XMLSOURCE", 0);
            oPostData.put("ChannelId", Integer.parseInt(sToChannel));// 目标栏目id
            oPostData.put("CurrUserName", "dev");
            oPostData.put("FileName", fileName);
            oPostData.put("JumpRepeat", 1);
            
            try {
                Dispatch result = WCMServiceCaller.Call("gov_webdocument", "importDocument", oPostData, true);
                if(result!=null){
                	
                    JSONObject rObject = JSONObject.fromObject(result.getResponseText().toString());
                    if (rObject.get("ISSUCCESS").toString().equals("true")){
                    	
                        System.out.println("迁移第"+count+"条，成功！wcmRecId:"+wcmRecId+";wcmdocid:"+wcmDocId);
                        JSONObject dataObject=Common.getRecIdFromHy(wcmDocId, sToChannel);
                        String hyRecId=dataObject.getString("RECID");
                        String hyDocId=dataObject.getString("DOCID");
                        
                        //记录原始文章的docorder
                        int res = wcm.updateChnldoc(hyRecId, ai.getProperty("docOrder"));
                        if(res<1){
                            Log_Exception.Logger_txt("chnldoc更新失败,海云recid:"+hyRecId+",wcm排序字段:"+ai.getProperty("OLDDOCORDER"));
                        }
                        
                        Map<String,Object> resultMap=new HashMap<>();
                        resultMap=wcm.GetResultInfo(wcmRecId);//
                        
                        //存在更新，不存在插入
                        if(resultMap!=null&&resultMap.size()>0){
                            Boolean isSuc=false;
                            isSuc=wcm.UpdateResult(Integer.valueOf(wcmRecId), Integer.valueOf(hyRecId), Integer.valueOf(wcmDocId),Integer.valueOf(hyDocId));
                            if(!isSuc){
                                Log_Exception.Logger_txt("结果表 "+wcmRecId+" :更新失败！");
                            }
                        }else{
                            Boolean isSuc=false;
                            isSuc=wcm.InsertResult(Integer.valueOf(wcmRecId), Integer.valueOf(hyRecId), Integer.valueOf(wcmDocId),Integer.valueOf(hyDocId), "", "");
                            if(!isSuc){
                                Log_Exception.Logger_txt("结果表 "+wcmRecId+" :插入失败！");
                            }
                        }
                    }else{
                        System.out.println("迁移第"+count+"条，失败！");
                        String messageInfo=rObject.getString("MSG");
                        Log_Exception.Logger_txt("失败！RecID："+wcmRecId+" 标题："+docTitle+"错误信息："+messageInfo);

                        //记录文档失败信息
                       /* Boolean isSuc=false;
                        Map<String,Object> Messagemap=wcm.GetLogMessageInfo(Integer.valueOf(wcmRecId));
                        if(Messagemap!=null&&Messagemap.size()>0){
                            isSuc=wcm.UpdateLogMessageInfo(Integer.valueOf(wcmRecId), messageInfo);
                        }else{
                            isSuc=wcm.InsertLogMessageInfo(Integer.valueOf(wcmRecId), "gk", messageInfo);
                        }
                        if(!isSuc){
                            Log_Exception.Logger_txt("错误信息表 "+wcmRecId+" :插入/更新失败！");
                        }*/
                        wcm.InsertLogMessageInfo(Integer.valueOf(wcmRecId), "gk2", messageInfo);
                    }
                }
                
            } catch(Exception e) {
            	Boolean isSuc=false;
            	isSuc = wcm.InsertLogMessageInfo(Integer.valueOf(wcmRecId), "gk2", "网络连接失败");
                if(!isSuc){
                    Log_Exception.Logger_txt("错误信息表 "+wcmRecId+" :插入失败！");
                }
				e.printStackTrace();
            }
			
	        //String sResult = SoapImport.importDoc(sZipFileName);
	        //record(ai.getID(), ai.getColumnID(), getWCMDocId(sResult));
	        return 10;
        } catch(Exception ex) {
        	
            try {
            	wcm.InsertLogMessageInfo(Integer.valueOf(ai.getProperty("RECID")), "gk2", "网络连接失败");
                CMyFile.writeFile(Common.TEMP_PATH + ai.getID() + ".txt", ex.getMessage(), "GBK");
            } catch (Exception e1) {
                e1.printStackTrace();
            }
            return 0;
        }
        
    }
}
