/// <summary>
        /// Saves the file menu item click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        protected virtual void SaveFileMenuItemClick(object sender, MenuItemEventArgs e)
        {
            IExplorerNode parentNode   = e.Owner as IExplorerNode;
            var           fileNodeInfo = parentNode.Annotations.GetValue <FileNodeInfo>();

            DTEManager.SetStatus(CKSProperties.FileUtilities_SavingFile);

            Document      file      = DTEManager.DTE.ActiveDocument;
            TextSelection selection = file.Selection as TextSelection;

            selection.SelectAll();
            fileNodeInfo.Contents = selection.Text;
            selection.StartOfDocument();

            bool result = parentNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, bool>(FileSharePointCommandIds.SaveFileCommand, fileNodeInfo);

            if (result)
            {
                DTEManager.SetStatus(CKSProperties.FileUtilities_FileSuccessfullySaved);
            }
            else
            {
                MessageBox.Show(CKSProperties.FileUtilities_FileSaveError, CKSProperties.FileUtilities_FileSaveErrorMessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Run project item finished generating which will move the sprite png into the SPI due to
        /// some VS quirk which means you can't call 'replace params' in the vstemplate for png files.
        /// </summary>
        /// <param name="projectItem">The project item</param>
        public override void RunProjectItemFinishedGenerating(ProjectItem projectItem)
        {
            base.RunProjectItemFinishedGenerating(projectItem);

            if (projectItem.Name.ToLower() == "tempsprites.png")
            {
                //Find the temp sprite project item
                ProjectItem spritesItem = DTEManager.FindItemByName(projectItem.ContainingProject.ProjectItems, "tempsprites.png", true);
                //We don't want this so bin it from the solution
                spritesItem.Remove();

                ProjectItem parent = spiItem.Collection.Parent as ProjectItem;

                FileInfo sourceFile = new FileInfo(spritesItem.FileNames[0]);

                FileInfo parentFile  = new FileInfo(parent.FileNames[0]);
                string   newFileName = parentFile.Directory.ToString() + Path.DirectorySeparatorChar + "sprites.png";

                File.Move(sourceFile.ToString(), newFileName);

                parent.ProjectItems.AddFromFileCopy(newFileName);

                //Final tidy up
                if (sourceFile.Exists)
                {
                    sourceFile.Delete();
                }
            }
            else
            {
                spiItem = projectItem;
            }
        }
        /// <summary>
        /// Handles the Click event of the CreatePageLayoutContentTypeNodeExtension control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.VisualStudio.SharePoint.MenuItemEventArgs" /> instance containing the event data.</param>
        void CreatePageLayoutContentTypeNodeExtension_Click(object sender, Microsoft.VisualStudio.SharePoint.MenuItemEventArgs e)
        {
            IExplorerNode ctNode = e.Owner as IExplorerNode;

            if (ctNode != null)
            {
                IContentTypeNodeInfo ctInfo = ctNode.Annotations.GetValue <IContentTypeNodeInfo>();

                string pageLayoutContents = ctNode.Context.SharePointConnection.ExecuteCommand <string, string>(ContentTypeSharePointCommandIds.CreatePageLayoutCommand, ctInfo.Name);
                DTEManager.CreateNewTextFile(SafeContentTypeName(ctInfo.Name) + ".aspx", pageLayoutContents);
            }
        }
        private void OnBeforeQueryStatus(object sender, EventArgs e)
        {
            if (sender is OleMenuCommand command)
            {
                command.Enabled = false;

                var window = DTEManager.GetCurrentAnalysisWindowEditorControl();
                if (window != null)
                {
                    command.Enabled = true;
                }
            }
        }
        /// <summary>
        /// Opens the file menu item click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        protected virtual void OpenFileMenuItemClick(object sender, MenuItemEventArgs e)
        {
            IExplorerNode fileNode     = e.Owner as IExplorerNode;
            var           fileNodeInfo = fileNode.Annotations.GetValue <FileNodeInfo>();

            DTEManager.SetStatus(CKSProperties.FileUtilities_OpeningFile);

            string fileContents = fileNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, string>(FileSharePointCommandIds.GetFileContentsCommand, fileNodeInfo);

            DTEManager.CreateNewTextFile(fileNodeInfo.Name, fileContents);

            DTEManager.SetStatus(CKSProperties.FileUtilities_FileSuccessfullyOpened);
        }
        /// <summary>
        /// Creates the files nodes.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        public static void CreateFilesNodes(IExplorerNode parentNode)
        {
            DTEManager.SetStatus(CKSProperties.FileNodeTypeProvider_RetrievingFolders);
            FolderNodeInfo[] folders = parentNode.Context.SharePointConnection.ExecuteCommand <FolderNodeInfo, FolderNodeInfo[]>(FileSharePointCommandIds.GetFoldersCommand, parentNode.Annotations.GetValue <FolderNodeInfo>());
            DTEManager.SetStatus(CKSProperties.FileNodeTypeProvider_RetrievingFiles);
            FileNodeInfo[] files = parentNode.Context.SharePointConnection.ExecuteCommand <FolderNodeInfo, FileNodeInfo[]>(FileSharePointCommandIds.GetFilesCommand, parentNode.Annotations.GetValue <FolderNodeInfo>());

            if (folders != null)
            {
                foreach (FolderNodeInfo folder in folders)
                {
                    var annotations = new Dictionary <object, object>
                    {
                        { typeof(FolderNodeInfo), folder }
                    };

                    string nodeTypeId = ExplorerNodeIds.FolderNode;

                    IExplorerNode fileNode = parentNode.ChildNodes.Add(nodeTypeId, folder.Name, annotations);
                }
            }

            if (files != null)
            {
                foreach (FileNodeInfo file in files)
                {
                    var annotations = new Dictionary <object, object>
                    {
                        { typeof(FileNodeInfo), file }
                    };

                    string nodeTypeId = ExplorerNodeIds.FileNode;

                    IExplorerNode fileNode = parentNode.ChildNodes.Add(nodeTypeId, file.Name, annotations);
                    fileNode.DoubleClick += delegate(object sender, ExplorerNodeEventArgs e)
                    {
                        var fileNodeInfo = e.Node.Annotations.GetValue <FileNodeInfo>();

                        DTEManager.SetStatus(CKSProperties.FileUtilities_OpeningFile);

                        string fileContents = fileNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, string>(FileSharePointCommandIds.GetFileContentsCommand, fileNodeInfo);
                        DTEManager.CreateNewTextFile(fileNodeInfo.Name, fileContents);

                        DTEManager.SetStatus(CKSProperties.FileUtilities_FileSuccessfullyOpened);
                    };
                    SetExplorerNodeIcon(file, fileNode);
                }
            }

            DTEManager.SetStatus(String.Empty);
        }
        /// <summary>
        /// Handles the Click event of the exportMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        void exportMenuItem_Click(object sender, MenuItemEventArgs e)
        {
            IExplorerNode pageNode = e.Owner as IExplorerNode;

            if (pageNode != null)
            {
                PublishingPageInfo pageInfo = pageNode.Annotations.GetValue <PublishingPageInfo>();
                if (pageInfo != null)
                {
                    string pageXml = pageNode.Context.SharePointConnection.ExecuteCommand <PublishingPageInfo, string>(PublishingPageCommandIds.ExportToXml, pageInfo);
                    DTEManager.CreateNewTextFile(String.Format("{0}.xml", pageInfo.Name), pageXml);
                }
            }
        }
        /// <summary>
        /// Discards the check out file menu item click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
        protected virtual void DiscardCheckOutFileMenuItemClick(object sender, MenuItemEventArgs e)
        {
            IExplorerNode parentNode   = e.Owner as IExplorerNode;
            var           fileNodeInfo = parentNode.Annotations.GetValue <FileNodeInfo>();

            DTEManager.SetStatus(CKSProperties.FileUtilities_DiscardingFileCheckOut);

            bool result = parentNode.Context.SharePointConnection.ExecuteCommand <FileNodeInfo, bool>(FileSharePointCommandIds.DiscardCheckOutCommand, fileNodeInfo);

            if (result)
            {
                parentNode.ParentNode.Refresh();
                DTEManager.SetStatus(CKSProperties.FileUtilities_FileCheckOutSuccessfullyDiscarded);
            }
            else
            {
                MessageBox.Show(CKSProperties.FileUtilities_DiscardFileCheckOutError, CKSProperties.FileUtilities_DiscardFileCheckOutErrorMessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void OnButtonASQADBInstall_Click(object sender, EventArgs e)
        {
            var helper = (AsqaHelperControl)this.Parent.Parent.Parent.Parent;

            helper.WaitStart();
            try
            {
                buttonASQADBInstall.Enabled = false;

                Func <string, string> getResource = (name) =>
                {
                    using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
                        using (var reader = new StreamReader(stream))
                            return(reader.ReadToEnd());
                };

                var scriptText = getResource(DatabaseInstallHeaderDatabaseEngineTypeStandaloneResourceName);
                if (GetCurrentSQLInstanceDatabaseEngineType() == DatabaseEngineType.SqlAzureDatabase)
                {
                    scriptText = getResource(DatabaseInstallHeaderDatabaseEngineTypeSqlAzureDatabaseResourceName);
                }

                scriptText += Environment.NewLine;
                scriptText += getResource(DatabaseInstallBodyResourceName);

                DTEManager.NewBlankWindow(ScriptType.Sql, scriptText);

                comboBoxSQLInstances.SelectedItem = null;
                OnComboBoxSQLInstances_SelectionChangeCommitted(comboBoxSQLInstances, null);

                DisableControls();
            }
            catch (Exception ex)
            {
                ex.HandleException(display: true);
            }
            finally
            {
                helper.WaitStop();
            }
        }
        private void OnButtonLoadAnalysisData_Click(object sender, EventArgs e)
        {
            var helper = (AsqaHelperControl)this.Parent.Parent.Parent.Parent;

            helper.WaitStart();
            try
            {
                var selectedRow = gridViewAnalysisData.SelectedRows[0];

                DTEManager.ExecuteLoadFromBatchAnalysisAsync(
                    connectionStringBatch: GetCurrentSQLInstanceConnectionString().ToAsqaSqlConnectionString(),
                    batchID: Convert.ToString(selectedRow.Cells["BatchID"].Value),
                    statement: Convert.ToString(selectedRow.Cells["Statement"].Value)
                    );
            }
            catch (Exception ex)
            {
                ex.HandleException(display: true);
            }
            finally
            {
                helper.WaitStop();
            }
        }
 /// <summary>
 /// Handles the Click event of the getTemplatePageMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="MenuItemEventArgs" /> instance containing the event data.</param>
 void getTemplatePageMenuItem_Click(object sender, MenuItemEventArgs e)
 {
     DTEManager.CreateNewTextFile("TemplatePage.aspx", CKSProperties.TemplatePage);
 }
 private void OnInvoke(object sender, EventArgs e)
 {
     DTEManager.FormatMDX();
 }
Esempio n. 13
0
 private void OnInvoke(object sender, EventArgs e)
 {
     DTEManager.NewAnalysisWindow();
 }
 private void OnInvoke(object sender, EventArgs e)
 {
     DTEManager.CreatePdfReport();
 }
Esempio n. 15
0
        public override void RunWizardFinished()
        {
            base.RunWizardFinished();

            // required to push changes from DTE.Project to ISharePointProject
            ISharePointProject spProject = DTEManager.ActiveSharePointProject;

            spProject.Synchronize();

            string projectPath = Path.GetDirectoryName(spProject.FullPath);

            ISharePointProjectItem webTemplate      = DTEManager.FindSPIItemByName(projectItemName, spProject);
            ISharePointProjectItem webTemplateStamp = DTEManager.FindSPIItemByName(String.Format("{0}Stamp", projectItemName), spProject);
            ISharePointProjectItem publishingPage   = DTEManager.FindSPIItemByName(String.Format("{0}PublishingPage", projectItemName), spProject);
            ISharePointProjectItem wikiPage         = DTEManager.FindSPIItemByName(String.Format("{0}WikiPage", projectItemName), spProject);
            ISharePointProjectItem webPartPage      = DTEManager.FindSPIItemByName(String.Format("{0}WebPartPage", projectItemName), spProject);

            ISharePointProjectFeature webTemplateFeature            = spProject.Features[projectItemName];
            ISharePointProjectFeature webTemplateStampFeature       = spProject.Features[String.Format("{0}Stamp", projectItemName)];
            ISharePointProjectFeature webTemplateWelcomePageFeature = spProject.Features[String.Format("{0}WelcomePage", projectItemName)];

            // remove automatically added feature associations
            foreach (ISharePointProjectFeature feature in spProject.Features)
            {
                feature.ProjectItems.Remove(webTemplate);
                feature.ProjectItems.Remove(webTemplateStamp);
                feature.ProjectItems.Remove(publishingPage);
                feature.ProjectItems.Remove(wikiPage);
                feature.ProjectItems.Remove(webPartPage);
            }

            // add standard spis to own features
            webTemplateFeature.ProjectItems.Add(webTemplate);
            webTemplateStampFeature.ProjectItems.Add(webTemplateStamp);
            webTemplateWelcomePageFeature.ProjectItems.Add(publishingPage);
            webTemplateWelcomePageFeature.ProjectItems.Add(wikiPage);
            webTemplateWelcomePageFeature.ProjectItems.Add(webPartPage);

            ProjectItem pagesFolder            = DTEManager.FindItemByName(DTEManager.ActiveProject.ProjectItems, "Pages", true);
            ProjectItem defaultPageProjectItem = null;

            switch (welcomePageType)
            {
            case WelcomePageType.WebPartPage:
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WikiPage", projectItemName), true));
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}PublishingPage", projectItemName), true));
                defaultPageProjectItem = DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WebPartPage", projectItemName), true);
                break;

            case WelcomePageType.WikiPage:
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WebPartPage", projectItemName), true));
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}PublishingPage", projectItemName), true));
                defaultPageProjectItem = DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WikiPage", projectItemName), true);
                break;

            case WelcomePageType.PublishingPage:
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WikiPage", projectItemName), true));
                DTEManager.SafeDeleteProjectItem(DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}WebPartPage", projectItemName), true));
                defaultPageProjectItem = DTEManager.FindItemByName(pagesFolder.ProjectItems, String.Format("{0}PublishingPage", projectItemName), true);
                break;
            }

            if (defaultPageProjectItem != null)
            {
                defaultPageProjectItem.Name = String.Format("{0}Default", projectItemName);
            }
        }
Esempio n. 16
0
 private void OnInvoke(object sender, EventArgs e)
 {
     DTEManager.CreatePowershellScript();
 }
Esempio n. 17
0
 private void OnInvoke(object sender, EventArgs e)
 {
     DTEManager.ExecuteBatchAnalysisAsync();
 }