SPSolutionExporter.ExportWorkFlowTemplate-Methode
Die angegebene Workflowvorlage exportiert als Lösungsdatei.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Shared Sub ExportWorkFlowTemplate ( _
web As SPWeb, _
solutionFilePath As String, _
title As String, _
description As String, _
workflowTemplateName As String _
)
'Usage
Dim web As SPWeb
Dim solutionFilePath As String
Dim title As String
Dim description As String
Dim workflowTemplateName As StringSPSolutionExporter.ExportWorkFlowTemplate(web, _
solutionFilePath, title, description, _
workflowTemplateName)
public static void ExportWorkFlowTemplate(
SPWeb web,
string solutionFilePath,
string title,
string description,
string workflowTemplateName
)
Parameter
web
Typ: Microsoft.SharePoint.SPWebDie Website, die die Workflow-Vorlage enthält.
solutionFilePath
Typ: System.StringDer Pfad, Dateiname und Erweiterung der Datei der Lösung, die erstellt wird. Wenn die Methode ausgeführt wird, werden Leerzeichen als andere unzulässige Zeichen werden aus dem Dateinamen entfernt. Wenn bereits eine Lösungsdatei (WSP-Datei) mit dem gleichen Namen im angegebenen Pfad vorhanden ist, wird sie überschrieben.
title
Typ: System.StringDer Titel der Workflowvorlage.
description
Typ: System.StringAusführliche Informationen, die die Vorlage beschreibt.
workflowTemplateName
Typ: System.StringDer Name der Workflowvorlage zu exportieren. Die Vorlage muss auf der Website vorhanden sein.
Beispiele
Das folgende Beispiel ist eine Konsolenanwendung, die eine Workflowvorlage als einer Lösungsdatei in das Verzeichnis 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.
Hinweis
Informationen zum Erstellen einer Workflow-Vorlage in Microsoft SharePoint Designer 2010, finden Sie unter "Erstellen eines SharePoint Designer wieder verwendbarer Workflow" in Exemplarische Vorgehensweise: Importieren eines SharePoint Designer wiederverwendbare Workflows in Visual Studio.
using System;
using System.IO;
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 solutionFile = "TaskWorkflow.wsp";
string solutionPath = AppDomain.CurrentDomain.BaseDirectory;
string solutionFilePath = SPSolutionExporter.PathCombine(solutionPath, solutionFile);
string solutionTitle = "Task";
string solutionDesc = "This template was saved programmatically.";
string templateName = "Task Workflow";
try
{
// Save the workflow in a solution file.
SPSolutionExporter.ExportWorkFlowTemplate(
web,
solutionFilePath,
solutionTitle,
solutionDesc,
templateName);
}
catch (SPException spx)
{
Console.WriteLine(spx.Message);
}
// Print information about the file.
FileInfo solutionFileInfo = new FileInfo(solutionFilePath);
if (solutionFileInfo.Exists)
{
Console.WriteLine("File name: {0}", solutionFileInfo.Name);
Console.WriteLine("File size: {0:n0} KB", solutionFileInfo.Length / 1024);
}
}
}
Console.Write("\nPress ENTER to continue....");
Console.ReadLine();
}
}
}
Imports System
Imports System.IO
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As New SPSite("https://localhost")
Using web As SPWeb = site.RootWeb
Dim solutionFile As String = "TaskWorkflow.wsp"
Dim solutionPath As String = AppDomain.CurrentDomain.BaseDirectory
Dim solutionFilePath As String = SPSolutionExporter.PathCombine(solutionPath, solutionFile)
Dim solutionTitle As String = "Task"
Dim solutionDesc As String = "This template was saved programmatically."
Dim templateName As String = "Task Workflow"
Try
' Save the workflow in a solution file.
SPSolutionExporter.ExportWorkFlowTemplate(web, solutionFilePath, solutionTitle, solutionDesc, templateName)
Catch spx As SPException
Console.WriteLine(spx.Message)
End Try
' Print information about the file.
Dim solutionFileInfo As New FileInfo(solutionFilePath)
If solutionFileInfo.Exists Then
Console.WriteLine("File name: {0}", solutionFileInfo.Name)
Console.WriteLine("File size: {0:n0} KB", solutionFileInfo.Length / 1024)
End If
End Using
End Using
Console.Write(vbCrLf & "Press ENTER to continue....")
Console.Read()
End Sub
End Module
Siehe auch
Referenz
Microsoft.SharePoint-Namespace