<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
	 xmlns:sql='http://schemas.microsoft.com/wix/SqlExtension'
     xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>

	<Product Id="b09859ac-3e0d-4f84-880f-c08406e2b311"
				 Name="Optimum Suite"
				 Language="1033"
				 Version="3.2.10920.5"
				 Manufacturer="Optimum Solutions, Inc."
				 UpgradeCode="8384a5a0-60cb-4ecb-a136-25e1bf915ab0">
		<Package Description="Installs a file that will be patched."
            Comments="This Product does not include all assemblies."
            InstallerVersion="200"
            Compressed="yes"/>
		<util:User Id="SQLUser" Name ="OSIAdministrator" Password="OptimumSolutions"/>
		<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />

		<!-- Load the custom action DLL into the binary table -->
		<Binary Id="ValidatePIDKEYCA" SourceFile="../ValidatePIDKEYCA/ValidatePIDKEYCA/Debug/ValidatePIDKEYCA.dll" />

		<!-- CUSTOM ACTIONS -->
		<CustomAction Id="Abort" Error="2322"/>
		
		<!-- Define a custom action to execute the PIDKEYValidation function from the DLL -->
		<CustomAction Id="PIDKEYValidation" BinaryKey="ValidatePIDKEYCA" DllEntry="PIDKEYValidation" />
		
		<!-- Define a custom action to set the PIDKEY property value -->
		<CustomAction Id="SetPIDKeyValue" Property="PIDKEY" Value="[PIDKEY]"/>

		<!-- ADD SQL SCRIPT BINARIES HERE -->
		<Binary Id="CreateTable" SourceFile=".\BuildOutput\Database\CreateTable.sql" />

		<!-- Builds the Features tree within the installer -->
		<FeatureRef Id="SuiteProductFeature">
			<FeatureRef Id="SuiteHelpFeature"/>
		</FeatureRef>
		<FeatureRef Id="SuiteDatabaseFeature"/>

		<!-- Defines the UI -->
		<UI Id="WixUI_Mondo">
			<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
			<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
			<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

			<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
			<Property Id="WixUI_Mode" Value="Mondo" />
			<Property Id="PIDTemplate" Value="????-????-????-????" />
			<Property Id="MACHTemplate" Value="???? ????"/>

			<DialogRef Id="ErrorDlg" />
			<DialogRef Id="FatalError" />
			<DialogRef Id="FilesInUse" />
			<DialogRef Id="MsiRMFilesInUse" />
			<DialogRef Id="PrepareDlg" />
			<DialogRef Id="ProgressDlg" />
			<DialogRef Id="ResumeDlg" />
			<DialogRef Id="UserExit" />

			<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

			<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>

			<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
			<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="LicenseKeyDlg">LicenseAccepted = "1"</Publish>

			<Publish Dialog="LicenseKeyDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
			<Publish Dialog="LicenseKeyDlg" Control="Next" Event="ValidateProductID" Value="[PIDKEY]" Order="1">1</Publish>
			<!--<Publish Dialog="LicenseKeyDlg" Control="Next" Event="SetPIDKeyValue" Value="[PIDKEY]" Order="1">1</Publish>
			<Publish Dialog="LicenseKeyDlg" Control="Next" Event="PIDKEYValidation" Value="[PIDKEY]" Order="1">1</Publish>-->
			<Publish Dialog="LicenseKeyDlg" Control="Next" Event="NewDialog" Value="DisplayLicenseDialog" Order="2">ProductID</Publish>

			<Publish Dialog="DisplayLicenseDialog" Control="Back" Event="NewDialog" Value="LicenseKeyDlg">1</Publish>
			<Publish Dialog="DisplayLicenseDialog" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="999">1</Publish>

			<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="DisplayLicenseDialog">1</Publish>
			<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
			<Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
			<Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

			<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish>
			<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish>
			<Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

			<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish>
			<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish>
			<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish>
			<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish>

			<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

			<Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
			<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
			<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
			<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>

			<Dialog Id="LicenseKeyDlg" Width="370" Height="270" Title="[ProductName] Setup">
				<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}User Information" />
				<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Enter the following information to personalize your installation" />
				<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
				<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />

				<Control Id="UserNameLabel" Type="Text" X="20" Y="60" Width="290" Height="13" Text="Full Name:" />
				<Control Id="UserName" Type="Edit" X="20" Y="72" Width="320" Height="18" Property="USERNAME" Text="47"/>
				<Control Id="OrgNameLabel" Type="Text" X="20" Y="93" Width="290" Height="13" Text="Organization:" />
				<Control Id="OrgName" Type="Edit" X="20" Y="105" Width="320" Height="18" Property="COMPANYNAME" Text="{53}" />
				<Control Id="MachineKeyLabel" Type="Text" X="20" Y="126" Width="290" Height="13" Text="Machine Key:" />
				<Control Id="MachineKey" Type="MaskedEdit" X="20" Y="139" Width="320" Height="15" Property="MACHKEY" Text="[MACHTemplate]"/>
				<Control Id="LicenseKeyLabel" Type="Text" X="20" Y="156" Width="290" Height="13" Text="License Key:" />
				<Control Id="LicenseKey" Type="MaskedEdit" X="20" Y="169" Width="320" Height="15" Property="PIDKEY" Text="[PIDTemplate]"/>

				<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
				<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next" />
				<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back" />
				<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
					<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
				</Control>
			</Dialog>
			<Dialog Id="DisplayLicenseDialog" Width="370" Height="270" Title="[ProductName] Setup">
				<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Test Dialog" />
				<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="This is a test dialog" />
				<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
				<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />

				<Control Id="PIDKEYLabel" Type="Text" X="20" Y="60" Width="290" Height="13" Text="PIDKEY:" />
				<Control Id="PIDKEYValue" Type="Text" X="20" Y="72" Width="320" Height="13" Text="[PIDKEY]"/>
				<Control Id="ProductIdLabel" Type="Text" X="20" Y="93" Width="290" Height="13" Text="ProductID:" />
				<Control Id="ProductIdLabelValue" Type="Text" X="20" Y="105" Width="320" Height="18" Text="[ProductID]" />

				<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
				<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next" />
				<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back" />
			</Dialog>
		</UI>

		<UIRef Id="WixUI_Common" />
		
		<UI>
			<Error Id="2322">User Cancelled</Error>
		</UI>

		<InstallUISequence>
			<Custom
			  Action="SetPIDKeyValue"
			  After="ValidateProductID" />
			<Custom
			  Action="PIDKEYValidation"
			  After="SetPIDKeyValue" />
			<Show
			  Dialog="TestDialog"
			  After="PIDKEYValidation" />
			<!--<Custom
			   Action="Abort"
			   After="TestDialog" />-->
		</InstallUISequence>

		<!--<InstallExecuteSequence>
			<Custom Action="SetPIDKeyValue" After="ValidateProductID"/>
			<Custom Action="PIDKEYValidation" After="SetPIDKeyValue"/>			
		</InstallExecuteSequence>-->
	</Product>
		
	<!-- Create Directory Structure-->
	<Fragment>
		<Directory Id="TARGETDIR" Name="SourceDir">
			<Directory Id="SuiteProductFolder" Name="OptimumSuite">
				<Directory Id="SuiteHelpFolder" Name="Help"></Directory>
			</Directory>
			<Directory Id="DATABASEDIR" Name="Database"></Directory>
		</Directory>				   
	</Fragment>

	<!-- Features -->
	<Fragment>
		<Feature Id="SuiteProductFeature" Title="Optimum Suite" Level="1" ConfigurableDirectory="TARGETDIR">
			<ComponentRef Id="SuiteProductComponent"/>
		</Feature>
		<Feature Id="SuiteHelpFeature" Title="Help" Level="1">
			<ComponentRef Id="SuiteHelpComponent"/>
		</Feature>		
		<Feature Id="SuiteDatabaseFeature" Title="Suite Database" Description="Installs the Optimum Suite Database" Level="1" ConfigurableDirectory="DATABASEDIR">
			<ComponentRef Id="SuiteDatabaseComponent" />
		</Feature>
	</Fragment>

	<!-- Components -->
	
	<Fragment>
		<DirectoryRef Id="SuiteProductFolder">
			<Component Id="SuiteProductComponent" Guid="C28843DA-EF08-41CC-BA75-D2B99D8A1983" DiskId="1" >
						 <!-- required files for the custom action -->
				<File Id="ValidateKey" Name="ValidateKey.dll" Source=".\BuildOutput\Resources\ValidateKey.dll"/>

				<!-- ADD ASSEMBLIES TO THE RUN DIRECTORY HERE-->
				<File Id="OptimumSuite" Name="OptimumSuite.exe" Source=".\BuildOutput\OptimumSuite.exe" />
			</Component>
		</DirectoryRef>
		<DirectoryRef Id ="DATABASEDIR">
			<Component Id="SuiteDatabaseComponent" Guid="d6e96011-3252-4e85-80b5-b1ff64045e88">
				<CreateFolder/>

				<!-- installs database -->
				<sql:SqlDatabase Id="db1"
				  Server="ELAT64" Instance="SQL_2005" Database="SuiteWix"
				  CreateOnInstall="yes" ConfirmOverwrite="yes"
				  DropOnUninstall="yes" User="SQLUser">

					<!-- define where the database files are saved -->
					<sql:SqlFileSpec Id="mdf"
						Name="SuiteWix_Data"
						Filename="[DATABASEDIR]SuiteWiX_Data.mdf"
						Size="2MB" GrowthSize="2MB"/>
					<sql:SqlLogFileSpec Id="ldf"
						Name="SuiteWix_Log"
						Filename="[DATABASEDIR]SuiteWiX_Log.ldf"/>

					<!-- add reference to database script bianarieshere -->
					<sql:SqlScript Id="CreateTable" BinaryKey="CreateTable" ExecuteOnInstall="yes"/>
				</sql:SqlDatabase>
			</Component>
		</DirectoryRef>
		<DirectoryRef Id="SuiteHelpFolder">
			<Component Id="SuiteHelpComponent" Guid="e1715113-721e-4dd9-b1cf-51a23bc3fdaa">
				<File Id="OptimumHelp" Name="Optimum_Suite_for_Windows.chm" Source=".\BuildOutput\Help\Optimum_Suite_for_Windows.chm" />
			</Component>
		</DirectoryRef>
	</Fragment>
</Wix>