Freigeben über


SPSolutionExporter.ExportWorkflowToList-Methode

Exportiert die angegebene Workflowvorlage als Lösung in einer Dokumentbibliothek.

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

Syntax

'Declaration
Public Shared Function ExportWorkflowToList ( _
    web As SPWeb, _
    solutionFileName As String, _
    title As String, _
    description As String, _
    workflowTemplateName As String, _
    destinationListUrl As String _
) As String
'Usage
Dim web As SPWeb
Dim solutionFileName As String
Dim title As String
Dim description As String
Dim workflowTemplateName As String
Dim destinationListUrl As String
Dim returnValue As String

returnValue = SPSolutionExporter.ExportWorkflowToList(web, _
    solutionFileName, title, description, _
    workflowTemplateName, destinationListUrl)
public static string ExportWorkflowToList(
    SPWeb web,
    string solutionFileName,
    string title,
    string description,
    string workflowTemplateName,
    string destinationListUrl
)

Parameter

  • solutionFileName
    Typ: System.String

    Der Name der Datei der Lösung, die erstellt wird.

  • description
    Typ: System.String

    Ausführliche Informationen, die der Beschreibung der Lösung.

  • workflowTemplateName
    Typ: System.String

    Der Name der Workflowvorlage zu exportieren.

  • destinationListUrl
    Typ: System.String

    Die serverrelative URL der Dokumentbibliothek, in der die Projektmappendatei erstellt werden soll.

Rückgabewert

Typ: System.String
Die URL der neuen Lösungsdatei. Wenn eine Lösung nicht erstellt werden konnte, wird eine leere Zeichenfolge zurückgegeben.

Hinweise

Diese Methode versucht, exportieren Sie die Datei mit der neuen Lösung an das angegebene Ziel mit dem angegebenen Dateinamen. Wenn bereits eine Datei mit diesem Namen, klicken Sie dann eine Reihe von "FileName-2.wsp" vorhanden sind "FileName-3.wsp" in einführen, um einen eindeutigen Dateinamen suchen versucht. Wenn "FileName-1000.wsp" erreicht ist, und eine Datei mit diesem Namen bereits vorhanden ist, löst die Methode eine Ausnahme InvalidOperationException .

Beispiele

Das folgende Beispiel ist eine Konsolenanwendung, die eine Workflow-Vorlage in der Liste Websiteobjekte exportiert. Die Workflow-Vorlage in der Beispielcode verwendet wird "Task Workflow". Sie sollten den Namen einer Workflowvorlage vorhanden ist, der auf Ihrer Website ersetzen, vor der Ausführung des Codes.

using System;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    string solutionFileName = "Task Workflow.wsp";
                    string title = "Task Workflow";
                    string description = "This solution was created programmatically.";
                    string templateName = "Task Workflow";
                    string solutionFileUrl = string.Empty;

                    // Get the Site Assets list.
                    SPList catalog = site.GetCatalog(SPListTemplateType.DocumentLibrary);
                    string destinationListUrl = catalog.RootFolder.ServerRelativeUrl;

                    try
                    {
                        // Export the template to a list.
                        solutionFileUrl = SPSolutionExporter.ExportWorkflowToList(
                            web,
                            solutionFileName,
                            title,
                            description,
                            templateName,
                            destinationListUrl);
                    }
                    catch (SPException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    // Get a reference to the solution package.
                    if (String.IsNullOrEmpty(solutionFileUrl))
                    {
                        Console.WriteLine("A solution was not created.");
                    }
                    else
                    {
                        // Get the solution file.
                        SPFile solutionFile = web.GetFile(solutionFileUrl);

                        // Print information about the solution file.
                        Console.WriteLine("Name: {0}", solutionFile.Name);
                        Console.WriteLine("Size: {0:n0} bytes", solutionFile.Length);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.ReadLine();
        }
    }
}
Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()

        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.RootWeb

                Dim solutionFileName As String = "Task Workflow.wsp"
                Dim title As String = "Task Workflow"
                Dim description As String = "This solution was created programmatically."
                Dim templateName As String = "Task Workflow"
                Dim solutionFileUrl As String = String.Empty

                ' Get the Site Assets list.
                Dim catalog As SPList = site.GetCatalog(SPListTemplateType.DocumentLibrary)
                Dim destinationListUrl As String = catalog.RootFolder.ServerRelativeUrl

                Try
                    ' Export the template to a list.
                    solutionFileUrl = SPSolutionExporter.ExportWorkflowToList( _
                        web, _
                        solutionFileName, _
                        title, _
                        description, _
                        templateName, _
                        destinationListUrl)
                Catch ex As SPException
                    Console.WriteLine(ex.Message)
                End Try

                ' Get a reference to the solution package.
                If String.IsNullOrEmpty(solutionFileUrl) Then
                    Console.WriteLine("A solution was not created.")
                Else
                    ' Get the solution file.
                    Dim solutionFile As SPFile = web.GetFile(solutionFileUrl)

                    ' Print information about the solution file.
                    Console.WriteLine("Name: {0}", solutionFile.Name)
                    Console.WriteLine("Size: {0:n0} bytes", solutionFile.Length)
                End If
            End Using
        End Using

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

Siehe auch

Referenz

SPSolutionExporter Klasse

SPSolutionExporter-Member

Microsoft.SharePoint-Namespace