<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<CustomAction Id="FillingListBox" BinaryKey="FillListBox" DllEntry="FillListBox" />
<UI Id="DatabaseScreen">
<Dialog Id="DatabaseDialog"
Width="370"
Height="270"
Title="Database Connections"
NoMinimize="no">
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no"
Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
<Control Id="Dbases" Type="ListBox" Sorted="no"
Indirect="no" Property="DBaseValues"
X="10" Y="50" Width="150" Height="180">
<ListBox Property="DBaseValues">
<ListItem Text="ARGHH!" Value="1"/>
</ListBox>
</Control>
<Control Id="Title"
Type="Text"
X="15"
Y="23"
Width="280"
Height="15"
Transparent="yes"
NoPrefix="yes"
Text="Database Information" />
<Control Id="InstallButton"
Type="PushButton"
Text="Install"
Height="17" Width="56"
X="300" Y="243"
TabSkip="yes">
<Publish Event="EndDialog" Value="Return" />
</Control>
<Control Id="BackButton"
Type="PushButton"
X="235" Y="243"
Height="17" Width="56"
Text="Back">
<Publish Event="NewDialog" Value="LicenseDialog" />
</Control>
<Control Id="CancelButton"
Type="PushButton"
X="10" Y="243"
Height="17" Width="56"
Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
</Dialog>
<InstallUISequence>
<Custom Action="FillingListBox" After="CostFinalize" />
<Show Dialog="DatabaseDialog" After="FillingListBox" />
</InstallUISequence>
</UI>
<Binary Id="FillListBox" SourceFile="C:\MyDir\GetConnections.dll" />
</Fragment>
</Wix>
public class DBase
{
public string Name { get; set; } = string.Empty;
}
public class CustomActions
{
[CustomAction]
public static ActionResult GetSQLConnections(Session session)
{
session.Log("Begin GetSQLConnections");
session["USER_DATABASES"] = "DefaultValue";
int i = 0;
int j = 0;
string s = string.Empty;
var dt = SmoApplication.EnumAvailableSqlServers(false);
if (dt != null)
{
List<DBase> db = new List<DBase>();
foreach (DataRow row in dt.Rows)
{
foreach (var item in row.ItemArray)
{
if (i == j)
{
db.Add(new DBase()
{
Name = item.ToString()
});
}
else
{
break;
}
j++;
}
i++;
}
var z = (from y in db
select y).ToList();
Microsoft.Deployment.WindowsInstaller.View listBoxView = session.Database.OpenView("SELECT * FROM ListBox");
i = 1;
foreach (var db1 in z)
{
s += db1.Name + "; ";
Record newListBoxRecord = new Record(4);
newListBoxRecord[1] = "DBaseValues";
newListBoxRecord[2] = i;
newListBoxRecord[3] = db1.Name;
newListBoxRecord[4] = db1.Name;
listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord);
i++;
}
}
//MessageBox.Show(s, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
return ActionResult.Success;
}
}
ASKER
ASKER
ASKER
ASKER
ASKER
<Binary Id="FillListBoxBinary"
SourceFile="$(var.SQLConnections.TargetDir)$(var.SQLConnections.TargetName).dll" />
<CustomAction Id="FillListBoxAction" BinaryKey="FillListBoxBinary" DllEntry="GetSQLConnections"
Execute="immediate" Return="check" />
<InstallUISequence>
<Custom Action="FillListBoxAction" After="CostFinalize" />
<Show Dialog="DatabaseDialog" After="FillListBoxAction" />
</InstallUISequence>
ASKER
ASKER
<Control Id="DbaseList" Type="ListBox" Sorted="no"
Indirect="no" Property="DBaseValues"
X="10" Y="50" Width="150" Height="180">
<ListBox Property="DBaseValues">
<ListItem Text="ARGHH!" Value="1"/>
<ListItem Text="$(var.SQLConnections.TargetDir)$(var.SQLConnections.TargetName).dll" Value="2"/>
</ListBox>
</Control>
ASKER
<CustomAction Id="FillListBoxAction" BinaryKey="FillListBoxBinary"
DllEntry="GetSQLConnections" Execute="immediate" Return="ignore" />
ASKER
<Binary Id="FillListBoxBinary"
SourceFile="$(var.DBConnect.TargetDir)$(var.DBConnect.TargetName).dll" />
<CustomAction Id="FillListBoxAction"
BinaryKey="FillListBoxBinary"
DllEntry="GetListofDB"
Execute="immediate" Return="check" />
<InstallUISequence>
<Custom Action="FillListBoxAction" After="CostFinalize" />
<Show Dialog="DatabaseDialog" After="FillListBoxAction" />
</InstallUISequence>
My Custom Actionnamespace DBConnect
{
public class CustomActions
{
[CustomAction]
public static ActionResult GetListofDB(Session session)
{
session.Log("Begin CustomAction1");
return ActionResult.Success;
}
}
}
ASKER
i = 2;
// foreach (var db1 in z)
// {
View listBoxView = session.Database.OpenView("SELECT * FROM ListBox");
Record newListBoxRecord = new Record(4);
newListBoxRecord[1] = "DBaseValues";
newListBoxRecord[2] = i;
newListBoxRecord[3] = "Test"; //db1.Name;
newListBoxRecord[4] = "Test"; //db1.Name;
listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord);
//}
ASKER
View listBoxView = session.Database.OpenView("SELECT * FROM ListBox");
Record newListBoxRecord = new Record(4);
When I do below it works but having it in a loop is better as I don't know what is going to return from the list. Any ideas?View listBoxView = session.Database.OpenView("SELECT * FROM ListBox");
Record newListBoxRecord = new Record(4);
newListBoxRecord[1] = "DBaseValues";
newListBoxRecord[2] = i;
newListBoxRecord[3] = z[0].Name; //sName; //"Test " + k; //db1.Name;
newListBoxRecord[4] = z[0].Name; //sName; //"Test " + k; //db1.Name;
listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord);
newListBoxRecord[1] = "DBaseValues";
newListBoxRecord[2] = 3;
newListBoxRecord[3] = z[1].Name; //sName; //"Test " + k; //db1.Name;
newListBoxRecord[4] = z[1].Name; //sName; //"Test " + k; //db1.Name;
listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord);
ASKER
ASKER
ASKER
ASKER
Installation is the act of making a computer program program ready for execution. Because the process varies programs often come with a specialized program responsible for doing whatever is needed for their installation. Installation may be part of a larger software deployment process. Cross platform installer builders that produce installers for Windows, Mac OS X and Linux include InstallAnywhere, InstallBuilder and Install4J. Installers for Microsoft Windows include Windows Installer, InstallShield, and Wise Installation Studio; free installer-authoring tools include NSIS, IzPack, Clickteam, InnoSetup, InstallSimple and WiX. Mac OS X includes Installer, and also includes a separate software updating application.
TRUSTED BY
ASKER
Oh, and for the Sourcefile I typed c:\.... but it's actuall G:\.... I don't know if that makes a difference. I'm developing this on an external drive.