Пример #1
0
        public void ValidateSettings()
        {
            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("ValidateSettings: Entered.");
            }

            SPDeploymentSettings settings = null;

            if (Type == DeploymentType.Export)
            {
                settings = ExportSettings;
                if (traceSwitch.TraceInfo)
                {
                    trace.TraceInfo("ValidateSettings: Validating export settings.");
                }
            }
            if (Type == DeploymentType.Import)
            {
                settings = ImportSettings;
                if (traceSwitch.TraceInfo)
                {
                    trace.TraceInfo("ValidateSettings: Validating import settings.");
                }
            }

            try
            {
                settings.Validate();
                if (traceSwitch.TraceInfo)
                {
                    trace.TraceInfo("ValidateSettings: Settings validated successfully.");
                }
            }
            catch (Exception e)
            {
                if (traceSwitch.TraceWarning)
                {
                    trace.TraceWarning("ValidateSettings: Caught exception when validating settings. Throwing exception. " +
                                       "Exception = '{0}'.", e);
                }

                throw;
            }

            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("ValidateSettings: Leaving.");
            }
        }
Пример #2
0
        internal static WizardImportSettings CollectImportSettings(XmlTextReader importSettingsXml)
        {
            if (traceSwitchStatic.TraceVerbose)
            {
                traceStatic.TraceVerbose("CollectImportSettings: Entered CollectImportSettings().");
            }

            if (importSettingsXml.Name != "ImportSettings")
            {
                importSettingsXml.Read();
            }

            // create SPImportSettings object..
            SPImportSettings importSettings = new SPImportSettings();

            if (importSettingsXml.Name == "ImportSettings")
            {
                if (importSettingsXml.MoveToAttribute("SiteUrl"))
                {
                    importSettings.SiteUrl = importSettingsXml.Value;
                }
                if (importSettingsXml.MoveToAttribute("ImportWebUrl"))
                {
                    if (!string.IsNullOrEmpty(importSettingsXml.Value))
                    {
                        importSettings.WebUrl = importSettingsXml.Value;
                    }
                }
                if (importSettingsXml.MoveToAttribute("FileLocation"))
                {
                    importSettings.FileLocation = importSettingsXml.Value;
                }
                if (importSettingsXml.MoveToAttribute("BaseFileName"))
                {
                    importSettings.BaseFileName = importSettingsXml.Value;
                }
                if (importSettingsXml.MoveToAttribute("IncludeSecurity"))
                {
                    importSettings.IncludeSecurity = (SPIncludeSecurity)Enum.Parse(typeof(SPIncludeSecurity), importSettingsXml.Value);
                }
                if (importSettingsXml.MoveToAttribute("VersionOptions"))
                {
                    importSettings.UpdateVersions = (SPUpdateVersions)Enum.Parse(typeof(SPUpdateVersions), importSettingsXml.Value);
                }
                if (importSettingsXml.MoveToAttribute("RetainObjectIdentity"))
                {
                    importSettings.RetainObjectIdentity = bool.Parse(importSettingsXml.Value);
                }
                if (importSettingsXml.MoveToAttribute("FileCompression"))
                {
                    importSettings.FileCompression = bool.Parse(importSettingsXml.Value);
                }
                if (importSettingsXml.MoveToAttribute("UserInfoUpdate"))
                {
                    importSettings.UserInfoDateTime = (SPImportUserInfoDateTimeOption)Enum.Parse(typeof(SPImportUserInfoDateTimeOption), importSettingsXml.Value);
                }
            }

            importSettingsXml.Close();

            // set other properties which aren't tied to values in XML..
            importSettings.LogFilePath = string.Format("{0}\\{1}.Import.log",
                                                       importSettings.FileLocation, importSettings.BaseFileName);

            if (traceSwitchStatic.TraceInfo)
            {
                traceStatic.TraceInfo("CollectImportSettings: Using site URL '{0}'.", importSettings.SiteUrl);
                traceStatic.TraceInfo("CollectImportSettings: Using web URL '{0}'.", importSettings.WebUrl);
                traceStatic.TraceInfo("CollectImportSettings: File location = '{0}'.", importSettings.FileLocation);
                traceStatic.TraceInfo("CollectImportSettings: Base filename = '{0}'.", importSettings.BaseFileName);
                traceStatic.TraceInfo("CollectImportSettings: Update versions = '{0}'.", importSettings.UpdateVersions);
                traceStatic.TraceInfo("CollectImportSettings: Log file path = '{0}'.", importSettings.LogFilePath);
                traceStatic.TraceInfo("CollectImportSettings: Include security = '{0}'.", importSettings.IncludeSecurity);
                traceStatic.TraceInfo("CollectImportSettings: Retain object identity = '{0}'.", importSettings.RetainObjectIdentity);
            }

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

            WizardImportSettings wiSettings = new WizardImportSettings(importSettings);

            return(wiSettings);
        }
Пример #3
0
        public int Run(string command, StringDictionary keyValues, out string output)
        {
            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("Run(): Entered.");
            }

#if DEBUG
            // comment back in to debug..
            //Console.WriteLine("Attach debugger and/or press enter to continue..");
            //Console.ReadLine();
#endif

            int              iReturn = 0;
            string           sResult = string.Empty;
            DeploymentType   deploymentType;
            WizardDeployment wizardDeployment = null;

            // determine command type..
            switch (command)
            {
            case f_csIMPORT_COMMAND:
                deploymentType = DeploymentType.Import;
                break;

            case f_csEXPORT_COMMAND:
                deploymentType = DeploymentType.Export;
                break;

            default:
                throw new ConfigurationErrorsException("Error - unexpected command! Supported commands are 'RunWizardImport' and 'RunWizardExport'.");
                break;
            }

            // validate passed settings..
            string sValidationMessage = validateSettings(keyValues, deploymentType);

            if (string.IsNullOrEmpty(sValidationMessage))
            {
                string sSettingsFilePath = keyValues[f_csSETTINGS_FILE_PARAM];
                if (keyValues[f_csQUIET_PARAM] != null)
                {
                    f_quiet = true;
                }

                using (XmlTextReader xReader = new XmlTextReader(sSettingsFilePath))
                {
                    wizardDeployment = new WizardDeployment(xReader, deploymentType);

                    // ask deployment API to validate settings..
                    try
                    {
                        wizardDeployment.ValidateSettings();
                        if (traceSwitch.TraceInfo)
                        {
                            trace.TraceInfo("Run(): Settings validated successfully.");
                        }
                    }
                    catch (Exception e)
                    {
                        if (traceSwitch.TraceWarning)
                        {
                            trace.TraceWarning("Run(): Failed to validate deployment settings! Deployment will not be done, showing error message.");
                        }

                        sResult = string.Format("Error - unable to validate the deployment settings you chose. Please ensure, for example, you are not exporting a web " +
                                                "and specific child objects in the same operation. Message = '{0}'.", e.Message);
                    }

                    if (string.IsNullOrEmpty(sResult))
                    {
                        // now run job..
                        wizardDeployment.ProgressUpdated += new EventHandler <SPDeploymentEventArgs>(wizardDeployment_ProgressUpdated);

                        if (deploymentType == DeploymentType.Export)
                        {
                            wizardDeployment.ValidChangeTokenNotFound += new EventHandler <InvalidChangeTokenEventArgs>(wizardDeployment_ValidChangeTokenNotFound);
                            sResult = runExportTask(wizardDeployment);
                        }
                        else if (deploymentType == DeploymentType.Import)
                        {
                            sResult = runImportTask(wizardDeployment);
                        }
                    }
                }
            }
            else
            {
                sResult = sValidationMessage;
            }

            if (traceSwitch.TraceVerbose)
            {
                trace.TraceVerbose("Run(): Returning '{0}'.", iReturn);
            }

            output = sResult;
            return(iReturn);
        }
Пример #4
0
        public frmContentDeployer()
        {
            f_traceSwitch = new TraceSwitch("COB.SharePoint.Utilities.ContentDeploymentWizard",
                "Trace switch for ContentDeploymentWizard");

            // initialise the trace helper for output formatting
            f_traceHelper = new TraceHelper(this);

            if (f_traceSwitch.TraceVerbose)
            {
                f_traceHelper.TraceVerbose("frmContentDeployer: Entered frmContentDeployer().");
            }

            InitializeComponent();
            performDataBinding();

            f_aListsNotForExport = fetchListsNotForExport();

            prgExport.Enabled = false;
            prgImport.Enabled = true;

            if (f_traceSwitch.TraceInfo)
            {
                f_traceHelper.TraceInfo("frmContentDeployer: Initialised and bound controls.");
            }

            if (f_traceSwitch.TraceVerbose)
            {
                f_traceHelper.TraceVerbose("frmContentDeployer: Exiting frmContentDeployer().");
            }
        }