|
@@ -73,13 +73,14 @@ namespace InABox.Mobile
|
|
|
SecureStorage.SetAsync(GlobalVariables.CachePasswordString, App.Settings.Password);
|
|
|
|
|
|
if (App.DBSettings.URLs.Count() > 0)
|
|
|
- SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL1, App.DBSettings.URLs[0]);
|
|
|
-
|
|
|
- if (App.DBSettings.URLs.Count() > 1)
|
|
|
- SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL2, App.DBSettings.URLs[1]);
|
|
|
-
|
|
|
- if (App.DBSettings.URLs.Count() > 2)
|
|
|
- SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL3, App.DBSettings.URLs[2]);
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ foreach (string url in App.DBSettings.URLs)
|
|
|
+ {
|
|
|
+ SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL + count, url);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
catch { }
|
|
|
}
|
|
@@ -89,21 +90,29 @@ namespace InABox.Mobile
|
|
|
try
|
|
|
{
|
|
|
var s = Encryption.Decrypt(GlobalVariables.LoadFromLinkString, "logindetailslink");
|
|
|
- var array = s.Split(',');
|
|
|
- DateTime expiry = DateTime.Parse(array[4]);
|
|
|
+ var index = s.IndexOf("ENDURLS");
|
|
|
+ var substring = s.Substring(index + 8, s.Length - index - 8);
|
|
|
+ var array = substring.Split(",");
|
|
|
+ DateTime expiry = DateTime.Parse(array[2]);
|
|
|
if (DateTime.Now.Subtract(expiry) < new TimeSpan(0, 5, 0))
|
|
|
{
|
|
|
- App.Settings.URL = array[0];
|
|
|
- App.Settings.Port = int.Parse(array[1]);
|
|
|
- App.Settings.UserID = array[2];
|
|
|
- App.Settings.Password = array[3];
|
|
|
+ var urls = s.Substring(0, s.IndexOf("ENDURLS") - 1);
|
|
|
+ App.DBSettings.URLs = urls.Split(",");
|
|
|
+ App.DBSettings.UserID = array[0];
|
|
|
+ App.DBSettings.Password = array[1];
|
|
|
+
|
|
|
ClientFactory.InvalidateUser();
|
|
|
- new LocalConfiguration<ConnectionSettings>().Delete();
|
|
|
- new LocalConfiguration<ConnectionSettings>().Save(App.Settings);
|
|
|
- App.Settings = new LocalConfiguration<ConnectionSettings>().Load();
|
|
|
+ new LocalConfiguration<DatabaseSettings>().Delete();
|
|
|
+ new LocalConfiguration<DatabaseSettings>().Save(App.DBSettings);
|
|
|
+ App.DBSettings = new LocalConfiguration<DatabaseSettings>().Load();
|
|
|
+ GlobalVariables.ChangeUser = true;
|
|
|
if (App.Current.Properties.ContainsKey("SessionID"))
|
|
|
App.Current.Properties.Remove("SessionID");
|
|
|
MobileUtils.SaveToSecureStorage();
|
|
|
+
|
|
|
+ var result = JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
|
|
|
+
|
|
|
+ ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
|
|
|
}
|
|
|
else
|
|
|
GlobalVariables.LoadFromLinkString = "Link has expired";
|