Update packages, add exception handling, update error handling (#34)

* add partner center http error codes

* add system.text.json remove newtonsoft, update hdcm package

* add try catch logic to http calls, add LogExceptionToConsole method, update json to system.text.json

* update LogExceptionToConsole

* revert back to newtonsoft json for now

* update Microsoft.Devices.HardwareDevCenterManager package to 2.2.7

* remove catch for HttpRequestException, now handled in Microsoft.Devices.HardwareDevCenterManager package

* add error code and message constants, add addtional error codes

* add EntityNotFound and RequestInvalidForCurrentState logic

* update LogExceptionToConsole summary

* code cleanup for AssemblyInfo
This commit is contained in:
Ben Carpenter 2022-04-10 12:08:11 -07:00 коммит произвёл GitHub
Родитель ba213fe9af
Коммит fab8e1f8ac
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 586 добавлений и 427 удалений

Просмотреть файл

@ -1,7 +1,7 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
--*/
namespace SurfaceDevCenterManager
@ -55,6 +55,23 @@ namespace SurfaceDevCenterManager
TRANSLATE_SUBMISSION_ID_MISSING = -44,
TRANSLATE_PUBLISHER_ID_MISSING = -45,
TRANSLATE_API_FAILED = -46,
HTTP_429_RATE_LIMIT_EXCEEDED = -429
SUBMISSION_ENTITY_NOT_FOUND = -47,
COMMIT_REQUEST_INVALID_FOR_CURRENT_STATE = -48,
HTTP_429_RATE_LIMIT_EXCEEDED = -429,
PARTNER_CENTER_HTTP_EXCEPTION = -1000
}
// https://docs.microsoft.com/en-us/windows-hardware/drivers/dashboard/get-product-data#error-codes
internal static class ErrorCodeConstants
{
public const string EntityNotFound = "entityNotFound";
public const string RequestInvalidForCurrentState = "requestInvalidForCurrentState";
}
//
internal static class ErrorMessageConstants
{
public const string OnlyPendingSubmissionsCanBeCommitted = "Only pending submissions can be committed.";
public const string InitialSubmissionAlreadyExists = "Initial submission already exists";
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SurfaceDevCenterManager")]
@ -13,8 +13,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
@ -24,11 +24,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]

Просмотреть файл

@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -25,7 +26,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.1.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
@ -101,7 +101,7 @@
<Version>5.8.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.Devices.HardwareDevCenterManager">
<Version>2.0.4</Version>
<Version>2.2.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
<Version>5.2.8</Version>

Просмотреть файл

@ -1,7 +1,7 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
--*/
using Microsoft.Devices.HardwareDevCenterManager.Utility;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
@ -99,16 +99,17 @@ namespace SurfaceDevCenterManager.Utility
{
try
{
myCreds = new List<AuthorizationHandlerCredentials>();
myCreds.Add(new AuthorizationHandlerCredentials()
myCreds = new List<AuthorizationHandlerCredentials>
{
TenantId = Environment.GetEnvironmentVariable("SDCM_CREDS_TENANTID"),
ClientId = Environment.GetEnvironmentVariable("SDCM_CREDS_CLIENTID"),
Key = Environment.GetEnvironmentVariable("SDCM_CREDS_KEY"),
Url = new Uri(Environment.GetEnvironmentVariable("SDCM_CREDS_URL"), UriKind.Absolute),
UrlPrefix = new Uri(Environment.GetEnvironmentVariable("SDCM_CREDS_URLPREFIX"), UriKind.Relative)
});
new AuthorizationHandlerCredentials()
{
TenantId = Environment.GetEnvironmentVariable("SDCM_CREDS_TENANTID"),
ClientId = Environment.GetEnvironmentVariable("SDCM_CREDS_CLIENTID"),
Key = Environment.GetEnvironmentVariable("SDCM_CREDS_KEY"),
Url = new Uri(Environment.GetEnvironmentVariable("SDCM_CREDS_URL"), UriKind.Absolute),
UrlPrefix = new Uri(Environment.GetEnvironmentVariable("SDCM_CREDS_URLPREFIX"), UriKind.Relative)
}
};
return myCreds;
}