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 PerformConnect(string fileName) { var config = ConfigurationService.ReadTaskboardConfiguration(fileName); ILoginData loginData = Factory.CreateObject <ILoginData>(); loginData.TeamProjectCollectionUri = new Uri(config.TeamProjectCollection); loginData.TeamProjectName = config.TeamProject; TaskboardService.LoginData = loginData; IsConnecting = true; TaskboardService.Connect(); OnConnectCompleted(); OnPropertyChanged("IsConnected"); OpenConfiguration(fileName); 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"); }