Example #1
0
        public static bool DoesSolutionItemHaveProjects(this Project solutionItem)
        {
            if (solutionItem == null || solutionItem.ProjectItems.Count == 0)
            {
                return(false);
            }

            bool hasValidProjects = false;

            foreach (ProjectItem projectItem in solutionItem.ProjectItems)
            {
                if (projectItem.Object is Project)
                {
                    Project       thisProject = projectItem.Object as Project;
                    VSProjectType vsProjType  = VSUtils.DetermineProjectType(thisProject.Kind);

                    switch (vsProjType)
                    {
                    case VSProjectType.VBProject:
                    case VSProjectType.VJSharpProject:
                    case VSProjectType.CPlusPlusProject:
                    case VSProjectType.CSharpProject:
                    case VSProjectType.FSharpProject:
                    case VSProjectType.SDECSharpProject:
                    case VSProjectType.SDEVBProject:
                        return(true);
                    }
                }
            }

            return(hasValidProjects);
        }
Example #2
0
        /// <summary>
        /// This handler is called when user clicks "Add Connect to QuickBooks" menu item.
        /// </summary>
        /// <param name="commandBarControl">The command bar control.</param>
        /// <param name="handled">if set to <c>true</c> [handled].</param>
        /// <param name="cancelDefault">if set to <c>true</c> [cancel default].</param>
        private void ConnecttoQuickBooksMenuItemHandler_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
        {
            if (this.visualStudio.Debugger.CurrentMode == dbgDebugMode.dbgRunMode)
            {
                MessageBox.Show(IntuitAnywhereResources.msg001, IntuitAnywhereResources.msgdialogtitle);
                return;
            }

            // Get the currenlly active project

            // Project selProject = m_VSStudio.SelectedItems.Item(1).Project;
            Array   activeProjectsArray = (Array)this.visualStudio.ActiveSolutionProjects;
            Project selProject          = null;

            if (activeProjectsArray != null)
            {
                if (activeProjectsArray.Length > 0)
                {
                    selProject = (Project)activeProjectsArray.GetValue(0);
                }
            }

            if (this.visualStudio.ActiveDocument == null)
            {
                MessageBox.Show(IntuitAnywhereResources.msg002, IntuitAnywhereResources.msgdialogtitle);
                return;
            }

            if (selProject == null)
            {
                if (this.visualStudio.ActiveDocument.ProjectItem.ContainingProject != null)
                {
                    selProject = this.visualStudio.ActiveDocument.ProjectItem.ContainingProject;
                }
                else
                {
                    MessageBox.Show(IntuitAnywhereResources.msg003, IntuitAnywhereResources.msgdialogtitle);
                    return;
                }
            }

            // Get the project type
            VSProjectType projectType = Common.GetProjectType(selProject);

            if (projectType == VSProjectType.Mvc)
            {
                MvcHandler.AddIntuitAnywhereSourceToMVCProject(selProject, "ConnecttoQuickBooks", "OauthResponse", this.codeFilesContentPath, this.visualStudio.ActiveDocument);
            }

            if (projectType == VSProjectType.AspNet)
            {
                AspHandler.AddSourceToAspnetProject(selProject, "ConnecttoQuickBooks", this.codeFilesContentPath, this.visualStudio.ActiveDocument);
            }

            if (projectType == VSProjectType.Other)
            {
                MessageBox.Show(IntuitAnywhereResources.msg004, IntuitAnywhereResources.msgdialogtitle);
            }
        }
Example #3
0
        public static VSProjectType DetermineProjectType(string kind)
        {
            VSProjectType projType = VSProjectType.Unknown;
            string        K        = kind.ToUpper();

            if (K.Equals(VSLangProj.PrjKind.prjKindVBProject.ToUpper()))
            {
                projType = VSProjectType.VBProject;
            }
            else if (K.Equals(VSLangProj.PrjKind.prjKindCSharpProject.ToUpper()))
            {
                projType = VSProjectType.CSharpProject;
            }
            else if (K.Equals(prjKindVJSharpProject))
            {
                projType = VSProjectType.VJSharpProject;
            }
            else if (K.Equals(prjKindSDEVBProject))
            {
                projType = VSProjectType.SDEVBProject;
            }
            else if (K.Equals(prjKindSDECSharpProject))
            {
                projType = VSProjectType.SDECSharpProject;
            }
            else if (K.Equals(EnvDTE.Constants.vsProjectItemKindMisc.ToUpper()))
            {
                projType = VSProjectType.Misc;
            }
            else if (K.Equals(EnvDTE.Constants.vsProjectItemKindSolutionItems.ToUpper()) || K.Equals(prjKindSolutionItems2) ||
                     K.Equals(vsProjectKindSolutionFolder.ToUpper()))
            {
                projType = VSProjectType.SolutionItems;
            }
            else if (K.Equals(EnvDTE.Constants.vsProjectKindUnmodeled.ToUpper()))
            {
                projType = VSProjectType.Unmodeled;
            }
            else if (K.Equals(VSLangProj.PrjKind.prjKindVSAProject.ToUpper()))
            {
                projType = VSProjectType.VSAProject;
            }
            else if (K.Equals(prjKindEnterpriseProject))
            {
                projType = VSProjectType.EnterpriseProject;
            }
            else if (K.Equals(prjKindCplusPlusProject))
            {
                projType = VSProjectType.CPlusPlusProject;
            }
            else if (K.Equals(prjKindVSNetSetupProject))
            {
                projType = VSProjectType.SetupProject;
            }

            return(projType);
        }
Example #4
0
        /// <summary>
        /// This handler is called when user clicks "Add Direct Connect to Intuit" menu item.
        /// </summary>
        /// <param name="commandBarControl">The command bar control.</param>
        /// <param name="handled">if set to <c>true</c> [handled].</param>
        /// <param name="cancelDefault">if set to <c>true</c> [cancel default].</param>
        private void DirectConnectToIntuitMenuItemHandler_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
        {
            if (this.visualStudio.Debugger.CurrentMode == dbgDebugMode.dbgRunMode)
            {
                MessageBox.Show(IntuitAnywhereResources.msg001, IntuitAnywhereResources.msgdialogtitle);
                return;
            }

            // Get the currenlly active project
            Array   activeProjectsArray = (Array)this.visualStudio.ActiveSolutionProjects;
            Project selProject          = null;

            if (activeProjectsArray != null)
            {
                if (activeProjectsArray.Length > 0)
                {
                    selProject = (Project)activeProjectsArray.GetValue(0);
                }
            }

            if (this.visualStudio.ActiveDocument == null)
            {
                MessageBox.Show(IntuitAnywhereResources.msg002, IntuitAnywhereResources.msgdialogtitle);
                return;
            }

            if (selProject == null)
            {
                if (this.visualStudio.ActiveDocument.ProjectItem.ContainingProject != null)
                {
                    selProject = this.visualStudio.ActiveDocument.ProjectItem.ContainingProject;
                }
                else
                {
                    MessageBox.Show(IntuitAnywhereResources.msg003, IntuitAnywhereResources.msgdialogtitle);
                    return;
                }
            }

            // Get the project type
            VSProjectType projectType = Common.GetProjectType(selProject);

            if (projectType == VSProjectType.AspNet)
            {
                AspHandler.AddDirectConnectToIntuitFunctionality("DirectConnectToIntuit", this.codeFilesContentPath, this.visualStudio.ActiveDocument);
            }

            if (projectType == VSProjectType.Mvc)
            {
                MvcHandler.AddDirectConnectToIntuitFunctionality("DirectConnectToIntuit", this.codeFilesContentPath, this.visualStudio.ActiveDocument);
            }

            if (projectType == VSProjectType.Other)
            {
                MessageBox.Show(IntuitAnywhereResources.msg004, IntuitAnywhereResources.msgdialogtitle);
            }
        }
        public void LoadSolution()
        {
            VSSolution solution = VSSolution.Load(@"..\..\..\ProjectPilot.sln");

            solution.ForEachProject(delegate(VSProjectInfo projectInfo)
            {
                VSProjectType projectType = solution.ProjectTypesDictionary.FindProjectType(projectInfo.ProjectTypeGuid);
                System.Console.Out.WriteLine(
                    "{0} ({1})",
                    projectInfo.ProjectName,
                    projectType.ProjectTypeName);
            });
        }
        private int GetImageIndexForProjType(VSProjectType projType)
        {
            int imageIndex;

            switch (projType)
            {
            case VSProjectType.CPlusPlusProject: imageIndex = 0; break;

            case VSProjectType.CSharpProject:
            case VSProjectType.SDECSharpProject: imageIndex = 1; break;

            case VSProjectType.FSharpProject: imageIndex = 2; break;

            case VSProjectType.VBProject:
            case VSProjectType.SDEVBProject: imageIndex = 4; break;

            default: imageIndex = 5; break;
            }
            return(imageIndex);
        }
Example #7
0
        public static bool IsValidSolutionProject(string kind)
        {
            if (string.IsNullOrEmpty(kind))
            {
                return(false);
            }

            VSProjectType projType = DetermineProjectType(kind);

            switch (projType)
            {
            case VSProjectType.CPlusPlusProject:
            case VSProjectType.CSharpProject:
            case VSProjectType.SDECSharpProject:
            case VSProjectType.FSharpProject:
            case VSProjectType.VBProject:
            case VSProjectType.SDEVBProject:
            case VSProjectType.VJSharpProject:
                return(true);
            }

            return(false);
        }
 public void RegisterProjectType(VSProjectType projectType)
 {
     projectTypes.Add(projectType.ProjectTypeGuid, projectType);
 }
Example #9
0
        private void Load()
        {
            if (!IsProjectFile(projectPath))
            {
                ThrowInvalidFileType(projectPath);
            }

            string       projectDirectory = Path.GetFullPath(Path.GetDirectoryName(projectPath));
            StreamReader rdr = new StreamReader(projectPath, System.Text.Encoding.UTF8);

            string[] extensions = { "", ".exe", ".dll", ".lib", "" };

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(rdr);

                string extension    = Path.GetExtension(projectPath);
                string assemblyName = null;

                switch (extension)
                {
                case ".vcproj":
                    this.projectType = VSProjectType.CPlusPlus;

                    XmlNode topNode     = doc.SelectSingleNode("/VisualStudioProject");
                    XmlNode keyWordAttr = topNode.Attributes["Keyword"];
                    this.isManaged = keyWordAttr != null && keyWordAttr.Value == "ManagedCProj";

                    // TODO: This is all very hacked up... replace it.
                    foreach (XmlNode configNode in doc.SelectNodes("/VisualStudioProject/Configurations/Configuration"))
                    {
                        string name        = RequiredAttributeValue(configNode, "Name");
                        int    config_type = System.Convert.ToInt32(RequiredAttributeValue(configNode, "ConfigurationType"));
                        string dirName     = name;
                        int    bar         = dirName.IndexOf('|');
                        if (bar >= 0)
                        {
                            dirName = dirName.Substring(0, bar);
                        }
                        string outputPath = RequiredAttributeValue(configNode, "OutputDirectory");
                        outputPath = outputPath.Replace("$(SolutionDir)", Path.GetFullPath(Path.GetDirectoryName(projectPath)) + Path.DirectorySeparatorChar);
                        outputPath = outputPath.Replace("$(ConfigurationName)", dirName);

                        string  outputDirectory = Path.Combine(projectDirectory, outputPath);
                        XmlNode toolNode        = configNode.SelectSingleNode("Tool[@Name='VCLinkerTool']");
                        if (toolNode != null)
                        {
                            assemblyName = SafeAttributeValue(toolNode, "OutputFile");
                            if (assemblyName != null)
                            {
                                assemblyName = Path.GetFileName(assemblyName);
                            }
                            else
                            {
                                assemblyName = Path.GetFileNameWithoutExtension(projectPath) + extensions[config_type];
                            }
                        }
                        else
                        {
                            toolNode = configNode.SelectSingleNode("Tool[@Name='VCNMakeTool']");
                            if (toolNode != null)
                            {
                                assemblyName = Path.GetFileName(RequiredAttributeValue(toolNode, "Output"));
                            }
                        }

                        assemblyName = assemblyName.Replace("$(OutDir)", outputPath);
                        assemblyName = assemblyName.Replace("$(ProjectName)", this.Name);

                        VSProjectConfig config = new VSProjectConfig(name);
                        if (assemblyName != null)
                        {
                            config.Assemblies.Add(Path.Combine(outputDirectory, assemblyName));
                        }

                        this.configs.Add(config);
                    }

                    break;

                case ".csproj":
                    this.projectType = VSProjectType.CSharp;
                    this.isManaged   = true;
                    LoadProject(projectDirectory, doc);
                    break;

                case ".vbproj":
                    this.projectType = VSProjectType.VisualBasic;
                    this.isManaged   = true;
                    LoadProject(projectDirectory, doc);
                    break;

                case ".vjsproj":
                    this.projectType = VSProjectType.JSharp;
                    this.isManaged   = true;
                    LoadProject(projectDirectory, doc);
                    break;

                default:
                    break;
                }
            }
            catch (FileNotFoundException)
            {
                throw;
            }
            catch (Exception e)
            {
                ThrowInvalidFormat(projectPath, e);
            }
            finally
            {
                rdr.Close();
            }
        }
Example #10
0
        /// <summary>
        /// This handler is called when user clicks "Add Data Services SDK V3" menu item.
        /// </summary>
        /// <param name="commandBarControl">The command bar control.</param>
        /// <param name="handled">if set to <c>true</c> [handled].</param>
        /// <param name="cancelDefault">if set to <c>true</c> [cancel default].</param>
        private void DataServicesSDKV3MenuItemHandler_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
        {
            if (this.visualStudio.Debugger.CurrentMode == dbgDebugMode.dbgRunMode)
            {
                MessageBox.Show(IntuitAnywhereResources.msg001, IntuitAnywhereResources.msgdialogtitle);
                return;
            }

            // Get the currenlly active project
            Array   activeProjectsArray = (Array)this.visualStudio.ActiveSolutionProjects;
            Project selProject          = null;

            if (activeProjectsArray != null)
            {
                if (activeProjectsArray.Length > 0)
                {
                    selProject = (Project)activeProjectsArray.GetValue(0);
                }
            }

            if (selProject == null)
            {
                if (this.visualStudio.SelectedItems != null && this.visualStudio.SelectedItems.Count == 1 && this.visualStudio.SelectedItems.Item(1) != null)
                {
                    if (this.visualStudio.SelectedItems.Item(1).Project == null)
                    {
                        MessageBox.Show(IntuitAnywhereResources.msg006, IntuitAnywhereResources.msgdialogtitle);
                        return;
                    }
                }

                if (this.visualStudio.ActiveDocument.ProjectItem.ContainingProject != null)
                {
                    selProject = this.visualStudio.ActiveDocument.ProjectItem.ContainingProject;
                }
                else
                {
                    MessageBox.Show(IntuitAnywhereResources.msg003, IntuitAnywhereResources.msgdialogtitle);
                    return;
                }
            }

            // Get the project type
            VSProjectType projectType = Common.GetProjectType(selProject);

            if (projectType == VSProjectType.AspNet || projectType == VSProjectType.Mvc)
            {
                //run the Nuget command
                string repositoryPath = "http://go.microsoft.com/fwlink/?LinkID=206669"; //// Can be modified to https://nuget.org/api/v2
                string packageId      = "IPPDotNetDevKitV3";
                Common.InstallNuGetPackageForProject(packageId, selProject, repositoryPath);

                if (projectType == VSProjectType.AspNet)
                {
                    AspHandler.AddQuickBookCustomerFilesForAsp(selProject, this.codeFilesContentPath);
                }
                else
                {
                    MvcHandler.AddQuickBookCustomerFilesForMvc(selProject, this.codeFilesContentPath);
                }
            }
            else
            {
                MessageBox.Show(IntuitAnywhereResources.msg004, IntuitAnywhereResources.msgdialogtitle);
            }
        }
Example #11
0
        /// <summary>
        /// Adds the web configuration entries.
        /// </summary>
        /// <param name="proj">The project object.</param>
        /// <param name="appSettingEntries">The app setting entries.</param>
        /// <param name="projType">Type of the proj.</param>
        internal static void AddWebConfigurationEntries(Project proj, Dictionary <string, string> appSettingEntries, VSProjectType projType)
        {
            // Get the path of the config file
            List <string> configurationFiles = GetConfigurationFileList();

            foreach (string configFile in configurationFiles)
            {
                string prjItemPath = Path.GetDirectoryName(proj.FullName) + "\\" + configFile;
                if (File.Exists(prjItemPath))
                {
                    bool         modified = false;
                    const string AppSettingStringXpath = "/configuration/appSettings";
                    var          xmlDoc = new XmlDocument();
                    xmlDoc.Load(prjItemPath);

                    // Add appSettings node to the webconfig if node doesn't exit and then add required keys
                    XmlNode appSettingsNode = xmlDoc.SelectSingleNode(AppSettingStringXpath);
                    if (appSettingsNode == null)
                    {
                        appSettingsNode = xmlDoc.CreateNode(XmlNodeType.Element, "appSettings", null);
                        XmlNode selectSingleNode = xmlDoc.SelectSingleNode("/configuration");
                        if (selectSingleNode != null)
                        {
                            selectSingleNode.AppendChild(appSettingsNode);
                        }

                        modified = true;
                    }

                    foreach (var appSettingEntry in appSettingEntries)
                    {
                        // check if key is present
                        string appSettingXpath = @"//add[@key='" + appSettingEntry.Key + "']";
                        if (appSettingsNode.SelectSingleNode(appSettingXpath) == null)
                        {
                            // create a new node to the <appSettings></appSettings>.
                            XmlNode      newAddNode   = xmlDoc.CreateNode(XmlNodeType.Element, "add", null);
                            XmlAttribute keyAttribute = xmlDoc.CreateAttribute("key");
                            keyAttribute.Value = appSettingEntry.Key;
                            XmlAttribute valueAttribute = xmlDoc.CreateAttribute("value");
                            valueAttribute.Value = appSettingEntry.Value;

                            // add the two attribute to the "add" element.
                            if (newAddNode.Attributes != null)
                            {
                                newAddNode.Attributes.Append(keyAttribute);
                                newAddNode.Attributes.Append(valueAttribute);
                            }

                            XmlComment comment = xmlDoc.CreateComment(IntuitAnywhereResources.comment004);
                            appSettingsNode.AppendChild(comment);
                            appSettingsNode.AppendChild(newAddNode);
                            modified = true;
                        }
                    }

                    if (projType == VSProjectType.AspNet)
                    {
                        // add http module for asp .net project
                        const string HttpModulesStringXpath = "/configuration/system.web/httpModules";
                        XmlNode      httpModulesNode        = xmlDoc.SelectSingleNode(HttpModulesStringXpath);
                        if (httpModulesNode == null)
                        {
                            httpModulesNode = xmlDoc.CreateNode(XmlNodeType.Element, "httpModules", null);
                            XmlNode selectSingleNode = xmlDoc.SelectSingleNode("/configuration/system.web");
                            if (selectSingleNode != null)
                            {
                                selectSingleNode.AppendChild(httpModulesNode);
                            }

                            modified = true;
                        }

                        // check if htttpIPP enty is present
                        const string HtttpIppXpath = @"//add[@name='IppTag']";
                        if (httpModulesNode.SelectSingleNode(HtttpIppXpath) == null)
                        {
                            // create a new node to the <httpModules></httpModules>.
                            XmlNode      newAddNode   = xmlDoc.CreateNode(XmlNodeType.Element, "add", null);
                            XmlAttribute keyAttribute = xmlDoc.CreateAttribute("name");
                            keyAttribute.Value = "IppTag";
                            XmlAttribute valueAttribute = xmlDoc.CreateAttribute("type");
                            valueAttribute.Value = "IntuitSampleWebsite.utils.IppTag";

                            // add the two attribute to the "add" element.
                            if (newAddNode.Attributes != null)
                            {
                                newAddNode.Attributes.Append(keyAttribute);
                                newAddNode.Attributes.Append(valueAttribute);
                            }

                            XmlComment comment = xmlDoc.CreateComment(IntuitAnywhereResources.comment005);
                            httpModulesNode.AppendChild(comment);
                            httpModulesNode.AppendChild(newAddNode);
                            modified = true;
                        }
                    }

                    if (modified)
                    {
                        xmlDoc.Save(prjItemPath);
                    }
                }
            }

            // ask the user to enter the values for the first time.
            if (appSettingEntries.ContainsKey("applicationToken") && appSettingEntries.ContainsKey("consumerKey") && appSettingEntries.ContainsKey("consumerSecret"))
            {
                GetKeysFromtheUser(proj);
            }
        }