Skip to content

Commit

Permalink
Added more notifications
Browse files Browse the repository at this point in the history
Grammatical corrections to tab descriptions
  • Loading branch information
Harabe-x committed Jan 17, 2024
1 parent 535b600 commit 98dd4a7
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 156 deletions.
6 changes: 3 additions & 3 deletions PixaiBot/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ protected override void OnStartup(StartupEventArgs e)

protected override void OnExit(ExitEventArgs e)
{
_logger.Log("=====Application Closed=====\n", _logger.ApplicationLogFilePath);
base.OnExit(e);
_logger.Log("=====Application Closed=====\n", _logger.ApplicationLogFilePath);
}

private void HandleUnhandledApplicationException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
//_logger.Log($"{e.Exception} | {e.Exception.Message}", _logger.ApplicationLogFilePath);
//e.Handled = true;
_logger.Log($"{e.Exception} | {e.Exception.Message} | {e.Exception.InnerException}", _logger.ApplicationLogFilePath);
e.Handled = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace PixaiBot.Business_Logic.Driver_and_Browser_Management;

internal class AccountCreatorV2 : IAccountCreator
{

#region Constructor
public AccountCreatorV2(IPixaiNavigation pixaiNavigation, ITempMailApiManager tempMailApiManager,
ILoginCredentialsMaker loginCredentialsMaker, ILogger logger, IProxyManager proxyManager)
{
Expand All @@ -21,8 +23,9 @@ public AccountCreatorV2(IPixaiNavigation pixaiNavigation, ITempMailApiManager te
_pixaiNavigation = pixaiNavigation;
}

#endregion


#region Methods
public void CreateAccounts(int amount, string tempMailApiKey, bool shouldVerifyEmail,
IDriverCreationStrategy driverCreationStrategy, TimeSpan interval, CancellationToken token)
{
Expand All @@ -33,7 +36,7 @@ public void CreateAccounts(int amount, string tempMailApiKey, bool shouldVerifyE
if (token.IsCancellationRequested) return;

var driver = driverCreationStrategy.CreateDriver();

_logger.Log("=====Launched Chrome Driver=====", _logger.CreditClaimerLogFilePath);

try
Expand All @@ -59,15 +62,15 @@ public void CreateAccounts(int amount, string tempMailApiKey, bool shouldVerifyE
_logger.Log("The account creation process has ended", _logger.CreditClaimerLogFilePath);
}

private void CreateAccount(IWebDriver driver,bool shouldVerifyEmail, string tempMailApiKey)
private void CreateAccount(IWebDriver driver, bool shouldVerifyEmail, string tempMailApiKey)
{
_logger.Log("Creating account login details", _logger.CreditClaimerLogFilePath);


var email = shouldVerifyEmail
? _loginCredentialsMaker.GenerateEmail(tempMailApiKey)
: _loginCredentialsMaker.GenerateEmail();

var password = _loginCredentialsMaker.GeneratePassword();

_logger.Log("Creating account login details", _logger.CreditClaimerLogFilePath);
Expand Down Expand Up @@ -136,7 +139,7 @@ private void VerifyEmail(UserAccount userAccount, IWebDriver driver, string temp

_logger.Log("Email verified\n=====Chrome Drive Closed=====\n", _logger.CreditClaimerLogFilePath);
}

#endregion

#region Fields

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Notification.Wpf;
using OpenQA.Selenium.Support.UI;
using PixaiBot.Business_Logic.Driver_and_Browser_Management.Driver_Creation_Strategy;
using PixaiBot.Data.Interfaces;
Expand All @@ -20,6 +21,7 @@ public AccountLoginChecker(ILogger logger, IPixaiNavigation pixaiNavigation)

#endregion

#region Methods

public bool CheckAccountLogin(UserAccount userAccount,IDriverCreationStrategy driverCreationStrategy)
{
Expand Down Expand Up @@ -64,19 +66,20 @@ public IEnumerable<UserAccount> CheckAllAccountsLogin(IEnumerable<UserAccount> a
if (CheckAccountLogin(userAccount,driverCreationStrategy))
{
validAccounts.Add(userAccount);
continue;
AccountChecked?.Invoke(this, new UI.Models.Notification { Message = $"{userAccount.Email} is valid", NotificationType = NotificationType.Success });
}
}
catch (Exception)
{
continue;
AccountChecked?.Invoke(this, new UI.Models.Notification { Message = $"{userAccount.Email} is invalid", NotificationType = NotificationType.Error });
}

ValidAccountLogin?.Invoke(this, userAccount);
}

return validAccounts;
}
#endregion

#region Fields

private const int MaxLoginAttemptSeconds = 5;

Expand All @@ -88,5 +91,9 @@ public IEnumerable<UserAccount> CheckAllAccountsLogin(IEnumerable<UserAccount> a

private readonly ILogger _logger;

public event EventHandler<UserAccount> ValidAccountLogin;
public event EventHandler<UI.Models.Notification>? AccountChecked;

#endregion


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,5 @@ public void ClaimCreditsForAllAccounts(IEnumerable<UserAccount> accounts,IDriver

public event EventHandler<UserAccount>? ProcessStartedForAccount;

public event EventHandler CreditsAlreadyClaimed;

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ namespace PixaiBot.Business_Logic.Driver_and_Browser_Management.WebNavigationCor

internal class PixaiDataReader : IPixaiDataReader
{

#region Constructor

public PixaiDataReader(ILogger logger)
{
_logger = logger;
}

#endregion

#region Methods

public string GetAccountId(ISearchContext searchContext)
{
_logger.Log("Reading Account Id", _logger.CreditClaimerLogFilePath);
Expand Down Expand Up @@ -86,7 +93,7 @@ private static string GetWebElementAttribute(ISearchContext searchContext, strin

return element.Text;
}

#endregion

#region Fields

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public PixaiNavigation(ILogger logger)

#endregion


#region Methods

#region IPixaiNavigation
Expand Down Expand Up @@ -198,7 +197,6 @@ public void SendKeysToElement(ISearchContext driver, string cssSelector, string

#endregion


#region Fields

private readonly ILogger _logger;
Expand Down
2 changes: 1 addition & 1 deletion PixaiBot/Data/Interfaces/IAccountInfoLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace PixaiBot.Data.Interfaces;
internal interface IAccountInfoLogger
{
/// <summary>
/// Clears the of the <see cref="StringBuilder"/> content.
/// Clears <see cref="StringBuilder"/> content.
/// </summary>
public void ClearStringBuilderContent();

Expand Down
4 changes: 2 additions & 2 deletions PixaiBot/Data/Interfaces/IAccountLoginChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace PixaiBot.Data.Interfaces;
public interface IAccountLoginChecker
{
/// <summary>
/// Occurs when login to the account is successful.
/// Occurs when the account is checked
/// </summary>
event EventHandler<UserAccount> ValidAccountLogin;
event EventHandler<UI.Models.Notification> AccountChecked;

/// <summary>
/// Checks the credentials of a single account.
Expand Down
16 changes: 16 additions & 0 deletions PixaiBot/UI/Models/Notification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Notification.Wpf;

namespace PixaiBot.UI.Models
{
public class Notification
{
public string Message { get; set; }

public NotificationType NotificationType { get; set; }
}
}
2 changes: 1 addition & 1 deletion PixaiBot/UI/View/AccountCreatorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TextBlock FontWeight="Regular" Foreground="#2d3436" Style="{StaticResource TitleText}"
HorizontalAlignment="Center" Text="Account Creator" VerticalAlignment="Center" />
<TextBlock FontWeight="Regular" Style="{StaticResource SecondaryText}" HorizontalAlignment="Center"
Text="Here you can create accounts" VerticalAlignment="Center" />
Text="Here, you can create accounts." VerticalAlignment="Center" />
</StackPanel>


Expand Down
2 changes: 1 addition & 1 deletion PixaiBot/UI/View/AccountInfoLoggerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TextBlock FontWeight="Regular" Foreground="#2d3436" Style="{StaticResource TitleText}"
HorizontalAlignment="Center" Text="Account Info Logger" VerticalAlignment="Center" />
<TextBlock FontWeight="Regular" Style="{StaticResource SecondaryText}" HorizontalAlignment="Center"
Text="Here you can log your accounts info to text file" VerticalAlignment="Center" />
Text="Here, you can log your account information to a text file." VerticalAlignment="Center" />
</StackPanel>


Expand Down
2 changes: 1 addition & 1 deletion PixaiBot/UI/View/AccountListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<TextBlock Style="{StaticResource SecondaryText}"
Text="Here you can see your accounts list and edit accounts" HorizontalAlignment="Center" />
Text="Here, you can view your list of accounts and edit them." HorizontalAlignment="Center" />
</StackPanel>

<Grid Grid.Row="1" Width="350" Height="500">
Expand Down
2 changes: 1 addition & 1 deletion PixaiBot/UI/View/CreditClaimerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<TextBlock FontWeight="Regular" Foreground="#2d3436" Style="{StaticResource TitleText}"
HorizontalAlignment="Center" Text="Dashboard" VerticalAlignment="Center" />
<TextBlock FontWeight="Regular" Style="{StaticResource SecondaryText}" HorizontalAlignment="Center"
Text="Here you can find claim button or info about added accounts" VerticalAlignment="Center" />
Text="Here, you can find the claim button and basic bot information." VerticalAlignment="Center" />
</StackPanel>


Expand Down
2 changes: 1 addition & 1 deletion PixaiBot/UI/View/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<TextBlock FontWeight="Regular" Foreground="#2d3436" Style="{StaticResource TitleText}"
HorizontalAlignment="Center" Text="Settings" VerticalAlignment="Center" />
<TextBlock FontWeight="Regular" Style="{StaticResource SecondaryText}" HorizontalAlignment="Center"
Text="Here you can add accounts and configure bot" VerticalAlignment="Center" />
Text="Here, you can add accounts and configure the bot." VerticalAlignment="Center" />
</StackPanel>

<Grid Grid.Row="1" Margin="0 -5 0 0">
Expand Down
3 changes: 3 additions & 0 deletions PixaiBot/UI/ViewModel/AccountCreatorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ private async void StartAccountCreation()
? new ProxyDriverCreationStrategy(_proxyManager)
: new HiddenDriverCreationStrategy();

if(_configManager.GetConfig().ToastNotifications) _toastNotificationSender.SendNotification("PixaiBot", "Account creation process started", NotificationType.Information);

await Task.Run(() =>
{

Expand All @@ -133,6 +135,7 @@ private void StopCreating()
{
IsRunning = false;
OperationStatus = "Idle.";
if (_configManager.GetConfig().ToastNotifications) _toastNotificationSender.SendNotification("PixaiBot", "Account creation process ended", NotificationType.Information);
AccountsCreatorButtonText = "Start Account Creation";
_tokenSource.Cancel();
_logger.Log("Account creation process ended", _logger.ApplicationLogFilePath);
Expand Down
Loading

0 comments on commit 98dd4a7

Please sign in to comment.