public IPlugin IstallNewPlugin(string fileName,
                                       ISonarConfiguration conf,
                                       IConfigurationHelper helper,
                                       INotificationManager manager,
                                       IVsEnvironmentHelper vshelper)
        {
            var assembliesInFile       = this.UnzipFiles(fileName, this.TempInstallPathFolder);
            var assembliesToTempFolder = this.GetAssembliesInTempFolder();
            var plugin = this.LoadPlugin(
                assembliesInFile.ToArray(),
                this.TempInstallPathFolder,
                conf, helper, manager, vshelper);

            if (plugin != null)
            {
                Directory.Delete(this.TempInstallPathFolder, true);
                this.UnzipFiles(fileName, this.PluginsFolder);
            }

            foreach (string path in assembliesInFile)
            {
                var file = Path.GetFileName(path);
                plugin.SetDllLocation(Path.Combine(this.PluginsFolder, file));
            }

            return(plugin);
        }
 public Profile(ISonarRestService service, ISonarConfiguration conf)
 {
     this.conf = conf;
     this.service = service;
     this.Rules = new Dictionary<string, Rule>();
     this.RulesByIternalKey = new Dictionary<string, Rule>();
 }
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="userConnectionConfig">The user connection config.</param>
        /// <param name="associatedProjectIn">The associated project in.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(
            ISonarConfiguration userConnectionConfig,
            Resource associatedProjectIn,
            string workingDir,
            ISourceControlProvider provider,
            IIssueTrackerPlugin sourcePlugin)
        {
            this.userConfiguration = userConnectionConfig;
            this.associatedProject = associatedProjectIn;
            this.Configuration     = userConnectionConfig;
            if (this.vsenvironmenthelper != null)
            {
                this.IsRunningInVisualStudio = this.vsenvironmenthelper.AreWeRunningInVisualStudio();
            }
            else
            {
                this.IsRunningInVisualStudio = false;
            }

            List <SonarActionPlan> usortedListofPlan = this.restservice.GetAvailableActionPlan(userConnectionConfig, this.associatedProject.Key);

            if (usortedListofPlan != null && usortedListofPlan.Count > 0)
            {
                this.AvailableActionPlans = new ObservableCollection <SonarActionPlan>(usortedListofPlan.OrderBy(i => i.Name));
            }
        }
        /// <summary>
        /// Generates the version data.
        /// </summary>
        private void GenerateVersionData(ISonarConfiguration configuration)
        {
            var version = new VersionData();

            version.DownloadPath = "/static/csharp/SonarLint.zip";
            version.InstallPath  = Path.Combine(this.roslynHomeDiagPath, "csharp", "lint");
            this.InternalVersionsCsharp.Add(version);
            version              = new VersionData();
            version.InstallPath  = Path.Combine(this.roslynHomeDiagPath, "csharp", "analyser");
            version.DownloadPath = "/static/csharp/SonarAnalyzer.zip";
            this.InternalVersionsCsharp.Add(version);

            var settings = this.rest.GetSettings(configuration);

            version             = new VersionData();
            version.InstallPath = Path.Combine(this.roslynHomeDiagPath, "csharp", "analyser");

            var result = settings.Where(x => x.key == "sonaranalyzer-cs.staticResourceName").FirstOrDefault();

            if (result != null)
            {
                version.DownloadPath = "/static/csharp/" + result.Value;
                this.InternalVersionsCsharp.Add(version);
            }
        }
        /// <summary>
        /// Associates the with new project.
        /// </summary>
        /// <param name="configIn">The configuration in.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
        {
            this.sourceDir         = workingDir;
            this.associatedProject = project;
            this.config            = configIn;

            if (this.CommandText.Equals("Add to Existent Plan"))
            {
                Application.Current.Dispatcher.Invoke(
                    delegate
                {
                    this.SubItems.Clear();

                    foreach (var item in this.rest.GetAvailableActionPlan(this.config, project.Key))
                    {
                        var menu = new PlanMenu(this.rest, this.model, this.manager, false)
                        {
                            CommandText = item.Name, IsEnabled = true
                        };
                        menu.AssociateWithNewProject(configIn, project, workingDir, provider, sourcePlugin);
                        this.SubItems.Add(menu);
                    }
                });
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="configuration">sonar configuration</param>
 /// <param name="availableProjects">The available projects.</param>
 /// <param name="issuePlugin">The issue plugin.</param>
 public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable <Resource> availableProjects, IList <IIssueTrackerPlugin> issuePlugin)
 {
     foreach (var plugin in this.plugins)
     {
         plugin.OnConnectToSonar(configuration);
     }
 }
 public Profile(ISonarRestService service, ISonarConfiguration conf)
 {
     this.conf              = conf;
     this.service           = service;
     this.Rules             = new Dictionary <string, Rule>();
     this.RulesByIternalKey = new Dictionary <string, Rule>();
 }
        /// <summary>
        /// Synchronizes the analysers from server.
        /// </summary>
        /// <param name="authentication">The authentication.</param>
        /// <param name="versionToUse">The version to use.</param>
        private bool SyncAnalysersFromServer(ISonarConfiguration authentication, VersionData versionToUse)
        {
            var  tmpFile = Path.GetTempFileName();
            var  tmpDir  = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            bool isOk    = false;

            if (File.Exists(tmpFile))
            {
                File.Delete(tmpFile);
            }

            try
            {
                isOk = DownloadFileFromServer(authentication, versionToUse, tmpFile, tmpDir);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (File.Exists(tmpFile))
            {
                File.Delete(tmpFile);
            }

            if (Directory.Exists(tmpDir))
            {
                Directory.Delete(tmpDir, true);
            }

            return(isOk);
        }
        /// <summary>
        /// Initializeds the server diagnostics.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        internal void InitializedServerDiagnostics(ISonarConfiguration configuration)
        {
            try
            {
                this.SelectCSharpZipFileToUse(configuration);
                if (this.InUsePluginsWithDiagnostics.Count > 0)
                {
                    List <VersionData> elementsToRemove = new List <VersionData>();
                    foreach (var item in this.InUsePluginsWithDiagnostics)
                    {
                        if (!this.SyncAnalysersFromServer(configuration, item))
                        {
                            elementsToRemove.Add(item);
                        }
                    }

                    foreach (var item in elementsToRemove)
                    {
                        this.InUsePluginsWithDiagnostics.Remove(item);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="sourceModelIn">The source model in.</param>
 /// <param name="sourcePluginIn">The source plugin in.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider sourceModelIn, IIssueTrackerPlugin sourcePluginIn)
 {
     this.sourceDir          = workingDir;
     this.associatedProject  = project;
     this.config             = configIn;
     this.issueTrackerPlugin = sourcePluginIn;
     this.sourceModel        = sourceModelIn;
 }
Esempio n. 11
0
        /// <summary>
        /// Associates the with new project.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="projectIn">The project in.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource projectIn, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
        {
            this.project = projectIn;

            foreach (var availableOption in this.AvailableOptionsModels)
            {
                availableOption.ReloadDataFromDisk(projectIn);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Called when [connect to sonar].
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="sourcePlugin">The source control plugin.</param>
        public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable <Resource> availableProjects, IList <IIssueTrackerPlugin> sourcePlugin)
        {
            if (this.PluginManager != null)
            {
                this.PluginManager.OnConnectToSonar(configuration, availableProjects, sourcePlugin);
            }

            this.RefreshDiagnostics();
        }
 /// <summary>
 /// Selects the zip file to use.
 /// </summary>
 private void SelectCSharpZipFileToUse(ISonarConfiguration configuration)
 {
     this.GenerateVersionData(configuration);
     this.InUsePluginsWithDiagnostics.Clear();
     foreach (var version in this.InternalVersionsCsharp)
     {
         version.InstallPath = Path.Combine(this.roslynHomeDiagPath, "csharp");
         this.InUsePluginsWithDiagnostics.Add(version);
     }
 }
Esempio n. 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchComponenetDialog" /> class.
        /// </summary>
        /// <param name="conf">The conf.</param>
        /// <param name="rest">The rest.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="listofSaveComp">The listof save comp.</param>
        /// <param name="vshelper">The vshelper.</param>
        public SearchComponenetDialog(ISonarConfiguration conf,
                                      ISonarRestService rest,
                                      List <Resource> availableProjectsIn,
                                      List <Resource> listofSaveComp,
                                      IVsEnvironmentHelper vshelper)
        {
            this.selectedItems     = new ObservableCollection <Resource>();
            this.availableProjects = new ObservableCollection <Resource>(availableProjectsIn);
            this.componentList     = new ObservableCollection <Resource>();

            this.conf     = conf;
            this.rest     = rest;
            this.vshelper = vshelper;

            InitializeComponent();

            this.Projects.ItemsSource         = this.availableProjects;
            this.SelectedDataGrid.ItemsSource = this.selectedItems;
            this.SearchDataGrid.ItemsSource   = this.componentList;

            if (listofSaveComp != null)
            {
                foreach (var item in listofSaveComp)
                {
                    try
                    {
                        IEnumerable <Resource> resourcesWithSameKey =
                            from resource in this.availableProjects
                            where this.CompareKeysInProjects(resource, item.Key)
                            select resource;

                        var element = resourcesWithSameKey.First();

                        if (element.BranchResources.Count != 0)
                        {
                            element = element.BranchResources.First(x => x.Key.Equals(item.Key));
                        }

                        element.Qualifier = "TRK";

                        this.selectedItems.Add(element);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Failed to import project: ", ex.Message);
                    }
                }

                this.SearchDataGrid.Items.Refresh();
            }


            this.MouseLeftButtonDown += this.MouseLeftButtonDownPressed;
            this.SearchData.KeyDown  += new KeyEventHandler(this.KeyboardKeyDown);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SQGitPlugin" /> class.
 /// </summary>
 /// <param name="notificationManager">The notification manager.</param>
 public TestTrackPlugin(INotificationManager notificationManager, ISonarConfiguration configuration)
 {
     this.userConf = configuration;
     this.notificationManager = notificationManager;
     this.descrition = new PluginDescription();
     this.descrition.Enabled = true;
     this.descrition.Description = "TestTrack Plugin";
     this.descrition.Name = "TestTrack Plugin";
     this.descrition.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
     this.descrition.AssemblyPath = Assembly.GetExecutingAssembly().Location;
     this.testTrackIntegration = new TestTrackConnector(configuration.Username, configuration.Password, true, new TtConnection());
 }
Esempio n. 16
0
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="sourceModelIn">The source model in.</param>
 /// <param name="sourcePluginIn">The source plugin in.</param>
 public void AssociateWithNewProject(
     Resource project,
     string workingDir,
     ISourceControlProvider sourceModelIn,
     Dictionary <string, Profile> profile,
     string visualStudioVersion)
 {
     this.sourceDir         = workingDir;
     this.associatedProject = project;
     this.sourceModel       = sourceModelIn;
     this.config            = AuthtenticationHelper.AuthToken;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SQGitPlugin" /> class.
 /// </summary>
 /// <param name="notificationManager">The notification manager.</param>
 public TestTrackPlugin(INotificationManager notificationManager, ISonarConfiguration configuration)
 {
     this.userConf                = configuration;
     this.notificationManager     = notificationManager;
     this.descrition              = new PluginDescription();
     this.descrition.Enabled      = true;
     this.descrition.Description  = "TestTrack Plugin";
     this.descrition.Name         = "TestTrack Plugin";
     this.descrition.Version      = Assembly.GetExecutingAssembly().GetName().Version.ToString();
     this.descrition.AssemblyPath = Assembly.GetExecutingAssembly().Location;
     this.testTrackIntegration    = new TestTrackConnector(configuration.Username, configuration.Password, true, new TtConnection());
 }
        /// <summary>
        /// The is plugin found.
        /// </summary>
        /// <param name="conf">
        /// The conf.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public PluginDescription LoadPluginDescription(ISonarConfiguration conf, IConfigurationHelper helper)
        {
            foreach (var assembly in this.trustedAssembly)
            {
                var types2 = assembly.GetTypes();
                foreach (var type in types2)
                {
                    Debug.WriteLine("Type In Assembly:" + type.FullName);

                    try
                    {
                        if (typeof(IAnalysisPlugin).IsAssignableFrom(type))
                        {
                            Debug.WriteLine("Can Cast Type In Assembly To: " + typeof(IAnalysisPlugin).FullName);
                            var plugin = (IAnalysisPlugin)Activator.CreateInstance(type);
                            return(plugin.GetPluginDescription());
                        }

                        if (typeof(IMenuCommandPlugin).IsAssignableFrom(type))
                        {
                            Debug.WriteLine("Can Cast Type In Assembly To: " + typeof(IMenuCommandPlugin).FullName);
                            var plugin = (IMenuCommandPlugin)Activator.CreateInstance(type);
                            return(plugin.GetPluginDescription());
                        }

                        if (typeof(ISourceVersionPlugin).IsAssignableFrom(type))
                        {
                            Debug.WriteLine("Can Cast Type In Assembly To: " + typeof(ISourceVersionPlugin).FullName);
                            var plugin = (ISourceVersionPlugin)Activator.CreateInstance(type);
                            return(plugin.GetPluginDescription());
                        }


                        if (typeof(IIssueTrackerPlugin).IsAssignableFrom(type))
                        {
                            Debug.WriteLine("Can Cast Type In Assembly To: " + typeof(IIssueTrackerPlugin).FullName);
                            var plugin = (IIssueTrackerPlugin)Activator.CreateInstance(type);
                            return(plugin.GetPluginDescription());
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.InnerException.Message + " : " + ex.InnerException.StackTrace);
                        throw;
                    }
                }
            }

            return(new PluginDescription());
        }
        /// <summary>
        /// Called when [connect to sonar].
        /// </summary>
        /// <param name="configuration">sonar configuration</param>
        /// <param name="availableProjectsIn">The available projects in.</param>
        public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable <Resource> availableProjectsIn, IList <IIssueTrackerPlugin> sourcePlugin)
        {
            // does nothing
            this.availableProjects = availableProjectsIn;
            this.issuesSearchViewModel.AvailableProjects = availableProjectsIn;
            this.issuesSearchViewModel.CanQUeryIssues    = true;
            this.notificationmanager.EndedWorking();

            List <User> usortedList = this.restService.GetUserList(AuthtenticationHelper.AuthToken);

            if (usortedList != null && usortedList.Count > 0)
            {
                this.issuesSearchViewModel.AssigneeList = new ObservableCollection <User>(usortedList.OrderBy(i => i.Name));
            }
        }
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
        {
            this.userConf                = config;
            this.associatedProject       = project;
            this.IsAssociatedWithProject = this.associatedProject != null;

            this.SourceWorkingDir = workingDir;

            if (!string.IsNullOrEmpty(this.SourceWorkingDir) && Directory.Exists(this.SourceWorkingDir))
            {
                this.CanRunAnalysis   = true;
                this.LoadingSonarData = true;
                this.localAnalyserModule.AssociateWithProject(project, config);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="sourceModelIn">The source model in.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider sourceModelIn, IIssueTrackerPlugin sourcePlugin)
        {
            this.sourceModel       = sourceModelIn;
            this.associatedProject = project;
            this.userConf          = config;
            this.issuesSearchViewModel.CanQUeryIssues = true;
            this.notificationmanager.EndedWorking();

            List <User> usortedList = this.restService.GetUserList(config);

            if (usortedList != null && usortedList.Count > 0)
            {
                this.issuesSearchViewModel.UsersList = new ObservableCollection <User>(usortedList.OrderBy(i => i.Name));
            }

            this.ReloadPlanData();
        }
        private static bool DownloadFileFromServer(ISonarConfiguration authentication, VersionData versionToUse, string tmpFile, string tmpDir)
        {
            try
            {
                var urldownload = authentication.Hostname + versionToUse.DownloadPath;
                using (var client = new WebClient())
                {
                    client.DownloadFile(urldownload, tmpFile);

                    ZipFile.ExtractToDirectory(tmpFile, tmpDir);

                    var files      = Directory.GetFiles(tmpDir);
                    var versionDir = "";

                    foreach (var file in files)
                    {
                        if (string.IsNullOrEmpty(versionDir))
                        {
                            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(file);
                            string          ver = fvi.FileVersion;
                            versionDir = Path.Combine(versionToUse.InstallPath, ver);
                            versionToUse.InstallPath = Path.Combine(versionToUse.InstallPath, ver);

                            if (!Directory.Exists(versionToUse.InstallPath))
                            {
                                Directory.CreateDirectory(versionToUse.InstallPath);
                            }
                        }

                        var endPath = Path.Combine(versionToUse.InstallPath, Path.GetFileName(file));
                        if (!File.Exists(endPath))
                        {
                            File.Copy(file, endPath, true);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }
        }
 /// <summary>
 /// The init data association.
 /// </summary>
 /// <param name="userConnectionConfig">The user connection config.</param>
 /// <param name="associatedProjectIn">The associated project in.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(
     ISonarConfiguration userConnectionConfig,
     Resource associatedProjectIn,
     string workingDir,
     ISourceControlProvider provider,
     IIssueTrackerPlugin sourcePlugin)
 {
     this.userConfiguration = userConnectionConfig;
     this.associatedProject = associatedProjectIn;
     this.Configuration     = userConnectionConfig;
     if (this.vsenvironmenthelper != null)
     {
         this.IsRunningInVisualStudio = this.vsenvironmenthelper.AreWeRunningInVisualStudio();
     }
     else
     {
         this.IsRunningInVisualStudio = false;
     }
 }
        /// <summary>
        /// The load plugin using dedicated domain.
        /// </summary>
        /// <param name="assemblies">
        /// The assemblies.
        /// </param>
        /// <param name="refAssemblies">
        /// The ref assemblies.
        /// </param>
        /// <param name="basePath">
        /// The base path.
        /// </param>
        /// <param name="conf">
        /// The conf.
        /// </param>
        /// <returns>
        /// The <see cref="PluginDescription"/>.
        /// </returns>
        public IPlugin LoadPlugin(
            string[] assemblies,
            string basePath,
            ISonarConfiguration conf,
            IConfigurationHelper helper,
            INotificationManager manager,
            IVsEnvironmentHelper vshelper)
        {
            try
            {
                var loader = PluginSandBoxLoader.Sandbox(AppDomain.CurrentDomain, assemblies, this.CurrentDomainAssemblyResolve);
                try
                {
                    var pluginDesc = loader.LoadPlugin(conf, helper, manager, vshelper);

                    foreach (string assembly in assemblies)
                    {
                        File.Delete(assembly);
                    }

                    return(pluginDesc);
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        this.ErrorMessage = "Cannot Load Plugin: " + ex.InnerException.Message + " : " + ex.InnerException.StackTrace;
                    }
                    else
                    {
                        this.ErrorMessage = "Cannot Load Plugin: " + ex.Message + " : " + ex.StackTrace;
                    }

                    Debug.WriteLine(ex.Message + " " + ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                this.ErrorMessage = "Cannot Create Domain: " + ex.Message + " : " + ex.StackTrace;
            }

            return(null);
        }
        /// <summary>
        /// Associates the with new project.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workDir">The work dir.</param>
        /// <param name="provider">The provider.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workDir, ISourceControlProvider provider)
        {
            this.sourceDir         = workDir;
            this.sonarConf         = config;
            this.associatedProject = project;

            foreach (var plugin in this.plugins)
            {
                var plugDesc = plugin.GetPluginDescription();
                try
                {
                    string isEnabled = this.configurationHelper.ReadSetting(Context.IssueTrackerProps, project.Name, plugDesc.Name).Value;
                    if (isEnabled.Equals("true", StringComparison.CurrentCultureIgnoreCase))
                    {
                        plugDesc.Enabled = true;
                    }
                    else
                    {
                        plugDesc.Enabled = false;
                    }
                }
                catch (Exception)
                {
                    this.configurationHelper.WriteOptionInApplicationData(Context.IssueTrackerProps, project.Name, plugDesc.Name, "true");
                    plugDesc.Enabled = true;
                }

                try
                {
                    plugin.AssociateProject(project, config);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }

            // select issue tracker plugin to use
            this.SelectIssueTrackerPlugin();
        }
        /// <summary>
        /// The get connection configuration.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="address">The address.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <returns>
        /// The <see cref="ConnectionConfiguration" />.
        /// </returns>
        public static bool EstablishAConnection(ISonarRestService service, string address, string userName, string password)
        {
            if (AuthToken != null)
            {
                return(true);
            }

            ErrorMessage = string.Empty;

            var token = new ConnectionConfiguration(address, userName, password, 4.5);

            if (!service.AuthenticateUser(token))
            {
                ErrorMessage = "Authentication Failed, Check User, Password and Hostname";
                return(false);
            }

            token.SonarVersion = service.GetServerInfo(token);
            AuthToken          = token;

            return(true);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchComponenetDialog" /> class.
        /// </summary>
        /// <param name="conf">The conf.</param>
        /// <param name="rest">The rest.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="listofSaveComp">The listof save comp.</param>
        public SearchComponenetDialog(ISonarConfiguration conf, ISonarRestService rest, List<Resource> availableProjects, List<Resource> listofSaveComp)
        {
            this.selectedItems = new ObservableCollection<Resource>();
            this.availableProjects = availableProjects;
            this.conf = conf;
            this.rest = rest;

            InitializeComponent();
            this.SearchDataGrid.ItemsSource = this.componentList;
            this.SearchDataGrid.Items.Refresh();
            this.Projects.ItemsSource = availableProjects;
            this.SelectedDataGrid.ItemsSource = this.selectedItems;
            if (listofSaveComp != null)
            {
                foreach (var item in listofSaveComp)
                {
                    this.selectedItems.Add(item);
                }
            }

            this.MouseLeftButtonDown += this.MouseLeftButtonDownPressed;
            this.SearchData.KeyDown += new KeyEventHandler(this.KeyboardKeyDown);
        }
Esempio n. 28
0
        /// <summary>
        /// Initializes the installed diagnostics.
        /// </summary>
        public void InitializedServerDiagnostics(ISonarConfiguration authentication)
        {
            if (!this.ExtensionDiagnostics.Any())
            {
                bool hasRoslynPlugin = VerifyExistenceOfRoslynPlugin();

                // load defined props in server and load up
                var props = this.rest.GetProperties(authentication);
                if (props.ContainsKey("sonar.roslyn.diagnostic.path"))
                {
                    var folders = props["sonar.roslyn.diagnostic.path"].Split(';');
                    foreach (var folder in folders)
                    {
                        if (Directory.Exists(folder) && !this.roslynExternalUserDiagPath.ToLower().Equals(folder.ToLower()))
                        {
                            this.LoadDiagnosticsFromPath(folder, hasRoslynPlugin);
                        }
                    }
                }

                this.LoadDiagnosticsFromPath(this.roslynExternalUserDiagPath, hasRoslynPlugin);

                foreach (var item in this.embedVersionController.GetInstalledPaths())
                {
                    try
                    {
                        this.LoadDiagnosticsFromPath(item, false);
                    }
                    catch (Exception ex)
                    {
                        this.notificationManager.WriteMessage("Failed to load diagnostics from: " + item + " : " + ex.Message);
                    }
                }
            }

            this.SyncSettings();
        }
Esempio n. 29
0
        /// <summary>
        /// Searches the components.
        /// </summary>
        /// <param name="conf">The conf.</param>
        /// <param name="rest">The rest.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="listofSaveComp">The listof save comp.</param>
        /// <returns>returns saved component list</returns>
        public static List <Resource> SearchComponents(
            ISonarConfiguration conf,
            ISonarRestService rest,
            List <Resource> availableProjects,
            List <Resource> listofSaveComp,
            IVsEnvironmentHelper helper)
        {
            var savedList = new List <Resource>();

            foreach (var item in listofSaveComp)
            {
                savedList.Add(item);
            }


            try
            {
                var searchComponenetDialog = new SearchComponenetDialog(conf, rest, availableProjects, listofSaveComp, helper);
                searchComponenetDialog.ShowDialog();

                if (searchComponenetDialog.DialogResult == true)
                {
                    return(searchComponenetDialog.SelectedDataGrid.Items.OfType <Resource>().ToList());
                }
                else
                {
                    return(savedList);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ups Something wrong has happened. Please Report : " + ex.Message + " -> " + ex.StackTrace);
            }

            return(new List <Resource>());
        }
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.sourceWorkDir = string.Empty;
     this.sonarConfiguration = null;
     this.associatedProject = null;
 }
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="configuration">sonar configuration</param>
 public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjects, IIssueTrackerPlugin issuePlugin)
 {
     this.ExtensionDiagnostics.Clear();
     this.embedVersionController.InitializedServerDiagnostics(configuration);
     this.InitializedServerDiagnostics(configuration);
 }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="sourceModel">The source model.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider sourceModel, IIssueTrackerPlugin sourcePlugin)
 {
     // not neccessary
 }
Esempio n. 33
0
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.config = null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectDuplicationTrackerModel"/> class.
 /// </summary>
 /// <param name="conf">
 /// The conf.
 /// </param>
 /// <param name="vshelper">
 /// The vshelper.
 /// </param>
 public ProjectDuplicationTrackerModel(ISonarConfiguration conf, IVsEnvironmentHelper vshelper)
 {
     this.vshelper = vshelper;
     this.UserIsLoggedIn = false;
     this.conf = conf;
     this.Login();
     this.IsIdle = true;
 }
        /// <summary>
        /// Called when [connect to sonar].
        /// </summary>
        /// <param name="configuration">sonar configuration</param>
        /// <param name="availableProjectsIn">The available projects in.</param>
        public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjectsIn, IIssueTrackerPlugin sourcePlugin)
        {
            // does nothing
            this.availableProjects = availableProjectsIn;
            this.issuesSearchViewModel.AvailableProjects = availableProjectsIn;
            this.issuesSearchViewModel.CanQUeryIssues = true;
            this.notificationmanager.EndedWorking();

            List<User> usortedList = this.restService.GetUserList(AuthtenticationHelper.AuthToken);
            if (usortedList != null && usortedList.Count > 0)
            {
                this.issuesSearchViewModel.AssigneeList = new ObservableCollection<User>(usortedList.OrderBy(i => i.Name));
            }
        }
 /// <summary>
 /// Associates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 public void AssociateProject(Resource project, ISonarConfiguration configuration, Dictionary<string, Profile> profiles, string vsVersion)
 {
     this.associatedProject = project;
     this.userConf = configuration;
     this.testTrackIntegration = new TestTrackConnector(configuration.Username, configuration.Password, true, new TtConnection());
 }
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.associatedProject = null;
     this.sourceDir = string.Empty;
     this.config = null;
 }
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="sourceModelIn">The source model in.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider sourceModelIn, IIssueTrackerPlugin sourcePlugin)
        {
            this.sourceModel = sourceModelIn;
            this.associatedProject = project;
            this.userConf = config;
            this.issuesSearchViewModel.CanQUeryIssues = true;
            this.notificationmanager.EndedWorking();

            List<User> usortedList = this.restService.GetUserList(config);
            if (usortedList != null && usortedList.Count > 0)
            {
                this.issuesSearchViewModel.UsersList = new ObservableCollection<User>(usortedList.OrderBy(i => i.Name));
            }

            this.ReloadPlanData();
        }
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="configuration">sonar configuration</param>
 /// <param name="availableProjectsIn">The available projects in.</param>
 public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjectsIn, IIssueTrackerPlugin sourcePlugin)
 {
     this.availableProjects = availableProjectsIn.ToList();
 }
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="configuration">sonar configuration</param>
 /// <param name="availableProjects">The available projects.</param>
 /// <param name="issuePlugin">The issue plugin.</param>
 public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjects, IIssueTrackerPlugin issuePlugin)
 {
     foreach (var plugin in this.plugins)
     {
         plugin.OnConnectToSonar(configuration);
     }
 }
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.config = null;
 }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
 {
     this.config = configIn;
 }
        /// <summary>
        /// Called when [connect to sonar].
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="sourcePlugin">The source control plugin.</param>
        public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjects, IIssueTrackerPlugin sourcePlugin)
        {
            if (this.PluginManager != null)
            {
                this.PluginManager.OnConnectToSonar(configuration, availableProjects, sourcePlugin);
            }

            this.RefreshDiagnostics();
        }
 /// <summary>
 /// Associates the project.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="connector">The connector.</param>
 public void AssociateProject(Resource project, ISonarConfiguration configuration, IIssueManagementConnection connector, string vsVersion)
 {
     this.associatedProject = project;
     this.userConf = configuration;
     this.testTrackIntegration = new TestTrackConnector(configuration.Username, configuration.Password, true, connector);
 }
        /// <summary>
        /// Associates the with new project.
        /// </summary>
        /// <param name="configIn">The configuration in.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
        {
            this.sourceDir = workingDir;
            this.associatedProject = project;
            this.config = configIn;

            if (this.CommandText.Equals("Add to Existent Plan"))
            {
                Application.Current.Dispatcher.Invoke(
                    delegate
                    {
                        this.SubItems.Clear();

                        foreach (var item in this.rest.GetAvailableActionPlan(this.config, project.Key))
                        {
                            var menu = new PlanMenu(this.rest, this.model, this.manager, false) { CommandText = item.Name, IsEnabled = true };
                            menu.AssociateWithNewProject(configIn, project, workingDir, provider, sourcePlugin);
                            this.SubItems.Add(menu);
                        }
                    });
            }
        }
 /// <summary>
 /// Generates the token identifier.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <returns></returns>
 public string GenerateTokenId(ISonarConfiguration configuration)
 {
     return string.Empty;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectDuplicationTrackerModel"/> class.
 /// </summary>
 public ProjectDuplicationTrackerModel()
 {
     this.UserIsLoggedIn = false;
     this.conf = new ConnectionConfiguration("http://localhost", "admin", "admin");
     this.vshelper = null;
     this.Login();
     this.IsIdle = true;
 }
 /// <summary>
 /// Gets the plugin control options.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="configuration">The configuration.</param>
 /// <returns></returns>
 public IPluginControlOption GetPluginControlOptions(Resource project, ISonarConfiguration configuration)
 {
     return null;
 }
        /// <summary>
        /// The update configuration.
        /// </summary>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <param name="vsenvironmentHelper">
        /// The vs environment helper.
        /// </param>
        public void UpdateConfiguration(ISonarConfiguration configuration, Resource project, IVsEnvironmentHelper vsenvironmentHelper)
        {
            this.conf = configuration;
            if (this.conf != null)
            {
                this.Login();
            }

            this.SelectMainResource(project);
            this.vshelper = vsenvironmentHelper;
        }
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="configuration">sonar configuration</param>
 public void OnConnectToSonar(ISonarConfiguration configuration, IEnumerable<Resource> availableProjects, IIssueTrackerPlugin plugin)
 {
     // does nothing
 }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="sourceModel">The source model.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider sourceModel, IIssueTrackerPlugin sourcePlugin)
 {
     // not neccessary
 }
        /// <summary>
        /// Associates the with new project.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workDir">The work dir.</param>
        /// <param name="provider">The provider.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workDir, ISourceControlProvider provider)
        {
            this.sourceDir = workDir;
            this.sonarConf = config;
            this.associatedProject = project;

            foreach (var plugin in this.plugins)
            {
                var plugDesc = plugin.GetPluginDescription();
                try
                {
                    string isEnabled = this.configurationHelper.ReadSetting(Context.IssueTrackerProps, project.Name, plugDesc.Name).Value;
                    if (isEnabled.Equals("true", StringComparison.CurrentCultureIgnoreCase))
                    {
                        plugDesc.Enabled = true;
                    }
                    else
                    {
                        plugDesc.Enabled = false;
                    }
                }
                catch (Exception)
                {
                    this.configurationHelper.WriteOptionInApplicationData(Context.IssueTrackerProps, project.Name, plugDesc.Name, "true");
                    plugDesc.Enabled = true;
                }

                try
                {
                    plugin.AssociateProject(project, config);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }

            // select issue tracker plugin to use
            this.SelectIssueTrackerPlugin();
        }
Esempio n. 53
0
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
 {
     this.config = configIn;
 }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="configIn">The configuration in.</param>
 /// <param name="project">The project.</param>
 /// <param name="workingDir">The working dir.</param>
 /// <param name="sourceModelIn">The source model in.</param>
 /// <param name="sourcePluginIn">The source plugin in.</param>
 public void AssociateWithNewProject(ISonarConfiguration configIn, Resource project, string workingDir, ISourceControlProvider sourceModelIn, IIssueTrackerPlugin sourcePluginIn)
 {
     this.sourceDir = workingDir;
     this.associatedProject = project;
     this.config = configIn;
     this.issueTrackerPlugin = sourcePluginIn;
     this.sourceModel = sourceModelIn;
 }
 /// <summary>
 /// Called when [connect to sonar].
 /// </summary>
 /// <param name="config">The configuration.</param>
 public void OnConnectToSonar(ISonarConfiguration config)
 {
     this.userConf = config;
     this.testTrackIntegration = new TestTrackConnector(config.Username, config.Password, true, new TtConnection());
 }
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="userConnectionConfig">The user connection config.</param>
        /// <param name="associatedProjectIn">The associated project in.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(
            ISonarConfiguration userConnectionConfig,
            Resource associatedProjectIn,
            string workingDir,
            ISourceControlProvider provider,
            IIssueTrackerPlugin sourcePlugin)
        {
            this.userConfiguration = userConnectionConfig;
            this.associatedProject = associatedProjectIn;
            this.Configuration = userConnectionConfig;
            if (this.vsenvironmenthelper != null)
            {
                this.IsRunningInVisualStudio = this.vsenvironmenthelper.AreWeRunningInVisualStudio();
            }
            else
            {
                this.IsRunningInVisualStudio = false;
            }

            List<SonarActionPlan> usortedListofPlan = this.restservice.GetAvailableActionPlan(userConnectionConfig, this.associatedProject.Key);
            if (usortedListofPlan != null && usortedListofPlan.Count > 0)
            {
                this.AvailableActionPlans = new ObservableCollection<SonarActionPlan>(usortedListofPlan.OrderBy(i => i.Name));
            }
        }
Esempio n. 57
0
 /// <summary>
 /// The end data association.
 /// </summary>
 public void EndDataAssociation()
 {
     this.config            = null;
     this.associatedProject = null;
     this.sourceDir         = string.Empty;
 }
        /// <summary>
        /// The init data association.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="project">The project.</param>
        /// <param name="workingDir">The working dir.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="sourcePlugin">The source plugin.</param>
        public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workingDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
        {
            this.userConf = config;
            this.associatedProject = project;
            this.IsAssociatedWithProject = this.associatedProject != null;

            this.SourceWorkingDir = workingDir;

            if (!string.IsNullOrEmpty(this.SourceWorkingDir) && Directory.Exists(this.SourceWorkingDir))
            {
                this.CanRunAnalysis = true;
                this.LoadingSonarData = true;
                this.localAnalyserModule.AssociateWithProject(project, config);
            }
        }
        /// <summary>
        /// Initializes the installed diagnostics.
        /// </summary>
        public void InitializedServerDiagnostics(ISonarConfiguration authentication)
        {
            if (!this.ExtensionDiagnostics.Any())
            {
                bool hasRoslynPlugin = VerifyExistenceOfRoslynPlugin();

                // load defined props in server and load up
                var props = this.rest.GetProperties(authentication);
                if (props.ContainsKey("sonar.roslyn.diagnostic.path"))
                {
                    var folders = props["sonar.roslyn.diagnostic.path"].Split(';');
                    foreach (var folder in folders)
                    {
                        if (Directory.Exists(folder) && !this.roslynExternalUserDiagPath.ToLower().Equals(folder.ToLower()))
                        {
                            this.LoadDiagnosticsFromPath(folder, hasRoslynPlugin);
                        }
                    }
                }

                this.LoadDiagnosticsFromPath(this.roslynExternalUserDiagPath, hasRoslynPlugin);

                foreach (var item in this.embedVersionController.GetInstalledPaths())
                {
                    try
                    {
                        this.LoadDiagnosticsFromPath(item, false);
                    }
                    catch (Exception ex)
                    {
                        this.notificationManager.WriteMessage("Failed to load diagnostics from: " + item + " : " + ex.Message);
                    }
                }
            }

            this.SyncSettings();
        }
 /// <summary>
 /// Associates the with new project.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="project">The project.</param>
 /// <param name="workDir">The work dir.</param>
 /// <param name="provider">The provider.</param>
 /// <param name="sourcePlugin">The source plugin.</param>
 public void AssociateWithNewProject(ISonarConfiguration config, Resource project, string workDir, ISourceControlProvider provider, IIssueTrackerPlugin sourcePlugin)
 {
     this.sonarConfig = config;
     this.associatedProject = project;
     this.sourceDir = workDir;
 }