Esempio n. 1
0
        public override void Execute()
        {
            string temppath = Path.Combine(Path.GetTempPath(), "SPSFListExport" + Guid.NewGuid().ToString());

            Directory.CreateDirectory(temppath);

            //export all to a temp folder
            DTE dte = GetService(typeof(DTE)) as DTE;

            SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);

            helper.ExportListAsTemplate(SiteUrl, _ListId, temppath);

            //add the exported items to the project
            foreach (string s in Directory.GetFiles(temppath))
            {
                if (SourceFileName != "")
                {
                    SourceFileName += ";";
                }
                SourceFileName += s;
            }

            //now add all collected files to the project as element files
            base.Execute();

            //delete temp folder
            Directory.Delete(temppath, true);
        }
      public override void Execute()
      {
        DTE dte = GetService<DTE>(true);

        try
        {
            string traceLogPath = new SharePointBrigdeHelper(dte).GetPathToTraceLogs();
            Helpers.LogMessage(dte, this, "Trace log location: " + traceLogPath);

            if (!Directory.Exists(traceLogPath))
            {
                throw new FileNotFoundException("Trace Log folder " + traceLogPath + " not found");
            }

            //start process with ShellExecute
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = "explorer.exe";
            psi.Arguments = "\"" + traceLogPath + "\"";
            psi.CreateNoWindow = true;
            psi.UseShellExecute = true;
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = psi;
            p.Start();
        }
        catch (Exception ex)
        {
            Helpers.LogMessage(dte, this, ex.Message);
        }        
      }
Esempio n. 3
0
        public override void Execute()
        {
            DTE dte = GetService <DTE>(true);

            try
            {
                string traceLogPath = new SharePointBrigdeHelper(dte).GetPathToTraceLogs();
                Helpers.LogMessage(dte, this, "Trace log location: " + traceLogPath);

                if (!Directory.Exists(traceLogPath))
                {
                    throw new FileNotFoundException("Trace Log folder " + traceLogPath + " not found");
                }

                //start process with ShellExecute
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName        = "explorer.exe";
                psi.Arguments       = "\"" + traceLogPath + "\"";
                psi.CreateNoWindow  = true;
                psi.UseShellExecute = true;
                Process p = new Process();
                p.StartInfo = psi;
                p.Start();
            }
            catch (Exception ex)
            {
                Helpers.LogMessage(dte, this, ex.Message);
            }
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            DTE service = (DTE)context.GetService(typeof(DTE));

              Cursor.Current = Cursors.WaitCursor;

              if (list != null)
              {
            return new StandardValuesCollection(list.ToArray());
              }

              list = new List<NameValueItem>();

              if (context != null)
              {
                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(service);
                foreach (SharePointSolution solution in helper.GetAllSharePointSolutions())
            {
              NameValueItem item = new NameValueItem();
              item.Name = solution.Name;
              item.Value = solution.Name;
              item.ItemType = "Solution";
              item.Description = solution.DeploymentState;
              list.Add(item);
            }
              }

              Cursor.Current = Cursors.Default;

              return new StandardValuesCollection(list.ToArray());
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            DTE service = (DTE)context.GetService(typeof(DTE));

            Cursor.Current = Cursors.WaitCursor;

            if (list != null)
            {
                return(new StandardValuesCollection(list.ToArray()));
            }

            list = new List <NameValueItem>();

            if (context != null)
            {
                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(service);
                foreach (SharePointSolution solution in helper.GetAllSharePointSolutions())
                {
                    NameValueItem item = new NameValueItem();
                    item.Name        = solution.Name;
                    item.Value       = solution.Name;
                    item.ItemType    = "Solution";
                    item.Description = solution.DeploymentState;
                    list.Add(item);
                }
            }

            Cursor.Current = Cursors.Default;

            return(new StandardValuesCollection(list.ToArray()));
        }
        public override void Execute()
        {

            string temppath = Path.Combine(Path.GetTempPath(), "SPSFListExport" + Guid.NewGuid().ToString());
            Directory.CreateDirectory(temppath);

            //export all to a temp folder
            DTE dte = GetService(typeof(DTE)) as DTE;

            SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
            helper.ExportListAsTemplate(SiteUrl, _ListId, temppath);

            //add the exported items to the project
            foreach (string s in Directory.GetFiles(temppath))
            {
                if (SourceFileName != "")
                {
                    SourceFileName += ";";
                }
                SourceFileName += s;
            }

            //now add all collected files to the project as element files
            base.Execute();

            //delete temp folder
            Directory.Delete(temppath, true);

        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper  = new SharePointBrigdeHelper(dte);
                SharePointWeb          rootweb = helper.GetWeb(textBox1.Text);

                treeView1.Nodes.Clear();
                foreach (SharePointList childList in rootweb.Lists)
                {
                    TreeNode listnode = new TreeNode();
                    listnode.Text             = childList.Title + " (List)";
                    listnode.Name             = childList.Title;
                    listnode.ImageKey         = "SPList";
                    listnode.SelectedImageKey = "SPList";
                    treeView1.Nodes.Add(listnode);

                    foreach (SharePointContentType ct in childList.ContentTypes)
                    {
                        TreeNode ctnode = new TreeNode();
                        ctnode.Text             = ct.Name + " (ContentType)";
                        ctnode.Name             = ct.Name;
                        ctnode.ImageKey         = "SPContentType";
                        ctnode.SelectedImageKey = "SPContentType";
                        listnode.Nodes.Add(ctnode);

                        foreach (SharePointField field in ct.Fields)
                        {
                            TreeNode fieldNode = new TreeNode();
                            fieldNode.Text             = field.Name + " (Field)";
                            fieldNode.Name             = field.Name;
                            fieldNode.ImageKey         = "SPField";
                            fieldNode.SelectedImageKey = "SPField";
                            ctnode.Nodes.Add(fieldNode);
                        }

                        /*
                         * listboxLists.Items.Add(childList.Title, false);
                         * */
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }
        private List <SharePointContentType> LoadContentTypes(string siteurl)
        {
            DTE dte = GetService(typeof(DTE)) as DTE;

            Cursor = Cursors.WaitCursor;

            SharePointBrigdeHelper       helper = new SharePointBrigdeHelper(dte);
            List <SharePointContentType> result = helper.GetContentTypes(siteurl);

            Cursor = Cursors.Default;
            return(result);
        }
        private List <SharePointField> LoadSiteColumns(string siteurl)
        {
            Cursor = Cursors.WaitCursor;

            DTE dte = GetService(typeof(DTE)) as DTE;
            SharePointBrigdeHelper helper      = new SharePointBrigdeHelper(dte);
            List <SharePointField> siteColumns = helper.GetSiteColumns(siteurl);

            Cursor = Cursors.Default;

            return(siteColumns);
        }
        private List<SharePointField> LoadSiteColumns(string siteurl)
        {
            Cursor = Cursors.WaitCursor;

            DTE dte = GetService(typeof(DTE)) as DTE;
            SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
            List<SharePointField> siteColumns = helper.GetSiteColumns(siteurl);

            Cursor = Cursors.Default;

            return siteColumns;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
                SharePointWeb rootweb = helper.GetWeb(textBox1.Text);

                treeView1.Nodes.Clear();
                foreach (SharePointList childList in rootweb.Lists)
                {
                    TreeNode listnode = new TreeNode();
                    listnode.Text = childList.Title + " (List)";
                    listnode.Name = childList.Title;
                    listnode.ImageKey = "SPList";
                    listnode.SelectedImageKey = "SPList";
                    treeView1.Nodes.Add(listnode);

                    foreach (SharePointContentType ct in childList.ContentTypes)
                    {
                        TreeNode ctnode = new TreeNode();
                        ctnode.Text = ct.Name + " (ContentType)";
                        ctnode.Name = ct.Name;
                        ctnode.ImageKey = "SPContentType";
                        ctnode.SelectedImageKey = "SPContentType";
                        listnode.Nodes.Add(ctnode);

                        foreach (SharePointField field in ct.Fields)
                        {
                            TreeNode fieldNode = new TreeNode();
                            fieldNode.Text = field.Name + " (Field)";
                            fieldNode.Name = field.Name;
                            fieldNode.ImageKey = "SPField";
                            fieldNode.SelectedImageKey = "SPField";
                            ctnode.Nodes.Add(fieldNode);
                        }
                        /*
                        listboxLists.Items.Add(childList.Title, false);
                         * */
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }
        public override void Execute()
        {
            DTE dte = GetService <DTE>(true);

            try
            {
                Helpers.LogMessage(dte, this, "Retrieving Central Administration");
                string centralAdminUrl = new SharePointBrigdeHelper(dte).GetCentralAdministrationUrl();


                Helpers.OpenWebPage(dte, centralAdminUrl);
            }
            catch (Exception ex)
            {
                Helpers.LogMessage(dte, this, ex.Message);
            }
        }
      public override void Execute()
      {
        DTE dte = GetService<DTE>(true);

        try
        {
            Helpers.LogMessage(dte, this, "Retrieving Central Administration");
            string centralAdminUrl = new SharePointBrigdeHelper(dte).GetCentralAdministrationUrl();

            
            Helpers.OpenWebPage(dte, centralAdminUrl);
        }
        catch (Exception ex)
        {
            Helpers.LogMessage(dte, this, ex.Message);
        }        
      }
      public override void Execute()
      {
        DTE dte = GetService<DTE>(true);

        try
        {
            string traceLogPath = new SharePointBrigdeHelper(dte).GetPathToTraceLogs();
            if (!Directory.Exists(traceLogPath))
            {
                throw new FileNotFoundException("Trace Log folder " + traceLogPath + " not found");
            }

            DateTime oldestDate = DateTime.Now.AddYears(-10);
            string newestFile = "";
            DirectoryInfo traceDir = new DirectoryInfo(traceLogPath);
            foreach(FileSystemInfo fileInfo in traceDir.GetFileSystemInfos("*.log"))
            {
                if (fileInfo.LastWriteTime > oldestDate)
                {
                    oldestDate = fileInfo.LastWriteTime;
                    newestFile = fileInfo.FullName;
                }
            }

            if (!string.IsNullOrEmpty(newestFile))
            {
                traceLogPath = newestFile;
            }

            //start process with ShellExecute
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = traceLogPath;
            psi.Arguments = "";
            psi.CreateNoWindow = true;
            psi.UseShellExecute = true;
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = psi;
            p.Start();
        }
        catch (Exception ex)
        {
            Helpers.LogMessage(dte, this, ex.Message);
        }        
      }
        public override void Execute()
        {
            DTE dte = GetService <DTE>(true);

            try
            {
                string traceLogPath = new SharePointBrigdeHelper(dte).GetPathToTraceLogs();
                if (!Directory.Exists(traceLogPath))
                {
                    throw new FileNotFoundException("Trace Log folder " + traceLogPath + " not found");
                }

                DateTime      oldestDate = DateTime.Now.AddYears(-10);
                string        newestFile = "";
                DirectoryInfo traceDir   = new DirectoryInfo(traceLogPath);
                foreach (FileSystemInfo fileInfo in traceDir.GetFileSystemInfos("*.log"))
                {
                    if (fileInfo.LastWriteTime > oldestDate)
                    {
                        oldestDate = fileInfo.LastWriteTime;
                        newestFile = fileInfo.FullName;
                    }
                }

                if (!string.IsNullOrEmpty(newestFile))
                {
                    traceLogPath = newestFile;
                }

                //start process with ShellExecute
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName        = traceLogPath;
                psi.Arguments       = "";
                psi.CreateNoWindow  = true;
                psi.UseShellExecute = true;
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo = psi;
                p.Start();
            }
            catch (Exception ex)
            {
                Helpers.LogMessage(dte, this, ex.Message);
            }
        }
      public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
      {
        Cursor.Current = Cursors.WaitCursor;

        /*
        if(list != null)
        {
          return new StandardValuesCollection(list.ToArray());
        }
        */

        list = new List<NameValueItem>();

        if (context != null)
        {
            DTE service = (DTE)context.GetService(typeof(DTE));

            try
            {
                

                List<SharePointWebApplication> webApplications = new SharePointBrigdeHelper(service).GetAllWebApplications();
                foreach (SharePointWebApplication webapp in webApplications)
                {
                    NameValueItem item = new NameValueItem();
                    item.Name = webapp.Url;
                    item.Value = webapp.Url;
                    item.ItemType = "WebApplication";
                    item.Description = webapp.Description;
                    list.Add(item);
                }
            }
            catch (Exception ex)
            {
                Helpers.LogMessage(service, service, ex.ToString());
            }
        }

        Cursor.Current = Cursors.Default;

        return new StandardValuesCollection(list.ToArray());
      }
        private void GetAllSiteCollections()
        {
            Cursor = Cursors.WaitCursor;
            this.comboBox1.Items.Clear();

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
                foreach (SharePointSiteCollection sitecoll in helper.GetAllSiteCollections())
                {
                    comboBox1.Items.Add(sitecoll.Url);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor = Cursors.Default;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            treeView_nodes.Nodes.Clear();

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper  = new SharePointBrigdeHelper(dte);
                SharePointWeb          rootweb = helper.GetRootWebOfSite(comboBox1.Text);

                DisplayWeb(rootweb, treeView_nodes.Nodes);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            treeView_nodes.Nodes.Clear();

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
                SharePointWeb rootweb = helper.GetRootWebOfSite(comboBox1.Text);

                DisplayWeb(rootweb, treeView_nodes.Nodes);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            Cursor.Current = Cursors.WaitCursor;

            /*
             * if(list != null)
             * {
             * return new StandardValuesCollection(list.ToArray());
             * }
             */

            list = new List <NameValueItem>();

            if (context != null)
            {
                DTE service = (DTE)context.GetService(typeof(DTE));

                try
                {
                    List <SharePointWebApplication> webApplications = new SharePointBrigdeHelper(service).GetAllWebApplications();
                    foreach (SharePointWebApplication webapp in webApplications)
                    {
                        NameValueItem item = new NameValueItem();
                        item.Name        = webapp.Url;
                        item.Value       = webapp.Url;
                        item.ItemType    = "WebApplication";
                        item.Description = webapp.Description;
                        list.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    Helpers.LogMessage(service, service, ex.ToString());
                }
            }

            Cursor.Current = Cursors.Default;

            return(new StandardValuesCollection(list.ToArray()));
        }
Esempio n. 21
0
        public override void Execute()
        {
            DTE    dte             = GetService <DTE>(true);
            string tempwspfolder   = "";
            string tempwspfilename = "";

            try
            {
                //retrieve the file locally
                tempwspfolder = Path.Combine(Path.GetTempPath(), "SPSFImport" + Guid.NewGuid().ToString());
                if (!Directory.Exists(tempwspfolder))
                {
                    Directory.CreateDirectory(tempwspfolder);
                }
                tempwspfilename = Path.Combine(tempwspfolder, WSPFilename);

                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
                helper.ExportSolutionAsFile(WSPFilename, tempwspfilename);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not download and save solution " + WSPFilename + " to temp folder " + tempwspfolder + ". " + ex.ToString());
            }

            if (File.Exists(tempwspfilename))
            {
                Helpers.ExtractWSPToProject(dte, tempwspfilename, _TargetProject, GetBasePath());
            }

            //clean up
            try
            {
                Directory.Delete(tempwspfolder, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not delete temp folder " + tempwspfolder + ". " + ex.ToString());
            }
        }
        public override void Execute()
        {
          DTE dte = GetService<DTE>(true);
          string tempwspfolder = "";
          string tempwspfilename = "";
          try
          {
            //retrieve the file locally
            tempwspfolder = Path.Combine(Path.GetTempPath(), "SPSFImport" + Guid.NewGuid().ToString());
            if (!Directory.Exists(tempwspfolder))
            {
              Directory.CreateDirectory(tempwspfolder);
            }
            tempwspfilename = Path.Combine(tempwspfolder, WSPFilename);

						SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
						helper.ExportSolutionAsFile(WSPFilename, tempwspfilename);            
          }
          catch (Exception ex)
          {
            MessageBox.Show("Could not download and save solution " + WSPFilename + " to temp folder " + tempwspfolder + ". " + ex.ToString());
          }

          if (File.Exists(tempwspfilename))
          {
            Helpers.ExtractWSPToProject(dte, tempwspfilename, _TargetProject, GetBasePath());
          }

          //clean up
          try
          {
            Directory.Delete(tempwspfolder, true);
          }
          catch (Exception ex)
          {
            MessageBox.Show("Could not delete temp folder " + tempwspfolder + ". " + ex.ToString());
          }
        }
        public override void Execute()
        {
            DTE service = (DTE)this.GetService(typeof(DTE));

            try
            {
                if (projectItem != null)
                {
                    string webUrl = Helpers.GetDebuggingWebApp(service, GetBasePath());

                    if (webUrl == "")
                    {
                        Helpers.LogMessage(service, this, "No web application for debugging defined in Application.config.");
                        return;
                    }

                    string relativetargetFileName = DeploymentHelpers.GetDeploymentPathOfItem(service, projectItem); //path starting with template

                    //check itempath for paths
                    string translatedPath = "";
                    if (relativetargetFileName.ToLower().StartsWith(@"\template\layouts\"))
                    {
                        //is layouts file
                        translatedPath = "/_layouts"+Helpers.GetVersionedFolder(service)+"/"+  GetRelativePath(relativetargetFileName, @"\template\layouts\");
                    }
                    else if (relativetargetFileName.ToLower().StartsWith(@"\template\admin\"))
                    {
                        //is layouts file
                        webUrl = new SharePointBrigdeHelper(service).GetCentralAdministrationUrl();
                        translatedPath = "/_admin/" + GetRelativePath(relativetargetFileName, @"\template\admin\");
                    }
                    else if (relativetargetFileName.ToLower().StartsWith(@"\template\images\"))
                    {
                        //is layouts file
                        translatedPath = "/_layouts" + Helpers.GetVersionedFolder(service) + "/images/" + GetRelativePath(relativetargetFileName, @"\template\images\");
                    }
                    else if (relativetargetFileName.ToLower().Contains(@"\isapi\"))
                    {
                        //is layouts file
                        translatedPath = "/_vti_bin/" + GetRelativePath(relativetargetFileName, @"\isapi\");
                    }
                    else if (relativetargetFileName.ToLower().Contains(@"\admisapi\"))
                    {
                        //is layouts file
                        webUrl = new SharePointBrigdeHelper(service).GetCentralAdministrationUrl();
                        translatedPath = "/_vti_adm/" + GetRelativePath(relativetargetFileName, @"\admisapi\");
                    }

                    if (webUrl.EndsWith("/"))
                    {
                        webUrl = webUrl.Substring(0, webUrl.Length - 1);
                    }

                    Helpers.LogMessage(service, this, "Opening " + webUrl + translatedPath);

                    /*
                    Window win = service.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
                    CommandWindow comwin = (CommandWindow)win.Object;
                    comwin.SendInput("nav \"" + webUrl + translatedPath + "\"", true);
                    */

                    Helpers.OpenWebPage(service, webUrl + translatedPath);
                    return;
                }
            }
            catch (Exception)
            {
            }
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            if (currentValue != null)
            {
                // Do not assign a new value, and return false to flag that
                // we don't want the current value to be changed.
                newValue = null;
                return(false);
            }

            DTE service = (DTE)this.GetService(typeof(DTE));

            Helpers.LogMessage(service, this, "Retrieving SharePoint version");
            Version farmVersion = new SharePointBrigdeHelper(service).GetSharePointVersion();

            string versionsXmlDocPath = Path.Combine(GetBasePath(), "SharePointVersions.xml");

            if (File.Exists(versionsXmlDocPath))
            {
                XmlDocument versionsDoc = new XmlDocument();
                versionsDoc.Load(versionsXmlDocPath);

                foreach (XmlNode versionNode in versionsDoc.SelectNodes("SPSD/SharePoint/Versions/Version"))
                {
                    try
                    {
                        Version checkVersion = new Version(versionNode.Attributes["Number"].Value);

                        //check if farmversion is larger than the checkversion
                        if (farmVersion.Equals(checkVersion))
                        {
                            newValue = versionNode.Attributes["Name"].Value + " (" + farmVersion.ToString() + ")";
                            Helpers.LogMessage(service, service, string.Format("Installed SharePoint Version: {0}", newValue));
                            return(true);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            switch (farmVersion.Major)
            {
            case 12:
                newValue = "SharePoint 2007 (" + farmVersion.ToString() + "), unkown patch level";
                break;

            case 14:
                newValue = "SharePoint 2010 (" + farmVersion.ToString() + "), unkown patch level";
                break;

            case 15:
                newValue = "SharePoint 2013 (" + farmVersion.ToString() + "), unkown patch level";
                break;

            default:
                newValue = "SharePoint ???? (" + farmVersion.ToString() + "), unkown SharePoint release";

                break;
            }

            Helpers.LogMessage(service, service, string.Format("Installed SharePoint Version: {0}", newValue));
            return(true);
        }
		public override void Execute()
		{
			dte = GetService<DTE>(true);

			//set the directory where to place the output
			tempExportDir = Path.Combine(Path.GetTempPath(), "SPSFExport" + Guid.NewGuid().ToString());
			Directory.CreateDirectory(tempExportDir);
			tempFilename = EXPORTFILENAME;
			tempLogFilePath = Path.Combine(tempExportDir, "SPSFExport.log");

			_ExportSettings.ExportMethod = _ExportMethod;
			_ExportSettings.IncludeSecurity = _IncludeSecurity;
			_ExportSettings.IncludeVersions = _IncludeVersions;
			_ExportSettings.ExcludeDependencies = _ExcludeDependencies;

			//start bridge 
			SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
			helper.ExportContent(_ExportSettings, tempExportDir, tempFilename, tempLogFilePath);

			if (_ExtractAfterExport)
			{
				//should they be extracted before
				string tempExtractFolder = tempExportDir; // Path.Combine(tempExportDir, "extracted");
				//Directory.CreateDirectory(tempExtractFolder);
				string fileToExtract = Path.Combine(tempExportDir, EXPORTFILENAME);

				// Launch the process and wait until it's done (with a 10 second timeout).
				string commandarguments = "\"" + fileToExtract + "\" \"" + tempExtractFolder + "\" -F:*";
				ProcessStartInfo startInfo = new ProcessStartInfo("expand ", commandarguments);
				startInfo.CreateNoWindow = true;
				startInfo.UseShellExecute = false;
				System.Diagnostics.Process snProcess = System.Diagnostics.Process.Start(startInfo);
				snProcess.WaitForExit(20000);

				//rename
				bool renameFilesAfterExport = true;
				if (renameFilesAfterExport)
				{
					//get the manifest.xml
					string manifestFilename = Path.Combine(tempExportDir, "Manifest.xml");
					if (File.Exists(manifestFilename))
					{
						XmlDocument doc = new XmlDocument();
						doc.Load(manifestFilename);

						//get the contents of the elements node in the new xml 
						XmlNamespaceManager newnsmgr = new XmlNamespaceManager(doc.NameTable);
						newnsmgr.AddNamespace("ns", "urn:deployment-manifest-schema");

						//read all 
						XmlNodeList datFiles = doc.SelectNodes("/ns:SPObjects/ns:SPObject/ns:File", newnsmgr);
						foreach (XmlNode datFile in datFiles)
						{
							//DispForm.aspx
							if (datFile.Attributes["Name"] != null)
							{
								if (datFile.Attributes["FileValue"] != null)
								{
									//is there a file with name 00000001.dat
									string datFilename = datFile.Attributes["FileValue"].Value;
									string datFilePath = Path.Combine(tempExportDir, datFilename);
									if (File.Exists(datFilePath))
									{
										//ok, lets change the name
										string newfilename = Path.GetFileNameWithoutExtension(datFilePath);
										string itemname = datFile.Attributes["Name"].Value;
										itemname = itemname.Replace(".", "_");
										itemname = itemname.Replace(" ", "_");
                                        newfilename = newfilename + SPSFConstants.NameSeparator + itemname + ".dat";

										string newfilePath = Path.Combine(tempExportDir, newfilename);
										//rename the file
										File.Move(datFilePath, newfilePath);

										//update the manifest.xml
										datFile.Attributes["FileValue"].Value = newfilename;
									}
								}
							}
						}
						doc.Save(manifestFilename);
					}
				}

				//todo delete the cmp file
				if (File.Exists(fileToExtract))
				{
					File.Delete(fileToExtract);
				}

				//create the ddf out of the contents (except the logfile);
				StringBuilder ddfcontent = new StringBuilder();
				ddfcontent.AppendLine(";*** Sample Source Code MakeCAB Directive file example");
				ddfcontent.AppendLine(";");
				ddfcontent.AppendLine(".OPTION EXPLICIT     ; Generate errors");
				ddfcontent.AppendLine(".Set CabinetNameTemplate=exportedData.cab");
				ddfcontent.AppendLine(".set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory");
				ddfcontent.AppendLine(".Set CompressionType=MSZIP;** All files are compressed in cabinet files");
				ddfcontent.AppendLine(".Set UniqueFiles=\"OFF\"");
				ddfcontent.AppendLine(".Set Cabinet=on");
				ddfcontent.AppendLine(".Set DiskDirectory1=.");
				ddfcontent.AppendLine(".Set CabinetFileCountThreshold=0");
				ddfcontent.AppendLine(".Set FolderFileCountThreshold=0");
				ddfcontent.AppendLine(".Set FolderSizeThreshold=0");
				ddfcontent.AppendLine(".Set MaxCabinetSize=0");
				ddfcontent.AppendLine(".Set MaxDiskFileCount=0");
				ddfcontent.AppendLine(".Set MaxDiskSize=0");

				foreach (string s in Directory.GetFiles(tempExportDir, "*.*", SearchOption.AllDirectories))
				{
					if (!s.EndsWith(".log"))
					{
						FileInfo info = new FileInfo(s);
						ddfcontent.AppendLine(info.Name);
					}
				}

				ddfcontent.AppendLine("");
				ddfcontent.AppendLine(";*** The end");

				//write the ddf file
				string ddfFilename = Path.Combine(tempExportDir, "_exportedData.ddf");
				TextWriter writer = new StreamWriter(ddfFilename);
				writer.Write(ddfcontent.ToString());
				writer.Close();
			}

			//add all elements in temp folder to the folder exported objects in the project
			ProjectItem targetFolder = Helpers.GetProjectItemByName(TargetProject.ProjectItems, TargetFolder);
			if (targetFolder != null)
			{
				//is there already a folder named "ExportedData"
				ProjectItem exportedDataFolder = null;
				try
				{
					exportedDataFolder = Helpers.GetProjectItemByName(targetFolder.ProjectItems, "ExportedData");
				}
				catch (Exception)
				{
				}
				if (exportedDataFolder == null)
				{
					exportedDataFolder = targetFolder.ProjectItems.AddFolder("ExportedData", EnvDTE.Constants.vsProjectItemKindPhysicalFolder);
				}

				//empty the exportedDataFolder
				foreach (ProjectItem subitem in exportedDataFolder.ProjectItems)
				{
					subitem.Delete();
				}

				//add all files in temp folder to the project (except log file
				foreach (string s in Directory.GetFiles(tempExportDir, "*.*", SearchOption.AllDirectories))
				{
					if (!s.EndsWith(".log"))
					{
						exportedDataFolder.ProjectItems.AddFromFileCopy(s);
					}
				}

				//add log file to the parent folder
				if (File.Exists(tempLogFilePath))
				{
					targetFolder.ProjectItems.AddFromFileCopy(tempLogFilePath);
				}
			}
		}
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            if (currentValue != null)
            {
                // Do not assign a new value, and return false to flag that 
                // we don't want the current value to be changed.
                newValue = null;
                return false;
            }

            DTE service = (DTE)this.GetService(typeof(DTE));

            Helpers.LogMessage(service, this, "Retrieving SharePoint version");
            Version farmVersion = new SharePointBrigdeHelper(service).GetSharePointVersion();

            string versionsXmlDocPath = Path.Combine(GetBasePath(), "SharePointVersions.xml");
            if (File.Exists(versionsXmlDocPath))
            {
                XmlDocument versionsDoc = new XmlDocument();
                versionsDoc.Load(versionsXmlDocPath);

                foreach (XmlNode versionNode in versionsDoc.SelectNodes("SPSD/SharePoint/Versions/Version"))
                {
                    try
                    {
                        Version checkVersion = new Version(versionNode.Attributes["Number"].Value);

                        //check if farmversion is larger than the checkversion
                        if (farmVersion.Equals(checkVersion))
                        {
                            newValue = versionNode.Attributes["Name"].Value + " (" + farmVersion.ToString() + ")";
                            Helpers.LogMessage(service, service, string.Format("Installed SharePoint Version: {0}", newValue));
                            return true;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            switch (farmVersion.Major)
            {
                case 12:
                    newValue = "SharePoint 2007 (" + farmVersion.ToString() + "), unkown patch level";
                    break;
                case 14:
                    newValue = "SharePoint 2010 (" + farmVersion.ToString() + "), unkown patch level";
                    break;
                case 15:
                    newValue = "SharePoint 2013 (" + farmVersion.ToString() + "), unkown patch level";
                    break;

                default:
                    newValue = "SharePoint ???? (" + farmVersion.ToString() + "), unkown SharePoint release";

                    break;
            }

            Helpers.LogMessage(service, service, string.Format("Installed SharePoint Version: {0}", newValue));
            return true;
        }
Esempio n. 27
0
        public override void Execute()
        {
            dte = GetService<DTE>(true);

            //set the directory where to place the output
            tempExportDir = Path.Combine(Path.GetTempPath(), "SPSFExport" + Guid.NewGuid().ToString());
            Directory.CreateDirectory(tempExportDir);
            tempFilename = EXPORTFILENAME;
            tempLogFilePath = Path.Combine(tempExportDir, "SPSFExport.log");

            _ExportSettings.ExportMethod = _ExportMethod;
            _ExportSettings.IncludeSecurity = _IncludeSecurity;
            _ExportSettings.IncludeVersions = _IncludeVersions;
            _ExportSettings.ExcludeDependencies = _ExcludeDependencies;

            //start bridge
            SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
            helper.ExportContent(_ExportSettings, tempExportDir, tempFilename, tempLogFilePath);

            if (_ExtractAfterExport)
            {
                //should they be extracted before
                string tempExtractFolder = tempExportDir; // Path.Combine(tempExportDir, "extracted");
                //Directory.CreateDirectory(tempExtractFolder);
                string fileToExtract = Path.Combine(tempExportDir, EXPORTFILENAME);

                // Launch the process and wait until it's done (with a 10 second timeout).
                string commandarguments = "\"" + fileToExtract + "\" \"" + tempExtractFolder + "\" -F:*";
                ProcessStartInfo startInfo = new ProcessStartInfo("expand ", commandarguments);
                startInfo.CreateNoWindow = true;
                startInfo.UseShellExecute = false;
                System.Diagnostics.Process snProcess = System.Diagnostics.Process.Start(startInfo);
                snProcess.WaitForExit(20000);

                //rename
                bool renameFilesAfterExport = true;
                if (renameFilesAfterExport)
                {
                    //get the manifest.xml
                    string manifestFilename = Path.Combine(tempExportDir, "Manifest.xml");
                    if (File.Exists(manifestFilename))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(manifestFilename);

                        //get the contents of the elements node in the new xml
                        XmlNamespaceManager newnsmgr = new XmlNamespaceManager(doc.NameTable);
                        newnsmgr.AddNamespace("ns", "urn:deployment-manifest-schema");

                        //read all
                        XmlNodeList datFiles = doc.SelectNodes("/ns:SPObjects/ns:SPObject/ns:File", newnsmgr);
                        foreach (XmlNode datFile in datFiles)
                        {
                            //DispForm.aspx
                            if (datFile.Attributes["Name"] != null)
                            {
                                if (datFile.Attributes["FileValue"] != null)
                                {
                                    //is there a file with name 00000001.dat
                                    string datFilename = datFile.Attributes["FileValue"].Value;
                                    string datFilePath = Path.Combine(tempExportDir, datFilename);
                                    if (File.Exists(datFilePath))
                                    {
                                        //ok, lets change the name
                                        string newfilename = Path.GetFileNameWithoutExtension(datFilePath);
                                        string itemname = datFile.Attributes["Name"].Value;
                                        itemname = itemname.Replace(".", "_");
                                        itemname = itemname.Replace(" ", "_");
                                        newfilename = newfilename + SPSFConstants.NameSeparator + itemname + ".dat";

                                        string newfilePath = Path.Combine(tempExportDir, newfilename);
                                        //rename the file
                                        File.Move(datFilePath, newfilePath);

                                        //update the manifest.xml
                                        datFile.Attributes["FileValue"].Value = newfilename;
                                    }
                                }
                            }
                        }
                        doc.Save(manifestFilename);
                    }
                }

                //todo delete the cmp file
                if (File.Exists(fileToExtract))
                {
                    File.Delete(fileToExtract);
                }

                //create the ddf out of the contents (except the logfile);
                StringBuilder ddfcontent = new StringBuilder();
                ddfcontent.AppendLine(";*** Sample Source Code MakeCAB Directive file example");
                ddfcontent.AppendLine(";");
                ddfcontent.AppendLine(".OPTION EXPLICIT     ; Generate errors");
                ddfcontent.AppendLine(".Set CabinetNameTemplate=exportedData.cab");
                ddfcontent.AppendLine(".set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory");
                ddfcontent.AppendLine(".Set CompressionType=MSZIP;** All files are compressed in cabinet files");
                ddfcontent.AppendLine(".Set UniqueFiles=\"OFF\"");
                ddfcontent.AppendLine(".Set Cabinet=on");
                ddfcontent.AppendLine(".Set DiskDirectory1=.");
                ddfcontent.AppendLine(".Set CabinetFileCountThreshold=0");
                ddfcontent.AppendLine(".Set FolderFileCountThreshold=0");
                ddfcontent.AppendLine(".Set FolderSizeThreshold=0");
                ddfcontent.AppendLine(".Set MaxCabinetSize=0");
                ddfcontent.AppendLine(".Set MaxDiskFileCount=0");
                ddfcontent.AppendLine(".Set MaxDiskSize=0");

                foreach (string s in Directory.GetFiles(tempExportDir, "*.*", SearchOption.AllDirectories))
                {
                    if (!s.EndsWith(".log"))
                    {
                        FileInfo info = new FileInfo(s);
                        ddfcontent.AppendLine(info.Name);
                    }
                }

                ddfcontent.AppendLine("");
                ddfcontent.AppendLine(";*** The end");

                //write the ddf file
                string ddfFilename = Path.Combine(tempExportDir, "_exportedData.ddf");
                TextWriter writer = new StreamWriter(ddfFilename);
                writer.Write(ddfcontent.ToString());
                writer.Close();
            }

            //add all elements in temp folder to the folder exported objects in the project
            ProjectItem targetFolder = Helpers.GetProjectItemByName(TargetProject.ProjectItems, TargetFolder);
            if (targetFolder != null)
            {
                //is there already a folder named "ExportedData"
                ProjectItem exportedDataFolder = null;
                try
                {
                    exportedDataFolder = Helpers.GetProjectItemByName(targetFolder.ProjectItems, "ExportedData");
                }
                catch (Exception)
                {
                }
                if (exportedDataFolder == null)
                {
                    exportedDataFolder = targetFolder.ProjectItems.AddFolder("ExportedData", EnvDTE.Constants.vsProjectItemKindPhysicalFolder);
                }

                //empty the exportedDataFolder
                foreach (ProjectItem subitem in exportedDataFolder.ProjectItems)
                {
                    subitem.Delete();
                }

                //add all files in temp folder to the project (except log file
                foreach (string s in Directory.GetFiles(tempExportDir, "*.*", SearchOption.AllDirectories))
                {
                    if (!s.EndsWith(".log"))
                    {
                        exportedDataFolder.ProjectItems.AddFromFileCopy(s);
                    }
                }

                //add log file to the parent folder
                if (File.Exists(tempLogFilePath))
                {
                    targetFolder.ProjectItems.AddFromFileCopy(tempLogFilePath);
                }
            }
        }
        private void GetAllSiteCollections()
        {
            Cursor = Cursors.WaitCursor;
            this.comboBox1.Items.Clear();

            try
            {
                DTE dte = GetService(typeof(DTE)) as DTE;

                SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
                foreach (SharePointSiteCollection sitecoll in helper.GetAllSiteCollections())
                {
                    comboBox1.Items.Add(sitecoll.Url);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor = Cursors.Default;
        }
        private List<SharePointContentType> LoadContentTypes(string siteurl)
        {
            DTE dte = GetService(typeof(DTE)) as DTE;

            Cursor = Cursors.WaitCursor;

            SharePointBrigdeHelper helper = new SharePointBrigdeHelper(dte);
            List<SharePointContentType> result = helper.GetContentTypes(siteurl);

            Cursor = Cursors.Default;
            return result;
        }
        public override void Execute()
        {
            DTE service = (DTE)this.GetService(typeof(DTE));

            try
            {
                if (projectItem != null)
                {
                    string webUrl = Helpers.GetDebuggingWebApp(service, GetBasePath());

                    if (webUrl == "")
                    {
                        Helpers.LogMessage(service, this, "No web application for debugging defined in Application.config.");
                        return;
                    }

                    string relativetargetFileName = DeploymentHelpers.GetDeploymentPathOfItem(service, projectItem); //path starting with template

                    //check itempath for paths
                    string translatedPath = "";
                    if (relativetargetFileName.ToLower().StartsWith(@"\template\layouts\"))
                    {
                        //is layouts file
                        translatedPath = "/_layouts" + Helpers.GetVersionedFolder(service) + "/" + GetRelativePath(relativetargetFileName, @"\template\layouts\");
                    }
                    else if (relativetargetFileName.ToLower().StartsWith(@"\template\admin\"))
                    {
                        //is layouts file
                        webUrl         = new SharePointBrigdeHelper(service).GetCentralAdministrationUrl();
                        translatedPath = "/_admin/" + GetRelativePath(relativetargetFileName, @"\template\admin\");
                    }
                    else if (relativetargetFileName.ToLower().StartsWith(@"\template\images\"))
                    {
                        //is layouts file
                        translatedPath = "/_layouts" + Helpers.GetVersionedFolder(service) + "/images/" + GetRelativePath(relativetargetFileName, @"\template\images\");
                    }
                    else if (relativetargetFileName.ToLower().Contains(@"\isapi\"))
                    {
                        //is layouts file
                        translatedPath = "/_vti_bin/" + GetRelativePath(relativetargetFileName, @"\isapi\");
                    }
                    else if (relativetargetFileName.ToLower().Contains(@"\admisapi\"))
                    {
                        //is layouts file
                        webUrl         = new SharePointBrigdeHelper(service).GetCentralAdministrationUrl();
                        translatedPath = "/_vti_adm/" + GetRelativePath(relativetargetFileName, @"\admisapi\");
                    }

                    if (webUrl.EndsWith("/"))
                    {
                        webUrl = webUrl.Substring(0, webUrl.Length - 1);
                    }

                    Helpers.LogMessage(service, this, "Opening " + webUrl + translatedPath);

                    /*
                     *                  Window win = service.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
                     *                  CommandWindow comwin = (CommandWindow)win.Object;
                     *                  comwin.SendInput("nav \"" + webUrl + translatedPath + "\"", true);
                     */

                    Helpers.OpenWebPage(service, webUrl + translatedPath);
                    return;
                }
            }
            catch (Exception)
            {
            }
        }