Skip to content

Commit

Permalink
Fixed ScheduledTaskHelper 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Inestic committed Mar 25, 2022
1 parent 88cf1ed commit 3194c16
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
3 changes: 3 additions & 0 deletions SophiApp/SophiApp/Controls/SearchBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
CommandParameter="{Binding Path=Text, ElementName=TextBoxSearch}"
Key="Return" />
</TextBox.InputBindings>
<TextBox.ContextMenu>
<ContextMenu Visibility="Collapsed" />
</TextBox.ContextMenu>
</TextBox>
</Grid>
</Border>
Expand Down
2 changes: 1 addition & 1 deletion SophiApp/SophiApp/Controls/TitleLeft.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
</ControlTemplate.Triggers>
</ControlTemplate>
</UserControl.Template>
</UserControl>
</UserControl>
6 changes: 3 additions & 3 deletions SophiApp/SophiApp/Customisations/CustomisationOs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ public static void _700(bool IsChecked)

RegHelper.DeleteKey(RegistryHive.CurrentUser, ACTION_CENTER_APPX_PATH, SHOW_IN_ACTION_CENTER);
ScheduledTaskHelper.TryDeleteTask(appCleanupTask, appNotificationTask, scriptCleanupTask, scriptNotificationTask);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH, SOPHIA_SCRIPT_SCHEDULED_PATH);
RegHelper.DeleteSubKeyTree(RegistryHive.ClassesRoot, _700_WINDOWS_CLEANUP);
}

Expand All @@ -1062,7 +1062,7 @@ public static void _701(bool ISChecked)
}

ScheduledTaskHelper.TryDeleteTask(appSoftwareDistributionTask, scriptSoftwareDistributionTask);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH, SOPHIA_SCRIPT_SCHEDULED_PATH);
}

public static void _702(bool IsChecked)
Expand All @@ -1082,7 +1082,7 @@ public static void _702(bool IsChecked)
}

ScheduledTaskHelper.TryDeleteTask(appClearTempTask, scriptClearTempTask);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH);
ScheduledTaskHelper.TryDeleteFolder(SOPHIA_APP_SCHEDULED_PATH, SOPHIA_SCRIPT_SCHEDULED_PATH);
}

public static void _800(bool IsChecked) => PowerShellHelper.InvokeScript($"{_800_SET_NETWORK_PROTECTION_PS} {(IsChecked ? ENABLED : DISABLED)}");
Expand Down
14 changes: 13 additions & 1 deletion SophiApp/SophiApp/Helpers/DebugHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SophiApp.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Foundation;

namespace SophiApp.Helpers
Expand Down Expand Up @@ -40,7 +41,11 @@ internal class DebugHelper
};

private static List<string> InitLog = new List<string>();

private static List<string> StatusLog = new List<string>();

private static List<string> TraceLog = new List<string>();

private static string DateTime { get => System.DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss"); }

private static void WriteInfoLog(string record)
Expand Down Expand Up @@ -99,7 +104,12 @@ internal static void HasUpdateRelease(ReleaseDto release) => WriteInfoLog(new Li

internal static void RiskAgreed() => WriteStatusLog("USER AGREED TO ASSUME THE RISK AND LIABILITY FOR ANY POSSIBLE DAMAGE");

internal static void Save(string path) => FileHelper.WriteAllLines(path, InfoLog.Split(string.Empty).Merge(ErrorsLog).Split(string.Empty).Merge(InitLog).Split(string.Empty).Merge(StatusLog));
internal static void Save(string path)
{
TraceLog = Environment.StackTrace.Split('\n').ToList();
var debugData = InfoLog.Split(string.Empty).Merge(ErrorsLog).Split(string.Empty).Merge(InitLog).Split(string.Empty).Merge(StatusLog).Split(string.Empty).Merge(TraceLog);
FileHelper.WriteAllLines(path, debugData);
}

internal static void SelectedLocalization(string localization) => WriteStatusLog($"Localization selected: {localization}");

Expand All @@ -115,6 +125,8 @@ internal static void HasUpdateRelease(ReleaseDto release) => WriteInfoLog(new Li

internal static void StartStartupConditions() => WriteStatusLog("The OS conditions checkings started");

internal static void StartupConditionsInvoked(string name) => WriteStatusLog($"{name} is: True");

internal static void StopApplyingSettings(double totalSeconds) => WriteStatusLog($"Applying setting(s) took {totalSeconds:N0} second(s)");

internal static void StopInitTextedElements(double totalSeconds) => WriteStatusLog($"It took {totalSeconds:N0} second(s) to initialize elements");
Expand Down
14 changes: 14 additions & 0 deletions SophiApp/SophiApp/Helpers/ScheduledTaskHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ internal static void TryChangeTaskState(string taskPath, string taskName, bool e
task.Enabled = enable;
}

internal static void TryDeleteFolder(params string[] folders)
{
foreach (var folder in folders)
{
try
{
TryDeleteFolder(folder);
}
catch (Exception)
{
}
}
}

internal static void TryDeleteFolder(string folder)
{
try
Expand Down
2 changes: 2 additions & 0 deletions SophiApp/SophiApp/Helpers/StartupConditionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ await Task.Run(() =>
ConditionHasProblem?.Invoke(null, condition);
break;
}
DebugHelper.StartupConditionsInvoked(condition.GetType().Name);
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions SophiApp/SophiApp/ViewModels/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ private void InitializeProperties()
}

private async Task InitializeTextedElements(string tag) => await Task.Run(() => TextedElements.Where(element => element.Tag == tag)
.ToList()
.ForEach(element => element.Initialize()));
.ToList()
.ForEach(element => element.Initialize()));

private async Task InitializeTextedElementsAsync()
{
Expand Down
11 changes: 0 additions & 11 deletions SophiApp/SophiApp/Views/ViewSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@
Header="{DynamicResource Localization.Settings.Advanced}"
IsChecked="{Binding AdvancedSettingsVisibility}" />

<TextBlock
Margin="{StaticResource BlockIndent}"
Style="{DynamicResource SubHeaderText}"
Text="{DynamicResource Localization.Settings.Debug}" />

<controls:SettingSwitch
Width="290"
Margin="{StaticResource BlockIndent}"
Expand All @@ -137,12 +132,6 @@
IsChecked="{Binding DebugMode}"
Visibility="{Binding DebugMode, Converter={StaticResource BoolToVisibilityConverter}}" />

<controls:CommandButton
Margin="{StaticResource BlockIndent}"
HorizontalAlignment="Left"
Command="{Binding SaveDebugLogCommand}"
Text="{DynamicResource Localization.Settings.Debug.Save}" />

<TextBlock
Margin="{StaticResource BlockIndent}"
Style="{DynamicResource SubHeaderText}"
Expand Down

0 comments on commit 3194c16

Please sign in to comment.