SPContentType.UpdateWorkflowAssociationsOnChildren method (Boolean, Boolean, Boolean, Boolean)
傳播此內容類型的工作流程關聯至衍生自這個內容類型的內容類型或清單,或兩者已套用此內容類型的執行個體中的變更。選擇性地標記為已變更,作業所涉及的物件。也可選擇抑制因為子系是密封或唯讀,所以會擲回的例外狀況。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
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
Type: System.Boolean若要標記為已變更 ; 這項作業接觸到的所有SPContentType物件的truefalse則沒有。
bPushdownDerivedCT
Type: System.Boolean若要將變更傳播到內容類型的true衍生自這個內容的型別 ;否則false。
bPushdownListCTs
Type: System.Boolean若要將變更傳播到清單的內容類型的true根據此內容的型別 ;否則false。
bThrowOnSealedOrReadOnly
Type: System.Booleantrue擲回例外狀況在遇到內容的型別為密封或唯讀的。否則false。
Exceptions
Exception | Condition |
---|---|
SPContentTypeSealedException | 此內容類型的子系的Sealed屬性的值為true。 |
SPContentTypeReadOnlyException | 此內容類型的子系的ReadOnly屬性的值為true。 |
備註
使用這個方法來選擇性地傳播到其中一個衍生的父系內容類型的工作流程關聯的變更或清單的內容類型,或兩者的版本。如果您將false作為引數傳遞給bGenerateFullChangeList參數時,會接觸到這項作業的SPContentType物件未標記為已變更,並不會引發OnChanged事件。將false作為引數傳遞給bThrowOnSealedOrReadOnly參數抑制例外狀況擲回時變更無法寫入至任何子系,因為它標示為密封或唯讀。
Examples
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 overload
Microsoft.SharePoint namespace