Пример #1
0
        private void HandleConnectionFailed(object sender, ErrorEventArgs e)
        {
            var item = StatusService.EnqueueStatusItem("ConnectionError");

            item.Message = string.Format("A connection error occured: {0}", e.ErrorMessage);
            OnPropertyChanged(string.Empty);
        }
Пример #2
0
 private void HandleTfsCommunicationError(object sender, ErrorEventArgs e)
 {
     if (StatusService != null)
     {
         StatusService.EnqueueStatusItem("TfsCommunicationError");
     }
 }
Пример #3
0
 private void SaveToXml(IConfiguration configuration, string fileName)
 {
     try
     {
         if (UseMemoryFile)
         {
             SaveToMemoryFile(configuration);
         }
         else
         {
             using (StreamWriter s = new StreamWriter(fileName))
             {
                 var serializer = new DataContractSerializer(configuration.GetType(), new[] { typeof(CustomState) });
                 serializer.WriteObject(s.BaseStream, configuration);
             }
         }
     }
     catch (UnauthorizedAccessException)
     {
         Logger.Write(TraceCategory.Warning, "File is not accessible, writing to memory file");
         // when is file readonly or not accessible then use memory file
         SaveToMemoryFile(configuration);
     }
     catch (IOException)
     {
         Logger.Write(TraceCategory.Warning, "File is not accessible, writing to memory file");
         SaveToMemoryFile(configuration);
     }
     catch (Exception e)
     {
         Logger.LogException(e);
         if (StatusService != null)
         {
             string message = string.Format(CultureInfo.InvariantCulture, Resources.CouldNotSaveConfigFile, fileName);
             var    item    = new StatusItem()
             {
                 Id = "CouldNotSaveConfigFile", IsAutoHide = false, Message = message
             };
             StatusService.EnqueueStatusItem(item);
         }
     }
 }
Пример #4
0
        public void EnsureConfigurationModel()
        {
            if (string.IsNullOrEmpty(ConfigurationFileName))
            {
                // Reset all Models
                StatusViewModel = new StatusViewModel(TaskboardService, StatusService, null, WorkItemTemplateProvider,
                                                      Logger);
                ReportViewModel = new ReportViewModel(TaskboardService, ConfigurationService, null)
                {
                    HideReports = false
                };
                ConfigurationViewModel = new ConfigurationViewModel(TaskboardService, ConfigurationService,
                                                                    StatusService, Factory, Logger);
                LinkedWorkItemViewModel = new LinkedWorkItemViewModel(TaskboardService, Logger);
            }
            else
            {
                // Ensure to setup the configuration view model
                ConfigurationViewModel = new ConfigurationViewModel(TaskboardService, ConfigurationService,
                                                                    StatusService, Factory, Logger)
                {
                    ConfigurationData = ConfigurationFileName
                };
                LinkedWorkItemViewModel = new LinkedWorkItemViewModel(TaskboardService, Logger);
                //listen for PropertyChanged event so that we know when CustomStates was updated
                ConfigurationViewModel.PropertyChanged += ConfigurationViewModel_PropertyChanged;
                try
                {
                    ConfigurationViewModel.LoadConfiguration();

                    if (ShowReportViewBarChangedFromUI)
                    {
                        ConfigurationViewModel.HideReportViewer = ShowReportViewerBar;
                        ShowReportViewBarChangedFromUI          = false;
                    }
                    else
                    {
                        if (!CreateNewConfigurationFromExisting)
                        {
                            ShowReportViewerBar = ConfigurationViewModel.HideReportViewer;
                        }
                        else
                        {
                            CreateNewConfigurationFromExisting = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    StatusService.DequeueStatusItem("ApplyConfiguration");
                    var errorMessage = StatusService.EnqueueStatusItem("ConfigurationError");
                    errorMessage.Message = "Configuration could not be loaded";
                    return;
                }
                ConfigurationViewModel.PropertyChanged -= ConfigurationViewModel_PropertyChanged;

                // Build a report view model that fits to the current configuration
                ReportViewModel = new ReportViewModel(TaskboardService, ConfigurationService,
                                                      ConfigurationViewModel.Configuration)
                {
                    ConfigurationData = ConfigurationFileName,
                    HideReports       = ConfigurationViewModel.HideReportViewer
                };
                // Build a status view model that fits to the current configuration
                StatusViewModel = new StatusViewModel(TaskboardService, StatusService,
                                                      ConfigurationViewModel.Configuration,
                                                      WorkItemTemplateProvider, Logger);
                RefreshFilter();
                //check if configuration size is valid. otherwise revert to default
            }
            OnPropertyChanged("ConfigurationViewModel");
            OnPropertyChanged("StatusViewModel");
            OnPropertyChanged("ReportViewModel");

            StatusService.DequeueStatusItem("ApplyConfiguration");
            SyncService.BeginInvoke(DispatcherPriority.Background, new Action <bool>(ConfigurationViewModel.Commit),
                                    false);

            OnSelectFilterItem();
        }
        public void LoadConfiguration(IConfiguration config)
        {
            Configuration = config;
            LinkTypes     = TaskBoardService.GetLinkTypes();
            OnPropertyChanged("LinkTypes");

            if (Configuration.QueryId != Guid.Empty)
            {
                try
                {
                    SetQueryItem(TaskBoardService.GetQueryItem(Configuration.QueryId));
                    CurrentSortField          = PossibleSortFields.SingleOrDefault(sf => sf.Name == Configuration.SortFieldName);
                    CurrentRowSummaryField    = PossibleSummaryFields.SingleOrDefault(sf => sf.Name == Configuration.RowSummaryFieldName);
                    CurrentColumnSummaryField = PossibleSummaryFields.SingleOrDefault(sf => sf.Name == Configuration.ColumnSummaryFieldName);
                    OnPropertyChanged("CurrentSortField");
                    OnPropertyChanged("CurrentRowSummaryField");
                    OnPropertyChanged("CurrentColumnSummaryField");
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    var statusItem = StatusService.EnqueueStatusItem("InvalidQueryId");
                    statusItem.Message = "The configured query is invalid. Please edit the configuration.";
                }
            }

            CurrentSortDirection       = Configuration.SortDirection;
            HideColumnSummaryFieldname = Configuration.HideColumnSummaryFieldName;
            WorkItemSize            = Configuration.WorkItemSize;
            HideReportViewer        = Configuration.HideReportViewer;
            CurrentLinkType         = LinkTypes.FirstOrDefault(linkType => linkType.ReferenceName == Configuration.LinkType);
            CurrentAutoRefreshDelay = Configuration.AutoRefreshDelay;
            OnPropertyChanged("CurrentSortDirection");
            OnPropertyChanged("HideColumnSummaryFieldname");
            OnPropertyChanged("WorkItemSize");
            OnPropertyChanged("CurrentLinkType");
            OnPropertyChanged("CurrentAutoRefreshDelay");
            QueryHierarchy = TaskBoardService.GetWorkItemQueries(true);
            var clonedStates = (from state in Configuration.States select state.Clone() as ICustomState).ToList();

            CustomStates = new ObservableCollection <ICustomState>(clonedStates);
            OnPropertyChanged("CustomStates");

            if (Configuration.ChildItems != null)
            {
                ChildItems = new List <string>(Configuration.ChildItems);
            }
            if (Configuration.BacklogItems != null)
            {
                BacklogItems = new List <string>(Configuration.BacklogItems);
            }

            LoadWorkItemTypes();
            SortDirections = new List <SortDirection>((IEnumerable <SortDirection>)Enum.GetValues(typeof(SortDirection)));
            if (!String.IsNullOrEmpty(Configuration.TeamProject))
            {
                TeamProjectName = Configuration.TeamProject;
            }
            if (!String.IsNullOrEmpty(Configuration.TeamProjectCollection))
            {
                TeamProjectCollectionUri = new Uri(Configuration.TeamProjectCollection);
            }

            TaskBoardService.ApplyConfiguration(Configuration);
            OnPropertyChanged("CustomStates");
            IsConfigurationLoaded = true;
        }