public override void Execute(Guid targetInstanceId)
 {
     var export = new SPExport(SetUpExportSettings());
     var import = new SPImport(SetUpImportSettings());
     export.Run();
     import.Run();
 }
示例#2
0
 /// <summary>
 /// Creates a Template file (.cmp file) based on the specified web site.
 /// File is stored in the specified location.
 /// </summary>
 /// <param name="spWeb"></param>
 /// <param name="pathForTemplateFile"></param>
 public static void exportSpWeb(SPWeb spWeb, string pathForTemplateFile)
 {
     try
     {
         SPExportObject spExportObject = new SPExportObject();
         spExportObject.Id = spWeb.ID;
         spExportObject.IncludeDescendants = SPIncludeDescendants.All;
         spExportObject.Type = SPDeploymentObjectType.Web;
         SPExportSettings exportSettings = new SPExportSettings();
         exportSettings.SiteUrl                   = spWeb.Url;
         exportSettings.ExportMethod              = SPExportMethodType.ExportAll;
         exportSettings.FileLocation              = Path.GetDirectoryName(pathForTemplateFile);
         exportSettings.BaseFileName              = Path.GetFileNameWithoutExtension(pathForTemplateFile);
         exportSettings.FileCompression           = true;
         exportSettings.IncludeSecurity           = SPIncludeSecurity.All;
         exportSettings.ExcludeDependencies       = true;
         exportSettings.OverwriteExistingDataFile = true;
         exportSettings.ExportObjects.Add(spExportObject);
         SPExport export = new SPExport(exportSettings);
         export.Run();
     }
     catch (Exception ex)
     {
         log.addError("Fatal Error: Could not export specified site. " + ex.ToString());
         throw;
     }
 }
示例#3
0
        private void BackupMenuItem_Click(object sender, EventArgs e)
        {
            //SaveFileDialog fileDialog = new SaveFileDialog();

            //DialogResult result = fileDialog.ShowDialog();
            //if (result == DialogResult.OK)
            //{
            Cursor.Current = Cursors.WaitCursor;

            SPSite           site       = CurrentNode.Tag as SPSite;
            SPSiteCollection collection = CurrentNode.SPParent as SPSiteCollection;

            string siteurl = site.Url;

            SPExportSettings exportSettings = new SPExportSettings();

            exportSettings.SiteUrl = site.Url;
            Guid           id  = new Guid("d151035f-a876-4d34-8f58-7b6cfdd3ace3");
            SPExportObject edf = new SPExportObject();

            edf.Id = id;
            edf.IncludeDescendants = SPIncludeDescendants.All;
            edf.Type            = SPDeploymentObjectType.File;
            edf.ExcludeChildren = false;

            //exportSettings.ExportMethod = SPExportMethodType.ExportAll;

            exportSettings.BaseFileName    = "MyFile";
            exportSettings.FileLocation    = @"c:\test\";
            exportSettings.FileCompression = true;
            exportSettings.ExportObjects.Add(edf);

            SPExport export = new SPExport(exportSettings);

            export.Run();


            SPImportSettings importSettings = new SPImportSettings();

            importSettings.SiteUrl         = siteurl;
            importSettings.BaseFileName    = "MyFile";
            importSettings.FileLocation    = @"c:\test\";
            importSettings.FileCompression = true;
            importSettings.WebUrl          = siteurl + "/PublishingImages/";

            //SPImportObject imp = new SPImportObject();
            //imp.Type = SPDeploymentObjectType.File;
            //imp.

            SPImport import = new SPImport();

            import.Run();


            //collection.Backup(site.Url, fileDialog.FileName, true);

            Cursor.Current = Cursors.Default;
//            }
        }
        protected void btnCopy_Click(object sender, EventArgs e)
        {
            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 = ContentCopierWebPart.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();

                }

            });

               SPSecurity.RunWithElevatedPrivileges(delegate
                {

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

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

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

                        SPImport import = new SPImport(settings);

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

                        Response.Redirect(destinationWeb.Url);

            });
        }
示例#5
0
        public SPExportInstance(ObjectInstance prototype, SPExport export)
            : this(prototype)
        {
            if (export == null)
            {
                throw new ArgumentNullException("export");
            }

            m_export = export;
        }
示例#6
0
        private void BackupMenuItem_Click(object sender, EventArgs e)
        {
            //SaveFileDialog fileDialog = new SaveFileDialog();

            //DialogResult result = fileDialog.ShowDialog();
            //if (result == DialogResult.OK)
            //{
                Cursor.Current = Cursors.WaitCursor;

                SPSite site = CurrentNode.Tag as SPSite;
                SPSiteCollection collection = CurrentNode.SPParent as SPSiteCollection;

                string siteurl = site.Url;

                SPExportSettings exportSettings = new SPExportSettings();
                exportSettings.SiteUrl = site.Url;
                Guid id = new Guid("d151035f-a876-4d34-8f58-7b6cfdd3ace3");
                SPExportObject edf = new SPExportObject();
                edf.Id = id;
                edf.IncludeDescendants = SPIncludeDescendants.All;
                edf.Type = SPDeploymentObjectType.File;
                edf.ExcludeChildren = false;

                //exportSettings.ExportMethod = SPExportMethodType.ExportAll;

                exportSettings.BaseFileName = "MyFile";
                exportSettings.FileLocation = @"c:\test\";
                exportSettings.FileCompression = true;
                exportSettings.ExportObjects.Add(edf);

                SPExport export = new SPExport(exportSettings);
                export.Run();

                SPImportSettings importSettings = new SPImportSettings();
                importSettings.SiteUrl = siteurl;
                importSettings.BaseFileName = "MyFile";
                importSettings.FileLocation = @"c:\test\";
                importSettings.FileCompression = true;
                importSettings.WebUrl = siteurl+"/PublishingImages/";

                //SPImportObject imp = new SPImportObject();
                //imp.Type = SPDeploymentObjectType.File;
                //imp.

                SPImport import = new SPImport();
                import.Run();

                //collection.Backup(site.Url, fileDialog.FileName, true);

                Cursor.Current = Cursors.Default;
            //            }
        }
        /// <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);
        }
示例#8
0
        public bool Export(SPWeb web, string filename)
        {
            SPExportSettings exportSettings = new SPExportSettings();

            exportSettings.SiteUrl      = web.Url;
            exportSettings.ExportMethod = SPExportMethodType.ExportAll;
            exportSettings.BaseFileName = Helper.Instance.ExtractFileName(filename);
            exportSettings.FileLocation = Helper.Instance.ExtractFolder(filename);
            exportSettings.OverwriteExistingDataFile = true;

            SPExport export = new SPExport(exportSettings);

            export.Run();

            return(true);
        }
        public ISPExport Create()
        {
            ISPExport export = null;

            try
            {
                export = new SPExport();
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(export);
        }
示例#10
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);
        }
示例#11
0
        public static void CopyFilesToDropLocation(SPExport export, string dropLocation)
        {
            //If a drop location is specified, copy the files to the target location.
            if (dropLocation.IsNullOrWhiteSpace())
            {
                return;
            }

            var filesToCopy = export.Settings.DataFiles.OfType <string>()
                              .Select(dataFile => new Tuple <string, string>(Path.Combine(export.Settings.FileLocation, dataFile), dataFile))
                              .ToList();

            SPSite   dropSite;
            SPWeb    dropWeb;
            SPFolder dropFolder;

            if (!SPHelper.TryGetSPFolder(dropLocation, out dropSite, out dropWeb, out dropFolder))
            {
                return;
            }

            try
            {
                foreach (var fileToCopy in filesToCopy)
                {
                    using (var fs = File.Open(fileToCopy.Item1, FileMode.Open, FileAccess.Read))
                    {
                        dropFolder.Files.Add(fileToCopy.Item2, fs, true, "", false);
                    }
                }
            }
            finally
            {
                if (dropSite != null)
                {
                    dropSite.Dispose();
                }

                if (dropWeb != null)
                {
                    dropWeb.Dispose();
                }
            }
        }
示例#12
0
        protected void exportButton_Click(object sender, EventArgs e)
        {
            //Create an export settings object to configure the export
            SPExportSettings exportSettings = new SPExportSettings();

            //Set the site you want to export from. Alter this to match your site.
            exportSettings.SiteUrl = "http://intranet.contoso.com";
            //Select a full export (alternatively you could do an incremental export to just include changes)
            exportSettings.ExportMethod = SPExportMethodType.ExportAll;
            //Set the location and name of the export file
            exportSettings.BaseFileName = "demoTasksExport";
            exportSettings.FileLocation = @"C:\";

            //To export just the Tasks list, first create an ExportObject
            SPExportObject tasksEO = new SPExportObject();

            //We must set it to export a SharePoint List
            tasksEO.Type = SPDeploymentObjectType.List;
            //We want to export everything in the list
            tasksEO.IncludeDescendants = SPIncludeDescendants.All;
            //Set the URL of the list to export.
            tasksEO.Url = "http://intranet.contoso.com/lists/tasks";
            //Add that to the Export Objects collection
            exportSettings.ExportObjects.Add(tasksEO);

            //Do the export
            SPExport export = new SPExport(exportSettings);

            try
            {
                export.Run();
                resultsLabel.Text = "The export ran successfully";
            }
            catch (Exception ex)
            {
                resultsLabel.Text = "The export generated an error: " + ex.Message;
            }
        }
示例#13
0
        public ArrayInstance Export(
            [JSDoc("An object that contains export settings properties or an instance of SPExportSettings")]
            object exportSettings,
            [JSDoc("The target drop location or null to keep in target folder.")]
            object dropLocation)
        {
            var export = new SPExport();

            if (exportSettings is SPExportSettingsInstance)
            {
                export.Settings = (exportSettings as SPExportSettingsInstance).SPExportSettings;
            }
            else if (exportSettings is ObjectInstance)
            {
                var settings = JurassicHelper.Coerce <SPExportSettingsInstance>(Engine, exportSettings as ObjectInstance);
                export.Settings = settings.SPExportSettings;
            }
            else
            {
                throw new JavaScriptException(Engine, "Error", "Expected the first argument to be a export settings object.");
            }

            export.Run();
            if (dropLocation != Null.Value && dropLocation != Undefined.Value)
            {
                SPExportInstance.CopyFilesToDropLocation(export, TypeConverter.ToString(dropLocation));
            }

            var result = Engine.Array.Construct();

            foreach (var dataFile in export.Settings.DataFiles.OfType <string>())
            {
                ArrayInstance.Push(result, dataFile);
            }
            return(result);
        }
示例#14
0
        public ExportOperationResult RunExport()
        {
            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("runExportTask: Entered runExportTask().");
            }

            ExportOperationResult exportResult;
            
            // set change token to use if incremental export selected..
            if (ExportSettings.ExportMethod == SPExportMethodType.ExportChanges)
            {
                // first check if we are exporting any site/web objects..
                if (!hasSiteOrWebObject(ExportSettings.ExportObjects))
                {
                    // raise event here if we didn't find a site or web being exported..
                    if (ValidChangeTokenNotFound != null)
                    {
                        ValidChangeTokenNotFound(this, new InvalidChangeTokenEventArgs
                        {
                            EventMessage = WizardDeployment.InvalidObjectsForIncrementalDeploymentMessage
                        });
                    }
                }
                else
                {
                    string lastToken = IncrementalManager.GetLastToken(ExportSettings);
                    if (!string.IsNullOrEmpty(lastToken))
                    {
                        if (traceSwitch.TraceInfo)
                        {
                            trace.TraceInfo(
                                string.Format("runExportTask: Incremental export selected, using change token '{0}'.",
                                              lastToken));
                        }

                        ExportSettings.ExportChangeToken = lastToken;
                    }
                    else
                    {
                        if (traceSwitch.TraceWarning)
                        {
                            trace.TraceWarning(
                                "runExportTask: Attempted to use incremental export selected but no valid change tokens have " +
                                "yet been stored. Defaulting to full export, *current* change token will be stored for future incremental deployments.");
                        }

                        // raise event here if we didn't find a suitable stored change token..
                        if (ValidChangeTokenNotFound != null)
                        {
                            ValidChangeTokenNotFound(this, new InvalidChangeTokenEventArgs
                            {
                                EventMessage = WizardDeployment.ChangeTokenNotFoundMessage
                            });
                        }

                        ExportSettings.ExportMethod = SPExportMethodType.ExportAll;
                    }
                }
            }

            using (SPExport export = new SPExport(ExportSettings))
            {
                export.ProgressUpdated += new EventHandler<SPDeploymentEventArgs>(export_ProgressUpdated);
                export.Completed += new EventHandler<SPDeploymentEventArgs>(export_Completed);

                if (traceSwitch.TraceInfo)
                {
                    trace.TraceInfo("runExportTask: Wired event handlers, about to call Run()..");
                }

                try
                {
                    // initialise to default..
                    exportResult = new ExportOperationResult(ResultType.Failure);

                    export.Run();

                    if (traceSwitch.TraceInfo)
                    {
                        trace.TraceInfo("runExportTask: Export completed successfully.");
                    }

                    // this distinction is to support incremental exports in case the client cares about the token..
                    if (ExportSettings.ExportMethod == SPExportMethodType.ExportAll)
                    {
                        exportResult = new ExportOperationResult(ResultType.Success);
                    }
                    else if (ExportSettings.ExportMethod == SPExportMethodType.ExportChanges)
                    {
                        exportResult = new ExportOperationResult(ResultType.Success, ExportSettings.CurrentChangeToken);
                    }

                    IncrementalManager.SaveToken(ExportSettings.CurrentChangeToken);
                }
                catch (Exception e)
                {
                    if (traceSwitch.TraceError)
                    {
                        trace.TraceError("runExportTask: Exception caught whilst running export: '{0}'.", e);
                    }

                    throw;
                }
            }

            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("runExportTask: Exiting runExportTask().");
            }

            return exportResult;
        }
 protected override void InternalProcessRecord()
 {
     bool createLogFile = !base.NoLogFile.IsPresent;
     if (!base.NoFileCompression.IsPresent)
     {
         this.ValidateDirectory(base.Path);
     }
     if ((!base.Force.IsPresent) && File.Exists(base.Path))
     {
         throw new SPException(string.Format("PSCannotOverwriteExport,{0}", base.Path));
     }
     SPExportSettings settings = new SPExportSettings();
     SPExport export = new SPExport(settings);
     base.SetDeploymentSettings(settings);
     settings.ExportMethod = SPExportMethodType.ExportAll;
     settings.ExcludeDependencies = !IncludeDependencies.IsPresent;
     SPDatabaseSnapshot snapshot = null;
     if (!this.UseSqlSnapshot.IsPresent)
     {
         settings.SiteUrl = this.SiteUrl;
     }
     else
     {
         snapshot = this.Site.ContentDatabase.Snapshots.CreateSnapshot();
         SPContentDatabase database2 = SPContentDatabase.CreateUnattachedContentDatabase(snapshot.ConnectionString);
         settings.UnattachedContentDatabase = database2;
         settings.SiteUrl = database2.Sites[this.Site.ServerRelativeUrl].Url;
     }
     SPExportObject exportObject = this.ExportObject;
     if (((exportObject.Type != SPDeploymentObjectType.Web) ||
         base.ShouldProcess(string.Format("ShouldProcessExportWeb,{0},{1}", this.SiteUrl, base.Path ))) &&
         ((exportObject.Type != SPDeploymentObjectType.List) ||
         base.ShouldProcess(string.Format("ShouldProcessExportList,{0},{1}", this.SiteUrl + "/" + this.ItemUrl, base.Path))))
     {
         if (exportObject != null)
         {
             exportObject.ExcludeChildren = ExcludeChildren.IsPresent;
             exportObject.IncludeDescendants = IncludeDescendants;
             settings.ExportObjects.Add(exportObject);
         }
         settings.IncludeVersions = this.IncludeVersions;
         if (base.IncludeUserSecurity.IsPresent)
         {
             settings.IncludeSecurity = SPIncludeSecurity.All;
         }
         settings.OverwriteExistingDataFile = (bool)base.Force;
         settings.FileMaxSize = this.CompressionSize;
         try
         {
             export.Run();
         }
         finally
         {
             if (base.Verbose && createLogFile)
             {
                 Console.WriteLine();
                 Console.WriteLine(SPResource.GetString("ExportOperationLogFile", new object[0]));
                 Console.WriteLine("\t{0}", settings.LogFilePath);
             }
             if ((this.UseSqlSnapshot.IsPresent) && (snapshot != null))
             {
                 snapshot.Delete();
             }
         }
         if (base.Verbose)
         {
             string fileLocation = settings.FileLocation;
             ArrayList dataFiles = settings.DataFiles;
             if (dataFiles != null)
             {
                 if (((fileLocation != null) && (fileLocation.Length > 0)) && (fileLocation[fileLocation.Length - 1] != System.IO.Path.DirectorySeparatorChar))
                 {
                     fileLocation = fileLocation + System.IO.Path.DirectorySeparatorChar;
                 }
                 Console.WriteLine();
                 Console.WriteLine(SPResource.GetString("ExportOperationFilesGenerated", new object[0]));
                 for (int i = 0; i < dataFiles.Count; i++)
                 {
                     Console.WriteLine("\t{0}{1}", fileLocation, dataFiles[i]);
                     Console.WriteLine();
                 }
                 if (base.NoFileCompression.IsPresent)
                 {
                     DirectoryInfo info = new DirectoryInfo(base.Path);
                     Console.WriteLine("\t{0}", info.FullName);
                 }
                 Console.WriteLine();
             }
         }
     }
 }
        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);
            }
        }
示例#17
0
        /// <summary>
        /// Performs the export.
        /// </summary>
        /// <param name="export">The export.</param>
        /// <param name="exportObject">The export object.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        /// <param name="url">The URL.</param>
        internal static void PerformExport(SPExport export, SPExportObject exportObject, SPExportSettings settings, bool logFile, bool quiet, string url, bool useSqlSnapshot)
        {
            SPDatabaseSnapshot snapshot = null;

            using (SPSite site = new SPSite(url))
            {
                ValidateUser(site);

                if (!useSqlSnapshot)
                {
                    settings.SiteUrl = site.Url;
                }
                else
                {
                    snapshot = site.ContentDatabase.Snapshots.CreateSnapshot();
                    SPContentDatabase database2 = SPContentDatabase.CreateUnattachedContentDatabase(snapshot.ConnectionString);
                    settings.UnattachedContentDatabase = database2;
                    settings.SiteUrl = database2.Sites[site.ServerRelativeUrl].Url;
                }

                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = Utilities.GetListFromViewUrl(web, url);

                    if (list == null)
                    {
                        throw new Exception("List not found.");
                    }

                    settings.SiteUrl = web.Url;
                    exportObject.Id  = list.ID;
                }

                settings.ExportObjects.Add(exportObject);


                try
                {
                    export.Run();
                    if (!quiet)
                    {
                        ArrayList dataFiles = settings.DataFiles;
                        if (dataFiles != null)
                        {
                            Console.WriteLine();
                            Console.WriteLine("File(s) generated: ");
                            for (int i = 0; i < dataFiles.Count; i++)
                            {
                                Console.WriteLine("\t{0}", Path.Combine(settings.FileLocation, (string)dataFiles[i]));
                                Console.WriteLine();
                            }
                            Console.WriteLine();
                        }
                    }
                }
                finally
                {
                    if (useSqlSnapshot && (snapshot != null))
                    {
                        snapshot.Delete();
                    }

                    if (logFile)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Log file generated: ");
                        Console.WriteLine("\t{0}", settings.LogFilePath);
                    }
                }
            }
        }
示例#18
0
        private ArrayInstance ExportInternal(object fileLocation, object baseFileName, object logFilePath, IEnumerable <SPExportObject> exportObjects, object dropLocation)
        {
            var exportSettings = new SPExportSettings
            {
                ExportMethod              = Microsoft.SharePoint.Deployment.SPExportMethodType.ExportAll,
                SiteUrl                   = SPBaristaContext.Current.Site.Url,
                IncludeSecurity           = Microsoft.SharePoint.Deployment.SPIncludeSecurity.All,
                IncludeVersions           = Microsoft.SharePoint.Deployment.SPIncludeVersions.All,
                OverwriteExistingDataFile = true
            };

            if (fileLocation != Null.Value && fileLocation != Undefined.Value)
            {
                var strFileLocation = TypeConverter.ToString(fileLocation);
                if (strFileLocation.IsNullOrWhiteSpace() == false)
                {
                    exportSettings.AutoGenerateDataFileName = false;
                    exportSettings.FileLocation             = strFileLocation;
                }
            }

            if (baseFileName != Null.Value && baseFileName != Undefined.Value)
            {
                var strBaseFileName = TypeConverter.ToString(baseFileName);
                if (strBaseFileName.IsNullOrWhiteSpace() == false)
                {
                    exportSettings.AutoGenerateDataFileName = false;
                    exportSettings.BaseFileName             = strBaseFileName;
                }
            }

            if (logFilePath != Null.Value && logFilePath != Undefined.Value)
            {
                var strLogFilePath = TypeConverter.ToString(logFilePath);
                if (strLogFilePath.IsNullOrWhiteSpace() == false)
                {
                    exportSettings.LogFilePath = strLogFilePath;
                }
            }

            foreach (var obj in exportObjects)
            {
                exportSettings.ExportObjects.Add(obj);
            }

            var export = new SPExport(exportSettings);

            export.Run();

            if (dropLocation != Null.Value && dropLocation != Undefined.Value)
            {
                SPExportInstance.CopyFilesToDropLocation(export, TypeConverter.ToString(dropLocation));
            }

            var result = Engine.Array.Construct();

            foreach (var dataFile in exportSettings.DataFiles.OfType <string>())
            {
                ArrayInstance.Push(result, Path.Combine(exportSettings.FileLocation, dataFile));
            }
            return(result);
        }
        /// <summary>
        /// Performs the export.
        /// </summary>
        /// <param name="export">The export.</param>
        /// <param name="exportObject">The export object.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="logFile">if set to <c>true</c> [log file].</param>
        /// <param name="quiet">if set to <c>true</c> [quiet].</param>
        /// <param name="url">The URL.</param>
        internal static void PerformExport(SPExport export, SPExportObject exportObject, SPExportSettings settings, bool logFile, bool quiet, string url, bool useSqlSnapshot)
        {
            SPDatabaseSnapshot snapshot = null;
            using (SPSite site = new SPSite(url))
            {
                ValidateUser(site);

                if (!useSqlSnapshot)
                {
                    settings.SiteUrl = site.Url;
                }
                else
                {
                    snapshot = site.ContentDatabase.Snapshots.CreateSnapshot();
                    SPContentDatabase database2 = SPContentDatabase.CreateUnattachedContentDatabase(snapshot.ConnectionString);
                    settings.UnattachedContentDatabase = database2;
                    settings.SiteUrl = database2.Sites[site.ServerRelativeUrl].Url;
                }

                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = Utilities.GetListFromViewUrl(web, url);

                    if (list == null)
                    {
                        throw new Exception("List not found.");
                    }

                    settings.SiteUrl = web.Url;
                    exportObject.Id = list.ID;
                }

                settings.ExportObjects.Add(exportObject);

                try
                {
                    export.Run();
                    if (!quiet)
                    {
                        ArrayList dataFiles = settings.DataFiles;
                        if (dataFiles != null)
                        {
                            Console.WriteLine();
                            Console.WriteLine("File(s) generated: ");
                            for (int i = 0; i < dataFiles.Count; i++)
                            {
                                Console.WriteLine("\t{0}", Path.Combine(settings.FileLocation, (string)dataFiles[i]));
                                Console.WriteLine();
                            }
                            Console.WriteLine();

                        }
                    }
                }
                finally
                {
                    if (useSqlSnapshot && (snapshot != null))
                    {
                        snapshot.Delete();
                    }

                    if (logFile)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Log file generated: ");
                        Console.WriteLine("\t{0}", settings.LogFilePath);
                    }
                }
            }
        }
示例#20
0
        public ExportOperationResult RunExport()
        {
            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("runExportTask: Entered runExportTask().");
            }

            ExportOperationResult exportResult;

            // set change token to use if incremental export selected..
            if (ExportSettings.ExportMethod == SPExportMethodType.ExportChanges)
            {
                // first check if we are exporting any site/web objects..
                if (!hasSiteOrWebObject(ExportSettings.ExportObjects))
                {
                    // raise event here if we didn't find a site or web being exported..
                    if (ValidChangeTokenNotFound != null)
                    {
                        ValidChangeTokenNotFound(this, new InvalidChangeTokenEventArgs
                        {
                            EventMessage = WizardDeployment.InvalidObjectsForIncrementalDeploymentMessage
                        });
                    }
                }
                else
                {
                    string lastToken = IncrementalManager.GetLastToken(ExportSettings);
                    if (!string.IsNullOrEmpty(lastToken))
                    {
                        if (traceSwitch.TraceInfo)
                        {
                            trace.TraceInfo(
                                string.Format("runExportTask: Incremental export selected, using change token '{0}'.",
                                              lastToken));
                        }

                        ExportSettings.ExportChangeToken = lastToken;
                    }
                    else
                    {
                        if (traceSwitch.TraceWarning)
                        {
                            trace.TraceWarning(
                                "runExportTask: Attempted to use incremental export selected but no valid change tokens have " +
                                "yet been stored. Defaulting to full export, *current* change token will be stored for future incremental deployments.");
                        }

                        // raise event here if we didn't find a suitable stored change token..
                        if (ValidChangeTokenNotFound != null)
                        {
                            ValidChangeTokenNotFound(this, new InvalidChangeTokenEventArgs
                            {
                                EventMessage = WizardDeployment.ChangeTokenNotFoundMessage
                            });
                        }

                        ExportSettings.ExportMethod = SPExportMethodType.ExportAll;
                    }
                }
            }

            using (SPExport export = new SPExport(ExportSettings))
            {
                export.ProgressUpdated += new EventHandler <SPDeploymentEventArgs>(export_ProgressUpdated);
                export.Completed       += new EventHandler <SPDeploymentEventArgs>(export_Completed);

                if (traceSwitch.TraceInfo)
                {
                    trace.TraceInfo("runExportTask: Wired event handlers, about to call Run()..");
                }

                try
                {
                    // initialise to default..
                    exportResult = new ExportOperationResult(ResultType.Failure);

                    export.Run();

                    if (traceSwitch.TraceInfo)
                    {
                        trace.TraceInfo("runExportTask: Export completed successfully.");
                    }

                    // this distinction is to support incremental exports in case the client cares about the token..
                    if (ExportSettings.ExportMethod == SPExportMethodType.ExportAll)
                    {
                        exportResult = new ExportOperationResult(ResultType.Success);
                    }
                    else if (ExportSettings.ExportMethod == SPExportMethodType.ExportChanges)
                    {
                        exportResult = new ExportOperationResult(ResultType.Success, ExportSettings.CurrentChangeToken);
                    }

                    IncrementalManager.SaveToken(ExportSettings.CurrentChangeToken);
                }
                catch (Exception e)
                {
                    if (traceSwitch.TraceError)
                    {
                        trace.TraceError("runExportTask: Exception caught whilst running export: '{0}'.", e);
                    }

                    throw;
                }
            }

            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("runExportTask: Exiting runExportTask().");
            }

            return(exportResult);
        }
        protected override void InternalProcessRecord()
        {
            bool createLogFile = !base.NoLogFile.IsPresent;

            if (!base.NoFileCompression.IsPresent)
            {
                this.ValidateDirectory(base.Path);
            }
            if ((!base.Force.IsPresent) && File.Exists(base.Path))
            {
                throw new SPException(string.Format("PSCannotOverwriteExport,{0}", base.Path));
            }
            SPExportSettings settings = new SPExportSettings();
            SPExport         export   = new SPExport(settings);

            base.SetDeploymentSettings(settings);
            settings.ExportMethod        = SPExportMethodType.ExportAll;
            settings.ExcludeDependencies = !IncludeDependencies.IsPresent;
            SPDatabaseSnapshot snapshot = null;

            if (!this.UseSqlSnapshot.IsPresent)
            {
                settings.SiteUrl = this.SiteUrl;
            }
            else
            {
                snapshot = this.Site.ContentDatabase.Snapshots.CreateSnapshot();
                SPContentDatabase database2 = SPContentDatabase.CreateUnattachedContentDatabase(snapshot.ConnectionString);
                settings.UnattachedContentDatabase = database2;
                settings.SiteUrl = database2.Sites[this.Site.ServerRelativeUrl].Url;
            }
            SPExportObject exportObject = this.ExportObject;

            if (((exportObject.Type != SPDeploymentObjectType.Web) ||
                 base.ShouldProcess(string.Format("ShouldProcessExportWeb,{0},{1}", this.SiteUrl, base.Path))) &&
                ((exportObject.Type != SPDeploymentObjectType.List) ||
                 base.ShouldProcess(string.Format("ShouldProcessExportList,{0},{1}", this.SiteUrl + "/" + this.ItemUrl, base.Path))))
            {
                if (exportObject != null)
                {
                    exportObject.ExcludeChildren    = ExcludeChildren.IsPresent;
                    exportObject.IncludeDescendants = IncludeDescendants;
                    settings.ExportObjects.Add(exportObject);
                }
                settings.IncludeVersions = this.IncludeVersions;
                if (base.IncludeUserSecurity.IsPresent)
                {
                    settings.IncludeSecurity = SPIncludeSecurity.All;
                }
                settings.OverwriteExistingDataFile = (bool)base.Force;
                settings.FileMaxSize = this.CompressionSize;
                try
                {
                    export.Run();
                }
                finally
                {
                    if (base.Verbose && createLogFile)
                    {
                        Console.WriteLine();
                        Console.WriteLine(SPResource.GetString("ExportOperationLogFile", new object[0]));
                        Console.WriteLine("\t{0}", settings.LogFilePath);
                    }
                    if ((this.UseSqlSnapshot.IsPresent) && (snapshot != null))
                    {
                        snapshot.Delete();
                    }
                }
                if (base.Verbose)
                {
                    string    fileLocation = settings.FileLocation;
                    ArrayList dataFiles    = settings.DataFiles;
                    if (dataFiles != null)
                    {
                        if (((fileLocation != null) && (fileLocation.Length > 0)) && (fileLocation[fileLocation.Length - 1] != System.IO.Path.DirectorySeparatorChar))
                        {
                            fileLocation = fileLocation + System.IO.Path.DirectorySeparatorChar;
                        }
                        Console.WriteLine();
                        Console.WriteLine(SPResource.GetString("ExportOperationFilesGenerated", new object[0]));
                        for (int i = 0; i < dataFiles.Count; i++)
                        {
                            Console.WriteLine("\t{0}{1}", fileLocation, dataFiles[i]);
                            Console.WriteLine();
                        }
                        if (base.NoFileCompression.IsPresent)
                        {
                            DirectoryInfo info = new DirectoryInfo(base.Path);
                            Console.WriteLine("\t{0}", info.FullName);
                        }
                        Console.WriteLine();
                    }
                }
            }
        }
        /// <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();
            }
        }
示例#23
0
 public void RunExport()
 {
     if (settings != null)
         if (settings.ExportObjects != null && settings.ExportObjects.Count > 0)
         {
             SPExport export = new SPExport(settings);
             export.Error += Export_Error;
             export.Run();
             ExportBaseFileName = export.Settings.BaseFileName;
             ExportPathFile = export.Settings.FileLocation + "\\" + export.Settings.BaseFileName;
         }
 }
示例#24
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();
                }
            }
        }