Пример #1
0
 public void Delete(object deleteADAccounts, object gradualDelete)
 {
     if (deleteADAccounts == Undefined.Value || gradualDelete == Undefined.Value)
     {
         m_site.Delete();
     }
     else if (deleteADAccounts != Undefined.Value && gradualDelete == Undefined.Value)
     {
         m_site.Delete(TypeConverter.ToBoolean(deleteADAccounts));
     }
     else if (deleteADAccounts != Undefined.Value && gradualDelete != Undefined.Value)
     {
         m_site.Delete(TypeConverter.ToBoolean(deleteADAccounts), TypeConverter.ToBoolean(gradualDelete));
     }
 }
Пример #2
0
        private void InitializeSiteAtManagedPath(string managedPath)
        {
            var defaultPortWebApp = this.GetDefaultPortWebApp();
            SPContentDatabase testContentDatabase = this.EnsureTestContentDatabase(defaultPortWebApp);

            var prefixCollection = defaultPortWebApp.Prefixes;

            if (!prefixCollection.Contains(managedPath))
            {
                // The hostname-site collection's prefix may still exist
                // if a test run was interrupted previously.
                prefixCollection.Add(managedPath, SPPrefixType.ExplicitInclusion);
            }

            // Flag so dispose will remove the managed path when the site collection is deleted
            this.ManagedPathCreated = managedPath;

            var siteUrl = defaultPortWebApp.GetResponseUri(SPUrlZone.Default) + managedPath;

            SPSiteCollection sites        = testContentDatabase.Sites;
            SPSite           existingSite = sites.FirstOrDefault(site => site.Url == siteUrl);

            if (existingSite != null)
            {
                existingSite.Delete();
                existingSite.Dispose();

                // Refresh Sites collection
                sites = testContentDatabase.Sites;
            }

            var newSite = sites.Add(siteUrl, Environment.UserName, "*****@*****.**");

            this.SiteCollection = newSite;
        }
Пример #3
0
        private void InitializeSite(string hostName, string templateName, uint lcid)
        {
            var defaultPortWebApp = this.GetDefaultPortWebApp();
            SPContentDatabase testContentDatabase = this.EnsureTestContentDatabase(defaultPortWebApp);

            SPSiteCollection sites = testContentDatabase.Sites;

            SPSite existingSite = testContentDatabase.Sites.FirstOrDefault(site => site.Url == hostName);

            if (existingSite != null)
            {
                existingSite.Delete();
                existingSite.Dispose();

                // Refresh Sites collection
                sites = testContentDatabase.Sites;
            }

            SPSite newSite = sites.Add(
                hostName,
                "Dynamite Test",
                "Integration test temporary site",
                lcid,
                templateName,
                Environment.UserName,
                "Dynamite Test Agent",
                "*****@*****.**",
                Environment.UserName,
                "Dynamite Test Agent",
                "*****@*****.**",
                true);

            this.SiteCollection = newSite;
        }
Пример #4
0
        protected override void TearDown()
        {
            try {
                DirectoryEntry root      = new DirectoryEntry(_rootDirectory);
                DirectoryEntry userEntry = root.Children.Find(_userName);
                root.Children.Remove(userEntry);
                root.CommitChanges();

                SPSite site = new SPSite(_newSPSiteUrl);
                site.Delete();
            } catch  {
            }
        }
Пример #5
0
        /// <summary>
        /// Task for deleting a SPSite.
        /// </summary>
        protected override void ExecuteTask() {
            try {
                SPSite site = new SPSite(Url);
                site.Delete();

                Log(Level.Info, LogPrefix + "Deleting site {0}.", Url);
            } catch (FileNotFoundException ex) { 
                // The SPS API will throw an exception when you try and create an 
                // instance of SPSite for a URL that doesn't exist.  
                throw new BuildException( 
                    string.Format("Cannot delete site {0}. The site does not exist.", 
                    Url), Location, ex);
            }
        }
Пример #6
0
        /// <summary>
        /// Task for deleting a SPSite.
        /// </summary>
        protected override void ExecuteTask()
        {
            try {
                SPSite site = new SPSite(Url);
                site.Delete();

                Log(Level.Info, LogPrefix + "Deleting site {0}.", Url);
            } catch (FileNotFoundException ex) {
                // The SPS API will throw an exception when you try and create an
                // instance of SPSite for a URL that doesn't exist.
                throw new BuildException(
                          string.Format("Cannot delete site {0}. The site does not exist.",
                                        Url), Location, ex);
            }
        }
Пример #7
0
        protected override void TearDown()
        {
            DirectoryEntry root      = new DirectoryEntry(_rootDirectory);
            DirectoryEntry userEntry = root.Children.Find(_userName);

            root.Children.Remove(userEntry);

            try {
                SPSite site = new SPSite(_newSPSiteUrl);
                site.Delete();
            } catch (FileNotFoundException) {
                // If a FileNotFoundException was raise it was because the site was
                // correctly deleted by the test.
            }
        }
Пример #8
0
        public static void RecreateSite(ISharePointCommandContext context, string defaultTemplate)
        {
            SPSite           siteCollection = context.Site;
            SPWebApplication webApp         = siteCollection.WebApplication;
            int    configuration            = siteCollection.RootWeb.Configuration;
            string template   = siteCollection.RootWeb.WebTemplate;
            string url        = siteCollection.ServerRelativeUrl;
            string ownerLogin = siteCollection.Owner.LoginName;
            string ownerEmail = siteCollection.Owner.Email;
            string ownerName  = siteCollection.Owner.Name;
            uint   lcid       = siteCollection.RootWeb.Language;
            string title      = siteCollection.RootWeb.Title;

            siteCollection.Delete();
            webApp.Sites.Add(url, title, null, lcid, defaultTemplate ?? String.Format("{0}#{1}", template, configuration), ownerLogin, ownerName, ownerEmail);
        }
        protected override void TearDown() {
            DirectoryEntry root = new DirectoryEntry(_rootDirectory);
            DirectoryEntry newUserEntry = root.Children.Find(_newUserName);
            root.Children.Remove(newUserEntry);
            
            DirectoryEntry userEntry = root.Children.Find(_userName);
            root.Children.Remove(userEntry);

            try {
                SPSite site = new SPSite(_newSPSiteUrl);
                site.Delete(); 
            } catch (FileNotFoundException) {
                // If a FileNotFoundException was raised it was because the site was 
                // correctly deleted by the test.
            }
        }
		protected override void TearDown() {
			try 
			{
				DirectoryEntry root = new DirectoryEntry(_rootDirectory);
				DirectoryEntry userEntry = root.Children.Find(_userName);
				root.Children.Remove(userEntry);
				root.CommitChanges();
    
				SPSite site = new SPSite(_newSPSiteUrl);
				site.Delete(); 
			} catch  {
			}
		}
        protected void btnMove_Click(object sender, EventArgs e)
        {
            if (ThisWebPart.DestionationSiteCollectionUrl != null)
            {

                oSite = new SPSite(ThisWebPart.DestionationSiteCollectionUrl + "/jobs/" + DateTime.Now.Year);

                SPSecurity.RunWithElevatedPrivileges(delegate
                {

                    using (SPWeb sourceWeb = new SPSite(SPContext.Current.Web.Url).OpenWeb())
                    {
                        SPExportSettings settings = new SPExportSettings();
                        settings.SiteUrl = sourceWeb.Site.Url;
                        settings.ExportMethod = SPExportMethodType.ExportAll;
                        settings.FileLocation = ThisWebPart.ExportLocation;
                        settings.FileCompression = false;
                        settings.CommandLineVerbose = true;
                        settings.OverwriteExistingDataFile = true;

                        foreach (SPList item in sourceWeb.Lists)
                        {
                            SPExportObject exportObject = new SPExportObject();
                            exportObject.Id = item.ID;
                            exportObject.Type = SPDeploymentObjectType.List;
                            settings.ExportObjects.Add(exportObject);
                        }

                        SPExport export = new SPExport(settings);

                        export.Run();

                    }

                });

                SPWeb destinationWeb = new SPSite(lstJobs.SelectedItem.Value).OpenWeb();

                SPSecurity.RunWithElevatedPrivileges(delegate
                {

                    HttpContext.Current.Items["FormDigestValidated"] = "false";
                    destinationWeb.AllowUnsafeUpdates = true;

                    SPImportSettings settings = new SPImportSettings();
                    settings.SiteUrl = destinationWeb.Site.Url;
                    settings.WebUrl = lstJobs.SelectedItem.Value;
                    settings.FileLocation = ThisWebPart.ExportLocation;
                    settings.FileCompression = false;
                    settings.RetainObjectIdentity = false;
                    settings.LogFilePath = ThisWebPart.ExportLocation + @"\export_log.txt";
                    settings.IgnoreWebParts = true;

                    SPImport import = new SPImport(settings);

                    import.Run();
                    HttpContext.Current.Items["FormDigestValidated"] = "false";
                    destinationWeb.AllowUnsafeUpdates = false;

                });

                var currentUser = Request.LogonUserIdentity.ToString();

                SPSecurity.RunWithElevatedPrivileges(delegate
                {

                    SPWeb sourceWeb = new SPSite(SPContext.Current.Web.Url).OpenWeb();

                    SPWeb blueberryWeb = sourceWeb.Site.AllWebs["Blueberry"];
                    SPList proposalList = blueberryWeb.Lists["Proposals"];
                    var proposalRecordID = int.Parse(sourceWeb.Properties["ProposalRecordID"].ToString());

                    SPListItem proposalRecord = proposalList.GetItemById(proposalRecordID);
                    proposalRecord["JobNumber"] = lstJobs.SelectedItem.Text;
                    proposalRecord["BecameJobOn"] = DateTime.Now;
                    proposalRecord.Update();

                    sourceWeb.AllowUnsafeUpdates = true;

                    sourceWeb.Delete();

                });

                Response.Redirect(destinationWeb.Url);
            }
        }