Skip to content

Commit

Permalink
Add bulk launcher password
Browse files Browse the repository at this point in the history
  • Loading branch information
Mag-nus committed Jun 30, 2019
1 parent 6e4fdb7 commit 44cce60
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Source/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<setting name="WindowPositionTop" serializeAs="String">
<value>0</value>
</setting>
<setting name="BulkLaunchPassword" serializeAs="String">
<value />
</setting>
</Mag_ACClientLauncher.Properties.Settings>
</userSettings>
</configuration>
18 changes: 10 additions & 8 deletions Source/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
<TabItem Header="Bulk Launcher" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid Background="#FFE5E5E5">
<ComboBox x:Name="cboBulkLauncherServerList" Margin="10,10,114,0" VerticalAlignment="Top" SelectionChanged="cboBulkLauncherServerList_SelectionChanged"/>
<Label Content="Quantity to launch" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchQuantity" Margin="163,47,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchQuantity, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="Start launch at index" HorizontalAlignment="Left" Margin="10,72,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchStartIndex" Margin="163,75,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Height="23" VerticalAlignment="Top" Text="{Binding BulkLaunchStartIndex, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="User name prefix" HorizontalAlignment="Left" Margin="10,100,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchUserNamePrefix" Margin="163,103,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchUserNamePrefix, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLines="1"/>
<Button x:Name="cmdBulkLaunch" Content="Bulk Launch" Margin="226,106,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" RenderTransformOrigin="2.764,0.605" HorizontalAlignment="Left" Width="75" Click="cmdBulkLaunch_Click"/>
<TextBox x:Name="txtBulkLaunchStatus" Margin="10,131,10,10" TextWrapping="Wrap" RenderTransformOrigin="1.927,-3.718" VerticalScrollBarVisibility="Auto" FontSize="10" FontFamily="Consolas"/>
<Label Content="Quantity to launch" HorizontalAlignment="Left" Margin="10,34,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchQuantity" Margin="163,37,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchQuantity, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="Start launch at index" HorizontalAlignment="Left" Margin="10,62,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchStartIndex" Margin="163,65,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Height="23" VerticalAlignment="Top" Text="{Binding BulkLaunchStartIndex, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLength="5" MaxLines="1"/>
<Label Content="User name prefix" HorizontalAlignment="Left" Margin="10,90,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchUserNamePrefix" Margin="163,93,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="53" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchUserNamePrefix, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLines="1"/>
<Button x:Name="cmdBulkLaunch" Content="Bulk Launch" Margin="226,95,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" RenderTransformOrigin="2.764,0.605" HorizontalAlignment="Left" Width="75" Click="cmdBulkLaunch_Click"/>
<TextBox x:Name="txtBulkLaunchStatus" Margin="10,149,10,10" TextWrapping="Wrap" RenderTransformOrigin="1.927,-3.718" VerticalScrollBarVisibility="Auto" FontSize="10" FontFamily="Consolas"/>
<Label Content="Password" HorizontalAlignment="Left" Margin="10,118,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtBulkLaunchPassword" Margin="163,121,0,0" TextWrapping="Wrap" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="138" RenderTransformOrigin="1.927,-3.718" Text="{Binding BulkLaunchPassword, Mode=TwoWay, Source={x:Static p:Settings.Default}}" MaxLines="1"/>
</Grid>
</TabItem>
<TabItem Header="Options">
Expand Down
20 changes: 17 additions & 3 deletions Source/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public partial class MainWindow
{
public MainWindow()
{
if (String.IsNullOrWhiteSpace(Properties.Settings.Default.BulkLaunchPassword))
{
// Create a random password if one doesn't exist
var rand = new Random();
for (int i = 0; i < 16; i++)
Properties.Settings.Default.BulkLaunchPassword += Convert.ToChar(rand.Next(97, 122));
}

InitializeComponent();

Title += " 1.1"; // Update line 55 in AssemblyInfo.cs
Expand Down Expand Up @@ -386,7 +394,7 @@ private async void cmdBulkLaunch_Click(object sender, RoutedEventArgs e)
{
bulkLaunchCTS = new CancellationTokenSource();

await DoBulkLaunch(Properties.Settings.Default.BulkLaunchQuantity, Properties.Settings.Default.BulkLaunchStartIndex, Properties.Settings.Default.BulkLaunchUserNamePrefix, TimeSpan.FromSeconds(Properties.Settings.Default.IntervalBetweenLaunches), server, bulkLaunchCTS.Token);
await DoBulkLaunch(Properties.Settings.Default.BulkLaunchQuantity, Properties.Settings.Default.BulkLaunchStartIndex, Properties.Settings.Default.BulkLaunchUserNamePrefix, Properties.Settings.Default.BulkLaunchPassword, TimeSpan.FromSeconds(Properties.Settings.Default.IntervalBetweenLaunches), server, bulkLaunchCTS.Token);
}
}
finally
Expand All @@ -395,8 +403,14 @@ private async void cmdBulkLaunch_Click(object sender, RoutedEventArgs e)
}
}

private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userNamePrefix, TimeSpan interval, Server server, CancellationToken token)
private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userNamePrefix, string password, TimeSpan interval, Server server, CancellationToken token)
{
if (String.IsNullOrWhiteSpace(password))
{
MessageBox.Show("Password cannot be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

for (int i = startIndex; i < (startIndex + launchQuantity); i++)
{
if (token.IsCancellationRequested)
Expand All @@ -407,7 +421,7 @@ private async Task DoBulkLaunch(int launchQuantity, int startIndex, string userN
txtBulkLaunchStatus.Text += $"{DateTime.Now}: Launching user {userName}, connection {(i - startIndex) + 1} of {launchQuantity}" + Environment.NewLine;
txtBulkLaunchStatus.ScrollToEnd();

var account = new Account {UserName = userName, Password = "password"};
var account = new Account {UserName = userName, Password = password };

if (!DoLaunch(server, account))
{
Expand Down
14 changes: 13 additions & 1 deletion Source/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Source/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
<Setting Name="WindowPositionTop" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="BulkLaunchPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 44cce60

Please sign in to comment.