Example #1
0
 public ApplicationViewModel(ITaskboardService taskboardService, IStatusService statusService)
 {
     TaskboardService = taskboardService;
     //TaskboardService.Connected += HandleTaskboardServiceConnected;
     TaskboardService.ConnectionFailed      += HandleConnectionFailed;
     TaskboardService.TfsCommunicationError += HandleTfsCommunicationError;
     TaskboardService.ConfigurationApplied  += HandleConfigurationApplied;
     MruFileManager  = new MruFileManager();
     StatusViewModel = new StatusViewModel(TaskboardService, statusService, null, WorkItemTemplateProvider, Logger);
     ShowPopupWindow = false;
     ShowEditbar     = true;
 }
        public void Commit(bool forceSaveToFile)
        {
            if (!IsConfigurationLoaded)
            {
                return;
            }
            string configurationData = ConfigurationData;

            if (!ConfigurationService.UseMemoryFile &&
                (string.IsNullOrEmpty(configurationData) || !File.Exists(configurationData)))
            {
                return;
            }
            // Now it's time to keep all the settings in the taskboards configuration
            IConfiguration configuration = ConfigurationService.ReadTaskboardConfiguration(configurationData);

            configuration.SortFieldName          = CurrentSortField != null ? CurrentSortField.Name : null;
            configuration.SortDirection          = CurrentSortDirection;
            configuration.AutoRefreshDelay       = CurrentAutoRefreshDelay;
            configuration.RowSummaryFieldName    = CurrentRowSummaryField != null ? CurrentRowSummaryField.Name: null;
            configuration.ColumnSummaryFieldName = CurrentColumnSummaryField != null ? CurrentColumnSummaryField.Name : null;
            EnsureItems(configuration.BacklogItems, BacklogItems);
            EnsureItems(configuration.ChildItems, ChildItems);
            configuration.States.Clear();
            foreach (var state in CustomStates)
            {
                configuration.States.Add(state.Clone() as ICustomState);
            }
            configuration.QueryId  = QueryItem != null ? QueryItem.Id : Guid.Empty;
            configuration.LinkType = CurrentLinkType != null ? CurrentLinkType.ReferenceName : null;
            // Store the current login information. This is required so that double clicking the file will open the right project from the right server
            configuration.TeamProject                = TeamProjectName;
            configuration.TeamProjectCollection      = TeamProjectCollectionUri.ToString();
            configuration.HideColumnSummaryFieldName = HideColumnSummaryFieldname;
            configuration.WorkItemSize               = WorkItemSize;
            configuration.HideReportViewer           = HideReportViewer;
            if (forceSaveToFile)
            {
                ConfigurationService.UseMemoryFile = false;
            }
            // Persist the configuration
            ConfigurationService.SaveTaskboardConfiguration(configurationData, configuration);
            if (!ConfigurationService.UseMemoryFile)
            {
                MruFileManager fileManager = new MruFileManager();
                fileManager.AddFile(ConfigurationData);
            }
            //TODO: is there any reason to re-apply the configuration?
            //TaskBoardService.ApplyConfiguration(configuration);
        }
Example #3
0
        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;
        }