- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
WORKFLOW RULES in Office Word
CHAPTER 8 WORKFLOW RULES Draw Data Matrix ECC200 In None Using Barcode drawer for Word Control to generate, create DataMatrix image in Word applications. www.OnBarcode.comEncoding Data Matrix ECC200 In None Using Barcode printer for Office Word Control to generate, create ECC200 image in Word applications. www.OnBarcode.com Lines 20 through 22 query the document library for items where the WorkflowName column match the name of the workflow we re working with. Again, remember that rulesets are tightly bound to a workflow template and shouldn t show the user rulesets that are not applicable to the workflow they have selected. Finally, lines 23 through 29 loop through and add each ruleset name to the combo box. They re now available for the user to choose from. Listing 8-18. Retrieving the Rulesets Applicable to the Selected Workflow 1 2 3 4 5 6 Cursor.Current = Cursors.WaitCursor; cmboExistingRulesets.Items.Clear(); pnlRuleSets.Enabled = false; if (WFDataCollection[lbWorkflows.SelectedIndex].AssemblyName == null) { WFDataCollection[lbWorkflows.SelectedIndex].AssemblyName = GetAssemblyName(WFDataCollection [lbWorkflows.SelectedIndex].ID.ToString()); } Assembly a = Assembly.Load(WFDataCollection [lbWorkflows.SelectedIndex].AssemblyName); foreach (Type type in a.GetTypes()) { if ((type.BaseType.Name.ToLower() == "sequentialworkflowactivity") || (type.BaseType.Name.ToLower() == "statemachineworkflowactivity")) { WFDataCollection[lbWorkflows.SelectedIndex].AssemblyType = type; break; } } SPSite site = new SPSite(sSiteURL); SPWeb web = site.OpenWeb(); SPDocumentLibrary dl = (SPDocumentLibrary)web.Lists["Rules"]; SPQuery qry = new SPQuery(); qry.Query = string.Format(@"<Where><Eq> <FieldRef Name='WorkflowName' /><Value Type='Text'>{0}</Value> </Eq></Where>", WFDataCollection[lbWorkflows.SelectedIndex].AssemblyType.Name); SPListItemCollection lic = dl.GetItems(qry); Create Denso QR Bar Code In None Using Barcode encoder for Word Control to generate, create QR Code 2d barcode image in Word applications. www.OnBarcode.comPrinting UCC - 12 In None Using Barcode creation for Office Word Control to generate, create UPC-A Supplement 5 image in Office Word applications. www.OnBarcode.com7 8 9 10 11 Drawing GS1-128 In None Using Barcode generation for Word Control to generate, create UCC.EAN - 128 image in Microsoft Word applications. www.OnBarcode.comGenerating Barcode In None Using Barcode encoder for Word Control to generate, create Barcode image in Word applications. www.OnBarcode.com12 13 14 15 16 17 18 19 20 21 Printing PDF-417 2d Barcode In None Using Barcode creator for Office Word Control to generate, create PDF-417 2d barcode image in Word applications. www.OnBarcode.comMSI Plessey Creation In None Using Barcode generator for Office Word Control to generate, create MSI Plessey image in Word applications. www.OnBarcode.comCHAPTER 8 WORKFLOW RULES
Data Matrix ECC200 Maker In Visual Basic .NET Using Barcode encoder for .NET framework Control to generate, create ECC200 image in Visual Studio .NET applications. www.OnBarcode.comData Matrix ECC200 Generation In None Using Barcode encoder for Microsoft Word Control to generate, create ECC200 image in Microsoft Word applications. www.OnBarcode.com23 24 25 26 27 28 29 30 31 32 33 EAN128 Creator In None Using Barcode creator for Font Control to generate, create EAN 128 image in Font applications. www.OnBarcode.comPainting Code 128 Code Set B In Objective-C Using Barcode drawer for iPhone Control to generate, create Code-128 image in iPhone applications. www.OnBarcode.comif (lic.Count > 0) { foreach (SPListItem li in lic) { cmboExistingRulesets.Items.Add (Path.GetFileNameWithoutExtension(li.File.Name)); } } cmboExistingRulesets.Items.Insert(0,"<New>"); cmboExistingRulesets.SelectedIndex = 0; pnlRuleSets.Enabled = true; Cursor.Current = Cursors.Default; UPC-A Supplement 2 Generation In None Using Barcode maker for Software Control to generate, create UPC Code image in Software applications. www.OnBarcode.comCode-39 Reader In Visual C#.NET Using Barcode recognizer for .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comA few times in the last few listings, we ve referenced a method named GetAssemblyName. Listing 8-19 finally shows the code for this method. This one is a little different from the rest in that it does some XML parsing instead of working with SharePoint or workflows. Again, we ll just step through the highlights: Line 4 begins our loop through the Features directory on our server. We grab any files named workflow.xml that we find and load them into an XmlDocument object. Line 10 retrieves the GUID ID of the workflow and line 11 checks to see whether it matches against the workflow template selected by the user. If not, this iteration ends and we continue the loop. If line 11 does match, then we have found the workflow.xml file for the workflow selected by the user. Lines 13 and 14 can do some additional querying to retrieve the internal name of the workflow (the Name attribute of the <Workflow> XML tag) and the fully qualified assembly name (from the CodeBesideAssembly attribute). Since we ve now found what we need, there is no reason to continue looping, so line 15 short-circuits the loop and drops us into line 18, which simply returns the assembly name. Listing 8-19. Getting the Name of the Assembly for the Selected Workflow from Its workflow.xml File 1 2 3 4 private string GetAssemblyName(string WFID) { string sRetVal = string.Empty; foreach (string sFileName in Directory.GetFiles(@"C:\Program Files\ Common Files\Microsoft Shared\ web server extensions\12\TEMPLATE\ FEATURES\", "workflow.xml", SearchOption.AllDirectories)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(sFileName); XmlNamespaceManager nsMgr = new XmlNamespaceManager (xDoc.NameTable); Creating Barcode In Java Using Barcode maker for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comCode 39 Extended Creator In Objective-C Using Barcode encoder for iPhone Control to generate, create Code 39 Extended image in iPhone applications. www.OnBarcode.com5 6 7 8 Code-128 Creation In Java Using Barcode encoder for Android Control to generate, create Code 128B image in Android applications. www.OnBarcode.comDrawing 1D Barcode In Visual Basic .NET Using Barcode generation for VS .NET Control to generate, create 1D image in .NET framework applications. www.OnBarcode.comCHAPTER 8 WORKFLOW RULES
USS-128 Encoder In Visual C# Using Barcode encoder for VS .NET Control to generate, create EAN / UCC - 13 image in VS .NET applications. www.OnBarcode.comBarcode Generator In .NET Framework Using Barcode encoder for .NET Control to generate, create Barcode image in .NET applications. www.OnBarcode.com9 10 11 12 13 14 15 16 17 18 19 nsMgr.AddNamespace("def", "http://schemas.microsoft.com/sharepoint/"); string wfid = xDoc.SelectSingleNode( "/def:Elements/def:Workflow/@Id",nsMgr).InnerText; if (wfid.ToLower() == WFID.ToLower()) { sWorkflowName = xDoc.SelectSingleNode( "/def:Elements/def:Workflow/@Name", nsMgr).InnerText; sRetVal = xDoc.SelectSingleNode( "/def:Elements/def:Workflow/@CodeBesideAssembly", nsMgr).InnerText; break; } } return sRetVal; } Note The code in Listing 8-19 only works because we are running it on our SharePoint server. For a real production environment, this method will need to be made into a web service and various security aspects taken care of in order to allow businesspeople to run the application from their desktop. Listing 8-20 shows the code to handle the click event on our btnRuleSet object. Like Listing 8-18, its pretty long; fortunately, though, most of it consists of auxiliary-type code that is simply supporting the real work of this method. Lines 4 through 12 set things up for creating a new ruleset. Lines 13 through 26 handle the editing of an existing ruleset, with line 24 creating the ruleset object by deserializing the XML stored in the document library. We saw this in the ExternalPolicy activity as well. Lines 29 and 30 show how easy it is to instantiate and show the Rule Set Editor provided by Microsoft. If the user clicks OK in the dialog box (as opposed to Cancel, checked in line 32), we grab the ruleset from the dialog box (line 34). If there are any rules (checked in line 35), lines 37 through 48 save the information back to SharePoint, including setting the WorkflowName column for the SPListItem to the name of the selected workflow template.
|
|