扩展 WSS3 任务列表以支持重复提醒

发布于 2024-08-17 06:34:20 字数 216 浏览 7 评论 0原文

当新任务添加到任务列表时,WSS 3.0 将允许我向组发送电子邮件。我想做的是运行一个每周任务,发送特定时间段内到期的任务提醒,即 2 天、7 天、14 天等。我认为最简单的方法是构建一个位于WS2K3 框并查询 WSS 数据库。我应该检查哪些表有什么想法吗?更一般地说,WSS3 数据库系统有一个总体架构吗?

如果有人知道现有的代码解决方案,请告诉我。

谢谢++

杰瑞

WSS 3.0 will let me send an email to a group when a new task is added to a task list. What I would like to do is to run a weekly task that sends out reminders of tasks due within certain periods, i.e. 2 days, 7 days, 14 days etc. I thought the simplest way would be to build a little C# app that sits on the WS2K3 box and queries the WSS database. Any ideas on which tables I should be checking? More generally is there an overall schema for the WSS3 database system?

If anyone is aware of an existing solution with code please let me know.

Thx++

Jerry

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谁人与我共长歌 2024-08-24 06:34:20

我的建议:

  • 不要创建控制台应用程序,创建一个继承自 SPJobDefinition 的类。
  • 运行多个前端服务器
  • SPJobLockType.Job 设置为此计时器,这将允许该作业在整个场中仅执行一次,即使您在计时器作业中 ,打开 SPSite,您需要的SPWeb对象,然后找到SPList\
  • 使用SPQuery过滤出您需要的项目 - 我相信,您必须过滤掉 Status!=Complete
  • 循环结果集合(其类型为 SPListItemCollection),应用您的规则,检查 DueDate 和 < code>Datetime.Now,发送电子邮件
  • 由于任务只是一个 SPListItem,它有一个 Properties 属性,它实际上是一个属性包 -您可以添加所需的任何属性。因此,请添加一个属性 My_LastSentReminderDate
  • 。 /code> 在 SharePoint 场中,您可以使用 PowerShell 脚本。如果需要的话,我可以给你举例。

不要忘记Threading.Thread.CurrentThread.CurrentCulture = Your_SPWeb_Instance.Locale,否则如果网络具有不同的区域设置,则日期比较可能不起作用!

编辑:这是我的应用程序中典型提醒的样子:

Public Class TypicalTimer
    Inherits SPJobDefinition

    Public Sub New(ByVal spJobName As String, ByVal opApplication As SPWebApplication)
        'this way we can explicitly specify we need to lock the JOB
        MyBase.New(spJobName, opApplication, Nothing, SPJobLockType.Job)
    End Sub

    Public Overrides Sub Execute(ByVal opGuid As System.Guid)
        'whatever functionality is there in the base class...
        MyBase.Execute(Guid.Empty)
        Try
            Using oSite As SPSite = New SPSite("http://yourserver/sites/yoursite/subsite")
                Using oWeb As SPWeb = oSite.OpenWeb()
                    Threading.Thread.CurrentThread.CurrentCulture = oWeb.Locale
                    'find the task list and read the "suspects"
                    Dim oTasks As SPList = oWeb.Lists("YourTaskListTitle")
                    Dim oQuery As New SPQuery()
                    oQuery.Query = "<Where><Neq><FieldRef Name='Status'/>" & _
                                    "<Value Type='Choice'>Complete</Value></Neq></Where>"
                    Dim oUndoneTasks As SPListItemCollection = oTasks.GetItems(oQuery)

                    'extra filtering of the suspects.
                    'this can also be done in the query, but I don't know your rules
                    For Each oUndoneTask As SPListItem In oUndoneTasks
                        If oUndoneTask(SPBuiltInFieldId.TaskDueDate) IsNot Nothing AndAlso _
                            CDate(oUndoneTask(SPBuiltInFieldId.TaskDueDate)) < Now().Date Then
                            ' this is where you send the mail
                        End If
                    Next
                End Using
            End Using
        Catch ex As Exception
            MyErrorHelper.LogMessage(ex)
        End Try
    End Sub
End Class

要注册计时器作业,我通常使用这种脚本:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
[System.Reflection.Assembly]::LoadWithPartialName("Your.Assembly.Name.Here")
$spsite= [Microsoft.SharePoint.SPSite]("http://yourserver/sites/yoursite/subsite")

$params = [System.String]("This text shows up in your timer job list (in Central Admin)", $spsite.WebApplication
$newTaskLoggerJob = new-object -type Your.Namespace.TypicalTimer -argumentList $params

$schedule = new-object Microsoft.SharePoint.SPDailySchedule
$schedule.BeginHour = 8
$schedule.BeginMinute = 0
$schedule.BeginSecond = 0
$schedule.EndHour = 8
$schedule.EndMinute = 59
$schedule.EndSecond = 59

$newTaskLoggerJob.Schedule = $schedule
$newTaskLoggerJob.Update()

My suggestions:

  • don't create a console app, create a class that inherits from SPJobDefinition.
  • set SPJobLockType.Job to this timer, this will grant that the job is executed only once in the whole farm, even if you are running multiple front-end servers
  • in the, timer job, open the SPSite, SPWeb objects you need, then find the SPList\
  • Using SPQuery filter out only the items you need - I believe, you will have to filter out the ones where Status!=Complete
  • Loop through the results collection (which will be of type SPListItemCollection, apply your rules, checking the DueDate and Datetime.Now, send the e-mails
  • Since a task is simply a SPListItem, it has a Properties property, which is actually a property bag - you can add whatever properties you need. So, add a property My_LastSentReminderDate. Use this property to check if you are not sending too much of "corporate spam" :-)
  • To install your SPJobDefinition in a SharePoint farm, you can use a PowerShell script. I can give you examples, if needed.

Don't forget to Threading.Thread.CurrentThread.CurrentCulture = Your_SPWeb_Instance.Locale, otherwise date comparisons may not work if the web has a different locale!

EDIT: This is how a typical reminder looks like in my applications:

Public Class TypicalTimer
    Inherits SPJobDefinition

    Public Sub New(ByVal spJobName As String, ByVal opApplication As SPWebApplication)
        'this way we can explicitly specify we need to lock the JOB
        MyBase.New(spJobName, opApplication, Nothing, SPJobLockType.Job)
    End Sub

    Public Overrides Sub Execute(ByVal opGuid As System.Guid)
        'whatever functionality is there in the base class...
        MyBase.Execute(Guid.Empty)
        Try
            Using oSite As SPSite = New SPSite("http://yourserver/sites/yoursite/subsite")
                Using oWeb As SPWeb = oSite.OpenWeb()
                    Threading.Thread.CurrentThread.CurrentCulture = oWeb.Locale
                    'find the task list and read the "suspects"
                    Dim oTasks As SPList = oWeb.Lists("YourTaskListTitle")
                    Dim oQuery As New SPQuery()
                    oQuery.Query = "<Where><Neq><FieldRef Name='Status'/>" & _
                                    "<Value Type='Choice'>Complete</Value></Neq></Where>"
                    Dim oUndoneTasks As SPListItemCollection = oTasks.GetItems(oQuery)

                    'extra filtering of the suspects.
                    'this can also be done in the query, but I don't know your rules
                    For Each oUndoneTask As SPListItem In oUndoneTasks
                        If oUndoneTask(SPBuiltInFieldId.TaskDueDate) IsNot Nothing AndAlso _
                            CDate(oUndoneTask(SPBuiltInFieldId.TaskDueDate)) < Now().Date Then
                            ' this is where you send the mail
                        End If
                    Next
                End Using
            End Using
        Catch ex As Exception
            MyErrorHelper.LogMessage(ex)
        End Try
    End Sub
End Class

To register a timer job, I typically use this kind of a script:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
[System.Reflection.Assembly]::LoadWithPartialName("Your.Assembly.Name.Here")
$spsite= [Microsoft.SharePoint.SPSite]("http://yourserver/sites/yoursite/subsite")

$params = [System.String]("This text shows up in your timer job list (in Central Admin)", $spsite.WebApplication
$newTaskLoggerJob = new-object -type Your.Namespace.TypicalTimer -argumentList $params

$schedule = new-object Microsoft.SharePoint.SPDailySchedule
$schedule.BeginHour = 8
$schedule.BeginMinute = 0
$schedule.BeginSecond = 0
$schedule.EndHour = 8
$schedule.EndMinute = 59
$schedule.EndSecond = 59

$newTaskLoggerJob.Schedule = $schedule
$newTaskLoggerJob.Update()
皓月长歌 2024-08-24 06:34:20

每当您需要在共享点中定期执行某些内容时,100 次中有 99 次您都需要构建 TimerJob。这些是在 SharePoint 内部运行的计划任务,您可以创建自己的计划任务,然后使用功能 + 功能接收器实际“安装”timoerjob(定义)并为其分配计划。

有关详细信息:请参阅 Andrew Connell 的有关 TimerJobs 的文章

PS 切勿直接查询/更新与 SharePoint 相关的数据库!这将使您“不受支持”,即如果发生任何事情,微软将收取(大量)金钱来修复它,而不是能够请求定期支持。 (如果您是 MSDN 订阅者,您每年最多可以获得 4 次免费支持电话)。

Any time you need something in sharepoint that is executed periodically, 99 times out of a 100 you'll need to build a TimerJob. These are scheduled tasks that run inside SharePoint and you can create your own, then using a feature + featurereceiver to actually "install" the timoerjob (definition) and assign it a schedule.

For more info: see Andrew Connell's article on TimerJobs.

P.S. Never query /update the databases related to SharePoint directly! This will make you "unsupported", i.e. if anything happens microsoft will charge (a lot of) money to come and fix it, instead of being able to ask for regular support. (if you are say an MSDN subscriber you get up to 4 free support calls a year).

你是年少的欢喜 2024-08-24 06:34:20

不必费心尝试直接访问数据库。您将会遇到非常困难的情况,因为它没有文档记录、不受支持且不推荐。事实上,SharePoint 确实有一个功能齐全的对象模型。

如果您引用 Microsoft.SharePoint.dll(位于安装了 SharePoint 的计算机的全局程序集缓存中),您可以通过这种方式访问​​数据。您想要开始的对象是 SPSiteSPWeb、SPList、SPQuery 和 SPListItem 。您可以通过搜索 http://msdn.microsoft.com 轻松找到所有这些内容。

您可以尝试的另一种不太灵活但无需代码的可能性是创建几个不同的视图,其中包括即将到来的任务,然后通过 GUI 设置何时将项目添加到该视图的警报。

Don't bother trying to go directly to the database. You will have a very hard time because it's undocumented, unsupported, and not recommended. SharePoint does in fact have a full featured object model though.

If you reference Microsoft.SharePoint.dll (located in the Global Assembly Cache of a machine with SharePoint installed on it) you can access the data that way. The objects you'll want to start with are SPSite, SPWeb, SPList, SPQuery, and SPListItem. All of which you can find very easily on http://msdn.microsoft.com in a search.

Another less-flexible but code-free possibility you could try is creating several different views that include upcoming tasks then via the GUI set up an alert for when items are added to that view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文