{
// ReSharper disable DoNotCallOverridableMethodsInConstructor
//Caliburn.Micro uses DisplayName for the view's title
- DisplayName = "Pithos Preferences";
+ DisplayName = "Pithos+ Preferences";
// ReSharper restore DoNotCallOverridableMethodsInConstructor
_windowManager = windowManager;
}
}
- public async Task RefreshApiKey()
+ public void RefreshApiKey()
{
- _events.Publish(new Notification { Title = "Authorization failed", Message = "Your API Key has probably expired. You will be directed to a page where you can renew it", Level = TraceLevel.Error });
-
+ //_events.Publish(new Notification { Title = "Authorization failed", Message = "Your API Key has probably expired. You will be directed to a page where you can renew it", Level = TraceLevel.Error });
+ if (CurrentAccount == null)
+ return;
try
{
- var credentials = await PithosAccount.RetrieveCredentials(Settings.PithosLoginUrl);
+ var name = CurrentAccount.AccountName;
+
+ var loginUri = new Uri(new Uri(CurrentAccount.ServerUrl), "login");
+ var credentials = PithosAccount.RetrieveCredentials(loginUri.ToString(),name);
+ if (credentials==null)
+ return;
//The server will return credentials for a different account, not just the current account
//We need to find the correct account first
- var account = Accounts.First(act => act.AccountName == credentials.UserName);
+ var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == ?? );
account.ApiKey = credentials.Password;
account.IsExpired = false;
Settings.Save();
{
Shell.OpenLogPath();
}
+
+ public void OpenLogConsole()
+ {
+ var logView=IoC.Get<LogConsole.LogConsoleViewModel>();
+ _windowManager.ShowWindow(logView);
+ }
+
public void SaveChanges()
{
DoSave();
{
Settings.Accounts.Add(account);
}
-
+
Settings.Save();
- foreach (var account in _accountsToRemove)
+ try
{
- Shell.RemoveMonitor(account.AccountName);
- }
+ foreach (var account in _accountsToRemove)
+ {
+ Shell.RemoveMonitor(account.AccountName);
+ Shell.RemoveAccountFromDatabase(account);
+ }
- foreach (var account in Settings.Accounts)
- {
- Shell.MonitorAccount(account);
+ foreach (var account in Settings.Accounts)
+ {
+ Shell.MonitorAccount(account);
+ }
+ }
+ finally
+ {
+ _accountsToRemove.Clear();
+ _accountsToAdd.Clear();
}
NotifyOfPropertyChange(()=>Settings);
if (_windowManager.ShowDialog(wizard) == true)
{
string selectedPath = wizard.AccountPath;
- var initialRootPath = Path.Combine(selectedPath, "Okeanos");
+ var initialRootPath = wizard.ShouldCreateOkeanosFolder?
+ Path.Combine(selectedPath, "Okeanos")
+ :selectedPath;
var actualRootPath= initialRootPath;
- int attempt = 1;
- while (Directory.Exists(actualRootPath) || File.Exists(actualRootPath))
+ if (wizard.ShouldCreateOkeanosFolder)
{
- actualRootPath = String.Format("{0} {1}", initialRootPath,attempt++);
+ int attempt = 1;
+ while (Directory.Exists(actualRootPath) || File.Exists(actualRootPath))
+ {
+ actualRootPath = String.Format("{0} {1}", initialRootPath, attempt++);
+ }
}
+ ### Check that the account does not already exist
var newAccount = new AccountSettings
{
}
- public async void AddPithosAccount()
+/*
+ public void AddPithosAccount()
{
- var credentials=await PithosAccount.RetrieveCredentials(Settings.PithosLoginUrl);
+ var credentials=PithosAccount.RetrieveCredentials(null);
+ if (credentials == null)
+ return;
var account = Settings.Accounts.FirstOrDefault(act => act.AccountName == credentials.UserName);
var accountVM = new AccountViewModel(account);
if (account == null)
NotifyOfPropertyChange(() => Accounts);
NotifyOfPropertyChange(()=>Settings);
}
+*/
readonly List<AccountSettings> _accountsToRemove = new List<AccountSettings>();
}
}
+ public bool DebugLoggingEnabled
+ {
+ get { return Settings.DebugLoggingEnabled; }
+ set {
+ Settings.DebugLoggingEnabled = value;
+ NotifyOfPropertyChange(()=>DebugLoggingEnabled);
+ }
+ }
#endregion
SearchOption.AllDirectories))
File.Copy(newFilePath, newFilePath.Replace(oldPath, newPath));
+ Log.InfoFormat("Deleting account folder {0}",oldPath);
Directory.Delete(oldPath, true);
//We also need to change the path of the existing file states