SPContentType.UpdateWorkflowAssociationsOnChildren 方法 (Boolean, Boolean, Boolean, Boolean)
将传播到从该内容类型派生的内容类型或列表,或者对二者同时已应用此内容类型的实例的此内容类型的工作流关联中的更改。(可选) 标记为已更改涉及的操作的对象。此外可以选择禁止因为子密封或只读引发的异常。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Sub UpdateWorkflowAssociationsOnChildren ( _
bGenerateFullChangeList As Boolean, _
bPushdownDerivedCT As Boolean, _
bPushdownListCTs As Boolean, _
bThrowOnSealedOrReadOnly As Boolean _
)
用法
Dim instance As SPContentType
Dim bGenerateFullChangeList As Boolean
Dim bPushdownDerivedCT As Boolean
Dim bPushdownListCTs As Boolean
Dim bThrowOnSealedOrReadOnly As Boolean
instance.UpdateWorkflowAssociationsOnChildren(bGenerateFullChangeList, _
bPushdownDerivedCT, bPushdownListCTs, _
bThrowOnSealedOrReadOnly)
public void UpdateWorkflowAssociationsOnChildren(
bool bGenerateFullChangeList,
bool bPushdownDerivedCT,
bool bPushdownListCTs,
bool bThrowOnSealedOrReadOnly
)
参数
bGenerateFullChangeList
类型:System.Booleantrue标记为已更改 ; 此操作涉及的所有SPContentType对象false却没有。
bPushdownDerivedCT
类型:System.Booleantrue将更改传播到内容类型派生自此内容类型 ;否则为false。
bPushdownListCTs
类型:System.Booleantrue将更改传播到列表内容类型基于此内容类型 ;否则为false。
bThrowOnSealedOrReadOnly
类型:System.Booleantrue引发异常在遇到密封或只读的内容类型否则为false。
异常
异常 | 条件 |
---|---|
SPContentTypeSealedException | 此内容类型的子级的Sealed属性的值为true。 |
SPContentTypeReadOnlyException | 此内容类型的子级的ReadOnly属性的值为true。 |
备注
使用此方法 (可选) 将下之一派生的父内容类型的工作流关联的更改传播或列表内容类型,或两者的版本。如果您将false作为参数传递给bGenerateFullChangeList参数时,涉及的此操作的SPContentType对象未标记为已更改,并不会引发OnChanged事件。将false作为参数传递给bThrowOnSealedOrReadOnly参数禁止异常时更改不能写入任何子,因为它被标记为密封或只读的。
示例
Dim siteCollection As SPSite = New SPSite("https://localhost")
Dim site As SPWeb = siteCollection.OpenWeb()
Dim siteContentType As SPContentType = site.ContentTypes("Test Document")
Dim taskListTitle As String = "Tasks"
Dim historyListTitle As String = "Workflow History"
Dim workflowName As String = "Red-Yellow-Green"
' Get a template.
Dim workflowTemplate As SPWorkflowTemplate = Nothing
For Each template As SPWorkflowTemplate In site.WorkflowTemplates
workflowTemplate = template
' We'll take a template everyone has.
If workflowTemplate.Name = "Three-state" Then
Exit For
End If
Next template
' Create an association.
Dim workflowAssociation As SPWorkflowAssociation = _
SPWorkflowAssociation.CreateSiteContentTypeAssociation(workflowTemplate, _
workflowName, _
taskListTitle, _
historyListTitle)
' Add the association to the content type or update it if it already exists.
Console.Write("Workflow association {0} has been ", workflowAssociation.Name)
If siteContentType.WorkflowAssociations.GetAssociationByName(workflowAssociation.Name, site.Locale) Is Nothing Then
siteContentType.AddWorkflowAssociation(workflowAssociation)
Console.WriteLine("added")
Else
siteContentType.UpdateWorkflowAssociation(workflowAssociation)
Console.WriteLine("updated")
End If
' Propagate to children of this content type.
siteContentType.UpdateWorkflowAssociationsOnChildren(False, True, True, False) ' Suppress exceptions
' Clean up.
site.Dispose()
siteCollection.Dispose()
SPSite siteCollection = new SPSite("https://localhost");
SPWeb site = siteCollection.OpenWeb();
SPContentType siteContentType = site.ContentTypes["Test Document"];
string taskListTitle = "Tasks";
string historyListTitle = "Workflow History";
string workflowName = "Red-Yellow-Green";
// Get a template.
SPWorkflowTemplate workflowTemplate = null;
foreach (SPWorkflowTemplate template in site.WorkflowTemplates)
{
workflowTemplate = template;
// We'll take a template everyone has.
if (workflowTemplate.Name == "Three-state") break;
}
// Create an association.
SPWorkflowAssociation workflowAssociation =
SPWorkflowAssociation.CreateSiteContentTypeAssociation(workflowTemplate,
workflowName,
taskListTitle,
historyListTitle);
// Add the association to the content type or update it if it already exists.
Console.Write"Workflow association {0} has been ", workflowAssociation.Name);
if (siteContentType.WorkflowAssociations.GetAssociationByName(workflowAssociation.Name, site.Locale) == null)
{
siteContentType.AddWorkflowAssociation(workflowAssociation);
Console.WriteLine("added.");
}
else
{
siteContentType.UpdateWorkflowAssociation(workflowAssociation);
Console.WriteLine("updated.");
}
// Propagate to children of this content type.
siteContentType.UpdateWorkflowAssociationsOnChildren(false, // Do not generate full change list
true, // Push down to derived content types
true, // Push down to list content types
false); // Do not throw an exception if sealed or readonly
site.Dispose();
siteCollection.Dispose();
另请参阅
引用
UpdateWorkflowAssociationsOnChildren 重载