private async void SendGetAppInfoRequest(Contracts.StateChangedEvent stateEvent)
        {
            var serviceUrl = _servicesCollector.GetServiceUrl(stateEvent.ServiceName);

            if (serviceUrl != null)
            {
                var query = HttpUtility.ParseQueryString(string.Empty);
                query["serviceName"] = _serviceConfig.GetServiceName();
                query["hash"]        = Uri.EscapeDataString(stateEvent.AppState.Hash);

                var response = await _httpClient.GetAsync(serviceUrl + "?" + query.ToString());

                var formattedResponse = await response.Content.ReadAsStringAsync();

                var serviceName = _serviceConfig.GetServiceAddress();
                var appInfo     = JsonConvert.DeserializeObject <AppInfoEx>(formattedResponse);
                appInfo.Weight = _servicesCollector.GetServiceWeight(appInfo.ServiceName);

                AppInfoStorageController.CheckAndSetAppInfo(appInfo, serviceName, stateEvent.ServiceName);
            }
        }
Пример #2
0
 private static void ProcessAppsSate(AppsHash appsState, ServiceItem service)
 {
     foreach (KeyValuePair <string, AppInfoEx> entry in appsState)
     {
         entry.Value.Weight = (entry.Value.ServiceName == _serviceConfig.GetServiceName()) ? 0 : _servicesCollector.GetServiceWeight(entry.Value.ServiceName);
         AppInfoStorageController.CheckAndSetAppInfo(entry.Value, _serviceConfig.GetServiceAddress(), service.Url);
     }
 }