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

📄 getnotifyinfo.txt

📁 从LOTUS库获取数据写入ORACLE库
💻 TXT
字号:
import lotus.domino.*;
import java.util.Vector;
import com.guanda.oa.entity.interfaces.OaNotifyInfoModel;
import com.guanda.oa.session.interfaces.WorkBench;
import com.guanda.oa.session.interfaces.ContactIncept;
import com.guanda.oa.session.ContactInceptFactory;
import com.guanda.oa.session.WorkBenchFactory;
import com.guanda.oa.session.exception.SystemException;
import java.lang.*;

public class JavaAgent extends AgentBase {

	public void NotesMain() {

		try {
			Session session = getSession();
			AgentContext agentContext = session.getAgentContext();

			// (Your code goes here)
                        
			//取反馈信息  
                        java.util.Vector notifyVecs = getNotifyInfo();
               
                        OaNotifyInfoModel model = null;
                        WorkBench workBench = null;

			//向新oa库写反馈信息
                       
                        if (!notifyVecs.isEmpty() ) 
                        {       	
                           for (int i = 0;i < notifyVecs.size();i++) 
                           {
                	          model = (OaNotifyInfoModel) notifyVecs.get(i);              
                              try
			           {
               	                       workBench = WorkBenchFactory.getWorkBenchInstance();
                                       workBench.addMessage(model);
                                   
    	                         }
                              catch (Exception se)
			               {
                                    se.printStackTrace();
                              }
                          }
                       } 

		    } 
               catch(Exception e) 
              {
			e.printStackTrace();
		}
	}


       /**
        *  从lotus库取反馈信息
        **/
     public static Vector getNotifyInfo()
    {
        OaNotifyInfoModel notifyInfoModel = null;
        java.util.Vector notifyVec = null;
        java.util.Vector fields = null;
        Document doc = null;
        View view = null;
        Item field = null;
        Session session = null;

        try
        {
            session = NotesFactory.createSession();
            lotus.domino.AgentContext agentContext = session.getAgentContext();
	    //获取反馈信息集合
            lotus.domino.DocumentCollection docs = agentContext.
                getUnprocessedDocuments();
            doc = docs.getFirstDocument();
	    //反馈信息model集合
            notifyVec = new java.util.Vector();

	    //组装反馈信息model
            ContactIncept contactIncept = ContactInceptFactory.
                getContactInceptInstance();
            while (doc != null)
            {
                notifyInfoModel = new OaNotifyInfoModel();
                fields = doc.getItems();
                String feedUnit = doc.getItemValueString("FeedUnit");
                System.out.println("feedUnit="+feedUnit);
                notifyInfoModel.setUnitinfo(feedUnit);
                String title = doc.getItemValueString("Subject");
                System.out.println("title="+title);
                notifyInfoModel.setTitle(title);
                java.util.Date notifyDate = doc.getCreated().toJavaDate();
                java.text.SimpleDateFormat dateFormat= new java.text.SimpleDateFormat("yyyy-MM-dd");
                String dateStr = dateFormat.format(notifyDate);
                System.out.println("dateStr"+dateStr);
                notifyInfoModel.setNotifyDate(notifyDate);

                long id = 0;
		/**获得反馈信息的公文id
		 *@param String  反馈信息中的公文标题
		 *@param String  反馈时间
		 */
                if (title != null && title != "" && dateStr != null)
                {
                    try
                    {
                        id = contactIncept.getDocumentID(title, dateStr);

                    }
                    catch (SystemException se)
                    {
                        se.printStackTrace();
                    }
                   
                }
                 notifyInfoModel.setDocumentID(id);
                 System.out.println("docid="+id);
                notifyVec.addElement(notifyInfoModel);
               // doc.recycle();
                agentContext.updateProcessedDoc(doc);
                System.out.println("get nextDoc>>>>>>>>>") ;
                doc = docs.getNextDocument(doc);
            }
        }
        catch (NotesException ne)
        {
            ne.printStackTrace();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        finally
        { 
        	try 
        	{
            if (doc != null)
            {
                doc.recycle();
            }
            if (session != null)
            {
                session.recycle();
            }
            }catch (NotesException nex)
            {
            	nex.printStackTrace();
            }

        }
        return notifyVec;
    }

}

⌨️ 快捷键说明

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