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

📄 aggetcurrentdept.java.svn-base

📁 一个包含排班信息的模块 2.1. 最新排班 6 2.2. 所有排班 6 2.3. 日常排班统计 7 2.4. 排班管理 7 2.5. 班次配置 7 2.6. 部门人员配置 7
💻 SVN-BASE
字号:
/*
 名称:获取当前部门信息代理
 作用:根据传入的部门名称,获取此部门的关键性信息

 参数:
 sDeptName    部门名称

 返回值:
 Case 1:
 <Return>0</Return>
 Case 1:
 <Return>1</Return>
 <Content>
 <Document>
 <DeptName>部门名称</DeptName>
 <DivideManager>排班负责人</DeptManager> 
 </Document>

 </Content>
 */
package com.fzet.cois.dividework.agents;

import lotus.domino.*;

import java.io.*;
import com.fzet.cois.common.scriptLib.*;

import lotus.domino.AgentBase;

public class AgGetCurrentDept extends AgentBase {

    public void NotesMain() {
	Session session = null;
	AgentContext ac = null;
	Database db = null;
	Database dbMain = null; //配置中心数据库
	Document doc = null;

	PrintWriter pw = null;
	ErrHandle err = null;

	View vwDept = null;
	DocumentCollection dc = null;
	Document docDept = null;
	Document docTemp = null;

	try {
	    session = getSession();
	    ac = session.getAgentContext();
	    db = ac.getCurrentDatabase();
	    doc = ac.getDocumentContext();
	    pw = getAgentOutput();
	    dbMain = Common.getMainDb(session);
	    err = new ErrHandle(session, 0, "", "agGetCurrentDept.xml");

	    // 提取查询参数
	    String sQuery = doc.getItemValueString("Query_String_Decoded");
	    String sDeptName = Common.parseParameter(sQuery, "DeptName");

	    // 如果部门名称为空,则返回错误信息
	    if (sDeptName == null || sDeptName.equals("")) {
		Common.returnXML(pw, "<root><Return>0</Return><Error>无效的部门名称。</Error></root>");
		return;
	    }

	    vwDept = dbMain.getView("vwDeptInfoByDeptName");
	    if (vwDept == null) {
		Common.returnXML(pw, "<root><Return>0</Return><Error>无法打开部门管理视图,读取部门信息失败</Error></root>");
		return;
	    }

	    // 生成查询向量
	    StringBuffer sbResult = new StringBuffer();
	    sbResult.append("<root><Return>1</Return><Content>");

	    dc = vwDept.getAllDocumentsByKey(sDeptName, true);
	    docDept = dc.getFirstDocument();
	    while (docDept != null) {
		//System.out.println(docDept.getItemValue("DivideManager").toString());
		sbResult.append("<Document>")
		.append("<DeptName>")
		.append(Util.getToCDATA(sDeptName))
		.append("</DeptName>")
		.append("<DeptManager>").append(docDept.getItemValueString("DeptManager")).append("</DeptManager>")
		.append("<DivideManager>")
		.append(docDept.getItemValue("DivideManager").toString())
		.append("</DivideManager>").append("</Document>");

		docTemp = docDept;
		docDept = dc.getNextDocument(docDept);
		docTemp.recycle();
	    }
	    sbResult.append("</Content></root>");
	    Common.returnXML(pw, sbResult.toString());

	} catch (Exception e) {
	    err.record(false, 0, e.toString());
	    e.printStackTrace();
	    Common.returnXML(pw, "<root><Return>0</Return><Error>" + e.toString() + "</Error></root>");
	} finally {
	    try {
		if (docTemp != null)
		    docTemp.recycle();
		if (docDept != null)
		    docDept.recycle();
		if (dc != null)
		    dc.recycle();
		if (vwDept != null)
		    vwDept.recycle();
		if (doc != null)
		    doc.recycle();
		if (db != null)
		    db.recycle();
		if (ac != null)
		    ac.recycle();
		if (session != null)
		    session.recycle();
	    } catch (Exception e) {
		e.printStackTrace();
	    }
	}
    }
}

⌨️ 快捷键说明

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