Эх сурвалжийг харах

fix appsettings.json, change AbstractConnection.cs - fix HttpClient creating

Dalibor Votruba 4 жил өмнө
parent
commit
8cab0d97eb

+ 14 - 9
AppServer/Connector/AbstractConnection.cs

@@ -51,14 +51,7 @@ namespace BO.Connector
         public void Open(string userName, string userPassword, string magicKey)
         {
             Log(LogSeverityEnum.Trace, $"Opening Connector '{ApiName}' open with magicKey='{magicKey}'");
-            _client = new HttpClient();
-            _client.BaseAddress = new Uri(_uriApiBase, ApiName);
-            _client.Timeout = _timeout;
-            _client.DefaultRequestHeaders.Accept.Clear();
-            _client.DefaultRequestHeaders.Add("User-Agent", "BO.Connector." + ApiName);
-            // Add an Accept header for JSON format.
-            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
-
+            _client = CreateClient();
             InitTicket(magicKey);
             Login(userName, userPassword);
             Log(LogSeverityEnum.Debug, $"Connector '{ApiName}' open for user '{userName}' with timeout setting {_timeout}.");
@@ -174,7 +167,7 @@ namespace BO.Connector
                         foreach (var key in headerAttributes.Keys)
                             req.Headers.Add(key,headerAttributes[key]);
                     req.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-                    resp = await _client.PostAsync(relativeUrlApiCall, req);
+                    resp = await CreateClient().PostAsync(relativeUrlApiCall, req);
                     break;
                 case RestCallTypeEnum.Put:
                     req = new StringContent(_binder.SaveToString(data));
@@ -228,6 +221,18 @@ namespace BO.Connector
         }
 
 
+        private HttpClient CreateClient()
+        {
+            var client = new HttpClient();
+            client.BaseAddress = new Uri(_uriApiBase, ApiName);
+            client.Timeout = _timeout;
+            client.DefaultRequestHeaders.Accept.Clear();
+            client.DefaultRequestHeaders.Add("User-Agent", "BO.Connector." + ApiName);
+            // Add an Accept header for JSON format.
+            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+            return client;
+        }
+
         #endregion
 
     }

+ 37 - 1
AppServer/Web/appsettings.json

@@ -6,5 +6,41 @@
       "Microsoft.Hosting.Lifetime": "Information"
     }
   },
-  "AllowedHosts": "*"
+  "Bo": {
+    "System": {
+      "SessionIdleTimeout": "00:05:00",
+      "AccountSystem": {
+        "Name": "System",
+        "Password": "Fr1cEKd0NTD13",
+        "Email": "system@bo.com",
+        "Culture": "en-US"
+      },
+      "AccountConsole": {
+        "Name": "Console",
+        "Password": "A1Abastr0vA",
+        "Email": "console@bo.com",
+        "Culture": "en-US"
+      },
+      "AccountAdmin": {
+        "Name": "Administrator",
+        "Password": "Pan1d0mAc1",
+        "Email": "admin@bo.com",
+        "Culture": "en-US"
+      }
+    },
+    "Business": {
+      "DefaultBillingPlanCode" :  "UNLIMITED" 
+    },
+    "Api": {
+      "Console": {
+        "MagicKeys": [
+          "6DEC4167-57A6-4333-92DA-ADE009A97DE9",
+          "SHARE"
+        ]
+
+
+      }
+    }
+  }
 }
+