Example #1
0
 /// <summary>
 /// Destroy the link to the Windows 7 HID driver.
 /// </summary>
 /// <returns></returns>
 private void disconnectWindowsTouch()
 {
     // Remove any provider links.
     //if (this.pTouchDevice != null)
     //    this.pTouchDevice.Provider = null;
     this.pTouchDevice = null;
 }
Example #2
0
 public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (values[0] == null)
     {
         return(null);
     }
     else
     {
         Guid providerId = new Guid(values[0].ToString());
         IEnumerable <ProviderHandler> providers = values[1] as IEnumerable <ProviderHandler>;
         if (providers == null)
         {
             return(null);
         }
         ProviderHandler selectedProvider = providers.FirstOrDefault(x => x.ProviderId.Equals(providerId));
         if (selectedProvider == null)
         {
             return(null);
         }
         else
         {
             return(selectedProvider.ProviderName);
         }
     }
 }
Example #3
0
        /// <summary>
        /// Create the link to the Windows 7 HID driver.
        /// </summary>
        /// <returns></returns>
        private bool connectWindowsTouch()
        {
            try
            {
                // Close any open connections.
                disconnectWindowsTouch();

                // Reconnect with the new API.
                this.pTouchDevice = new ProviderHandler();
                return(true);
            }
            catch (Exception pError)
            {
                // Tear down.
                try
                {
                    this.disconnectWindowsTouch();
                }
                catch { }

                // Report the error.
                showMessage(pError.Message, MessageType.Error);
                //MessageBox.Show(pError.Message, "WiiTUIO", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
Example #4
0
        public IEnumerable <Provider> GetAllProviders()
        {
            // return providers;
            ProviderHandler ph  = new ProviderHandler();
            List <Provider> prv = ph.retrieveAllProviders();

            return(prv);
        }
Example #5
0
        /// <summary>
        /// Check for form errors.
        /// </summary>
        /// <returns>Whether or not configuration has been serialized already.</returns>
        public bool Validate()
        {
            foreach (ProviderElement provider in Providers)
            {
                Guid            providerId      = new Guid(provider.ReferenceName);
                ProviderHandler providerHandler = AllProviders.FirstOrDefault(x => x.ProviderId.Equals(providerId));
                if (providerHandler != null)
                {
                    RegisterFilterStringExtension(providerHandler.ProviderDescriptionAttribute.ShellAdapterIdentifier, providerId);
                }
            }

            bool xmlHasBeenSerialized = false;

            m_formErrors.Clear();

            var invalidProviders = from p in Providers
                                   where !Guid.Empty.Equals(new Guid(p.ReferenceName)) &&
                                   !AllProviders.Select(x => x.ProviderId).Contains(new Guid(p.ReferenceName))
                                   select p;

            foreach (var provider in invalidProviders)
            {
                m_formErrors.Add(string.Format("Provider '{0}' not found", provider.FriendlyName));
            }

            if (Sessions.Count == 0)
            {
                m_formErrors.Add("Need to add at least 1 session.");
            }
            else
            {
                foreach (SerializableSession session in SerializableSessions)
                {
                    if (!session.LeftMigrationSource.IsConfigured)
                    {
                        m_formErrors.Add("Need to configure left migration source for " + session.Model.FriendlyName);
                    }
                    if (!session.RightMigrationSource.IsConfigured)
                    {
                        m_formErrors.Add("Need to configure right migration source for " + session.Model.FriendlyName);
                    }
                    if (session.Model.Filters.FilterPair.Count == 0 && session.LeftMigrationSource.IsConfigured && session.RightMigrationSource.IsConfigured)
                    {
                        m_formErrors.Add("Need to add filter pair");
                    }
                }
                if (m_formErrors.Count == 0)
                {
                    // no form errors, check xml errors
                    SerializedContent    = Serialize();
                    xmlHasBeenSerialized = true;
                }
            }

            return(xmlHasBeenSerialized);
        }
Example #6
0
        public IHttpActionResult GetProvider(int id)
        {
            ProviderHandler ph  = new ProviderHandler();
            Provider        prv = ph.retrieveProivder(id);

            if (prv == null)
            {
                return(NotFound());
            }
            return(Ok(prv));
        }
Example #7
0
        public void LoadConflictTypes()
        {
            ExtensibilityViewModel = new ExtensibilityViewModel();

            // load corresponding shell adapters and decorate extensibility view model, e.g. connect dialogs, conflict types (assert if user controls not paired)
            foreach (MigrationSource migrationSource in DataModel.Configuration.SessionGroup.MigrationSources.MigrationSource)
            {
                Guid sourceId   = new Guid(migrationSource.InternalUniqueId);
                Guid providerId = new Guid(migrationSource.ProviderReferenceName);

                Guid            shellAdapterIdentifier;
                ProviderHandler providerHandler = ConfigViewModel.AllProviders.FirstOrDefault(x => x.ProviderId.Equals(providerId));
                if (providerHandler != null)
                {
                    shellAdapterIdentifier = providerHandler.ProviderDescriptionAttribute.ShellAdapterIdentifier;
                }
                else
                {
                    shellAdapterIdentifier = providerId;
                }

                IEnumerable <IConflictTypeView> shellAdapterConflictTypes = PluginManager.GetConflictTypes(shellAdapterIdentifier) ?? new List <IConflictTypeView>();
                IEnumerable <ConflictType>      providerConflictTypes     = ConflictManager.Sync.GetConflictTypes(sourceId);
                IEnumerable <ConflictType>      sessionGroupConflictTypes = ConflictManager.Sync.GetConflictTypes(sourceId);

                foreach (ConflictType conflictType in providerConflictTypes)
                {
                    IConflictTypeView conflictTypeView = shellAdapterConflictTypes.FirstOrDefault(x => x.Guid.Equals(conflictType.ReferenceName));
                    if (conflictTypeView != null)
                    {
                        ExtensibilityViewModel.AddConflictTypeView(conflictTypeView, sourceId);
                    }
                    else
                    {
                        Debug.Fail(string.Format("UserControl not found for conflict type: {0}", conflictType.FriendlyName));
                    }
                }

                foreach (ConflictType conflictType in sessionGroupConflictTypes)
                {
                    IConflictTypeView conflictTypeView = shellAdapterConflictTypes.FirstOrDefault(x => x.Guid.Equals(conflictType.ReferenceName));
                    if (conflictTypeView != null)
                    {
                        ExtensibilityViewModel.AddConflictTypeView(conflictTypeView, Microsoft.TeamFoundation.Migration.Toolkit.Constants.FrameworkSourceId);
                    }
                    else
                    {
                        Debug.Fail(string.Format("UserControl not found for conflict type: {0}", conflictType.FriendlyName));
                    }
                }
            }
        }
Example #8
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            SerializableSource serializableSource = (sender as FrameworkElement).DataContext as SerializableSource;
            ProviderHandler    providerView       = (e.OriginalSource as FrameworkElement).DataContext as ProviderHandler;

            if (serializableSource != null && providerView != null)
            {
                if (m_configuration.Providers.Count(x => providerView.ProviderId.Equals(new Guid(x.ReferenceName))) == 0)
                {
                    ProviderElement provider = new ProviderElement();
                    provider.FriendlyName  = providerView.ProviderName;
                    provider.ReferenceName = providerView.ProviderId.ToString();
                    m_configuration.Providers.Add(provider);
                }

                MigrationSource migrationSource  = serializableSource.Model;
                string          cachedProviderId = migrationSource.ProviderReferenceName;

                IMigrationSourceView serverView = m_configuration.ExtensibilityViewModel.GetMigrationSourceView(providerView.ProviderDescriptionAttribute.ShellAdapterIdentifier);
                serverView.Command(migrationSource);

                if (migrationSource.ProviderReferenceName == null) // user cancelled
                {
                    migrationSource.ProviderReferenceName = cachedProviderId;
                }
                else
                {
                    migrationSource.ProviderReferenceName = providerView.ProviderId.ToString();
                }

                serializableSource.Refresh();

                var session = m_configuration.SerializableSessions.FirstOrDefault(x => x.LeftMigrationSource.Model == migrationSource || x.RightMigrationSource.Model == migrationSource);
                if (session != null)
                {
                    foreach (FilterPair filterPair in session.Model.Filters.FilterPair)
                    {
                        foreach (FilterItem filterItem in filterPair.FilterItem)
                        {
                            if (string.Equals(filterItem.MigrationSourceUniqueId, migrationSource.InternalUniqueId, StringComparison.OrdinalIgnoreCase))
                            {
                                filterItem.FilterString = filterItem.FilterString.Replace("<SourceIdentifier>", migrationSource.SourceIdentifier);
                            }
                        }
                    }
                }
                UpdateActiveProviders();
            }
        }
Example #9
0
        /// <summary>
        /// Returns an IDiffProvider given a Migration source and a Dictionary of the providers found
        /// </summary>
        private IDiffProvider GetDiffProviderForMigrationSource(
            Microsoft.TeamFoundation.Migration.BusinessModel.MigrationSource migrationSource,
            Dictionary <Guid, ProviderHandler> providerHandlers)
        {
            Guid            providerGuid     = new Guid(migrationSource.InternalUniqueId);
            ProviderHandler providerHandler  = providerHandlers[providerGuid];
            Type            diffProviderType = Session.SessionType == SessionTypeEnum.VersionControl ? typeof(IVCDiffProvider) : typeof(IWITDiffProvider);
            IDiffProvider   diffProvider     = providerHandler.Provider.GetService(diffProviderType) as IDiffProvider;

            if (diffProvider == null)
            {
                throw new Exception(string.Format(CultureInfo.InvariantCulture, ServerDiffResources.ProviderDoesNotImplementVCDiffInterface, providerHandler.ProviderName));
            }

            DiffServiceContainer = new ServiceContainer();
            DiffServiceContainer.AddService(typeof(ConfigurationService), new ConfigurationService(Config, Session, providerGuid));
            DiffServiceContainer.AddService(typeof(Session), Session);
            DiffServiceContainer.AddService(typeof(ICredentialManagementService), new CredentialManagementService(Config));

            // If this is a work item session, and the provider implements ILinkProvider, get and initialize
            // the ILinkProvider service and add it to the ServiceContainer so that the IDiffProvider implementation
            // can get and use the ILinkProvider implementation
            ILinkProvider linkProvider = null;

            if (Session.SessionType == SessionTypeEnum.WorkItemTracking)
            {
                DiffServiceContainer.AddService(typeof(ITranslationService), new WITTranslationService(Session, null));

                linkProvider = providerHandler.Provider.GetService(typeof(ILinkProvider)) as ILinkProvider;
                if (linkProvider != null)
                {
                    ServerDiffLinkTranslationService diffLinkTranslationService =
                        new ServerDiffLinkTranslationService(this, new Guid(migrationSource.InternalUniqueId), new LinkConfigurationLookupService(Config.SessionGroup.Linking));
                    DiffServiceContainer.AddService(typeof(ILinkTranslationService), diffLinkTranslationService);

                    linkProvider.Initialize(DiffServiceContainer);
                    linkProvider.RegisterSupportedLinkTypes();
                    DiffServiceContainer.AddService(typeof(ILinkProvider), linkProvider);
                    m_linkProvidersByMigrationSourceId.Add(new Guid(migrationSource.InternalUniqueId), linkProvider);
                }
            }

            diffProvider.InitializeServices(DiffServiceContainer);
            diffProvider.InitializeClient(migrationSource);

            return(diffProvider);
        }
Example #10
0
        private void UpdateActiveProviders()
        {
            ICollection <ProviderElement> providers = m_configuration.Providers;

            bool providersSynced = m_configuration.MigrationSources.Select(x => x.ProviderReferenceName).Where(x => x != null).Distinct().SequenceEqual(providers.Select(x => x.ReferenceName));

            if (!providersSynced)
            {
                providers.Clear();

                foreach (var source in m_configuration.MigrationSources)
                {
                    if (source.ProviderReferenceName != null)
                    {
                        ProviderHandler providerView = m_configuration.AllProviders.FirstOrDefault(x => x.ProviderId.Equals(new Guid(source.ProviderReferenceName)));
                        if (providerView != null && providers.Count(x => providerView.ProviderId.Equals(new Guid(x.ReferenceName))) == 0)
                        {
                            ProviderElement provider = new ProviderElement();
                            provider.FriendlyName  = providerView.ProviderName;
                            provider.ReferenceName = providerView.ProviderId.ToString();
                            providers.Add(provider);
                        }
                    }
                }
            }

            m_configuration.Validate();

            foreach (var session in m_configuration.SerializableSessions)
            {
                if (session.DefaultFilterPair != null)
                {
                    session.DefaultFilterPair.UpdateFilterStringExtensions();
                }
                foreach (var filter in session.FilterPairs)
                {
                    filter.UpdateFilterStringExtensions();
                }
            }

            m_configuration.RefreshFilterStrings();
        }