<?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;
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE