<?xml version="1.0" encoding="utf-16"?><customize><CoresuiteServiceRules><RuleDto xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Rule" RuleName="SAMPLE: Print Open Sales Orders" RuleId="3b9eefc9-ba1e-4b05-8d9b-8463fab47005" Version="-1" Active="N" EndType="N" Recurrence="S" Monday="N" Tuesday="N" Wednesday="N" Thursday="N" Friday="N" Saturday="N" Sunday="N"><Expression>// Define connectionstring databaseServerInstance = @"vma-200";string companyDatabase = @"SBODemoCH";// Get connection to designer based on configuration filevar conf = CoresuiteServiceAPI.Designer.ConnectionManager.Instance.GetConnection(databaseServerInstance, companyDatabase);// Get the print api for the connectionvar api = new CoresuiteServiceAPI.Designer.PrintAPI(conf);// Create a query to get open/not printed sales ordersvar query = new CoresuiteServiceAPI.SqlQuery(companyDatabase);string printQuery = @"	SELECT TOP 10 ""DocEntry"", ""DocNum""	FROM ""ORDR""	WHERE ""DocStatus"" = 'O'	AND ""Printed"" = 'N'";using (var rdr = query.ExecuteReader(printQuery)){	while (rdr.Read())	{		string docEntry = rdr["DocEntry"].ToString();		string docNum = rdr["DocNum"].ToString();				// ProcessedSalesOrders is a list defined in the extended code. It is used to ensure that each document is only processed once.		if (!ProcessedSalesOrders.Contains(docEntry))		{					ProcessedSalesOrders.Add(docEntry);						api.ExecutePrintDef("DocSalesOrder", CoresuiteServiceAPI.Designer.PrintAPI.OpenLayoutModes.PDF, "DocEntry", docEntry);			CoresuiteServiceAPI.DebugLog.Info(companyDatabase, "Processed Sales Order Document No: " + docNum + " (DocEntry " + docEntry + ")" );		}	}}CoresuiteServiceAPI.DebugLog.Info(companyDatabase, "Rule successfully executed: SAMPLE: Print Open Sales Orders");</Expression><StartDate>2022-11-30T00:00:00</StartDate><NotBefore>0</NotBefore><EndAfter>0</EndAfter><EndBy>9999-12-31T00:00:00</EndBy><Seconds>20</Seconds><Days>0</Days><Weeks>0</Weeks><MonthlyD>0</MonthlyD><MonthlyO>0</MonthlyO><YearlyM>0</YearlyM><YearlyD>0</YearlyD><ExecDate xsi:nil="true" /><ScriptLanguage>CS</ScriptLanguage></RuleDto><RuleDto xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Rule" RuleName="SAMPLE: Print Open Sales Orders Load Balancing" RuleId="6b740b97-ad49-4bc0-8546-3478bdda3635" Version="-1" Active="N" EndType="N" Recurrence="S" Monday="N" Tuesday="N" Wednesday="N" Thursday="N" Friday="N" Saturday="N" Sunday="N"><Expression>// This rule demonstrates how to use load balancing for printing.// Prerequisites: Multiple designer instances must have been set up in the service configuration file.// This sample assumes that 3 instances have been configured to run concurrently.// The relevant configuration element would look as follows:// &lt;designer instancecount="3"/&gt;// Define connectionstring databaseServerInstance = @"vma-200";string companyDatabase = @"SBODemoCH";// Get connection to designer based on configuration filevar conf = CoresuiteServiceAPI.Designer.ConnectionManager.Instance.GetConnection(databaseServerInstance, companyDatabase);// Get the print apis for the connectionvar apis = new System.Collections.Generic.Dictionary&lt;int, CoresuiteServiceAPI.Designer.PrintAPI&gt;();apis.Add(0, new CoresuiteServiceAPI.Designer.PrintAPI(conf, 0));apis.Add(1, new CoresuiteServiceAPI.Designer.PrintAPI(conf, 1));apis.Add(2, new CoresuiteServiceAPI.Designer.PrintAPI(conf, 2));// Create a query to get open/not printed sales ordersvar query = new CoresuiteServiceAPI.SqlQuery(companyDatabase);string printQuery = @"	SELECT TOP 9 ""DocEntry"", ""DocNum""	FROM ""ORDR""	WHERE ""DocStatus"" = 'O'	AND ""Printed"" = 'N'";// Start with print api #0int counter = 0;using (var rdr = query.ExecuteReader(printQuery)){	while (rdr.Read())	{		string docEntry = rdr["DocEntry"].ToString();		string docNum = rdr["DocNum"].ToString();				// ProcessedSalesOrders is a list defined in the extended code. It is used to ensure that each document is only processed once.		if (!ProcessedSalesOrders.Contains(docEntry))		{					ProcessedSalesOrders.Add(docEntry);							apis[counter].ExecutePrintDef("DocSalesOrder", CoresuiteServiceAPI.Designer.PrintAPI.OpenLayoutModes.PDF, "DocEntry", docEntry);			CoresuiteServiceAPI.DebugLog.Info(companyDatabase, "Processed Sales Order Document No: " + docNum + " (DocEntry " + docEntry + ")" );						// Next loop, use another print api			counter++;						if (counter &gt; 2)			{				counter = 0;			}		}	}}CoresuiteServiceAPI.DebugLog.Info(companyDatabase, "Rule successfully executed: SAMPLE: Print Open Sales Orders Load Balancing");</Expression><StartDate>2022-11-30T00:00:00</StartDate><NotBefore>0</NotBefore><EndAfter>0</EndAfter><EndBy>9999-12-31T00:00:00</EndBy><Seconds>20</Seconds><Days>0</Days><Weeks>0</Weeks><MonthlyD>0</MonthlyD><MonthlyO>0</MonthlyO><YearlyM>0</YearlyM><YearlyD>0</YearlyD><ExecDate xsi:nil="true" /><ScriptLanguage>CS</ScriptLanguage></RuleDto></CoresuiteServiceRules></customize>