finish healthy check & other sources implemtation
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using ModpackUpdater.Apps.Manager.Ui;
|
||||
using ModpackUpdater.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
internal class CheckAllActionsHealthyFeature : PluginFunction, IPluginFeatureProvider<CheckAllActionsHealthyFeature>
|
||||
{
|
||||
public static CheckAllActionsHealthyFeature Instance { get; } = new();
|
||||
|
||||
public CheckAllActionsHealthyFeature() : base(FeatureTypes.Tools, "origin.checkallactionshearlthy", FeatureNamesLangRes.CheckAllActionsHealthy)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.heart_with_pulse, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p
|
||||
|| p.Api.MainWindow is not MainForm mainForm
|
||||
|| mainForm.Controls.Find("radGridView_Actions", true).FirstOrDefault() is not RadGridView gridView
|
||||
|| mainForm.Controls.Find("radWaitingBar_Actions", true).FirstOrDefault() is not RadWaitingBar rwb)
|
||||
return null;
|
||||
|
||||
rwb.StartWaiting();
|
||||
rwb.ShowText = true;
|
||||
var rowsCount = gridView.Rows.Count;
|
||||
rwb.Text = "0 / " + rowsCount;
|
||||
gridView.BeginUpdate();
|
||||
|
||||
var rows = new Dictionary<GridViewRowInfo, InstallAction>();
|
||||
for (var i = 0; i < gridView.Rows.Count; i++)
|
||||
{
|
||||
var row = gridView.Rows[i];
|
||||
var failed = false;
|
||||
|
||||
if (row.Tag is InstallAction action)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var factory = new ModpackFactory();
|
||||
var result = await factory.ResolveSourceUrl(action);
|
||||
failed = string.IsNullOrWhiteSpace(result);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}).Wait();
|
||||
}
|
||||
|
||||
foreach (var c in row.Cells)
|
||||
{
|
||||
c.Style.CustomizeFill = true;
|
||||
c.Style.BackColor = failed ? Color.IndianRed : Color.ForestGreen;
|
||||
}
|
||||
|
||||
rwb.Text = $"{i} / {rowsCount}";
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
gridView.EndUpdate();
|
||||
rwb.ShowText = false;
|
||||
rwb.StopWaiting();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using ModpackUpdater.Apps.Manager.Ui;
|
||||
using ModpackUpdater.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
internal class CheckSingleActionHealthyFeature : PluginFunction, IPluginFeatureProvider<CheckSingleActionHealthyFeature>
|
||||
{
|
||||
public static CheckSingleActionHealthyFeature Instance { get; } = new();
|
||||
|
||||
public CheckSingleActionHealthyFeature() : base(FeatureTypes.ActionsContextMenu, "origin.checksingleactionhearlthy", FeatureNamesLangRes.CheckSingleActionHealthy)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.heart_with_pulse, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p
|
||||
|| p.Api.MainWindow is not MainForm mainForm
|
||||
|| mainForm.Controls.Find("radGridView_Actions", true).FirstOrDefault() is not RadGridView gridView
|
||||
|| gridView.SelectedRows.FirstOrDefault() is not GridViewRowInfo row
|
||||
|| row.Tag is not InstallAction action)
|
||||
return null;
|
||||
|
||||
bool failed = true;
|
||||
string? msg = null;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var factory = new ModpackFactory();
|
||||
var result = await factory.ResolveSourceUrl(action);
|
||||
failed = string.IsNullOrWhiteSpace(result);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
msg = ex.Message;
|
||||
}
|
||||
}).Wait();
|
||||
|
||||
gridView.BeginUpdate();
|
||||
foreach (var c in row.Cells)
|
||||
{
|
||||
c.Style.CustomizeFill = true;
|
||||
c.Style.BackColor = failed ? Color.IndianRed : Color.ForestGreen;
|
||||
}
|
||||
gridView.EndUpdate();
|
||||
|
||||
if (failed && !string.IsNullOrWhiteSpace(msg))
|
||||
MessageBox.Show(msg);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user