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

📄 agcalendarwr.java.svn-base

📁 一个包含排班信息的模块 2.1. 最新排班 6 2.2. 所有排班 6 2.3. 日常排班统计 7 2.4. 排班管理 7 2.5. 班次配置 7 2.6. 部门人员配置 7
💻 SVN-BASE
字号:
package com.fzet.cois.dividework.agents;

import java.io.PrintWriter;
import java.util.Vector;

import com.fzet.cois.common.scriptLib.Common;
import com.fzet.cois.common.scriptLib.ErrHandle;

import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.NotesError;
import lotus.domino.NotesException;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.ViewEntry;
import lotus.domino.ViewEntryCollection;

public class AgCalendarWr extends AgentBase {

	public void NotesMain() {
		ErrHandle err = null; // 错误日志
		Session session = null; // 当前会话
		AgentContext ac = null; // 当前上下文环境
		Database db = null; // 当前数据库
		View vwCalendar = null; // 日程安排查询视图
		ViewEntryCollection vecReturn = null; // 日程安排返回查询结果记录集实体
		ViewEntry veReturn = null; // 查询结果集中一条实体
		Document doc = null; // 当前文档
		PrintWriter pw = null; // 输出流
		String sQuery = null; // 查询参数
		String sViewName = null; // 视图名称------------参数1
		String sCondition = null; // 查询条件------------参数2
		String sDeptName = null; // 查询条件------部门名称
		String sIsMgr = null; // 查詢條件----------參數3
		Vector vQuery = new Vector(); // 查询向量
		StringBuffer sbResult = new StringBuffer(); // 输出结果字符串缓冲:查询结果
		// 定义返回值的变量

		String sWeekID = null; // 周次
		String sBETime = null; // 起止时间

		String sLastModifyUser = null; // 最后修改人
		String sLastModified = null; // 最后修改时间
		String sUNID = null; // 文档ID
		String sYearMonth = null;// 标题
		String sIsSubmit = null;// 是否提交
		Vector vTemp = null; // 条目字符串变量
		ViewEntry veTemp = null; // 条目临时变量

		try {
			// 初始化过程
			session = getSession();
			ac = session.getAgentContext();
			doc = ac.getDocumentContext();
			db = ac.getCurrentDatabase();
			pw = getAgentOutput();

			// 初始化错误日志类
			err = new ErrHandle(session, 0, "", "agCalendarWr.xml");
			// 取得查询参数
			sQuery = doc.getItemValueString("Query_String_Decoded");
			// 提取管理員參數
			sIsMgr = Common.parseParameter(sQuery, "IsMgr");
			// 提取视图名称
			sViewName = Common.parseParameter(sQuery, "ViewName");
			if (sViewName == null)
				throw new NotesException(NotesError.NOTES_ERR_OBJECT_NOT_FOUND,
						"未找到参数ViewName");
			if (sViewName.equals("vwAllPaib") || sViewName.equals("vwDeptWr")) {
				// 提取查询参数
				sCondition = Common.parseParameter(sQuery, "Time");
				if (sCondition == null)
					throw new NotesException(
							NotesError.NOTES_ERR_OBJECT_NOT_FOUND, "未找到参数Time");
				vQuery.addElement(sCondition);
			}
			// 提取部门名称,如果是以个人方式查看时,部门名称为空
			sDeptName = Common.parseParameter(sQuery, "DeptName");
			if (sDeptName == null)
				throw new NotesException(NotesError.NOTES_ERR_OBJECT_NOT_FOUND,
						"未找到参数DeptName");
			// String sIsDeptUsers = Common.parseParameter(sQuery,
			// "IsDeptUsers");
			// 生成查询向量
			if (!sDeptName.equals("")) {
				vQuery.addElement(sDeptName);
			}
			// 从特定视图查询结果
			vwCalendar = db.getView(sViewName);
			if (vwCalendar == null)
				throw new NotesException(NotesError.NOTES_ERR_NOSUCH_VIEW,
						"未找到视图:" + sViewName);
			// 单击周排班时部门为空,用户为系统管理员时部门为空
			// 用户为系统管理员时,且视图为班次设置,排班管理,人员配置时执行前一个if
			// 单击周排班,用户也为空,执行else语句。
			// System.out.println(vQuery);
			if (sDeptName.equals("") || sIsMgr.equals("1")) {
				// 用户为系统管理员时,显示所有记录
				if (sViewName.equals("vwAffair")
						|| sViewName.equals("vwPaibManage")
						|| sViewName.equals("vwDeptUsers")
						|| sViewName.equals("vwUserModify")) {
					vecReturn = vwCalendar.getAllEntries();
				} else
					vecReturn = vwCalendar.getAllEntriesByKey(vQuery, true);
			} else {
				vecReturn = vwCalendar.getAllEntriesByKey(vQuery, true);
			}
			// 生成结果
			if (vecReturn.getCount() == 0) {
				Common
						.returnXML(pw,
								"<root><Return>0</Return><Error>没有符合条件的文档!</Error></root>");
				return;
			}
			sbResult.append("<root><Return>1</Return><Content>");
			// 循环生成结果
			veReturn = vecReturn.getFirstEntry();
			while (veReturn != null) {
				vTemp = veReturn.getColumnValues();
				if (sViewName.equals("vwDeptUsers")
						|| sViewName.equals("vwAffair")
						|| sViewName.equals("vwUserModify")) {
					sDeptName = (String) vTemp.elementAt(0);
					String sContent = vTemp.elementAt(1).toString();
					sUNID = (String) vTemp.elementAt(2);
					// 生成XML
					sbResult.append("<PaibConfig>").append("<DeptName>")
							.append(sDeptName).append("</DeptName>").append(
									"<Content>").append(sContent).append(
									"</Content>").append("<UNID>")
							.append(sUNID).append("</UNID>").append(
									"</PaibConfig>");
				} else {
					if (sViewName.equals("vwPaibManage")) {
						// 发布部门,年月,周次,开始日期~结束日期,修改人,修改时间,ID
						sDeptName = (String) vTemp.elementAt(0);
						sYearMonth = (String) vTemp.elementAt(1);
						sWeekID = (String) vTemp.elementAt(2);
						sBETime = (String) vTemp.elementAt(3);
						sLastModifyUser = (String) vTemp.elementAt(4);
						sLastModified = (String) vTemp.elementAt(5);
						sUNID = (String) vTemp.elementAt(6);
					} else {
						// 发布部门,年月,周次,开始日期~结束日期,修改人,修改时间,ID
						sDeptName = (String) vTemp.elementAt(2);
						sYearMonth = (String) vTemp.elementAt(3);
						sWeekID = (String) vTemp.elementAt(4);
						sBETime = (String) vTemp.elementAt(5);
						sLastModifyUser = (String) vTemp.elementAt(6);
						sLastModified = (String) vTemp.elementAt(7);
						sUNID = (String) vTemp.elementAt(8);
						sIsSubmit = (String) vTemp.elementAt(9);

					}
					// 生成XML
					sbResult.append("<PaibConfig>").append("<DeptName>")
							.append(sDeptName).append("</DeptName>").append(
									"<YearMonth>").append(sYearMonth).append(
									"</YearMonth>").append("<WeekID>").append(
									sWeekID).append("</WeekID>").append(
									"<BETime>").append(sBETime).append(
									"</BETime>").append("<LastModifyUser>")
							.append(sLastModifyUser)
							.append("</LastModifyUser>").append(
									"<LastModified>").append(sLastModified)
							.append("</LastModified>").append("<UNID>").append(
									sUNID).append("</UNID>").append(
									"<IsSubmit>").append(sIsSubmit).append(
									"</IsSubmit>").append("</PaibConfig>");
				}
				veTemp = veReturn;
				veReturn = vecReturn.getNextEntry(veReturn);
				veTemp.recycle();
			}
			sbResult.append("</Content></root>");

			// 输出结果
			Common.returnXML(pw, sbResult.toString());
		} catch (NotesException e) {
			StringBuffer sbReturn = new StringBuffer().append(
					"<root><Return>0</Return><Error>").append(e.text).append(
					"</Error></root>");
			Common.returnXML(pw, sbReturn.toString());
			err.record(true, e.id, e.text);
			e.printStackTrace();
		} catch (Exception e) {
			StringBuffer sbReturn = new StringBuffer().append(
					"<root><Return>0</Return><Error>").append(e.toString())
					.append("</Error></root>");
			Common.returnXML(pw, sbReturn.toString());
			err.record(true, 0, e.toString());
			e.printStackTrace();
		} finally {
			// 释放所有申请的资源
			try {
				if (doc != null)
					doc.recycle();
				if (veReturn != null)
					veReturn.recycle();
				if (vecReturn != null)
					vecReturn.recycle();
				if (vwCalendar != null)
					vwCalendar.recycle();
				if (db != null)
					db.recycle();
				if (ac != null)
					ac.recycle();
				if (session != null)
					session.recycle();
			} catch (NotesException e) {
				System.out.println(e.text);
				e.printStackTrace();
			}
		}
	}
}

⌨️ 快捷键说明

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