다음을 통해 공유


SPMeeting Class

Provides methods and properties that can be used to work with a Meeting Workspace.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Meetings.SPMeeting

Namespace:  Microsoft.SharePoint.Meetings
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Class SPMeeting
'Usage
Dim instance As SPMeeting
public class SPMeeting

Remarks

A Meeting Workspace is a Web site that can be used to gather all the information and materials that are needed for one or more meetings. This can include information about the date, time, and place of the meeting, a library of shared documents, and lists of agenda items and objectives for the meeting, tasks assigned, and decisions taken.

You can create a Meeting Workspace site by calling the Add method of the collection that is returned by the Webs property of a Web site. The following table includes a list of templates that can be used with the Add method.

Value

Workspace Definition

MPS#0

Basic Meeting Workspace

MPS#1

Blank Meeting Workspace

MPS#2

Decision Meeting Workspace

MPS#3

Social Meeting Workspace

MPS#4

Multipage Meeting Workspace

You can retrieve a list of existing Meeting Workspace sites in either of two ways. The first way is simply to iterate through all subsites of the current Web site and test each one by calling the static IsMeetingWorkspaceWeb(SPWeb) method. This technique is illustrated in the following example.

Dim mwsWebs As New List(Of SPWeb)
Dim subWebs As SPWebCollection =  webSite.Webs 
For Each web As SPWeb In subWebs
   If SPMeeting.IsMeetingWorkspaceWeb(web) Then
      mwsWebs.Add(web)
   End If
Next
List<SPWeb> mwsWebs = new List<SPWeb>();
SPWebCollection subWebs = webSite.Webs;
foreach (SPWeb web in subWebs)
   if (SPMeeting.IsMeetingWorkspaceWeb(web))
      mwsWebs.Add(web);

Another technique is useful when you intend to create a new instance of a meeting in an existing Meeting Workspace. The key task in this situation is to find an existing site that can accommodate another meeting. Single-instance meetings are easy to create because there is no limit on how many single-instance meetings a Meeting Workspace can host. However, a recurring meeting must have a Meeting Workspace of its own. If you want a workspace for a recurring meeting, you need to find one that is empty—one that has no meetings of any kind. (More than likely, this is a newly created Meeting Workspace site.)

The GetWorkspacesToLinkTo(Boolean) method provides a solution. Begin by calling the static GetMeetingInformation(SPWeb) method, passing the SPWeb object that represents the parent Web site as an argument. Then call the GetWorkspacesToLinkTo method, passing false to get subsites that can host single-instance meetings or true to get subsites that are available to host a recurring meeting (that is, empty workspace sites).

The following example demonstrates the technique.

' Create a meeting object.
Dim meetInfo As SPMeeting = SPMeeting.GetMeetingInformation(webSite)

' Get a collection of Meeting Workspace subsites for recurring meetings.
Dim mwsWebs As SPWebCollection = meetInfo.GetWorkspacesToLinkTo(True)
// Create a meeting object.
SPMeeting meetingInfo = SPMeeting.GetMeetingInformation(webSite);

// Get a collection of Meeting Workspace sites for recurring meetings.
SPWebCollection mwsWebs = meetingInfo.GetWorkspacesToLinkTo(true);

After you have a Meeting Workspace site, the next task is to add a meeting to it. The SPMeeting class has two methods that can help you accomplish this. The LinkWithEvent method adds a meeting to a Meeting Workspace and then links the meeting to an item in an events list, such as the Calendar list that is a feature of the standard Team Site configuration.

If you are working with a scheduling application that maintains its own appointment calendar, the Add() method is better suited to your needs. One overload of the Add method imports meeting information that is in the format defined by RFC 2445, "Internet Calendaring and Scheduling Core Object Specification (iCalendar)". Many scheduling applications can export event data in iCalendar format, including the Microsoft Windows Calendar.

The Add method adds a meeting to a specified workspace and returns the meeting instance identifier (ID). The method does not link the meeting to an appointment on the Calendar list. However, you could use the instance ID to create a URL for the meeting, as SharePoint Foundation does, by appending it to a query string.

https://localhost/single%20instance%20workspace/default.aspx?InstanceID=2

https://localhost/recurring%20meeting%20workspace/default.aspx?InstanceID=20091231

Examples

The following example is a console application that finds all the Meeting Workspace subsites that are associated with a Web site. For each workspace that it finds, the example application gets a list of meetings that are scheduled over the next 14 days. The application then prints information about each meeting to the console in the following format.

Meeting: Team Meeting
Location: Conf Room
Date: Wednesday, March 04, 2009
Time: 10:00 AM
Workspace URL: http://spvm/Team Meeting/default.aspx?InstanceID=20090304
Linked to the Calendar list at http://spvm/Lists/Calendar

Note that the last line is optional, depending on whether the meeting is linked to a SharePoint Foundation events list.

Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Meetings

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")
         Using webSite As SPWeb = siteCollection.OpenWeb()

            ' Construct a query to get meetings scheduled for the next 14 days.
            Dim startDate As String = DateTime.Now.ToString("s")
            Dim endDate As String = DateTime.Now.AddDays(14).ToString("s")
            Dim query As SPQuery = New SPQuery()
            query.ViewXml = _
               "<View><Query><Where><And>" + _
               "<Geq><FieldRef Name='EventDate'/><Value Type='DateTime'>" + startDate + "</Value></Geq>" + _
               "<Leq><FieldRef Name='EventDate'/><Value Type='DateTime'>" + endDate + "</Value></Leq>" + _
               "</And></Where></Query></View>"

            ' Find all Meeting Workspace sites.
            Dim subWebs As SPWebCollection = webSite.Webs
            For Each web As SPWeb In subWebs
               If SPMeeting.IsMeetingWorkspaceWeb(web) Then

                  ' A Meeting Workspace has a Meeting Series list with
                  ' information about all meetings in the workspace.
                  Dim meetings As SPList = web.Lists("Meeting Series")

                  ' Get the meeting items that fit the criteria.
                  Dim items As SPListItemCollection = meetings.GetItems(query)

                  ' Now extract useful information about each meeting.
                  For Each item As SPListItem In items
                     Dim instanceID As Integer = CType(item("InstanceID"), Integer)

                     ' Skip the master record for this workspace.
                     If instanceID > 0 Then
                        Dim url As String = web.Url + "/default.aspx?InstanceID=" + instanceID.ToString()

                        ' The EventUID field can indicate a link to the calendar.
                        Dim eventUID As String
                        Dim isLinked As Boolean = False
                        Dim isRecurring As Boolean = CType(item("fRecurrence"), Boolean)
                        If isRecurring Then
                           ' For recurring events, look in the first item's field.
                           Dim master As SPListItem = meetings.Items(0)
                           eventUID = CType(master("EventUID"), String)
                        Else
                           eventUID = CType(item("EventUID"), String)
                        End If
                        If Nothing <> eventUID Then
                           isLinked = eventUID.StartsWith("STSTeamCalendarEvent")
                        End If

                        Dim dt As DateTime = CType(item("EventDate"), DateTime)

                        ' Print the title, location, date, and time of the meeting,
                        ' the URL to the workspace and optionally the calendar link.
                        Console.WriteLine(vbCrLf + "Meeting: {0}", item.Title)
                        Console.WriteLine("Location: {0}", item("Location"))
                        Console.WriteLine("Date: {0}", dt.ToLongDateString())
                        Console.WriteLine("Time: {0}", dt.ToShortTimeString())
                        Console.WriteLine("Workspace URL: {0}", url)
                        If isLinked Then
                           Dim eventURL As String = CType(item("EventUrl"), String)
                           Dim parts() As String = eventURL.Split(","c)
                           Console.WriteLine("Linked to the {0} list at {1}", _
                                 parts(1).Trim(), parts(0))
                        End If
                     End If
                  Next
               End If
               web.Dispose()
            Next

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Meetings;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            using (SPWeb webSite = siteCollection.OpenWeb())
            {
               // Construct a query to get meetings scheduled for the next 14 days.
               string startDate = DateTime.Now.ToString("s");
               string endDate = DateTime.Now.AddDays(14).ToString("s");
               SPQuery query = new SPQuery();
               query.ViewXml = 
                  "<View><Query><Where><And>" +
                  "<Geq><FieldRef Name='EventDate'/><Value Type='DateTime'>" + startDate + "</Value></Geq>" +
                   "<Leq><FieldRef Name='EventDate'/><Value Type='DateTime'>" + endDate + "</Value></Leq>" +
                   "</And></Where></Query></View>";

               // Find all Meeting Workspace sites.
               SPWebCollection subWebs = webSite.Webs;
               foreach (SPWeb web in subWebs)
               {
                  if (SPMeeting.IsMeetingWorkspaceWeb(web))
                  {
                     // A Meeting Workspace has a Meeting Series list with
                     // information about all meetings in the workspace.
                     SPList meetings = web.Lists["Meeting Series"];

                     // Get the meeting items that fit the criteria.
                     SPListItemCollection items = meetings.GetItems(query);

                     // Now extract useful information about each meeting.
                     foreach (SPListItem item in items)
                     {
                        int instanceID = (int)item["InstanceID"];

                        // Skip the master record for this workspace.
                        if (instanceID > 0)
                        {
                           string url = web.Url + "/default.aspx?InstanceID=" + instanceID.ToString();

                           // The EventUID field can indicate a link to the calendar.
                           string eventUID;
                           bool isLinked = false;
                           bool isRecurring = (bool)item["fRecurrence"];
                           if (isRecurring)
                           {
                              // For recurring events, look in the first item's field.
                              SPListItem master = meetings.Items[0];
                              eventUID = (string)master["EventUID"];
                           }
                           else
                           {
                              eventUID = (string)item["EventUID"];
                           }
                           if (null != eventUID)
                              isLinked = eventUID.StartsWith("STSTeamCalendarEvent");
                           
                           DateTime dt = (DateTime)item["EventDate"];

                           // Print the title, location, date, and time of the meeting,
                           // the URL to the workspace and optionally the calendar link.
                           Console.WriteLine("\nMeeting: {0}", item.Title);
                           Console.WriteLine("Location: {0}", item["Location"]);
                           Console.WriteLine("Date: {0}", dt.ToLongDateString());
                           Console.WriteLine("Time: {0}", dt.ToShortTimeString());
                           Console.WriteLine("Workspace URL: {0}", url);
                           if (isLinked)
                           {
                              string eventURL = (string)item["EventUrl"];
                              string[] parts = eventURL.Split(',');
                              Console.WriteLine("Linked to the {0} list at {1}",
                                 parts[1].Trim(), parts[0]);
                           }
                        }
                     }
                  }
                  web.Dispose();
               }
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPMeeting Members

Microsoft.SharePoint.Meetings Namespace

Other Resources

How to: Customize Meeting Workspaces by Using the SharePoint Foundation Object Model

How to: Add a Recurring Event to Lists on Multiple Sites