Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public void Run()
 {
     m_export.Run();
     SPExportInstance.CopyFilesToDropLocation(m_export, m_dropLocation);
 }