mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-06-07 22:59:14 +08:00
Add Run multiple commands at one time
This commit is contained in:
parent
78be273c7a
commit
41c644f2af
@ -442,7 +442,7 @@ namespace GrasscutterTools.Forms
|
||||
/// <returns>是否执行成功</returns>
|
||||
private async Task<bool> RunRawCommands(string commands)
|
||||
{
|
||||
if (commands.IndexOf('|') == -1)
|
||||
if (commands.IndexOf('|') == -1 || Common.OC?.CanInvokeMultipleCmd == true)
|
||||
return await RunCommands(FormatCommand(commands));
|
||||
return await RunCommands(commands.Split('|').Select(FormatCommand).ToArray());
|
||||
}
|
||||
|
@ -44,11 +44,28 @@ namespace GrasscutterTools.OpenCommand
|
||||
|
||||
public bool CanInvoke { get; private set; }
|
||||
|
||||
private Version version = new Version(1, 6, 1);
|
||||
|
||||
public Version Version
|
||||
{
|
||||
get => version;
|
||||
private set
|
||||
{
|
||||
version = value;
|
||||
CanInvokeMultipleCmd = version >= new Version(1, 7);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanInvokeMultipleCmd { get; private set; }
|
||||
|
||||
public async Task<bool> Ping()
|
||||
{
|
||||
//try
|
||||
//{
|
||||
var response = await DoRequest("ping");
|
||||
if (response.Data is string str && Version.TryParse(str, out var version))
|
||||
Version = version;
|
||||
|
||||
return response.RetCode == 200;
|
||||
//}
|
||||
//catch (Exception)
|
||||
|
@ -190,11 +190,21 @@ namespace GrasscutterTools
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var cmd in commands.Split('|').Select(FormatCommand))
|
||||
Common.OC.Ping().Wait(1000);
|
||||
|
||||
if (Common.OC.CanInvokeMultipleCmd)
|
||||
{
|
||||
var msg = Common.OC.Invoke(cmd).Result;
|
||||
var msg = Common.OC.Invoke(FormatCommand(commands)).Result;
|
||||
Console.WriteLine(string.IsNullOrEmpty(msg) ? "OK" : msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var cmd in commands.Split('|').Select(FormatCommand))
|
||||
{
|
||||
var msg = Common.OC.Invoke(cmd).Result;
|
||||
Console.WriteLine(string.IsNullOrEmpty(msg) ? "OK" : msg);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user