![](/Images/OutliningIndicators/ContractedBlock.gif)
cs_EmailQueue_Failure
ALTER proc dbo.cs_EmailQueue_Failure
@EmailID uniqueidentifier,
@FailureInterval int,
@MaxNumberOfTries int
as
SET Transaction Isolation Level Read UNCOMMITTED
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
declare @NumberOfTries int --重试次数
select @NumberOfTries = NumberOfTries + 1 from cs_EmailQueue where EmailID = @EmailID
![](/Images/OutliningIndicators/None.gif)
if @NumberOfTries <= @MaxNumberOfTries
begin --如果重试次数小于最大次数,更新重试次数和第二次重试次数
update cs_EmailQueue set
NumberOfTries = @NumberOfTries,
NextTryTime = dateadd(minute, @NumberOfTries * @FailureInterval, getdate())
where EmailID = @EmailID
end
else
begin --如果重试次数超过限制,删除此条邮件
delete from cs_EmailQueue where EmailID = @EmailID
end
![](/Images/OutliningIndicators/None.gif)
GO
![](/Images/OutliningIndicators/ContractedBlock.gif)
cs_Emails_Dequeue
ALTER PROCEDURE [dbo].cs_Emails_Dequeue
(
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
![](/Images/OutliningIndicators/None.gif)
SELECT * FROM cs_EmailQueue Where SettingsID = @SettingsID and NextTryTime < getdate()
END
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*列出最后重试发送时间小于当前时间的所有邮件*/
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
GO
![](/Images/OutliningIndicators/ContractedBlock.gif)
cs_Emails_Enqueue
ALTER PROCEDURE [dbo].cs_Emails_Enqueue
(
@EmailTo nvarchar(2000),
@EmailCc ntext,
@EmailBcc ntext,
@EmailFrom nvarchar(256),
@EmailSubject nvarchar(1024),
@EmailBody ntext,
@EmailPriority int,
@EmailBodyFormat int,
@SettingsID int
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
![](/Images/OutliningIndicators/None.gif)
INSERT INTO
cs_EmailQueue
(
emailTo,
emailCc,
emailBcc,
EmailFrom,
EmailSubject,
EmailBody,
emailPriority,
emailBodyFormat,
SettingsID
)
VALUES
(
@EmailTo,
@EmailCc,
@EmailBcc,
@EmailFrom,
@EmailSubject,
@EmailBody,
@EmailPriority,
@EmailBodyFormat,
@SettingsID
)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*插入新的邮件到邮件队列中*/
END
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
GO
posted on
2006-09-05 09:11
MainIsUsed
阅读(
217)
评论()
编辑
收藏
举报