Skip to content

Commit 76ea32e

Browse files
Merge pull request #6 from easymorph/ver.1.3
Ver.1.3.4
2 parents fa0b706 + d48eea9 commit 76ea32e

File tree

7 files changed

+29
-5
lines changed

7 files changed

+29
-5
lines changed

src/BusinessLogic/Commands/BaseCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal abstract class BaseCommand
1919
protected readonly IInputEndpoint _input;
2020
protected readonly IMorphServerApiClient _apiClient;
2121
protected readonly CancellationTokenSource _cancellationTokenSource;
22+
public CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource; }
2223

2324
public BaseCommand(IOutputEndpoint output, IInputEndpoint input, IMorphServerApiClient apiClient)
2425
{

src/BusinessLogic/Commands/DownloadFileCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public async Task Execute(Parameters parameters)
6262
progress.Dispose();
6363
progress = null;
6464
}
65+
else if (e.State == FileProgressState.Cancelled)
66+
{
67+
progress.Dispose();
68+
progress = null;
69+
_output.WriteError("File download canceled.");
70+
}
6571

6672
};
6773

src/BusinessLogic/Commands/RunTaskAndWaitCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public RunTaskAndWaitCommand(IOutputEndpoint output, IInputEndpoint input, IMorp
2121
}
2222

2323
public bool IsApiSessionRequired => true;
24+
2425

2526
public async Task Execute(Parameters parameters)
2627
{

src/BusinessLogic/Commands/UploadFileCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ public async Task Execute(Parameters parameters)
6464
progress.Dispose();
6565
progress = null;
6666
}
67-
67+
else if(e.State == FileProgressState.Cancelled)
68+
{
69+
progress.Dispose();
70+
progress = null;
71+
_output.WriteError("File upload canceled.");
72+
}
6873
};
6974

7075
using (var apiSession = await OpenSession(parameters))

src/BusinessLogic/CommandsHandler.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,25 @@ public async Task Handle(Parameters parameters)
4646
parameters.SpaceName = "default";
4747
}
4848

49+
#if DEBUG
50+
await Task.Factory.StartNew (async () => { try { await cmd.Execute(parameters); } catch (Exception ex) { Console.WriteLine(ex.Message); } });
51+
Console.ReadLine();
52+
cmd.CancellationTokenSource.Cancel();
53+
Console.ReadLine();
54+
#else
4955
await cmd.Execute(parameters);
56+
#endif
57+
5058
}
59+
5160
catch (WrongCommandFormatException)
5261
{
5362
_output.WriteError("Wrong command format");
5463

5564
RunUsageSamples.WriteCommadUsage(parameters.Command, _output);
5665

5766
throw;
58-
}
67+
}
5968
finally
6069
{
6170
apiSession?.Dispose();

src/Interfaces/ICommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Linq;
66
using System.Text;
7+
using System.Threading;
78
using System.Threading.Tasks;
89

910
namespace MorphCmd.Interfaces
@@ -12,6 +13,7 @@ namespace MorphCmd.Interfaces
1213
internal interface ICommand
1314
{
1415
Task Execute(Parameters parameters);
16+
CancellationTokenSource CancellationTokenSource { get; }
1517

1618
}
1719
}

src/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[assembly: AssemblyConfiguration("")]
99
[assembly: AssemblyCompany("")]
1010
[assembly: AssemblyProduct("ems-cmd")]
11-
[assembly: AssemblyCopyright("Copyright © EasyMorph Inc. 2017")]
11+
[assembly: AssemblyCopyright("Copyright © EasyMorph Inc. 2017-2018")]
1212
[assembly: AssemblyTrademark("")]
1313
[assembly: AssemblyCulture("")]
1414

@@ -18,5 +18,5 @@
1818
[assembly: Guid("6e61eac0-2957-415d-89af-ea675fc244cb")]
1919

2020

21-
[assembly: AssemblyVersion("1.3.3.0")]
22-
[assembly: AssemblyFileVersion("1.3.3.0")]
21+
[assembly: AssemblyVersion("1.3.4.0")]
22+
[assembly: AssemblyFileVersion("1.3.4.0")]

0 commit comments

Comments
 (0)