diff --git a/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs b/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs index b06eb72..cc12895 100644 --- a/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs +++ b/BackendWorkerService/Quartz/Jobs/EmergencyRecordJob.cs @@ -1,6 +1,7 @@ using FrontendWebApi.Models; using Microsoft.Extensions.Logging; using Quartz; +using Repository.BackendRepository.Implement; using Repository.BackendRepository.Interface; using System; using System.Collections.Generic; @@ -52,8 +53,10 @@ namespace BackendWorkerService.Quartz.Jobs using (HttpClient client = new HttpClient()) { - string username = "stanGG"; - string password = "St12345678"; + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = backendRepository.GetAllAsync(sqlObix).Result; + string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault(); + string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault(); string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); diff --git a/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs b/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs index d49c272..c230c8f 100644 --- a/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs +++ b/BackendWorkerService/Quartz/Jobs/WeatherAPIJob.cs @@ -42,8 +42,11 @@ namespace BackendWorkerService.Quartz.Jobs { try { - string username = "stanGG"; - string password = "St12345678"; + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + + var variableObix = backgroundServiceRepository.GetAllAsync(sqlObix).Result; + string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault(); + string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault(); string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(url); Postrequest.Method = "POST"; diff --git a/FrontendWebApi/ApiControllers/AlarmController.cs b/FrontendWebApi/ApiControllers/AlarmController.cs index 170053a..4a6c11c 100644 --- a/FrontendWebApi/ApiControllers/AlarmController.cs +++ b/FrontendWebApi/ApiControllers/AlarmController.cs @@ -61,8 +61,10 @@ namespace FrontendWebApi.ApiControllers using (HttpClient client = new HttpClient()) { - string username = "stanGG"; - string password = "St12345678"; + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = frontendRepository.GetAllAsync(sqlObix).Result; + string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault(); + string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault(); string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); diff --git a/FrontendWebApi/ApiControllers/WarningValueController.cs b/FrontendWebApi/ApiControllers/WarningValueController.cs index 54111b9..e243490 100644 --- a/FrontendWebApi/ApiControllers/WarningValueController.cs +++ b/FrontendWebApi/ApiControllers/WarningValueController.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using Repository.BackendRepository.Implement; +using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System; using System.Collections.Generic; @@ -82,8 +83,10 @@ namespace FrontendWebApi.ApiControllers using (HttpClient client = new HttpClient()) { apiUrl = Path.Combine(baseApiUrl, "obix/config/", apiUrl); - string username = "stanGG"; - string password = "St12345678"; + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = frontendRepository.GetAllAsync(sqlObix).Result; + string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault(); + string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault(); string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); @@ -165,8 +168,10 @@ namespace FrontendWebApi.ApiControllers using (HttpClient client = new HttpClient()) { apiUrl = Path.Combine(baseApiUrl, "obix/config/", apiUrl); - string username = "stanGG"; - string password = "St12345678"; + var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'"; + var variableObix = frontendRepository.GetAllAsync(sqlObix).Result; + string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault(); + string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault(); string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);