1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5: using Microsoft.SharePoint;
6: using Microsoft.SharePoint.Workflow;
7:
8: namespace WorkflowAssosiation
9: {
10: class Program
11: {
12: static void Main(string[] args)
13: {
14:
15: using (SPSite site = new SPSite("http://blre3r15-5:3000/sites/TestSite"))
16: {
17: using (SPWeb web = site.RootWeb)
18: {
19: SPListCollection lists = web.Lists;
20: SPWorkflowAssociation[] myUpdate = new SPWorkflowAssociation[15];;
21: int cwaUpdate = 0;
22: string ListId = string.Empty;
23: foreach (SPList list in lists)
24: {
25: SPWorkflowAssociationCollection collection = list.WorkflowAssociations;
26: foreach (SPWorkflowAssociation assosiation in collection)
27: {
28:
29: //SPWorkflowAssociation assosiation = collection.GetAssociationByBaseID(guid);
30: if (assosiation != null)
31: {
32:
33: Console.WriteLine(assosiation.Enabled.ToString());
34:
35: assosiation.Enabled = false;
36: myUpdate[cwaUpdate++] = assosiation;
37: Console.WriteLine(assosiation.Enabled.ToString());
38: ListId = list.ID.ToString();
39: }
40: }
41:
42: }
43: if (ListId != null || ListId == string.Empty)
44: {
45: System.Guid guid2 = new Guid(ListId);
46: SPList newList = web.Lists[guid2];
47: for (int i = 0; i < cwaUpdate; i++)
48: {
49: newList.UpdateWorkflowAssociation(myUpdate[i]);
50: }
51: }
52: }
53: Console.WriteLine("Press any key to continue....");
54: Console.Read();
55: }
56:
57: }
58: }
59: }