zoukankan      html  css  js  c++  java
  • SharePOint 2010 编程导入导出站点

    /// <summary>
            /// Exports plant site
            /// </summary>
            /// <param name="sourceSiteURL"></param>
            protected void ExportSite(string sourceSiteURL, ArrayList arrMoveSite)
            {
                try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite site = new SPSite(sourceSiteURL))
                        {
                            using (SPWeb web = site.OpenWeb())
                            {
                                SPExportObject exportObject = new SPExportObject();
                                exportObject.Type = SPDeploymentObjectType.Web;
                                exportObject.Id = web.ID;
                                exportObject.IncludeDescendants = SPIncludeDescendants.All;
    
    
                                SPExportSettings settings = new SPExportSettings();
                                settings.OverwriteExistingDataFile = true;
                                settings.SiteUrl = sourceSiteURL;
                                settings.BaseFileName = EXPORT_FILENAME;
                                settings.ExportMethod = SPExportMethodType.ExportAll;
                                settings.FileLocation = exportFolderName;
                                settings.FileCompression = true;
                                settings.IncludeSecurity = SPIncludeSecurity.All;
                                settings.IncludeVersions = SPIncludeVersions.All;
                                settings.LogFilePath = exportFolderName + web.ID + ".log";
                                settings.ExcludeDependencies = true;
                                settings.ExportObjects.Add(exportObject);
    
                                SPExport export = new SPExport(settings);
                                export.Run();
                                //Display Result
                                arrMoveSite.Add("Site "+web.Url.Substring(web.Url.LastIndexOf("/") + 1) + " has been exported successfully!");
                            }
                        }
                    });
                }
                catch (Exception ex)
                {
                    Log(ex, ex.Message);
                }
            }
    
            /// <summary>
            /// Imports plant site.
            /// </summary>
            /// <param name="destSiteURL"></param>
            protected void ImportSite(string destSiteURL)
            {
                try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite rootSiteColl = new SPSite(destSiteURL))
                        {
                            rootSiteColl.AllowUnsafeUpdates = true;
                            using (SPWeb rootWeb = rootSiteColl.OpenWeb())
                            {
                                rootWeb.AllowUnsafeUpdates = true;
                                SPUtility.ValidateFormDigest();
                                SPImportSettings importSettings = new SPImportSettings();
                                importSettings.SiteUrl = rootWeb.Url;
                                importSettings.WebUrl = rootWeb.Url;
                                importSettings.FileLocation = exportFolderName;
                                importSettings.FileCompression = true;
                                importSettings.BaseFileName = EXPORT_FILENAME;
                                importSettings.UserInfoDateTime = SPImportUserInfoDateTimeOption.ImportAll;
                                importSettings.IncludeSecurity = SPIncludeSecurity.All;
                                importSettings.UpdateVersions = SPUpdateVersions.Append;
                                importSettings.LogFilePath = exportFolderName + rootWeb.ID + ".log";
                                //importSettings.RetainObjectIdentity = false;
                                importSettings.Validate();
                                SPImport import = new SPImport(importSettings);
                                import.Run();
    
                                rootWeb.AllowUnsafeUpdates = false;
                                rootWeb.Close();
                            }
                            rootSiteColl.AllowUnsafeUpdates = false;
    
                        }
                    });
                }
                catch (Exception ex)
                {
                    Log(ex, ex.Message);
                }
  • 相关阅读:
    PHP中多维数组var_dump展示不全
    postman 请求接口 Could not get any response
    TP5中用redis缓存
    前端控制台 JavaScript函数报错 SyntaxError: expected expression, got ';' SyntaxError: expected expression, got 'if'
    jQuery 虚拟数字键盘代码
    判断当前点击的是第几个标签 例如 <li></li> 、<option></option>
    layui checkbox , radio 清除所有选中项
    layui select 联动渲染赋值不了数据的问题
    TP5 isEmpty() 判空方法 所用场景
    排序(插入排序、折半插入排序、希尔排序、冒泡排序、快速排序、简单选择排序、堆排、归并排序、基数排序)
  • 原文地址:https://www.cnblogs.com/ahghy/p/2879644.html
Copyright © 2011-2022 走看看