public void ExecuteUserOptionsCommand() { if (!userOptionsReceived) { ConnectionStatus = "Requesting options from CMS service..."; IsAuthenticationRequired = false; } Services.ConnectionManager manager = new Services.ConnectionManager(); var login = new StubLoginInfo { Hostname = HostName, Security = 0, Port = PortNumber }; manager.GetUserOptions(login, (state, options) => { App.Current.Dispatcher.BeginInvokeOnMainThread(new Action(() => UserOptionsRetrieved(state, options, manager))); }); }
public void UserOptionsRetrieved(ConnectionSystemState state, UserOptions options, Services.ConnectionManager manager) { if (manager == null || (manager.Hostname == HostName && manager.Port == PortNumber)) { if (options == null || options.GroupID == null || options.Locale == null) { GroupIDs = new List <Symbol>(); SelectedGroup = null; LocaleIDs = new List <string>(); SelectedLocale = string.Empty; userOptionsReceived = false; IsAuthenticationRequired = false; if (state == ConnectionSystemState.NotReady) { ConnectionStatus = "Initialising connection..."; IsAuthenticationRequired = false; } else { ConnectionStatus = "Cannot connect"; IsAuthenticationRequired = false; } } else if (manager != null) { GroupIDs = options.GroupID.ToList(); LocaleIDs = options.Locale.ToList(); SelectedGroup = GroupIDs[0]; SelectedLocale = LocaleIDs[0]; ConnectionStatus = "Server contacted"; IsAuthenticationRequired = true; userOptionsReceived = true; if (!options.AuthenticationRequired) { Username = string.Empty; } } } }