aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.BL
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-20 17:46:21 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-20 17:46:21 +0300
commit54ef796c5afa8d1ccb4b8b148d765f590b4de03a (patch)
treee3b1390c25736abe588048421844f0a17905ba68 /Software/Visual_Studio/FSE/Tango.FSE.BL
parent128a245cf12d7720e0fd0cea8810426ac32bc84d (diff)
downloadTango-54ef796c5afa8d1ccb4b8b148d765f590b4de03a.tar.gz
Tango-54ef796c5afa8d1ccb4b8b148d765f590b4de03a.zip
Improved Gateway environments handling.
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.BL')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedLoginResponse.cs8
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.BL/Gateway/GatewayClient.cs3
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.BL/Services/AuthenticationService.cs8
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.BL/Services/GatewayService.cs4
4 files changed, 17 insertions, 6 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedLoginResponse.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedLoginResponse.cs
index f01f53f00..cc5a1de80 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedLoginResponse.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedLoginResponse.cs
@@ -13,8 +13,14 @@ namespace Tango.FSE.BL.CacheEntities
/// </summary>
public class CachedLoginResponse
{
- public LoginResponse Response { get; set; }
[BsonId]
+ public String ID
+ {
+ get { return Email + "_" + "Env_" + EnvironmentId; }
+ }
+
+ public String EnvironmentId { get; set; }
+ public LoginResponse Response { get; set; }
public String Email { get; set; }
public String Password { get; set; }
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Gateway/GatewayClient.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Gateway/GatewayClient.cs
index f63ab354b..aab238342 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Gateway/GatewayClient.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Gateway/GatewayClient.cs
@@ -315,6 +315,9 @@ namespace Tango.MachineService.Gateway
[Newtonsoft.Json.JsonProperty("MachineServiceAddress", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string MachineServiceAddress { get; set; }
+ [Newtonsoft.Json.JsonProperty("DisplayIndex", Required = Newtonsoft.Json.Required.Always)]
+ public int DisplayIndex { get; set; }
+
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/AuthenticationService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/AuthenticationService.cs
index ce2269cb8..e43ecb4cf 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/AuthenticationService.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/AuthenticationService.cs
@@ -49,7 +49,8 @@ namespace Tango.FSE.BL.Services
{
Response = response,
Email = request.Email,
- Password = request.Password
+ Password = request.Password,
+ EnvironmentId = Authentication.CurrentEnvironment.ID
});
}
}
@@ -82,11 +83,12 @@ namespace Tango.FSE.BL.Services
{
using (var cache = DiskCache.CreateContext())
{
- var cachedResponse = cache.Database.GetCollection<CachedLoginResponse>(LOGIN_RESPONSES_COLLECTION).FindOne(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password);
+ String currentEnvironmentID = Authentication.CurrentEnvironment.ID;
+ var cachedResponse = cache.Database.GetCollection<CachedLoginResponse>(LOGIN_RESPONSES_COLLECTION).FindOne(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password && x.EnvironmentId == currentEnvironmentID);
if (cachedResponse == null)
{
- throw new KeyNotFoundException($"Could not locate cached response for {request.Email}.");
+ throw context.LastError;
}
cachedResponse.Response.PasswordChangeRequired = false;
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/GatewayService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/GatewayService.cs
index bd82d3615..f7c603fe2 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/GatewayService.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/GatewayService.cs
@@ -44,7 +44,7 @@ namespace Tango.FSE.BL.Services
using (HttpClient http = new HttpClient())
{
GatewayClient client = new GatewayClient(ConfigurationManager.AppSettings.Get("GatewayUrl"), http);
- var list = client.GetEnvironments(new EnvironmentsRequest()).Environments.ToList();
+ var list = client.GetEnvironments(new EnvironmentsRequest()).Environments.OrderBy(x => x.DisplayIndex).ToList();
LogManager.Log("Online environments retrieved successfully. Caching environments...");
@@ -86,7 +86,7 @@ namespace Tango.FSE.BL.Services
using (var cache = DiskCache.CreateContext())
{
var collection = cache.Database.GetCollection<EnvironmentConfiguration>(ENVIRONMENTS_COLLECTION);
- var environments = collection.FindAll().ToList();
+ var environments = collection.FindAll().OrderBy(x => x.DisplayIndex).ToList();
if (environments.Count == 0)
{