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

📄 message.inc

📁 物业管理和办公自动化系统
💻 INC
字号:
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 消息有关的常量定义
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const IN_BOX		= "1"		'' 收件箱
		Const INBOX_BULLETIN	= "101"		'' 公告
		Const INBOX_MEETING	= "102"		'' 会议相关
		Const INBOX_APPROVE	= "103"		'' 审批相关
		Const INBOX_TASK		= "104"		'' 任务相关

Const OUT_BOX		= "2"		'' 发件箱
Const DRAFT_BOX	= "3"		'' 草稿箱 

'' 回收站 TRASH_BOX
Const TRASH_BOX = "4"	'' 回收站
Const TRASH_MSG_FROM_INBOX		= "1001"		'	1001			收件箱					-> 回收站
Const TRASH_MSG_FROM_BULLETIN	= "1101"		'	1101			收件箱 · 公告			-> 回收站 
Const TRASH_MSG_FROM_MEETING		= "1102"		'	1102			收件箱 · 会议相关	-> 回收站 
Const TRASH_MSG_FROM_APPROVE	= "1103"		'	1103			收件箱 · 审批相关	-> 回收站 
Const TRASH_MSG_FROM_TASK			= "1104"		'	1104			收件箱 · 任务相关	-> 回收站 
Const TRASH_MSG_FROM_OUTBOX		= "1002"		'	1002			发件箱					-> 回收站
Const TRASH_MSG_FROM_DRAFTBOX	= "1003"		'	1003			草稿箱					-> 回收站

'' 消息类别
Const MSG_COMMON		= "1"
Const MSG_BULLETIN		= "101"
Const MSG_MEETING		= "102"
Const MSG_APPROVE		= "103"
Const MSG_TASK			= "104"

'' 消息读取状态
Const MSG_UNINFORMED = "1"
Const MSG_INFORMED	  = "2"
Const MSG_READ			  = "3"

function NewMsgId()
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'' 以下代码产生一个唯一的MsgId
	'' MsgId的数据类型为UniqueIdentifier,这种数据类型可以通过两种方法得到:
	'' 1. 调用 NEWID 函数得到
	'' 2. 由一个32位长度格式如xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx的字串转换, 其中x为0-9, a-f之间的十六进制数字。
	''     如 6F9619FF-8B86-D011-B42D-00C04FC964FF 就是一个有效的 uniqueidentifier 值
	''
	'' 产生MsgId的过程就是构造一个32位字串的过程,大致如下:
	'' 1. 前面16位用时间来构造,如yyyymmdd-hhmm-ss00
	'' 2. 产生一个0~9999的随机数,长度为四位,即0000~9999
	'' 3. 最后12位数字的前几位全零,后几位为该员工的序列号Emp_Serial
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

	'' 首先调用Randomize使后面调用的Rnd函数以系统时间为种子产生一个随机数
	Randomize

	'' 产生一个在lowerbound ~ upperbound 之间的随机整数的公式为:Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
	dim rndInt		: rndInt = Int((9999 - 0 + 1) * Rnd + 0)		'' 9999为upperbound,0为lowerbound
	dim rnd4Digit	: rnd4Digit = CStr(rndInt)
	rnd4Digit = Right("0000" & rnd4Digit, 4)			'' 先补4个前导0,然后取后4位
	
	'' 取到时间的各个数据
	dim sYear, sMonth, sDay, sHour, sMinute, sSecond
	sYear	= CStr(Year(date))
	sMonth	= CStr(Month(date))			: if len(sMonth) = 1 then sMonth = "0" & sMonth
	sDay		= CStr(Day(date))				: if len(sDay) = 1 then sDay = "0" & sDay
	sHour	= CStr(Hour(now))				: if len(sHour) = 1 then sHour = "0" & sHour
	sMinute	= CStr(Minute(now))			: if len(sMinute) = 1 then sMinute = "0" & sMinute
	sSecond	= CStr(Second(now))		: if len(sSecond) = 1 then sSecond = "0" & sSecond

	'' 构造最后12位,先补12个前导0,然后取后12位
	dim sLast12Digit
	sLast12Digit = Right("000000000000" & GetEmpSerial, 12)

	'' 构造32位长度的字串xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
	NewMsgId = sYear & sMonth & sDay & "-" & sHour & sMinute & "-" & sSecond & "00-" & rnd4Digit & "-" & sLast12Digit
	'' MsgId 构造完毕
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
end function

sub CommonSendMsg(msg_type, parent_msg_id, subject, content, sender, receiver)
	dim sSQL, sFolder, sEmpSerial
	dim sParentMsgId, sMsgType, sSubject, sContent, sSender, sReceiver, sSendTime, sStatus

	sParentMsgId = parent_msg_id
	sMsgType = msg_type
	sSubject = subject
	sContent = content
	sSender = sender
	sReceiver = receiver
	sSendTime = now()

	if IsEmpty(sSubject) and IsEmpty(sContent) then sSubject = "(无内容)"

	
	dim sMsgId			: sMsgId = NewMsgId
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'' 一条记录保存到我的发件箱
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'' msg_type = 1						一般的消息
	'' msg_type = 102 --> 104		系统发送的消息(会议相关、审批相关、任务相关),不需要送到发件人的发件箱中
	if CStr(sMsgType) = MSG_COMMON then
			sEmpSerial = GetEmpSerial()	'' 消息的主人是我自己
			sFolder = OUT_BOX				'' 常量 OUT_BOX 在 message.inc 中有定义,表示发件箱
			sStatus = MSG_READ				'' 常量 MSG_READ 在 message.inc 中有定义,表示状态为已读
			sSQL = "insert into t_msg(emp_serial, msg_id, msg_type, subject, content, folder, sender, receiver, send_time, parent_msg_id, status)" & _
					" values(" & ToSQL(sEmpSerial, "Number") & _
					", " & ToSQL(sMsgId, "Text") & _
					", " & ToSQL(sMsgType, "Number") & _
					", " & ToSQL(sSubject, "Text") & _
					", " & ToSQL(sContent, "Text") & _
					", " & ToSQL(sFolder, "Number") & _
					", " & ToSQL(sSender, "Number") & _
					", " & ToSQL(sReceiver, "Text") & _
					", " & ToSQL(sSendTime, "Text") & _
					", " & ToSQL(sParentMsgId, "Text") & _
					", " & ToSQL(sStatus, "Number") & _
					")"
			''Response.Write sSQL & "<br><br>"
			call ExecuteSQL(dbLocal, sSQL)
	end if

	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'' 分解sReceiver为多个emp_serial,每个emp_serial 插入一条记录,放到收件箱中
	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	dim arrayEmpSerial	: arrayEmpSerial = split(sReceiver, ",")
	dim j
	for j = 0 to UBound(arrayEmpSerial) step 1
		sEmpSerial = arrayEmpSerial(j)	'' 消息的主人是收件人
		sFolder = sMsgType					'' Folder 的值和 MsgType 的值保持一致
		sStatus = MSG_UNINFORMED		'' 常量 MSG_UNINFORMED 在msg.inc 中有定义,表示状态为未通知的新消息
		sSQL = "insert into t_msg(emp_serial, msg_id, msg_type, subject, content, folder, sender, receiver, send_time, parent_msg_id, status)" & _
			" values(" & ToSQL(sEmpSerial, "Number") & _
			", " & ToSQL(sMsgId, "Text") & _
			", " & ToSQL(sMsgType, "Number") & _
			", " & ToSQL(sSubject, "Text") & _
			", " & ToSQL(sContent, "Text") & _
			", " & ToSQL(sFolder, "Number") & _
			", " & ToSQL(sSender, "Number") & _
			", " & ToSQL(sReceiver, "Text") & _
			", " & ToSQL(sSendTime, "Text") & _
			", " & ToSQL(sParentMsgId, "Text") & _
			", " & ToSQL(sStatus, "Number") & _
			")"
		''Response.Write sSQL & "<br>"
		call ExecuteSQL(dbLocal, sSQL)
	next
end sub
%>

⌨️ 快捷键说明

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