Skip to content

Commit c738b80

Browse files
committed
Add example for getting license details via the Command Line Interface
1 parent bfceda2 commit c738b80

File tree

5 files changed

+71
-18
lines changed

5 files changed

+71
-18
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,20 @@ Run the following command in your windows command prompt `cmd.exe`
4848
```
4949
"C:\Program Files (x86)\MaxCut Software\MaxCut\MaxCut.exe" license --activate "license code"
5050
```
51-
Example: [ActivateCommand.cs](examples/ActivateCommand.cs) is used in [Program.cs](examples/Program.cs).
51+
Example: [LicenseActivateCommand.cs](examples/LicenseActivateCommand.cs) is used in [Program.cs](examples/Program.cs).
5252

5353
### Getting license details
54+
Run the following command in your windows command prompt `cmd.exe`
55+
```
56+
"C:\Program Files (x86)\MaxCut Software\MaxCut\MaxCut.exe" license --details
57+
```
58+
Example: [LicenseInfoCommand.cs](examples/LicenseInfoCommand.cs) is used in [Program.cs](examples/Program.cs).
5459

5560
### Deactivating a license
61+
Run the following command in your windows command prompt `cmd.exe`
62+
```
63+
"C:\Program Files (x86)\MaxCut Software\MaxCut\MaxCut.exe" license --deactivate
64+
```
5665

57-
An example can be found in [DeactivateCommand.cs](examples/DeactivateCommand.cs) and is being leveraged in [Program.cs](examples/Program.cs).
66+
Example: [LicenseDeactivateCommand.cs](examples/LicenseDeactivateCommand.cs) is used in [Program.cs](examples/Program.cs).
5867

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ namespace examples;
44

55
/**
66
* <summary>
7-
* The <c>ActivateCommand</c> class is responsible for executing the MaxCut software command line interface to activate a license.
7+
* The <c>LicenseActivateCommand</c> class is responsible for executing the MaxCut software command line interface to activate a license.
88
* This class uses the <c>System.Diagnostics.Process</c> class to run the MaxCut executable with the appropriate arguments.
99
* </summary>
1010
*
1111
* <remarks>
1212
* For more information about MaxCut software, visit <a href="https://www.maxcutsoftware.com">MaxCut Software</a>.
1313
* </remarks>
1414
*/
15-
public class ActivateCommand
15+
public class LicenseActivateCommand
1616
{
1717
/**
1818
* <summary>Runs the MaxCut executable to activate the license.</summary>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ namespace examples;
44

55
/**
66
* <summary>
7-
* The <c>DeactivateCommand</c> class is responsible for executing the MaxCut software command line interface to deactivate a license.
7+
* The <c>LicenseDeactivateCommand</c> class is responsible for executing the MaxCut software command line interface to deactivate a license.
88
* This class uses the <c>System.Diagnostics.Process</c> class to run the MaxCut executable with the appropriate arguments.
99
* </summary>
1010
*
1111
* <remarks>
1212
* For more information about MaxCut software, visit <a href="https://www.maxcutsoftware.com">MaxCut Software</a>.
1313
* </remarks>
1414
*/
15-
public class DeactivateCommand
15+
public class LicenseDeactivateCommand
1616
{
1717
/**
1818
* <summary>Runs the MaxCut executable to deactivate the license.</summary>

examples/LicenseInfoCommand.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Diagnostics;
2+
3+
namespace examples;
4+
5+
/**
6+
* <summary>
7+
* The <c>LicenseInfoCommand</c> class is responsible for executing the MaxCut software command line interface to get license information.
8+
* This class uses the <c>System.Diagnostics.Process</c> class to run the MaxCut executable with the appropriate arguments.
9+
* </summary>
10+
*
11+
* <remarks>
12+
* For more information about MaxCut software, visit <a href="https://www.maxcutsoftware.com">MaxCut Software</a>.
13+
* </remarks>
14+
*/
15+
public class LicenseInfoCommand
16+
{
17+
/**
18+
* <summary>Runs the MaxCut executable to get license information.</summary>
19+
*/
20+
public void Run()
21+
{
22+
var startInfo = new ProcessStartInfo
23+
{
24+
FileName = @"C:\Program Files (x86)\MaxCut Software\MaxCut\MaxCut.exe",
25+
Arguments = $"license --details",
26+
RedirectStandardOutput = true,
27+
UseShellExecute = false,
28+
CreateNoWindow = true
29+
};
30+
31+
using var process = Process.Start(startInfo);
32+
process?.WaitForExit();
33+
34+
if (process == null) return;
35+
36+
var result = process.StandardOutput.ReadToEnd();
37+
38+
Console.WriteLine(result);
39+
}
40+
}

examples/Program.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22

33
var entryAssemblyDirectory = AppContext.BaseDirectory;
44

5-
// Example of importing a KDMax file via the MaxCut command line interface.
5+
// // Example of importing a KDMax file via the MaxCut command line interface.
66
// var importKdMaxCommand = new ImportKdMaxCommand();
77
// importKdMaxCommand.Run($"{entryAssemblyDirectory}\\test_files\\kdmax.csv");
8-
9-
// Example of importing a Cab Master file via the MaxCut command line interface.
8+
//
9+
// // Example of importing a Cab Master file via the MaxCut command line interface.
1010
// var importCabMasterCommand = new ImportCabMasterCommand();
1111
// importCabMasterCommand.Run($"{entryAssemblyDirectory}\\test_files\\cabmaster.csv");
12-
13-
// Example of opening a MaxCut job file (.mc3) via the MaxCut command line interface.
12+
//
13+
// // Example of opening a MaxCut job file (.mc3) via the MaxCut command line interface.
1414
// var openMaxCutJobCommand = new OpenMaxCutJobCommand();
1515
// openMaxCutJobCommand.Run($"{entryAssemblyDirectory}\\test_files\\F300.mc3");
16+
//
17+
// // Example of activating a license code via the MaxCut command line interface.
18+
// var licenseActivateCommand = new LicenseActivateCommand();
19+
// licenseActivateCommand.Run("my-license-code");
20+
//
21+
// // Example of deactivating a license code via the MaxCut command line interface.
22+
// var licenseDeactivateCommand = new LicenseDeactivateCommand();
23+
// licenseDeactivateCommand.Run();
1624

17-
// Example of activating a license code via the MaxCut command line interface.
18-
// var activateCommand = new ActivateCommand();
19-
// activateCommand.Run("my-license-code");
20-
21-
// Example of activating a license code via the MaxCut command line interface.
22-
var deactivateCommand = new DeactivateCommand();
23-
deactivateCommand.Run();
25+
// Example of deactivating a license code via the MaxCut command line interface.
26+
var licenseInfoCommand = new LicenseInfoCommand();
27+
licenseInfoCommand.Run();

0 commit comments

Comments
 (0)