Ejemplo n.º 1
0
        protected void SetDeploymentSettings(SPDeploymentSettings settings)
        {
            string filePath;

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            settings.CommandLineVerbose  = this.Verbose;
            settings.HaltOnNonfatalError = (bool)this.HaltOnError;
            settings.HaltOnWarning       = (bool)this.HaltOnWarning;
            //settings.WarnOnUsingLastMajor = true;
            settings.FileCompression = !NoFileCompression.IsPresent;
            string filename = string.Empty;

            if (!NoFileCompression.IsPresent)
            {
                SplitPathFile(this.Path, out filePath, out filename);
                settings.FileLocation = filePath;
                settings.BaseFileName = filename;
            }
            else
            {
                settings.FileLocation = filePath = this.Path;
            }
            if (!NoLogFile.IsPresent)
            {
                string logFileName;
                if (this is SPCmdletExport)
                {
                    logFileName = "export.log";
                }
                else
                {
                    logFileName = "import.log";
                }
                if (NoFileCompression.IsPresent)
                {
                    settings.LogFilePath = System.IO.Path.Combine(settings.FileLocation, filename + logFileName);
                }
                else
                {
                    settings.LogFilePath = System.IO.Path.Combine(settings.FileLocation, filename + "." + logFileName);
                }
                bool fileExists = File.Exists(settings.LogFilePath) && !(this is SPCmdletImportWeb2);
                if ((!this.Force.IsPresent) && fileExists)
                {
                    throw new SPException(SPResource.GetString("DataFileExists", new object[] { settings.LogFilePath }));
                }
                if (fileExists)
                {
                    File.Delete(settings.LogFilePath);
                }
            }
        }
Ejemplo n.º 2
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.");
            }
        }
 protected void SetDeploymentSettings(SPDeploymentSettings settings)
 {
     string filePath;
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     settings.CommandLineVerbose = this.Verbose;
     settings.HaltOnNonfatalError = (bool)this.HaltOnError;
     settings.HaltOnWarning = (bool)this.HaltOnWarning;
     //settings.WarnOnUsingLastMajor = true;
     settings.FileCompression = !NoFileCompression.IsPresent;
     string filename = string.Empty;
     if (!NoFileCompression.IsPresent)
     {
         SplitPathFile(this.Path, out filePath, out filename);
         settings.FileLocation = filePath;
         settings.BaseFileName = filename;
     }
     else
     {
         settings.FileLocation = filePath = this.Path;
     }
     if (!NoLogFile.IsPresent)
     {
         string logFileName;
         if (this is SPCmdletExport)
         {
             logFileName = "export.log";
         }
         else
         {
             logFileName = "import.log";
         }
         if (NoFileCompression.IsPresent)
         {
             settings.LogFilePath = System.IO.Path.Combine(settings.FileLocation, filename + logFileName);
         }
         else
         {
             settings.LogFilePath = System.IO.Path.Combine(settings.FileLocation, filename + "." + logFileName);
         }
         bool fileExists = File.Exists(settings.LogFilePath) && !(this is SPCmdletImportWeb2);
         if ((!this.Force.IsPresent) && fileExists)
         {
             throw new SPException(SPResource.GetString("DataFileExists", new object[] { settings.LogFilePath }));
         }
         if (fileExists)
         {
             File.Delete(settings.LogFilePath);
         }
     }
 }