Skip to content

Commit

Permalink
Update DeviceTenantFinder to .NET Core 6.0, add prompt for Device Id (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehall-ms committed Sep 12, 2023
1 parent 641f55d commit fbb73f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
16 changes: 10 additions & 6 deletions DeviceTenantFinder/Src/DeviceTenantFinder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ class Program

public static async Task<int> Main(string[] args)
{
string deviceId = string.Empty;
if (args.Count() != 1)
{
Console.WriteLine("App requires a device id on the command line");
return -1;
Console.Write("Enter a device id >");
deviceId = Console.ReadLine();
}
else
{
deviceId = args[0];
}

if (args[0].Length != 128)
if (deviceId.Length != 128)
{
Console.WriteLine("Device Id Length is expected to be 128 characters, try again");
return -1;
Expand Down Expand Up @@ -85,7 +90,7 @@ public static async Task<int> Main(string[] args)
Devices devices = JsonSerializer.Deserialize<Devices>(result);
foreach (Item item in devices.Items)
{
if (item.DeviceId.ToLower() == args[0].ToLower())
if (item.DeviceId.ToLower() == deviceId.ToLower())
{
deviceFound = true;
tenantId = tenant.Id;
Expand All @@ -105,13 +110,12 @@ public static async Task<int> Main(string[] args)
return -1;
}

Console.WriteLine($"Device Found : {args[0]}");
Console.WriteLine($"Device Found : {deviceId}");
Console.WriteLine($"Tenant Id : {tenantId}");
Console.WriteLine($"Tenant Name : {tenantName}");
Console.WriteLine($"Product Id : {productId}");
Console.WriteLine($"Device Group Id: {deviceGroupId}");


return 0;
}

Expand Down

0 comments on commit fbb73f1

Please sign in to comment.