不知道为什么我会收到上述错误,我知道它是因为 UpdateWorkflowAssociation 在 foreach 内部,但我需要这样一个简单的帮助将不胜感激
`siteName = "http://xyz";
newCleanupDays = 5;
assoCounter = 0;
using (wfSite = new SPSite(siteName))
{
using (wfWeb = wfSite.OpenWeb())
{
//wfList = wfWeb.Lists[libraryName];
SPListCollection collList = wfWeb.Lists; //Open Lists
SPWorkflowAssociation _wfAssociation = null;
foreach (SPList oList in collList)
{
if (oList.WorkflowAssociations.Count > 0)
{
foreach (SPWorkflowAssociation a in oList.WorkflowAssociations)
{
if (a.Name != null || a.Name != string.Empty)
{
a.AutoCleanupDays = newCleanupDays;
_wfAssociation = a;
assoCounter++;
}
else
{
_wfAssociation = a;
}
}
oList.UpdateWorkflowAssociation(_wfAssociation);
}
}
System.Console.WriteLine("\n" + wfAssoName + ": " + assoCounter.ToString() + " workflow association(s) changed successfuly!\n");
}
}`