This commit is contained in:
Isaiah Williams 2017-05-13 12:04:21 -05:00
Родитель 85390d5a72
Коммит a5f5861965
4 изменённых файлов: 19 добавлений и 10 удалений

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

@ -143,7 +143,7 @@
}, },
"repoUrl": { "repoUrl": {
"type": "string", "type": "string",
"defaultValue": "https://github.com/Microsoft/Partner-Center-Bot.git" "defaultValue": "https://github.com/Microsoft/Partner-Center-Bot"
}, },
"siteName": { "siteName": {
"type": "string", "type": "string",

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

@ -245,10 +245,12 @@ namespace Microsoft.Store.PartnerCenter.Bot.Controllers
/// </exception> /// </exception>
private bool Validate(IBotData botData, IDictionary<string, string> stateData) private bool Validate(IBotData botData, IDictionary<string, string> stateData)
{ {
string uniqueId;
botData.AssertNotNull(nameof(botData)); botData.AssertNotNull(nameof(botData));
stateData.AssertNotNull(nameof(stateData)); stateData.AssertNotNull(nameof(stateData));
if (botData.PrivateConversationData.TryGetValue(BotConstants.UniqueIdentifierKey, out string uniqueId)) if (botData.PrivateConversationData.TryGetValue(BotConstants.UniqueIdentifierKey, out uniqueId))
{ {
if (!uniqueId.Equals(stateData[BotConstants.UniqueIdentifierKey], StringComparison.CurrentCultureIgnoreCase)) if (!uniqueId.Equals(stateData[BotConstants.UniqueIdentifierKey], StringComparison.CurrentCultureIgnoreCase))
{ {

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

@ -11,6 +11,11 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
/// </summary> /// </summary>
internal static class BotConstants internal static class BotConstants
{ {
/// <summary>
/// Name of the application used for identification purposes with the Partner Center API.
/// </summary>
public const string ApplicationName = "US HMSP - Partner Center Bot v0.5";
/// <summary> /// <summary>
/// Key utilized to access the authentication token stored in the user data. /// Key utilized to access the authentication token stored in the user data.
/// </summary> /// </summary>

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

@ -78,7 +78,7 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
{ {
startTime = DateTime.Now; startTime = DateTime.Now;
correlationId = Guid.NewGuid(); correlationId = Guid.NewGuid();
operations = await this.GetAppOperationsAsync(correlationId); operations = await GetAppOperationsAsync(correlationId);
rules = await operations.CountryValidationRules.ByCountry(countryCode).GetAsync(); rules = await operations.CountryValidationRules.ByCountry(countryCode).GetAsync();
@ -95,7 +95,7 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
{ "ParternCenterCorrelationId", correlationId.ToString() } { "ParternCenterCorrelationId", correlationId.ToString() }
}; };
this.service.Telemetry.TrackEvent("GetCountryValidationRulesAsync", eventProperties, eventMetrics); service.Telemetry.TrackEvent("GetCountryValidationRulesAsync", eventProperties, eventMetrics);
return rules; return rules;
} }
@ -114,7 +114,7 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
/// <returns>An instance of <see cref="Customer"/> that represents the specified customer.</returns> /// <returns>An instance of <see cref="Customer"/> that represents the specified customer.</returns>
public async Task<Customer> GetCustomerAsync(CustomerPrincipal principal) public async Task<Customer> GetCustomerAsync(CustomerPrincipal principal)
{ {
return await this.GetCustomerAsync(principal, principal.Operation.CustomerId); return await GetCustomerAsync(principal, principal.Operation.CustomerId);
} }
/// <summary> /// <summary>
@ -145,9 +145,9 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
{ {
startTime = DateTime.Now; startTime = DateTime.Now;
correlationId = Guid.NewGuid(); correlationId = Guid.NewGuid();
operations = await this.GetAppOperationsAsync(correlationId); operations = await GetAppOperationsAsync(correlationId);
if (principal.CustomerId.Equals(this.service.Configuration.PartnerCenterApplicationTenantId)) if (principal.CustomerId.Equals(service.Configuration.PartnerCenterApplicationTenantId))
{ {
customer = await operations.Customers.ById(customerId).GetAsync(); customer = await operations.Customers.ById(customerId).GetAsync();
} }
@ -170,7 +170,7 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
{ "ParternCenterCorrelationId", correlationId.ToString() } { "ParternCenterCorrelationId", correlationId.ToString() }
}; };
this.service.Telemetry.TrackEvent("GetCustomerAsync", eventProperties, eventMetrics); service.Telemetry.TrackEvent("GetCustomerAsync", eventProperties, eventMetrics);
return customer; return customer;
} }
@ -209,11 +209,11 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
{ {
startTime = DateTime.Now; startTime = DateTime.Now;
correlationId = Guid.NewGuid(); correlationId = Guid.NewGuid();
operations = await this.GetAppOperationsAsync(correlationId); operations = await GetAppOperationsAsync(correlationId);
customers = new List<Customer>(); customers = new List<Customer>();
if (principal.CustomerId.Equals(this.service.Configuration.PartnerCenterApplicationTenantId)) if (principal.CustomerId.Equals(service.Configuration.PartnerCenterApplicationTenantId))
{ {
seekCustomers = await operations.Customers.GetAsync(); seekCustomers = await operations.Customers.GetAsync();
customersEnumerator = operations.Enumerators.Customers.Create(seekCustomers); customersEnumerator = operations.Enumerators.Customers.Create(seekCustomers);
@ -461,6 +461,8 @@ namespace Microsoft.Store.PartnerCenter.Bot.Logic
.GetPartnerCenterAppOnlyCredentialsAsync( .GetPartnerCenterAppOnlyCredentialsAsync(
$"{service.Configuration.ActiveDirectoryEndpoint}/{service.Configuration.PartnerCenterApplicationTenantId}"); $"{service.Configuration.ActiveDirectoryEndpoint}/{service.Configuration.PartnerCenterApplicationTenantId}");
PartnerService.Instance.ApplicationName = BotConstants.ApplicationName;
lock (appLock) lock (appLock)
{ {
appOperations = PartnerService.Instance.CreatePartnerOperations(credentials); appOperations = PartnerService.Instance.CreatePartnerOperations(credentials);