Compartir a través de


(String, String, Int16, Int32, String, String[]) del método SPMeeting.Add

Agrega una instancia de reunión representada en formato de calendario de Internet (iCalendar) en el sitio de área de reuniones actual.

Espacio de nombres:  Microsoft.SharePoint.Meetings
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
Public Function Add ( _
    icalText As String, _
    organizer As String, _
    <OutAttribute> ByRef nMeetingCount As Short, _
    <OutAttribute> ByRef attendeeUpdateStatus As Integer, _
    <OutAttribute> ByRef attendeeUpdateMessage As String, _
    <OutAttribute> ByRef AttendeeEmailsUnresolved As String() _
) As Integer
'Uso
Dim instance As SPMeeting
Dim icalText As String
Dim organizer As String
Dim nMeetingCount As Short
Dim attendeeUpdateStatus As Integer
Dim attendeeUpdateMessage As String
Dim AttendeeEmailsUnresolved As String()
Dim returnValue As Integer

returnValue = instance.Add(icalText, organizer, _
    nMeetingCount, attendeeUpdateStatus, _
    attendeeUpdateMessage, AttendeeEmailsUnresolved)
public int Add(
    string icalText,
    string organizer,
    out short nMeetingCount,
    out int attendeeUpdateStatus,
    out string attendeeUpdateMessage,
    out string[] AttendeeEmailsUnresolved
)

Parámetros

  • icalText
    Tipo: System.String

    string que contiene la representación de iCalendar de una reunión.

  • organizer
    Tipo: System.String

    string que contiene la dirección de correo electrónico del organizador de la reunión, especificado como email_address@domain.ext. Este parámetro se usa en escenarios de delegado. Si el organizador de la reunión no es un delegado, se puede pasar una cadena vacía. En ese caso, se considera que el usuario que se ejecuta la aplicación es el organizador de la reunión.

  • nMeetingCount
    Tipo: System.Int16

    Una referencia a una variable que va a recibir el número total de instancias de reunión que están asociados con el área de trabajo de reunión actual o, en el caso de una reunión periódica, un valor que es igual a la constante MeetingCountRecurring .

  • attendeeUpdateStatus
    Tipo: System.Int32

    Una referencia a una variable que va a recibir el estado de actualización de attendee. Los valores posibles se enumeran en la siguiente tabla.

    Value

    Description

    0

    Se ha producido ningún error.

    -2130575232

    Algunos asistentes no se concedieron permiso de acceso del área de trabajo.

    -2130575231

    No se agregaron algunos asistentes debido al límite de cuota del usuario.

  • attendeeUpdateMessage
    Tipo: System.String

    Una referencia a una variable que va a recibir el mensaje de actualización de attendee.

  • AttendeeEmailsUnresolved
    Tipo: []

    Una referencia a una variable de matriz que va a recibir las direcciones de correo electrónico que no se pueda resolver como usuarios de SharePoint Foundation.

Valor devuelto

Tipo: System.Int32
El identificador de instancia de la reunión. Si la cadena de iCalendar representa una reunión periódica, el valor devuelto es 0. De lo contrario, el valor devuelto es mayor que 0.

Comentarios

Esta sobrecarga del método Add acepta datos de eventos en el formato definido por RFC 2445, "Calendarios de Internet y la especificación de objetos principales de programación (iCalendar)". Muchas aplicaciones de programación pueden exportar los datos del evento en formato iCalendar , incluido el calendario de Microsoft Windows.

El método Add crea una nueva instancia de reunión en el sitio de área de reuniones. No se agrega una cita en el calendario de SharePoint Foundation.

Ejemplos

En el siguiente ejemplo es una aplicación de consola que lee el texto de un archivo de iCalendar en una variable de cadena y, a continuación, se pasa la variable al método Add .

Antes de ejecutar la aplicación de consola, guarde el siguiente texto en un archivo denominado Sharepoint.ics de prueba y, a continuación, colóquelo en el directorio bin\Debug de la aplicación.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Windows Calendar 1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Pacific Time (US & Canada)
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZNAME:Pacific Standard Time
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZNAME:Pacific Daylight Time
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20090224T222033Z
DTSTART;TZID=Pacific Time (US & Canada):20100301T130000
DTEND;TZID=Pacific Time (US & Canada):20100301T133000
RRULE:FREQ=WEEKLY;COUNT=5;BYDAY=MO,TU,WE,TH,FR
SUMMARY:Test Sharepoint
UID:0EE4D0CD-305A-4ED3-B530-0350A89CC324
END:VEVENT
END:VCALENDAR
Imports System
Imports System.IO
Imports System.Text
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Meetings

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

            Dim fileName As String = "Test Sharepoint.ics"
            Dim workspaceName As String = fileName.Substring(0, fileName.Length - 4)

            ' Create a Meeting Workspace site.
            Dim mwsWeb As SPWeb = CreateWorkspace(web, 0, workspaceName, workspaceName, "This is a test workspace.")

            ' Get the meeting information for the workspace.
            Dim meeting As SPMeeting = SPMeeting.GetMeetingInformation(mwsWeb)

            '  Get an iCalendar event.
            Dim icalText As String = ReadICal(fileName)

            If Not String.IsNullOrEmpty(icalText) Then

               ' Create output parameters.
               Dim meetingCount As Short = 0
               Dim attendeeUpdateStatus As Integer = 0
               Dim attendeeUpdateMessage As String = String.Empty
               Dim attendeeEmailsUnresolved() As String = {String.Empty}

               ' Add the meeting.
               Try
                  Dim instanceID As Integer = meeting.Add(icalText, _
                                                          String.Empty, _
                                                          meetingCount, _
                                                          attendeeUpdateStatus, _
                                                          attendeeUpdateMessage, _
                                                          attendeeEmailsUnresolved)

                  ' Interpret the attendeeUpdateStatus output.
                  Dim updateStatus As String
                  Select Case attendeeUpdateStatus
                     Case -2130575232
                        updateStatus = _
                           "Some attendees could not be granted permission to access the workspace."
                     Case -2130575231
                        updateStatus = "Some attendees were not added due to user quota limit."
                     Case Else
                        updateStatus = "No errors."
                  End Select
                  ' Print the URL and number of meetings.
                  Dim mswUrl As String = mwsWeb.Url + "/default.aspx?InstanceID=" + instanceID.ToString()
                  Console.WriteLine(mswUrl)
                  Console.WriteLine("Meeting count: {0} | Update status: {1}", meetingCount, updateStatus)
               Catch ex As Exception
                  Console.WriteLine(ex.Message)
               End Try
            End If

            ' Clean up.
            mwsWeb.Dispose()

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub

   Function CreateWorkspace(ByVal parentWeb As SPWeb, ByVal templateNumber As System.UInt32, ByVal internalName As String, ByVal title As String, ByVal description As String) As SPWeb
      If 5 <= templateNumber Then
         Throw New ArgumentException("The templateNumber argument must be less than 5.")
      End If

      Dim templateName As String = SPWebTemplate.WebTemplateMWS + "#" + templateNumber.ToString()

      If String.IsNullOrEmpty(title) Then
         title = "Untitled"
      End If

      Dim mwsName As String = MakeUniqueName(parentWeb.Webs.Names, internalName)

      Dim language As System.UInt32 = CType(parentWeb.Locale.LCID, System.UInt32)

      Return parentWeb.Webs.Add(mwsName, title, description, language, templateName, False, False)
   End Function

   Function MakeUniqueName(ByVal names() As String, ByVal name As String) As String
      Dim NewName As String = name.Replace(";", "").Replace("'", "")
      Dim baseName As String = name
      Dim n As Integer = 0

      Dim pos As Integer = name.LastIndexOf("("c)
      If pos > -1 And name.EndsWith(")") Then
         baseName = name.Substring(0, pos)
         Dim ext As String = name.Substring(baseName.Length + 1).Replace(")", "")
         Dim IsNumber As Boolean = Integer.TryParse(ext, n)
         If IsNumber Then
            n = n + 1
         End If
      End If

      Dim i As Integer = Array.IndexOf(names, name)
      If i >= 0 Then
         baseName = baseName + "(" + n.ToString() + ")"
         NewName = MakeUniqueName(names, baseName)
      End If

      Return NewName
   End Function

   Function ReadICal(ByVal fileName As String) As String
      Dim sb As StringBuilder = New StringBuilder()
      If Not File.Exists(fileName) Then
         Console.WriteLine("{0} does not exist.", fileName)
         Return sb.ToString()
      End If
      Using sr As StreamReader = File.OpenText(fileName)
         Dim input As String
         Do
            input = sr.ReadLine()
            sb.AppendLine(input)
         Loop Until input Is Nothing
         sr.Close()
      End Using
      Return sb.ToString()
   End Function

End Module
using System;
using System.IO;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Meetings;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("https://localhost"))
         {
            using (SPWeb web = site.OpenWeb())
            {
               string fileName = "Test Sharepoint.ics";
               string workspaceName = fileName.Substring(0, fileName.Length - 4);

               // Create a Meeting Workspace site.
               SPWeb mwsWeb = CreateWorkspace(web, 0, workspaceName, workspaceName, "This is a test workspace.");

               // Get the meeting information for the workspace.
               SPMeeting meeting = SPMeeting.GetMeetingInformation(mwsWeb);

               // Get an iCalendar event.
               string icalText = ReadICal(fileName);

               if (!String.IsNullOrEmpty(icalText))
               {
                  // Create output parameters.
                  short meetingCount;
                  int attendeeUpdateStatus;
                  string attendeeUpdateMessage;
                  string[] attendeeEmailsUnresolved;

                  // Add the meeting.
                  try
                  {
                     int instanceID = meeting.Add(icalText,
                                                  String.Empty,
                                                  out meetingCount,
                                                  out attendeeUpdateStatus,
                                                  out attendeeUpdateMessage,
                                                  out attendeeEmailsUnresolved);

                     // Interpret the attendeeUpdateStatus output.
                     string updateStatus;
                     switch (attendeeUpdateStatus)
                     {
                        case -2130575232:
                           updateStatus =
                              "Some attendees could not be granted permission to access the workspace.";
                           break;
                        case -2130575231:
                           updateStatus = "Some attendees were not added due to user quota limit.";
                           break;
                        default:
                           updateStatus = "No errors.";
                           break;
                     }
                     // Print the URL and number of meetings.
                     string mswUrl = mwsWeb.Url + "/default.aspx?InstanceID=" + instanceID.ToString();
                     Console.WriteLine(mswUrl);
                     Console.WriteLine("Meeting count: {0} | Update status: {1}", meetingCount, updateStatus);
                  }
                  catch (Exception ex)
                  {
                     Console.WriteLine(ex.Message);
                  }
               }
               // Clean up
               mwsWeb.Dispose();
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }

      static SPWeb CreateWorkspace(SPWeb parentWeb, uint templateNumber, string internalName, string title, string description)
      {
         if (5 <= templateNumber)
            throw new ArgumentException("The templateNumber argument must be less than 5.");

         string templateName = SPWebTemplate.WebTemplateMWS + "#" + templateNumber.ToString();

         if (String.IsNullOrEmpty(title))
            title = "Untitled";

         string mwsName = MakeUniqueName(parentWeb.Webs.Names, internalName);

         uint language = (uint)parentWeb.Locale.LCID;

         return parentWeb.Webs.Add(mwsName, title, description, language, templateName, false, false);
      }

      static string MakeUniqueName(string[] names, string name)
      {
         string newName = name.Replace(";", "").Replace("'", "");
         string baseName = name;
         int n = 0;

         int pos = name.LastIndexOf('(');
         if (pos > -1 & name.EndsWith(")"))
         {
            baseName = name.Substring(0, pos);
            string ext = name.Substring(baseName.Length + 1).Replace(")", "");
            bool IsNumber = int.TryParse(ext, out n);
            if (IsNumber) n++;
         }

         int i = Array.IndexOf(names, name);
         if (i >= 0)
         {
            baseName = baseName + "(" + n.ToString() + ")";
            newName = MakeUniqueName(names, baseName);
         }
         return newName;
      }

      static string ReadICal(string fileName)
      {
         StringBuilder sb = new StringBuilder();
         if (!File.Exists(fileName))
         {
            Console.WriteLine("{0} does not exist.", fileName);
            return sb.ToString();
         }
         using (StreamReader sr = File.OpenText(fileName))
         {
            String input;
            while ((input = sr.ReadLine()) != null)
            {
               sb.AppendLine(input);
            }
            sr.Close();
         }
         return sb.ToString();
      }
   }
}

Vea también

Referencia

clase SPMeeting

Miembros SPMeeting

Sobrecarga Add

Espacio de nombres Microsoft.SharePoint.Meetings

MeetingCount

InstanceId

Update(String, Boolean, Int32, String, [])