private void HandleConnectionFailed(object sender, ErrorEventArgs e) { // disconnect on connect error ConfigurationFileName = null; TaskboardService.Disconnect(); EnsureConfigurationModel(); OnPropertyChanged("IsConnected"); SelectedWorkItem = null; OnConnectCompleted(); IsConnecting = false; // TODO: Visualize the issue }
public void OpenConfiguration(string fileName) { IsConnecting = true; // inform configuration service to use file ConfigurationService.UseMemoryFile = false; // Note: When starting with a new config the config will be set up based on the current team project // That's why we still need access to it var configuration = ConfigurationService.ReadTaskboardConfiguration(fileName); // A configuration always contains it's connection data. Therefore we disconnect the taskboard service // and reconnect it afterwards using the connection data from the configuration TaskboardService.Disconnect(); if (!configuration.IsAssociatedWithTeamProject) { EnsureConfigurationModel(); ConfigurationViewModel.ConfigurationData = ConfigurationFileName = fileName; IsConnecting = false; return; } bool connectSucceeded = false; EventHandler <LoginDataEventArgs> handleRequestLoginData = delegate(object sender, LoginDataEventArgs args) { args.LoginData.TeamProjectCollectionUri = new Uri(configuration.TeamProjectCollection); args.LoginData.TeamProjectName = configuration.TeamProject; }; EventHandler handleTaskboardServiceConnected = delegate { connectSucceeded = true; }; TaskboardService.RequestLoginData += handleRequestLoginData; TaskboardService.Connected += handleTaskboardServiceConnected; TaskboardService.Connect(); TaskboardService.RequestLoginData -= handleRequestLoginData; TaskboardService.Connected -= handleTaskboardServiceConnected; if (connectSucceeded) { ConfigurationFileName = fileName; MruFileManager.AddFile(fileName); EnsureConfigurationModel(); } else { // TODO: Handle the case when connection was not possible ConfigurationFileName = null; EnsureConfigurationModel(); } IsConnecting = false; }
private void PerformQuickConnect(Uri teamProjectCollectionUri, string projectName) { // Before connecting to a new team project we close the current configuration ConfigurationFileName = null; ConfigurationService.UseMemoryFile = true; TaskboardService.Disconnect(); ConfigurationViewModel.QueryItem = null; OnPropertyChanged("IsConnected"); // Now prepare for connection and connect. In case the service cannot connect it will ask for login data...and we will answer TaskboardService.LoginData = Factory.CreateObject <ILoginData>(); TaskboardService.LoginData.TeamProjectCollectionUri = teamProjectCollectionUri; TaskboardService.LoginData.TeamProjectName = projectName; TaskboardService.Connect(); IsConnecting = false; OnConnectCompleted(); OnPropertyChanged("IsConnected"); }