protected override void InternalProcessRecord()
        {
            using (SPWeb targetWeb = TargetWeb.Read())
            {
                SPList sourceList = SourceList.Read();
                try
                {
                    bool   compressFile        = !NoFileCompression.IsPresent;
                    bool   quiet               = !Verbose;
                    bool   haltOnWarning       = HaltOnWarning.IsPresent;
                    bool   haltOnFatalError    = HaltOnError.IsPresent;
                    bool   includeusersecurity = IncludeUserSecurity.IsPresent;
                    bool   excludeDependencies = !IncludeDependencies.IsPresent;
                    bool   copySecurity        = includeusersecurity;
                    bool   logFile             = !NoLogFile.IsPresent;
                    bool   deleteSource        = DeleteSource.IsPresent;
                    string directory           = null;
                    if (!string.IsNullOrEmpty(Path))
                    {
                        directory = Path;
                    }
                    bool suppressAfterEvents = SuppressAfterEvents.IsPresent;
                    bool retargetLinks       = RetargetLinks.IsPresent;

                    SPIncludeVersions versions = SPIncludeVersions.All;
                    if (IncludeVersions.HasValue)
                    {
                        versions = IncludeVersions.Value;
                    }

                    SPUpdateVersions updateVersions = SPUpdateVersions.Append;
                    if (UpdateVersions.HasValue)
                    {
                        updateVersions = UpdateVersions.Value;
                    }

                    SPIncludeDescendants includeDescendents = SPIncludeDescendants.All;
                    if (IncludeDescendants.HasValue)
                    {
                        includeDescendents = IncludeDescendants.Value;
                    }

                    bool useSqlSnapshot  = UseSqlSnapshot.IsPresent;
                    bool excludeChildren = ExcludeChildren.IsPresent;
                    Common.Lists.ImportList importList = new Common.Lists.ImportList(sourceList, targetWeb, retargetLinks);

                    importList.Copy(directory, compressFile, CompressionSize, includeusersecurity, excludeDependencies, haltOnFatalError, haltOnWarning, versions, updateVersions, suppressAfterEvents, copySecurity, deleteSource, logFile, quiet, includeDescendents, useSqlSnapshot, excludeChildren, RetainObjectIdentity);
                }
                finally
                {
                    targetWeb.Site.Dispose();
                    sourceList.ParentWeb.Dispose();
                    sourceList.ParentWeb.Site.Dispose();
                }
            }
        }
Beispiel #2
0
 public SPObjectData(Guid ID, Guid FileID, string Title, string Url, SPDeploymentObjectType DeploymentObjectType,
                     SPIncludeDescendants IncludeDescendents, SPWeb Web)
 {
     id                 = ID;
     fileId             = FileID;
     title              = Title;
     url                = Url;
     objectType         = DeploymentObjectType;
     includeDescendents = IncludeDescendents;
     parentWeb          = Web;
 }
Beispiel #3
0
 public SPObjectData(Guid ID, Guid FileID, string Title, string Url, SPDeploymentObjectType DeploymentObjectType, 
     SPIncludeDescendants IncludeDescendents, SPWeb Web)
 {
     id = ID;
     fileId = FileID;
     title = Title;
     url = Url;
     objectType = DeploymentObjectType;
     includeDescendents = IncludeDescendents;
     parentWeb = Web;
 }
        /// <summary>
        /// Runs the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="keyValues">The key values.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public override int Execute(string command, System.Collections.Specialized.StringDictionary keyValues, out string output)
        {
            output = string.Empty;

            string sourceUrl           = Params["sourceurl"].Value;
            string targetUrl           = Params["targeturl"].Value;
            bool   compressFile        = !Params["nofilecompression"].UserTypedIn;
            bool   quiet               = Params["quiet"].UserTypedIn;
            bool   haltOnWarning       = Params["haltonwarning"].UserTypedIn;
            bool   haltOnFatalError    = Params["haltonfatalerror"].UserTypedIn;
            bool   includeusersecurity = Params["includeusersecurity"].UserTypedIn;
            bool   excludeDependencies = Params["excludedependencies"].UserTypedIn;
            bool   copySecurity        = includeusersecurity;
            bool   logFile             = !Params["nologfile"].UserTypedIn;
            bool   deleteSource        = Params["deletesource"].UserTypedIn;
            string directory           = null;

            if (Params["temppath"].UserTypedIn)
            {
                directory = Params["temppath"].Value;
            }
            bool suppressAfterEvents   = Params["suppressafterevents"].UserTypedIn;
            bool retargetLinks         = Params["retargetlinks"].UserTypedIn;
            SPIncludeVersions versions = SPIncludeVersions.All;

            if (Params["versions"].UserTypedIn)
            {
                versions = (SPIncludeVersions)Enum.Parse(typeof(SPIncludeVersions), Params["versions"].Value);
            }
            SPUpdateVersions updateVersions = SPUpdateVersions.Append;

            if (Params["updateversions"].UserTypedIn)
            {
                updateVersions = (SPUpdateVersions)Enum.Parse(typeof(SPUpdateVersions), Params["updateversions"].Value);
            }
            SPIncludeDescendants includeDescendents = (SPIncludeDescendants)Enum.Parse(typeof(SPIncludeDescendants), Params["includedescendants"].Value, true);
            bool useSqlSnapshot  = Params["usesqlsnapshot"].UserTypedIn;
            bool excludeChildren = Params["excludechildren"].UserTypedIn;
            int  cabSize         = 0;

            if (Params["cabsize"].UserTypedIn)
            {
                cabSize = int.Parse(Params["cabsize"].Value);
            }

            Common.Lists.ImportList importList = new Common.Lists.ImportList(sourceUrl, targetUrl, retargetLinks);

            importList.Copy(directory, compressFile, cabSize, includeusersecurity, excludeDependencies, haltOnFatalError, haltOnWarning, versions, updateVersions, suppressAfterEvents, copySecurity, deleteSource, logFile, quiet, includeDescendents, useSqlSnapshot, excludeChildren, false);

            return((int)ErrorCodes.NoError);
        }
        /// <summary>
        /// Performs the export.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="compressFile">if set to <c>true</c> [compress file].</param>
        /// <param name="haltOnFatalError">if set to <c>true</c> [halt on fatal error].</param>
        /// <param name="haltOnWarning">if set to <c>true</c> [halt on warning].</param>
        /// <param name="includeusersecurity">if set to <c>true</c> [includeusersecurity].</param>
        /// <param name="cabSize">Size of the CAB.</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        /// <param name="versions">The versions.</param>
        /// <param name="includeDescendents">The include descendents.</param>
        /// <param name="excludeDependencies">if set to <c>true</c> [exclude dependencies].</param>
        public static void PerformExport(string url, string filename, bool compressFile, bool haltOnFatalError, bool haltOnWarning, bool includeusersecurity, int cabSize, bool logFile, bool overwrite, bool quiet, SPIncludeVersions versions, SPIncludeDescendants includeDescendents, bool excludeDependencies, bool useSqlSnapshot, bool excludeChildren)
        {
            SPExportObject exportObject = new SPExportObject();
            SPExportSettings settings = new SPExportSettings();
            settings.ExcludeDependencies = excludeDependencies;
            SPExport export = new SPExport(settings);

            exportObject.Type = SPDeploymentObjectType.List;
            exportObject.IncludeDescendants = includeDescendents;
            exportObject.ExcludeChildren = excludeChildren;
            StsAdm.OperationHelpers.ExportHelper.SetupExportObjects(settings, cabSize, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, overwrite, quiet, versions);

            PerformExport(export, exportObject, settings, logFile, quiet, url, useSqlSnapshot);
        }
Beispiel #6
0
        /// <summary>
        /// Runs the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="keyValues">The key values.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public override int Execute(string command, System.Collections.Specialized.StringDictionary keyValues, out string output)
        {
            output = string.Empty;

            string url                 = Params["url"].Value;
            bool   compressFile        = !Params["nofilecompression"].UserTypedIn;
            string filename            = Params["filename"].Value;
            bool   overwrite           = Params["overwrite"].UserTypedIn;
            bool   quiet               = Params["quiet"].UserTypedIn;
            bool   haltOnWarning       = Params["haltonwarning"].UserTypedIn;
            bool   haltOnFatalError    = Params["haltonfatalerror"].UserTypedIn;
            bool   includeusersecurity = Params["includeusersecurity"].UserTypedIn;
            bool   excludeDependencies = Params["excludedependencies"].UserTypedIn;
            bool   logFile             = !Params["nologfile"].UserTypedIn;
            bool   useSqlSnapshot      = Params["usesqlsnapshot"].UserTypedIn;
            bool   excludeChildren     = Params["excludechildren"].UserTypedIn;

            int cabSize = 0;

            if (Params["cabsize"].UserTypedIn)
            {
                cabSize = int.Parse(Params["cabsize"].Value);
            }

            SPIncludeVersions versions = SPIncludeVersions.All;

            if (Params["versions"].UserTypedIn)
            {
                versions = (SPIncludeVersions)Enum.Parse(typeof(SPIncludeVersions), Params["versions"].Value);
            }
            SPIncludeDescendants includeDescendents = (SPIncludeDescendants)Enum.Parse(typeof(SPIncludeDescendants), Params["includedescendants"].Value, true);

            Common.Lists.ExportList.PerformExport(url, filename, compressFile, haltOnFatalError, haltOnWarning, includeusersecurity, cabSize, logFile, overwrite, quiet, versions, includeDescendents, excludeDependencies, useSqlSnapshot, excludeChildren);


            return((int)ErrorCodes.NoError);
        }
Beispiel #7
0
        /// <summary>
        /// Performs the export.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="compressFile">if set to <c>true</c> [compress file].</param>
        /// <param name="haltOnFatalError">if set to <c>true</c> [halt on fatal error].</param>
        /// <param name="haltOnWarning">if set to <c>true</c> [halt on warning].</param>
        /// <param name="includeusersecurity">if set to <c>true</c> [includeusersecurity].</param>
        /// <param name="cabSize">Size of the CAB.</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        /// <param name="versions">The versions.</param>
        /// <param name="includeDescendents">The include descendents.</param>
        /// <param name="excludeDependencies">if set to <c>true</c> [exclude dependencies].</param>
        public static void PerformExport(string url, string filename, bool compressFile, bool haltOnFatalError, bool haltOnWarning, bool includeusersecurity, int cabSize, bool logFile, bool overwrite, bool quiet, SPIncludeVersions versions, SPIncludeDescendants includeDescendents, bool excludeDependencies, bool useSqlSnapshot, bool excludeChildren)
        {
            SPExportObject   exportObject = new SPExportObject();
            SPExportSettings settings     = new SPExportSettings();

            settings.ExcludeDependencies = excludeDependencies;
            SPExport export = new SPExport(settings);


            exportObject.Type = SPDeploymentObjectType.List;
            exportObject.IncludeDescendants = includeDescendents;
            exportObject.ExcludeChildren    = excludeChildren;
            StsAdm.OperationHelpers.ExportHelper.SetupExportObjects(settings, cabSize, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, overwrite, quiet, versions);



            PerformExport(export, exportObject, settings, logFile, quiet, url, useSqlSnapshot);
        }
        /// <summary>
        /// Copies the specified source list to the target URL.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="compressFile">if set to <c>true</c> [compress file].</param>
        /// <param name="includeusersecurity">if set to <c>true</c> [includeusersecurity].</param>
        /// <param name="excludeDependencies">if set to <c>true</c> [exclude dependencies].</param>
        /// <param name="haltOnFatalError">if set to <c>true</c> [halt on fatal error].</param>
        /// <param name="haltOnWarning">if set to <c>true</c> [halt on warning].</param>
        /// <param name="versions">The versions.</param>
        /// <param name="updateVersions">The update versions.</param>
        /// <param name="suppressAfterEvents">if set to <c>true</c> [suppress after events].</param>
        /// <param name="copySecurity">if set to <c>true</c> [copy security].</param>
        /// <param name="deleteSource">if set to <c>true</c> [delete source].</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        internal void Copy(string directory, bool compressFile, int cabSize, bool includeusersecurity, bool excludeDependencies, bool haltOnFatalError, bool haltOnWarning, SPIncludeVersions versions, SPUpdateVersions updateVersions, bool suppressAfterEvents, bool copySecurity, bool deleteSource, bool logFile, bool quiet, SPIncludeDescendants includeDescendents, bool useSqlSnapshot, bool excludeChildren, bool retainObjectIdentity)
        {
            if (string.IsNullOrEmpty(directory))
                directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            string filename = directory;
            if (compressFile)
                filename = Path.Combine(directory, "temp.cmp");

            SPExportObject exportObject = new SPExportObject();
            SPExportSettings exportSettings = new SPExportSettings();
            exportSettings.ExcludeDependencies = excludeDependencies;
            SPExport export = new SPExport(exportSettings);

            exportObject.Type = SPDeploymentObjectType.List;
            exportObject.IncludeDescendants = includeDescendents;
            exportObject.ExcludeChildren = excludeChildren;
            StsAdm.OperationHelpers.ExportHelper.SetupExportObjects(exportSettings, cabSize, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, true, quiet, versions);

            ExportList.PerformExport(export, exportObject, exportSettings, logFile, quiet, m_sourceUrl, useSqlSnapshot);

            SPImportSettings importSettings = new SPImportSettings();
            SPImport import = new SPImport(importSettings);

            StsAdm.OperationHelpers.ImportHelper.SetupImportObject(importSettings, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, quiet, updateVersions, retainObjectIdentity, suppressAfterEvents);

            try
            {
                m_targetSite = new SPSite(m_targetUrl);
                m_targetWeb = m_targetSite.AllWebs[Utilities.GetServerRelUrlFromFullUrl(m_targetUrl)];

                PerformImport(import, importSettings, logFile, m_targetUrl);

                // If the list is a discussion list then attempt to resolve flattened threads.
                //if (m_targetList != null)
                //    SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RepairDiscussionList(m_targetSite, m_targetList);

                if (!logFile && !deleteSource)
                {
                    Directory.Delete(directory, true);
                }
                else if (logFile && !deleteSource)
                {
                    foreach (string s in Directory.GetFiles(directory))
                    {
                        FileInfo file = new FileInfo(s);
                        if (file.Extension == ".log")
                            continue;
                        file.Delete();
                    }
                }

                if (deleteSource || copySecurity)
                {
                    using (SPSite sourceSite = new SPSite(m_sourceUrl))
                    using (SPWeb sourceWeb = sourceSite.OpenWeb())
                    {
                        SPList sourceList = Utilities.GetListFromViewUrl(sourceWeb, m_sourceUrl);

                        if (sourceList != null)
                        {
                            // If the user has chosen to include security then assume they mean for all the settings to match
                            // the source - copy those settings using the CopyListSecurity operation.
                            if (copySecurity)
                            {
                                Common.Lists.CopyListSecurity.CopySecurity(sourceList, m_targetList, m_targetWeb, true, quiet);
                            }

                            // If the user wants the source deleted (move operation) then delete using the DeleteList operation.
                            if (deleteSource)
                            {
                                DeleteList.Delete(sourceList, true);
                                Console.WriteLine("Source list deleted.  You can find the exported list here: " +
                                                  directory);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (m_targetSite != null)
                    m_targetSite.Dispose();
                if (m_targetWeb != null)
                    m_targetWeb.Dispose();
            }
        }
Beispiel #9
0
 public SPObjectData(Guid ID, string Title, string Url, SPDeploymentObjectType DeploymentObjectType,
     SPIncludeDescendants IncludeDescendents, SPWeb Web)
     : this(ID, Guid.Empty, Title, Url, DeploymentObjectType, IncludeDescendents, Web)
 {
 }
Beispiel #10
0
        internal static WizardExportSettings CollectExportSettings(XmlTextReader exportSettingsXml)
        {
            if (traceSwitchStatic.TraceVerbose)
            {
                traceStatic.TraceVerbose("CollectExportSettings: Entered CollectExportSettings().");
            }

            // create SPExportSettings object..
            SPExportSettings    exportSettings      = new SPExportSettings();
            List <SPObjectData> exportObjectDetails = new List <SPObjectData>();

            if (exportSettingsXml.Name != "ExportSettings")
            {
                exportSettingsXml.Read();
            }

            if (exportSettingsXml.Name == "ExportSettings")
            {
                if (exportSettingsXml.MoveToAttribute("SiteUrl"))
                {
                    exportSettings.SiteUrl = exportSettingsXml.Value;
                }
                if (exportSettingsXml.MoveToAttribute("ExcludeDependencies"))
                {
                    exportSettings.ExcludeDependencies = bool.Parse(exportSettingsXml.Value);
                }
                if (exportSettingsXml.MoveToAttribute("ExportMethod"))
                {
                    exportSettings.ExportMethod =
                        (SPExportMethodType)Enum.Parse(typeof(SPExportMethodType), exportSettingsXml.Value);
                }
                if (exportSettingsXml.MoveToAttribute("IncludeVersions"))
                {
                    exportSettings.IncludeVersions =
                        (SPIncludeVersions)Enum.Parse(typeof(SPIncludeVersions), exportSettingsXml.Value);
                }
                if (exportSettingsXml.MoveToAttribute("IncludeSecurity"))
                {
                    exportSettings.IncludeSecurity =
                        (SPIncludeSecurity)Enum.Parse(typeof(SPIncludeSecurity), exportSettingsXml.Value);
                }
                if (exportSettingsXml.MoveToAttribute("FileCompression"))
                {
                    exportSettings.FileCompression = bool.Parse(exportSettingsXml.Value);
                }
                if (exportSettingsXml.MoveToAttribute("FileLocation"))
                {
                    exportSettings.FileLocation = exportSettingsXml.Value;
                }
                if (exportSettingsXml.MoveToAttribute("BaseFileName"))
                {
                    exportSettings.BaseFileName = exportSettingsXml.Value;
                }
                if (exportSettingsXml.MoveToAttribute("IncludeSecurity"))
                {
                    exportSettings.IncludeSecurity =
                        (SPIncludeSecurity)Enum.Parse(typeof(SPIncludeSecurity), exportSettingsXml.Value);
                }

                exportSettingsXml.MoveToElement();
            }

            while (exportSettingsXml.Read())
            {
                if (exportSettingsXml.Name == "DeploymentObject")
                {
                    SPExportObject exportObject     = new SPExportObject();
                    SPObjectData   exportObjectData = new SPObjectData();

                    if (exportSettingsXml.MoveToAttribute("Id"))
                    {
                        Guid gID = new Guid(exportSettingsXml.Value);
                        exportObject.Id     = gID;
                        exportObjectData.ID = gID;
                    }
                    if (exportSettingsXml.MoveToAttribute("Type"))
                    {
                        SPDeploymentObjectType type = (SPDeploymentObjectType)
                                                      Enum.Parse(typeof(SPDeploymentObjectType), exportSettingsXml.Value);
                        exportObject.Type           = type;
                        exportObjectData.ObjectType = type;
                    }
                    if (exportSettingsXml.MoveToAttribute("ExcludeChildren"))
                    {
                        bool bExcludeChildren = bool.Parse(exportSettingsXml.Value);
                        exportObject.ExcludeChildren     = bExcludeChildren;
                        exportObjectData.ExcludeChildren = bExcludeChildren;
                    }
                    if (exportSettingsXml.MoveToAttribute("IncludeDescendants"))
                    {
                        SPIncludeDescendants includeDescs = (SPIncludeDescendants)
                                                            Enum.Parse(typeof(SPIncludeDescendants),
                                                                       exportSettingsXml.Value);
                        exportObject.IncludeDescendants     = includeDescs;
                        exportObjectData.IncludeDescendents = includeDescs;
                    }
                    if (exportSettingsXml.MoveToAttribute("Url"))
                    {
                        exportObject.Url     = exportSettingsXml.Value;
                        exportObjectData.Url = exportSettingsXml.Value;
                    }
                    if (exportSettingsXml.MoveToAttribute("Title"))
                    {
                        exportObjectData.Title = exportSettingsXml.Value;
                    }

                    exportSettings.ExportObjects.Add(exportObject);
                    exportObjectDetails.Add(exportObjectData);
                }
            }

            exportSettingsXml.Close();

            // set other properties which aren't tied to values in XML..
            exportSettings.TestRun = false;
            exportSettings.OverwriteExistingDataFile = true;
            exportSettings.LogFilePath = string.Format("{0}\\{1}.Export.log",
                                                       exportSettings.FileLocation, exportSettings.BaseFileName);

            if (traceSwitchStatic.TraceInfo)
            {
                traceStatic.TraceInfo("CollectExportSettings: Using site URL '{0}'.", exportSettings.SiteUrl);
                traceStatic.TraceInfo("CollectExportSettings: Exclude dependencies IDs = '{0}'.", exportSettings.ExcludeDependencies);
                traceStatic.TraceInfo("CollectExportSettings: Export method = '{0}'.", exportSettings.ExportMethod);
                traceStatic.TraceInfo("CollectExportSettings: File location = '{0}'.", exportSettings.FileLocation);
                traceStatic.TraceInfo("CollectExportSettings: Base filename = '{0}'.", exportSettings.BaseFileName);
                traceStatic.TraceInfo("CollectExportSettings: Include versions = '{0}'.", exportSettings.IncludeVersions);
                traceStatic.TraceInfo("CollectExportSettings: Log file path = '{0}'.", exportSettings.LogFilePath);
                traceStatic.TraceInfo("CollectExportSettings: Include security = '{0}'.", exportSettings.IncludeSecurity);
            }

            WizardExportSettings weSettings = new WizardExportSettings(exportSettings, exportObjectDetails);

            if (traceSwitchStatic.TraceVerbose)
            {
                traceStatic.TraceVerbose("CollectExportSettings: Leaving CollectExportSettings().");
            }

            return(weSettings);
        }
Beispiel #11
0
 public SPObjectData(Guid ID, string Title, string Url, SPDeploymentObjectType DeploymentObjectType,
                     SPIncludeDescendants IncludeDescendents, SPWeb Web)
     : this(ID, Guid.Empty, Title, Url, DeploymentObjectType, IncludeDescendents, Web)
 {
 }
Beispiel #12
0
        /// <summary>
        /// Copies the specified source list to the target URL.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="compressFile">if set to <c>true</c> [compress file].</param>
        /// <param name="includeusersecurity">if set to <c>true</c> [includeusersecurity].</param>
        /// <param name="excludeDependencies">if set to <c>true</c> [exclude dependencies].</param>
        /// <param name="haltOnFatalError">if set to <c>true</c> [halt on fatal error].</param>
        /// <param name="haltOnWarning">if set to <c>true</c> [halt on warning].</param>
        /// <param name="versions">The versions.</param>
        /// <param name="updateVersions">The update versions.</param>
        /// <param name="suppressAfterEvents">if set to <c>true</c> [suppress after events].</param>
        /// <param name="copySecurity">if set to <c>true</c> [copy security].</param>
        /// <param name="deleteSource">if set to <c>true</c> [delete source].</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        internal void Copy(string directory, bool compressFile, int cabSize, bool includeusersecurity, bool excludeDependencies, bool haltOnFatalError, bool haltOnWarning, SPIncludeVersions versions, SPUpdateVersions updateVersions, bool suppressAfterEvents, bool copySecurity, bool deleteSource, bool logFile, bool quiet, SPIncludeDescendants includeDescendents, bool useSqlSnapshot, bool excludeChildren, bool retainObjectIdentity)
        {
            if (string.IsNullOrEmpty(directory))
            {
                directory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            }
            string filename = directory;

            if (compressFile)
            {
                filename = Path.Combine(directory, "temp.cmp");
            }

            SPExportObject   exportObject   = new SPExportObject();
            SPExportSettings exportSettings = new SPExportSettings();

            exportSettings.ExcludeDependencies = excludeDependencies;
            SPExport export = new SPExport(exportSettings);

            exportObject.Type = SPDeploymentObjectType.List;
            exportObject.IncludeDescendants = includeDescendents;
            exportObject.ExcludeChildren    = excludeChildren;
            StsAdm.OperationHelpers.ExportHelper.SetupExportObjects(exportSettings, cabSize, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, true, quiet, versions);

            ExportList.PerformExport(export, exportObject, exportSettings, logFile, quiet, m_sourceUrl, useSqlSnapshot);

            SPImportSettings importSettings = new SPImportSettings();
            SPImport         import         = new SPImport(importSettings);

            StsAdm.OperationHelpers.ImportHelper.SetupImportObject(importSettings, compressFile, filename, haltOnFatalError, haltOnWarning, includeusersecurity, logFile, quiet, updateVersions, retainObjectIdentity, suppressAfterEvents);

            try
            {
                m_targetSite = new SPSite(m_targetUrl);
                m_targetWeb  = m_targetSite.AllWebs[Utilities.GetServerRelUrlFromFullUrl(m_targetUrl)];

                PerformImport(import, importSettings, logFile, m_targetUrl);

                // If the list is a discussion list then attempt to resolve flattened threads.
                //if (m_targetList != null)
                //    SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RepairDiscussionList(m_targetSite, m_targetList);

                if (!logFile && !deleteSource)
                {
                    Directory.Delete(directory, true);
                }
                else if (logFile && !deleteSource)
                {
                    foreach (string s in Directory.GetFiles(directory))
                    {
                        FileInfo file = new FileInfo(s);
                        if (file.Extension == ".log")
                        {
                            continue;
                        }
                        file.Delete();
                    }
                }

                if (deleteSource || copySecurity)
                {
                    using (SPSite sourceSite = new SPSite(m_sourceUrl))
                        using (SPWeb sourceWeb = sourceSite.OpenWeb())
                        {
                            SPList sourceList = Utilities.GetListFromViewUrl(sourceWeb, m_sourceUrl);

                            if (sourceList != null)
                            {
                                // If the user has chosen to include security then assume they mean for all the settings to match
                                // the source - copy those settings using the CopyListSecurity operation.
                                if (copySecurity)
                                {
                                    Common.Lists.CopyListSecurity.CopySecurity(sourceList, m_targetList, m_targetWeb, true, quiet);
                                }

                                // If the user wants the source deleted (move operation) then delete using the DeleteList operation.
                                if (deleteSource)
                                {
                                    DeleteList.Delete(sourceList, true);
                                    Console.WriteLine("Source list deleted.  You can find the exported list here: " +
                                                      directory);
                                }
                            }
                        }
                }
            }
            finally
            {
                if (m_targetSite != null)
                {
                    m_targetSite.Dispose();
                }
                if (m_targetWeb != null)
                {
                    m_targetWeb.Dispose();
                }
            }
        }