static async Task Run(string[] args) { _httpClient = new HttpClient(new RetryDelegatingHandler.RetryDelegatingHandler()); string middlewareAddress = ConfigurationManager.AppSettings["middlewareAddress"]; var appInfo = new Contracts.AppInfo() { Name = ConfigurationManager.AppSettings["appName"], Url = ConfigurationManager.AppSettings["applicationAddress"], Status = Contracts.AppStatus.Started }; string jsonString = JsonConvert.SerializeObject(appInfo); HttpContent content = new StringContent(jsonString); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var sendStartTask = await _httpClient.PostAsync(middlewareAddress, content); Console.WriteLine(jsonString); Console.WriteLine("Web Applicationr is running."); Console.WriteLine("Press any key to quit."); Console.ReadKey(); appInfo.Status = Contracts.AppStatus.Stoped; jsonString = JsonConvert.SerializeObject(appInfo); content = new StringContent(jsonString); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var sendStopTask = await _httpClient.PostAsync(middlewareAddress, content); }
public void Post(Contracts.AppInfo appInfo) { var appInfoEx = new AppInfoEx() { Name = appInfo.Name, Url = appInfo.Url, Weight = 0, Status = appInfo.Status, Time = 1, Hash = AppInfoStorageController.GenerateHash(appInfo.Url), ServiceName = _serviceConfig.GetServiceName(), }; AppInfoStorageController.StepForwardAndSetAppInfo(appInfoEx); Console.WriteLine("Application with name: " + appInfo.Name + " and status: " + appInfo.Status + " and url: " + appInfo.Url + " and weight: 0 "); Task.WaitAll(SendStateChangedEvent(appInfoEx)); }