当前位置: 首页>>代码示例>>C#>>正文


C# SPSite.Delete方法代码示例

本文整理汇总了C#中SPSite.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# SPSite.Delete方法的具体用法?C# SPSite.Delete怎么用?C# SPSite.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPSite的用法示例。


在下文中一共展示了SPSite.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteTask

        /// <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);
            }
        }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:17,代码来源:DeleteSPSiteTask.cs

示例2: TearDown

        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.
            }
        }
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:16,代码来源:AddRoleToSPSiteTaskTest.cs

示例3: TearDown

		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  {
			}
		}
开发者ID:kiprainey,项目名称:nantcontrib,代码行数:13,代码来源:AddListToSPSiteTaskTest.cs

示例4: btnMove_Click

        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);
            }
        }
开发者ID:dreckner,项目名称:RecknerSharePointSolutions,代码行数:86,代码来源:Proposal2JobUserControl.ascx.cs


注:本文中的SPSite.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。