[BGService][WebApi]將obix帳密寫死的地方改成DB撈
This commit is contained in:
parent
db77070dd3
commit
b97828ca6a
@ -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<KeyValue>(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);
|
||||
|
@ -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<KeyValue>(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";
|
||||
|
@ -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<KeyValue>(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);
|
||||
|
@ -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<KeyValue>(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<KeyValue>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user