﻿<?xml version="1.0" encoding="utf-16"?>
<JiwaDocument xmlns:jiwa="http://www.jiwa.com.au/xml/schemas" Type="JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin">
  <RecID>33061578-6a62-4180-a4bd-8e09810ab0cc</RecID>
  <Name>Print work order example</Name>
  <Description>Demonstrates how to print a work order by adding a tool to the work order ribbon "Custom Print".&amp;#13;&amp;#10;When pressed, this tool prints one of the defined reports - the logic to decide which one is within the PrintCustomReport method.</Description>
  <IsEnabled>true</IsEnabled>
  <IsIsolatedToOwnAppDomain>false</IsIsolatedToOwnAppDomain>
  <ExecutionOrder>0</ExecutionOrder>
  <Author>Jiwa Financials</Author>
  <Version>7.2.1.0</Version>
  <Code>using System;
using System.Windows.Forms;
using System.Linq;
using Infragistics;

#region "FormPlugin"
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
		if (JiwaForm is JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)
		{
			JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder workOrderForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)JiwaForm;
			
			// Add custom print tool to ribbon			
			Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("Custom Print");
			buttonTool.SharedProps.Caption = "Custom Print";        	
        	workOrderForm.UltraToolbarsManager1.Tools.Add(buttonTool);
        
			Infragistics.Win.UltraWinToolbars.RibbonGroup ribbonGroup = workOrderForm.UltraToolbarsManager1.Ribbon.Tabs["Main"].Groups["Print"];
        	ribbonGroup.Tools.AddTool("Custom Print");
			
			workOrderForm.UltraToolbarsManager1.ToolClick += UltraToolbarsManager1_ToolClick;
		}				
    }
	
	private void UltraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
	{		
		JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder workOrderForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)(((Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)(sender)).DockWithinContainer);
		
		if (e.Tool.Key == "Custom Print")
		{
			PrintCustomReport(workOrderForm);
		}
	}
	
	private void PrintCustomReport(JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder workOrderForm)
	{
		// Print default report
		//JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition reportDefinition = workOrderForm.ReportDefinitionCollection.Cast&lt;JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition&gt;().Where(x =&gt; x.IsDefault == true).FirstOrDefault();
		
		// Print report with description "test"
		JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition reportDefinition = workOrderForm.ReportDefinitionCollection.Cast&lt;JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition&gt;().Where(x =&gt; x.Description == "test").FirstOrDefault();

		// Print report with filename "MNT12601 - Work Order.rpt"
		//JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition reportDefinition = workOrderForm.ReportDefinitionCollection.Cast&lt;JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition&gt;().Where(x =&gt; x.Report.FileName == "MNT12601 - Work Order.rpt").FirstOrDefault();
		
		if (reportDefinition != null)
		{
			workOrderForm.PrintRecord(reportDefinition);
		}
	}
}
#endregion
</Code>
  <ExceptionPolicy>Abort</ExceptionPolicy>
  <Language>CSharp</Language>
  <PluginFormCollection>
    <PluginForm>
      <RecID>b0c9540c-3686-4699-b3a8-14b3d0720a81</RecID>
      <Description>Work Order</Description>
      <ClassName>JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder</ClassName>
    </PluginForm>
  </PluginFormCollection>
  <ReferenceCollection>
    <Reference>
      <RecID>8cd2b777-e519-4f27-a3ae-361d90edd1d0</RecID>
      <AssemblyFullName>JiwaApplication, Version=7.2.1.0, Culture=neutral, PublicKeyToken=e30ce81e37f29c8c</AssemblyFullName>
      <AssemblyName>JiwaApplication.dll</AssemblyName>
      <AssemblyLocation>C:\VSTS\Jiwa 7\07.02.00\Built Files\JiwaApplication.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>088a94dd-d1e0-401f-acdb-df0eec064b59</RecID>
      <AssemblyFullName>mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>mscorlib.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>a0450c21-73b6-4346-b684-5d81c9f0b374</RecID>
      <AssemblyFullName>System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>System.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>fcaa9aa0-5524-4a43-9ffa-2b2dacbee7b0</RecID>
      <AssemblyFullName>System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</AssemblyFullName>
      <AssemblyName>System.Drawing.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>afbc3083-b385-4f22-ab59-5dccbe05a11d</RecID>
      <AssemblyFullName>System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>System.Data.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>929bb129-0e82-447b-b744-a4292722fd6c</RecID>
      <AssemblyFullName>System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>System.Runtime.Serialization.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>c1b013c4-c679-4d96-9a37-db2137ce3596</RecID>
      <AssemblyFullName>System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>System.Windows.Forms.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>ebb5c1f7-7242-4142-9b18-6d93afd60583</RecID>
      <AssemblyFullName>System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyFullName>
      <AssemblyName>System.Core.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>2457ba25-d238-4cb9-99fc-141eb3321433</RecID>
      <AssemblyFullName>System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</AssemblyFullName>
      <AssemblyName>System.Security.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>23c790fa-59a9-4c28-bc64-5d35667c18a9</RecID>
      <AssemblyFullName>JiwaBillOfMaterialsUI, Version=7.2.1.0, Culture=neutral, PublicKeyToken=e30ce81e37f29c8c</AssemblyFullName>
      <AssemblyName>JiwaBillOfMaterialsUI.dll</AssemblyName>
      <AssemblyLocation>C:\VSTS\Jiwa 7\07.02.00\Built Files\JiwaBillOfMaterialsUI.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>d8cdf7df-c39f-4303-a934-be1c12bcbe3a</RecID>
      <AssemblyFullName>JiwaBillOfMaterials, Version=7.2.1.0, Culture=neutral, PublicKeyToken=e30ce81e37f29c8c</AssemblyFullName>
      <AssemblyName>JiwaBillOfMaterials.dll</AssemblyName>
      <AssemblyLocation>C:\VSTS\Jiwa 7\07.02.00\Built Files\JiwaBillOfMaterials.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>48a66439-7649-4b06-9860-4b33e3cc127d</RecID>
      <AssemblyFullName>Infragistics4.Shared.v13.1, Version=13.1.20131.2060, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</AssemblyFullName>
      <AssemblyName>Infragistics4.Shared.v13.1.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Infragistics4.Shared.v13.1\v4.0_13.1.20131.2060__7dd5c3163f2cd0cb\Infragistics4.Shared.v13.1.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>098d30c9-1ab0-4280-8329-b4beaceea91c</RecID>
      <AssemblyFullName>Infragistics4.Win.Misc.v13.1, Version=13.1.20131.2060, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</AssemblyFullName>
      <AssemblyName>Infragistics4.Win.Misc.v13.1.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Infragistics4.Win.Misc.v13.1\v4.0_13.1.20131.2060__7dd5c3163f2cd0cb\Infragistics4.Win.Misc.v13.1.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>ae4984d9-ceaa-47b0-9cac-d833c516ed40</RecID>
      <AssemblyFullName>Infragistics4.Win.UltraWinToolbars.v13.1, Version=13.1.20131.2060, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</AssemblyFullName>
      <AssemblyName>Infragistics4.Win.UltraWinToolbars.v13.1.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Infragistics4.Win.UltraWinToolbars.v13.1\v4.0_13.1.20131.2060__7dd5c3163f2cd0cb\Infragistics4.Win.UltraWinToolbars.v13.1.dll</AssemblyLocation>
    </Reference>
    <Reference>
      <RecID>38df8f64-fd6c-4230-9f49-dfe48c3f009e</RecID>
      <AssemblyFullName>Infragistics4.Win.v13.1, Version=13.1.20131.2060, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</AssemblyFullName>
      <AssemblyName>Infragistics4.Win.v13.1.dll</AssemblyName>
      <AssemblyLocation>C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Infragistics4.Win.v13.1\v4.0_13.1.20131.2060__7dd5c3163f2cd0cb\Infragistics4.Win.v13.1.dll</AssemblyLocation>
    </Reference>
  </ReferenceCollection>
</JiwaDocument>