/// <summary> /// Starts import process with given settings. Returns true if import was started successfully, false otherwise (error label is set in this case). /// </summary> /// <param name="settings">Import settings</param> /// <returns>Returns true if import was started successfully, false otherwise.</returns> private bool StartImport(SiteImportSettings settings) { if (!string.IsNullOrEmpty(ImportExportControl.CheckLicenses(settings))) { // License is missing, let's try to import some from package. EnsureLicenseFromPackage(settings); } // Check licences string error = ImportExportControl.CheckLicenses(settings); if (!string.IsNullOrEmpty(error)) { SetErrorLabel(error); return(false); } // Start asynchronnous Import if (settings.SiteIsIncluded) { settings.EventLogSource = String.Format(settings.GetAPIString("ImportSite.EventLogSiteSource", "Import '{0}' site"), ResHelper.LocalizeString(settings.SiteDisplayName)); } var manager = ImportManager; settings.LogContext = ctlAsyncImport.CurrentLog; manager.Settings = settings; ctlAsyncImport.RunAsync(manager.Import, WindowsIdentity.GetCurrent()); return(true); }
private static void ImportObject(string packagePath, string userName) { string objectType = ""; int objectID = 0; SiteImportSettings settings = new SiteImportSettings(UserInfoProvider.GetUserInfo(userName)); settings.UseAutomaticSiteForTranslation = true; settings.LogSynchronization = true; settings.WebsitePath = SystemContext.WebApplicationPhysicalPath; settings.SourceFilePath = packagePath; var obj = ObjectSelections(objectType); var importObj = SingleObjectSelection(objectID, obj); if (importObj.ObjectSiteID > 0) { settings.SiteId = importObj.ObjectSiteID; settings.ExistingSite = true; settings.SiteIsContentOnly = settings.SiteInfo.SiteIsContentOnly; // Do not update site definition when restoring a single object settings.SetSettings(ImportExportHelper.SETTINGS_UPDATE_SITE_DEFINITION, false); } ImportProvider.CreateTemporaryFiles(settings); settings.LoadDefaultSelection(); ImportProvider.ImportObjectsData(settings); }
/// <summary> /// Creates new settings object for Import. /// </summary> private SiteImportSettings GetNewSettings() { SiteImportSettings result = new SiteImportSettings(CMSContext.CurrentUser); result.WebsitePath = Server.MapPath("~/"); result.PersistentSettingsKey = PersistentSettingsKey; return(result); }
/// <summary> /// Creates new settings object for Import. /// </summary> private SiteImportSettings GetNewSettings() { SiteImportSettings result = new SiteImportSettings(MembershipContext.AuthenticatedUser); result.WebsitePath = Server.MapPath("~/"); result.PersistentSettingsKey = PersistentSettingsKey; return(result); }
/// <summary> /// Returns <c>true</c> if imported package contains site which is compatible with current version. /// </summary> private bool SiteIsSupported(SiteImportSettings settings) { DataTable table = ImportProvider.GetObjectsData(settings, SiteInfo.OBJECT_TYPE, true); if ((table != null) && settings.IsLowerVersion("13.0")) { return DataHelper.GetBoolValue(table.Rows[0], "SiteIsContentOnly", false); } return true; }
/// <summary> /// Procedures which automatically imports the upgrade export package with all WebParts, Widgets, Reports and TimeZones. /// </summary> private static void UpgradeImportPackage() { // Import try { RequestStockHelper.Remove("CurrentDomain", true); var importSettings = new SiteImportSettings(MembershipContext.AuthenticatedUser) { DefaultProcessObjectType = ProcessObjectEnum.All, SourceFilePath = mUpgradePackagePath, WebsitePath = mWebsitePath }; using (var context = new CMSActionContext()) { context.DisableLogging(); context.CreateVersion = false; context.LogIntegration = false; ImportProvider.ImportObjectsData(importSettings); // Regenerate time zones TimeZoneInfoProvider.GenerateTimeZoneRules(); // Delete the files for separable modules which are not install and therefore not needed DeleteWebPartsOfUninstalledModules(); ImportMetaFiles(Path.Combine(mWebsitePath, "App_Data\\CMSTemp\\Upgrade")); } } catch (Exception ex) { EventLogProvider.LogException(EVENT_LOG_INFO, "Upgrade", ex); } finally { try { RefreshMacroSignatures(); EventLogProvider.LogInformation(EVENT_LOG_INFO, "Upgrade - Finish"); } catch (Exception ex) { EventLogProvider.LogException(EVENT_LOG_INFO, "Upgrade", ex); } } }
private static SiteImportSettings CreateImportSettings(string sourceFilePath, string userName) { SiteImportSettings result = new SiteImportSettings(UserInfoProvider.GetUserInfo(userName)); result.SourceFilePath = sourceFilePath; result.WebsitePath = SystemContext.WebApplicationPhysicalPath; result.ImportType = ImportTypeEnum.AllForced; result.CopyFiles = false; result.CopyCodeFiles = false; result.DefaultProcessObjectType = ProcessObjectEnum.All; result.LogSynchronization = false; result.RefreshMacroSecurity = true; return(result); }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { chkDocuments.Checked = (Settings.GetObjectsProcessType(TreeNode.OBJECT_TYPE, true) != ProcessObjectEnum.None); chkDocumentsHistory.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_HISTORY), true); chkRelationships.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_RELATIONSHIPS), true); chkACLs.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_ACLS), true); // Visibility SiteImportSettings settings = (SiteImportSettings)Settings; chkACLs.Visible = settings.IsIncluded(AclInfo.OBJECT_TYPE, false); chkDocumentsHistory.Visible = settings.IsIncluded(VersionHistoryInfo.OBJECT_TYPE, false); chkRelationships.Visible = settings.IsIncluded(RelationshipInfo.OBJECT_TYPE, false); pnlDocumentData.Visible = chkDocumentsHistory.Visible || chkACLs.Visible || chkRelationships.Visible; }
/// <summary> /// Checks the version of the controls (without hotfix version). /// </summary> public bool CheckVersion() { if (VersionCheck == -1) { SiteImportSettings importSettings = (SiteImportSettings)this.Settings; if ((importSettings != null) && importSettings.TemporaryFilesCreated) { VersionCheck = ImportExportHelper.IsLowerVersion(importSettings.Version, null, CMSContext.SYSTEM_VERSION, null) ? 1 : 0; } else { return(false); } } return(VersionCheck > 0); }
/// <summary> /// Checks the hotfix version of the controls. /// </summary> public bool CheckHotfixVersion() { if (HotfixVersionCheck == -1) { SiteImportSettings importSettings = (SiteImportSettings)Settings; if ((importSettings != null) && importSettings.TemporaryFilesCreated) { HotfixVersionCheck = (ValidationHelper.GetInteger(importSettings.HotfixVersion, 0) < ValidationHelper.GetInteger(CMSContext.HotfixVersion, 0)) ? 1 : 0; } else { return(false); } } return(HotfixVersionCheck > 0); }
/// <summary> /// Imports the license keys from package defined by <paramref name="settings"/>. /// </summary> private static void EnsureLicenseFromPackage(SiteImportSettings settings) { // Clone import settings so they aren't changed by license import process SiteImportSettings settingsCopy; using (var stream = new IOExceptions.MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, settings); stream.Position = 0; settingsCopy = (SiteImportSettings)formatter.Deserialize(stream); } ImportProvider.ImportObjectType(settingsCopy, LicenseKeyInfo.OBJECT_TYPE, false, new TranslationHelper(), ProcessObjectEnum.Selected, new List <int>()); }
private void btnRestore_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lstImports.SelectedValue)) { siteObject = (exportObj.ObjectSiteID > 0); // Prepare the settings ImportSettings = new SiteImportSettings(MembershipContext.AuthenticatedUser); ImportSettings.UseAutomaticSiteForTranslation = true; ImportSettings.LogSynchronization = true; ImportSettings.WebsitePath = Server.MapPath("~/"); ImportSettings.SourceFilePath = GetSelectedFilePath(); if (siteObject) { ImportSettings.SiteId = exportObj.ObjectSiteID; ImportSettings.ExistingSite = true; ImportSettings.SiteIsContentOnly = ImportSettings.SiteInfo.SiteIsContentOnly; // Do not update site definition when restoring a single object ImportSettings.SetSettings(ImportExportHelper.SETTINGS_UPDATE_SITE_DEFINITION, false); } // Set the filename lblProgress.Text = string.Format(GetString("RestoreObject.RestoreProgress"), exportObjectDisplayName); pnlDetails.Visible = false; btnRestore.Enabled = false; pnlProgress.Visible = true; try { // Export the data ScriptHelper.RegisterStartupScript(this, typeof(string), "StartTimer", "StartTimer();", true); ucAsyncControl.RunAsync(RestoreSingleObject, WindowsIdentity.GetCurrent()); } catch (Exception ex) { DisplayError(ex); } } }
/// <summary> /// Imports user object. Called when the "Import object" button is pressed. /// </summary> private bool ImportObject() { // Create site import settings SiteImportSettings settings = new SiteImportSettings(MembershipContext.AuthenticatedUser); // Initialize the settings settings.WebsitePath = Server.MapPath("~/"); settings.SourceFilePath = settings.WebsitePath + "CMSAPIExamples\\Code\\Tools\\ImportExport\\Packages\\APIExample_User.zip"; settings.ImportType = ImportTypeEnum.AllNonConflicting; settings.LoadDefaultSelection(); // Import ImportProvider.ImportObjectsData(settings); // Delete temporary data ImportProvider.DeleteTemporaryFiles(settings, false); return(true); }
private void btnOk_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lstImports.SelectedValue)) { // Init the Mimetype helper (required for the export) MimeTypeHelper.LoadMimeTypes(); siteObject = (exportObj.ObjectSiteID > 0); // Prepare the settings ImportSettings = new SiteImportSettings(CMSContext.CurrentUser); ImportSettings.UseAutomaticSiteForTranslation = true; ImportSettings.WebsitePath = Server.MapPath("~/"); ImportSettings.SourceFilePath = GetSelectedFilePath(); if (siteObject) { ImportSettings.SiteId = exportObj.ObjectSiteID; ImportSettings.ExistingSite = true; } // Set the filename lblProgress.Text = string.Format(GetString("RestoreObject.RestoreProgress"), exportObjectDisplayName); pnlDetails.Visible = false; btnOk.Enabled = false; pnlProgress.Visible = true; try { // Export the data ltlScript.Text = ScriptHelper.GetScript("StartTimer();"); ucAsyncControl.RunAsync(RestoreSingleObject, WindowsIdentity.GetCurrent()); } catch (Exception ex) { DisplayError(ex); } } }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { chkDocuments.Checked = (Settings.GetObjectsProcessType(TreeNode.OBJECT_TYPE, true) != ProcessObjectEnum.None); chkDocumentsHistory.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_HISTORY), true); chkRelationships.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_RELATIONSHIPS), true); chkACLs.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_DOC_ACLS), true); chkEventAttendees.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_EVENT_ATTENDEES), true); chkBlogComments.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_BLOG_COMMENTS), true); chkUserPersonalizations.Checked = ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_USER_PERSONALIZATIONS), !ExistingSite); // Visibility SiteImportSettings settings = (SiteImportSettings)Settings; chkACLs.Visible = settings.IsIncluded(AclInfo.OBJECT_TYPE, false); chkDocumentsHistory.Visible = settings.IsIncluded(VersionHistoryInfo.OBJECT_TYPE, false); chkRelationships.Visible = settings.IsIncluded(RelationshipInfo.OBJECT_TYPE, false); //this.chkUserPersonalizations.Visible = settings.IsIncluded(PortalObjectType.PERSONALIZATION, false); pnlDocumentData.Visible = chkDocumentsHistory.Visible || chkACLs.Visible || chkRelationships.Visible || chkUserPersonalizations.Visible; chkBlogComments.Visible = settings.IsIncluded(PredefinedObjectType.BLOGCOMMENT, false); chkEventAttendees.Visible = settings.IsIncluded(PredefinedObjectType.EVENTATTENDEE, false); pnlModules.Visible = chkBlogComments.Visible || chkEventAttendees.Visible; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Handle Import settings if (!Page.IsCallback && !RequestHelper.IsPostBack()) { // Check if any template is present on the disk if (!WebTemplateInfoProvider.IsAnyTemplatePresent()) { selectTemplate.StopProcessing = true; pnlWrapper.Visible = false; lblError.Visible = true; lblError.Text = GetString("NewSite.NoWebTemplate"); } // Initialize virtual path provider VirtualPathHelper.Init(Page); // Initialize import settings ImportSettings = new SiteImportSettings(CMSContext.CurrentUser); ImportSettings.WebsitePath = Server.MapPath("~/"); ImportSettings.PersistentSettingsKey = PersistentSettingsKey; } if (Page.IsCallback) { // Stop processing when callback selectTemplate.StopProcessing = true; selectMaster.StopProcessing = true; } else { selectTemplate.StopProcessing = (CausedPostback(PreviousButton) && (wzdImport.ActiveStepIndex == 2)) ? false : (wzdImport.ActiveStepIndex != 1); selectMaster.StopProcessing = (wzdImport.ActiveStepIndex != 5); PreviousButton.Enabled = true; PreviousButton.Visible = (wzdImport.ActiveStepIndex <= 4); NextButton.Enabled = true; // Bind async controls events ctrlAsync.OnFinished += ctrlAsync_OnFinished; ctrlAsync.OnError += ctrlAsync_OnError; ctrlImport.OnFinished += ctrlImport_OnFinished; if (wzdImport.ActiveStepIndex < 4) { siteDetails.Settings = ImportSettings; pnlImport.Settings = ImportSettings; } // Javascript functions string script = "var nMessageText = '';\n" + "var nErrorText = '';\n" + "var nWarningText = '';\n" + "var nMachineName = '" + SqlHelperClass.MachineName.ToLowerCSafe() + "';\n" + "var getBusy = false; \n" + "function GetImportState(cancel) \n" + "{ if(window.Activity){window.Activity();} if (getBusy && !cancel) return; getBusy = true; setTimeout(\"getBusy = false;\", 2000); var argument = cancel + ';' + nMessageText.length + ';' + nErrorText.length + ';' + nWarningText.length + ';' + nMachineName; return " + Page.ClientScript.GetCallbackEventReference(this, "argument", "SetImportStateMssg", "argument", true) + " } \n"; script += "function SetImportStateMssg(rValue, context) \n" + "{ \n" + " getBusy = false; \n" + " if(rValue!='') \n" + " { \n" + " var args = context.split(';');\n" + " var values = rValue.split('" + SiteExportSettings.SEPARATOR + "');\n" + " var messageElement = document.getElementById('" + lblProgress.ClientID + "');\n" + " var errorElement = document.getElementById('" + lblError.ClientID + "');\n" + " var warningElement = document.getElementById('" + lblWarning.ClientID + "');\n" + " var messageText = nMessageText;\n" + " messageText = values[1] + messageText.substring(messageText.length - args[1]);\n" + " if(messageText.length > nMessageText.length){ nMessageText = messageElement.innerHTML = messageText; }\n" + " var errorText = nErrorText;\n" + " errorText = values[2] + errorText.substring(errorText.length - args[2]);\n" + " if(errorText.length > nErrorText.length){ nErrorText = errorElement.innerHTML = errorText; }\n" + " var warningText = nWarningText;\n" + " warningText = values[3] + warningText.substring(warningText.length - args[3]);\n" + " if(warningText.length > nWarningText.length){ nWarningText = warningElement.innerHTML = warningText; }\n" + " if((values=='') || (values[0]=='F')) \n" + " { \n" + " StopImportStateTimer(); \n" + " if (!document.importCancelled) { \n" + " if(values[2] == '') { \n" + " BTN_Enable('" + NextButton.ClientID + "'); \n" + " } \n" + " else { \n" + " BTN_Enable('" + PreviousButton.ClientID + "'); \n" + " } \n" + " BTN_Disable('" + CancelButton.ClientID + "'); \n" + " } \n" + " } \n" + " } \n" + "} \n"; // Register the script to perform get flags for showing buttons retrieval callback ScriptHelper.RegisterClientScriptBlock(this, GetType(), "GetSetImportState", ScriptHelper.GetScript(script)); // Add cancel button attribute CancelButton.Attributes.Add("onclick", "BTN_Disable('" + CancelButton.ClientID + "'); " + "CancelImport();" + ((wzdImport.ActiveStepIndex == 3) ? string.Empty : "BTN_Enable('" + PreviousButton.ClientID + "'); ") + "document.importCancelled = true;return false;" ); wzdImport.NextButtonClick += wzdImport_NextButtonClick; wzdImport.PreviousButtonClick += wzdImport_PreviousButtonClick; wzdImport.FinishButtonClick += wzdImport_FinishButtonClick; } }
/// <summary> /// Starts import process with given settings. Returns true if import was started successfully, false otherwise (error label is set in this case). /// </summary> /// <param name="importSettings">Import settings</param> /// <returns>Returns true if import was started successfully, false otherwise.</returns> private bool StartImport(SiteImportSettings importSettings) { // Check licences string error = ImportExportControl.CheckLicenses(importSettings); if (!string.IsNullOrEmpty(error)) { SetErrorLabel(error); return false; } // Init the Mimetype helper (required for the Import) MimeTypeHelper.LoadMimeTypes(); // Start asynchronnous Import if (importSettings.SiteIsIncluded) { importSettings.EventLogSource = string.Format(importSettings.GetAPIString("ImportSite.EventLogSiteSource", "Import '{0}' site"), ResHelper.LocalizeString(importSettings.SiteDisplayName)); } ImportManager.Settings = importSettings; AsyncWorker worker = new AsyncWorker(); worker.OnFinished += worker_OnFinished; worker.OnError += worker_OnError; worker.RunAsync(ImportManager.Import, WindowsIdentity.GetCurrent()); return true; }
private static DataSet GetEmptyDataSet(SiteImportSettings settings, string objectType, bool siteObjects, bool selectionOnly, out GeneralizedInfo infoObj, bool forceXMLStructure = false) { DataSet ds; // Raise prepare data event var eData = new ImportGetDataEventArgs { Settings = settings, ObjectType = objectType, SiteObjects = siteObjects, SelectionOnly = selectionOnly }; // Handle the event SpecialActionsEvents.GetEmptyObject.StartEvent(eData); // Ensure empty object infoObj = eData.Object ?? ModuleManager.GetReadOnlyObject(objectType); // Get data set if (forceXMLStructure || (infoObj == null) || (infoObj.MainObject is NotImplementedInfo)) { // Create empty data set ds = new DataSet(); // Ensure translation table if (objectType == ImportExportHelper.OBJECT_TYPE_TRANSLATION) { ds.Tables.Add(TranslationHelper.GetEmptyTable()); } } else { // Get objects DataSet if (selectionOnly) { // Code name column ds = DataHelper.GetSingleColumnDataSet(ObjectHelper.GetSerializationTableName(infoObj), infoObj.CodeNameColumn, typeof(string)); // Display name column var dt = ds.Tables[0]; if (infoObj.CodeNameColumn != infoObj.DisplayNameColumn) { DataHelper.EnsureColumn(dt, infoObj.DisplayNameColumn, typeof(string)); } // GUID column var ti = infoObj.TypeInfo; if ((ti.GUIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN) && (infoObj.CodeNameColumn != ti.GUIDColumn)) { DataHelper.EnsureColumn(dt, ti.GUIDColumn, typeof(Guid)); } // Columns used by type condition var tc = ti.TypeCondition; if (tc != null) { foreach (var conditionColumn in tc.ConditionColumns) { DataHelper.EnsureColumn(dt, conditionColumn, ti.ClassStructureInfo.GetColumnType(conditionColumn)); } } } else { ds = ObjectHelper.GetObjectsDataSet(OperationTypeEnum.Export, infoObj, true); } // Add tasks table DataSet tasksDS; if (selectionOnly) { tasksDS = DataHelper.GetSingleColumnDataSet("Export_Task", "TaskID", typeof(int)); DataTable dt = tasksDS.Tables[0]; dt.Columns.Add("TaskTitle", typeof(string)); dt.Columns.Add("TaskType", typeof(string)); dt.Columns.Add("TaskTime", typeof(DateTime)); } else { tasksDS = DataClassInfoProvider.GetDataSet("Export.Task"); } DataHelper.TransferTable(ds, tasksDS, "Export_Task"); } return(ds); }
public static DataSet LoadObjects(SiteImportSettings settings, string objectType, bool siteObjects, bool selectionOnly = false, bool forceXMLStructure = false) { DataSet ds; var e = new ImportGetDataEventArgs { Settings = settings, ObjectType = objectType, SiteObjects = siteObjects, SelectionOnly = selectionOnly }; // Get empty data set GeneralizedInfo infoObj; ds = GetEmptyDataSet(settings, objectType, siteObjects, selectionOnly, out infoObj, forceXMLStructure); // Turn off constrains check ds.EnforceConstraints = false; // Raise prepare data event var eData = new ImportGetDataEventArgs { Data = ds, Settings = settings, ObjectType = objectType, SiteObjects = siteObjects, SelectionOnly = selectionOnly }; // Handle the event SpecialActionsEvents.PrepareDataStructure.StartEvent(eData); // Lowercase table names for compatibility DataHelper.LowerCaseTableNames(ds); Stream reader = null; XmlReader xml = null; string safeObjectType = ImportExportHelper.GetSafeObjectTypeName(objectType); // Prepare the path string filePath = DirectoryHelper.CombinePath(settings.TemporaryFilesPath, ImportExportHelper.DATA_FOLDER) + "\\"; // Get object type subfolder filePath += ImportExportHelper.GetObjectTypeSubFolder(settings, objectType, siteObjects); filePath += safeObjectType + ".xml"; string rootElement = safeObjectType; filePath = ImportExportHelper.GetExportFilePath(filePath); // Import only if file exists if (System.IO.File.Exists(filePath)) { // Reader setting XmlReaderSettings rs = new XmlReaderSettings(); rs.CloseInput = true; rs.CheckCharacters = false; // Open reader reader = FileStream.New(filePath, CMS.IO.FileMode.Open, CMS.IO.FileAccess.Read, CMS.IO.FileShare.Read, 8192); xml = XmlReader.Create(reader, rs); // Read main document element do { xml.Read(); } while ((xml.NodeType != XmlNodeType.Element) && !xml.EOF); if (xml.Name.ToLowerInvariant() != rootElement.ToLowerInvariant()) { throw new Exception("[ImportProvider.LoadObjects]: The required page element is '" + safeObjectType + "', element found is '" + xml.Name + "'."); } // Get version if (xml.HasAttributes) { xml.MoveToAttribute("version"); } if ((xml.NodeType != XmlNodeType.Attribute) || (xml.Name.ToLowerInvariant() != "version")) { throw new Exception("[ImportProvider.LoadObjects]: Cannot find version attribute."); } // Get the dataset do { xml.Read(); } while (((xml.NodeType != XmlNodeType.Element) || (xml.Name != "NewDataSet")) && !xml.EOF); // Read data if (xml.Name == "NewDataSet") { ds.ReadXml(xml); } // Filter data by object type condition for selection, some object types may overlap if (selectionOnly && !DataHelper.DataSourceIsEmpty(ds)) { // Remove unwanted rows from data collection with dependence on type condition if (infoObj.TypeInfo.TypeCondition != null) { var dt = ObjectHelper.GetTable(ds, infoObj); var where = infoObj.TypeInfo.WhereCondition; where.Replace(" N'", " '").Replace("(N'", "('"); DataHelper.KeepOnlyRows(dt, where); dt.AcceptChanges(); } } } // Safely close readers if (xml != null) { xml.Close(); } if (reader != null) { reader.Close(); } return(ds); }
private static void Upgrade60Import() { EventLogProvider evp = new EventLogProvider(); // Import try { RequestStockHelper.Remove("CurrentDomain", true); SiteImportSettings importSettings = new SiteImportSettings(CMSContext.CurrentUser) { DefaultProcessObjectType = ProcessObjectEnum.All, SourceFilePath = mUpgradePackagePath, WebsitePath = mWebsitePath }; ImportProvider.ImportObjectsData(importSettings); // Regenerate time zones TimeZoneInfoProvider.GenerateTimeZoneRules(); #region "Separability" String webPartsPath = mWebsitePath + "CMSWebParts\\"; List<String> files = new List<string>(); // Create list of files to remove if (!ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM)) { files.AddRange(GetAllFiles(webPartsPath + "BizForms")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.BLOGS)) { files.AddRange(GetAllFiles(webPartsPath + "Blogs")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY)) { files.AddRange(GetAllFiles(webPartsPath + "Community")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { files.AddRange(GetAllFiles(webPartsPath + "Ecommerce")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.EVENTMANAGER)) { files.AddRange(GetAllFiles(webPartsPath + "Events")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS)) { files.AddRange(GetAllFiles(webPartsPath + "Forums")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MEDIALIBRARY)) { files.AddRange(GetAllFiles(webPartsPath + "MediaLibrary")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGEBOARD)) { files.AddRange(GetAllFiles(webPartsPath + "MessageBoards")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGING)) { files.AddRange(GetAllFiles(webPartsPath + "Messaging")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.NEWSLETTER)) { files.AddRange(GetAllFiles(webPartsPath + "Newsletters")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.NOTIFICATIONS)) { files.AddRange(GetAllFiles(webPartsPath + "Notifications")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ONLINEMARKETING)) { files.AddRange(GetAllFiles(webPartsPath + "OnlineMarketing")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.POLLS)) { files.AddRange(GetAllFiles(webPartsPath + "Polls")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.PROJECTMANAGEMENT)) { files.AddRange(GetAllFiles(webPartsPath + "ProjectManagement")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.REPORTING)) { files.AddRange(GetAllFiles(webPartsPath + "Reporting")); } // Remove webparts for separated modules foreach (String file in files) { try { File.Delete(file); } catch (Exception ex) { evp.LogEvent("Upgrade to 6.0", "Upgrade", ex); } } #endregion evp.LogEvent("I", DateTime.Now, "Upgrade to 6.0", "Upgrade - Finish"); } catch (Exception ex) { evp.LogEvent("Upgrade to 6.0", "Upgrade", ex); } }
/// <summary> /// Checks the license for selected objects. /// </summary> public static string CheckLicenses(SiteImportSettings settings) { string result = null; object[,] checkFeatures = new object[,] { { FeatureEnum.Unknown, "", false }, { FeatureEnum.BizForms, FormObjectType.BIZFORM, true }, { FeatureEnum.Forums, PredefinedObjectType.FORUM, true }, { FeatureEnum.Newsletters, PredefinedObjectType.NEWSLETTER, true }, { FeatureEnum.Subscribers, PredefinedObjectType.NEWSLETTERUSERSUBSCRIBER + ";" + PredefinedObjectType.NEWSLETTERROLESUBSCRIBER + ";" + PredefinedObjectType.NEWSLETTERSUBSCRIBER, true }, { FeatureEnum.Staging, SynchronizationObjectType.STAGINGSERVER, true }, { FeatureEnum.Ecommerce, PredefinedObjectType.SKU, false }, { FeatureEnum.Polls, PredefinedObjectType.POLL, false }, { FeatureEnum.Webfarm, WebFarmObjectType.WEBFARMSERVER, false }, { FeatureEnum.SiteMembers, SiteObjectType.USER, false }, { FeatureEnum.WorkflowVersioning, PredefinedObjectType.WORKFLOW, false } }; // Get imported licenses DataSet ds = ImportProvider.LoadObjects(settings, LicenseObjectType.LICENSEKEY, false); string domain = string.IsNullOrEmpty(settings.SiteDomain) ? URLHelper.GetCurrentDomain().ToLower() : URLHelper.RemovePort(settings.SiteDomain).ToLower(); // Remove application path int slashIndex = domain.IndexOf("/"); if (slashIndex > -1) { domain = domain.Substring(0, slashIndex); } bool anyDomain = ((domain == "localhost") || (domain == "127.0.0.1")); // Check all features for (int i = 0; i <= checkFeatures.GetUpperBound(0); i++) { string[] objectTypes = ((string)checkFeatures[i, 1]).Split(';'); bool siteObject = (bool)checkFeatures[i, 2]; string objectType = objectTypes[0]; // Check objects int count = (objectType != "") ? 0 : 1; for (int j = 0; j < objectTypes.Length; ++j) { objectType = objectTypes[j]; if (objectType != "") { ArrayList codenames = settings.GetSelectedObjects(objectType, siteObject); count += (codenames == null) ? 0 : codenames.Count; } } // Check a special case for Workflows if (objectType.Equals(PredefinedObjectType.WORKFLOW)) { // Check workflows bool includeWorkflowScopes = ValidationHelper.GetBoolean(settings.GetSettings(ImportExportHelper.SETTINGS_WORKFLOW_SCOPES), false); if (includeWorkflowScopes) { // Check if there are any workflow scopes in the imported package and if there are, increase the count. DataSet dsScopes = ImportProvider.LoadObjects(settings, PredefinedObjectType.WORKFLOWSCOPE, true); if (!DataHelper.DataSourceIsEmpty(dsScopes)) { count++; } } } if (count > 0) { FeatureEnum feature = (FeatureEnum)checkFeatures[i, 0]; // Get best available license from DB LicenseKeyInfo bestLicense = LicenseKeyInfoProvider.GetLicenseKeyInfo(domain, feature); if ((bestLicense != null) && (bestLicense.ValidationResult != LicenseValidationEnum.Valid)) { bestLicense = null; } // Check new licenses LicenseKeyInfo bestSelected = null; if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { LicenseKeyInfo lki = new LicenseKeyInfo(dr); // Use license only if selected if ((settings.IsSelected(LicenseObjectType.LICENSEKEY, lki.Domain, false)) && (anyDomain || (lki.Domain.ToLower() == domain)) && LicenseKeyInfoProvider.IsBetterLicense(lki, bestSelected, feature)) { bestSelected = lki; if (bestSelected.Domain.ToLower() == domain) { break; } } } } // Check the license if (feature == FeatureEnum.Unknown) { if ((bestLicense == null) && (bestSelected == null)) { return ResHelper.GetString("Import.NoLicense"); } } else { // Check the limit int limit = GetLimit(bestLicense, feature); // Use a database license if it is better than the one which is being imported if (LicenseKeyInfoProvider.IsBetterLicense(bestLicense, bestSelected, feature)) { bestSelected = bestLicense; } int selectedLimit = GetLimit(bestSelected, feature); if (bestSelected != null) { if (bestSelected.ValidationResult == LicenseValidationEnum.Valid) { if (!anyDomain || (bestSelected.Domain.ToLower() == domain)) { limit = selectedLimit; } else { // If selected better, take the selected if (selectedLimit > limit) { limit = selectedLimit; } } } else { if (!anyDomain || (bestSelected.Domain.ToLower() == domain)) { limit = 0; } } } if (limit < count) { if (limit <= 0) { result += String.Format(ResHelper.GetString("Import.LimitZero"), ResHelper.GetString("ObjectTasks." + objectType.Replace(".", "_"))); } else { result += String.Format(ResHelper.GetString("Import.LimitExceeded"), ResHelper.GetString("ObjectTasks." + objectType.Replace(".", "_")), limit); } // If better license if ((bestLicense != null) && (bestSelected != null) && LicenseKeyInfoProvider.IsBetterLicense(bestLicense, bestSelected, feature)) { result += " " + ResHelper.GetString("Import.BetterLicenseExists"); } result += "<br />"; } } } } return result; }
/// <summary> /// Checks the license for selected objects. /// </summary> public static string CheckLicenses(SiteImportSettings settings) { string result = null; object[,] checkFeatures = new object[, ] { { FeatureEnum.Unknown, "", false }, { FeatureEnum.BizForms, FormObjectType.BIZFORM, true }, { FeatureEnum.Forums, PredefinedObjectType.FORUM, true }, { FeatureEnum.Newsletters, PredefinedObjectType.NEWSLETTER, true }, { FeatureEnum.Subscribers, PredefinedObjectType.NEWSLETTERUSERSUBSCRIBER + ";" + PredefinedObjectType.NEWSLETTERROLESUBSCRIBER + ";" + PredefinedObjectType.NEWSLETTERSUBSCRIBER, true }, { FeatureEnum.Staging, SynchronizationObjectType.STAGINGSERVER, true }, { FeatureEnum.Ecommerce, PredefinedObjectType.SKU, false }, { FeatureEnum.Polls, PredefinedObjectType.POLL, false }, { FeatureEnum.Webfarm, WebFarmObjectType.WEBFARMSERVER, false }, { FeatureEnum.SiteMembers, SiteObjectType.USER, false }, { FeatureEnum.WorkflowVersioning, PredefinedObjectType.WORKFLOW, false } }; // Get imported licenses DataSet ds = ImportProvider.LoadObjects(settings, LicenseObjectType.LICENSEKEY, false); string domain = string.IsNullOrEmpty(settings.SiteDomain) ? URLHelper.GetCurrentDomain().ToLower() : URLHelper.RemovePort(settings.SiteDomain).ToLower(); // Remove application path int slashIndex = domain.IndexOf("/"); if (slashIndex > -1) { domain = domain.Substring(0, slashIndex); } bool anyDomain = ((domain == "localhost") || (domain == "127.0.0.1")); // Check all features for (int i = 0; i <= checkFeatures.GetUpperBound(0); i++) { string[] objectTypes = ((string)checkFeatures[i, 1]).Split(';'); bool siteObject = (bool)checkFeatures[i, 2]; string objectType = objectTypes[0]; // Check objects int count = (objectType != "") ? 0 : 1; for (int j = 0; j < objectTypes.Length; ++j) { objectType = objectTypes[j]; if (objectType != "") { ArrayList codenames = settings.GetSelectedObjects(objectType, siteObject); count += (codenames == null) ? 0 : codenames.Count; } } // Check a special case for Workflows if (objectType.Equals(PredefinedObjectType.WORKFLOW)) { // Check workflows bool includeWorkflowScopes = ValidationHelper.GetBoolean(settings.GetSettings(ImportExportHelper.SETTINGS_WORKFLOW_SCOPES), false); if (includeWorkflowScopes) { // Check if there are any workflow scopes in the imported package and if there are, increase the count. DataSet dsScopes = ImportProvider.LoadObjects(settings, PredefinedObjectType.WORKFLOWSCOPE, true); if (!DataHelper.DataSourceIsEmpty(dsScopes)) { count++; } } } if (count > 0) { FeatureEnum feature = (FeatureEnum)checkFeatures[i, 0]; // Get best available license from DB LicenseKeyInfo bestLicense = LicenseKeyInfoProvider.GetLicenseKeyInfo(domain, feature); if ((bestLicense != null) && (bestLicense.ValidationResult != LicenseValidationEnum.Valid)) { bestLicense = null; } // Check new licenses LicenseKeyInfo bestSelected = null; if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { LicenseKeyInfo lki = new LicenseKeyInfo(dr); // Use license only if selected if ((settings.IsSelected(LicenseObjectType.LICENSEKEY, lki.Domain, false)) && (anyDomain || (lki.Domain.ToLower() == domain)) && LicenseKeyInfoProvider.IsBetterLicense(lki, bestSelected, feature)) { bestSelected = lki; if (bestSelected.Domain.ToLower() == domain) { break; } } } } // Check the license if (feature == FeatureEnum.Unknown) { if ((bestLicense == null) && (bestSelected == null)) { return(ResHelper.GetString("Import.NoLicense")); } } else { // Check the limit int limit = GetLimit(bestLicense, feature); // Use a database license if it is better than the one which is being imported if (LicenseKeyInfoProvider.IsBetterLicense(bestLicense, bestSelected, feature)) { bestSelected = bestLicense; } int selectedLimit = GetLimit(bestSelected, feature); if (bestSelected != null) { if (bestSelected.ValidationResult == LicenseValidationEnum.Valid) { if (!anyDomain || (bestSelected.Domain.ToLower() == domain)) { limit = selectedLimit; } else { // If selected better, take the selected if (selectedLimit > limit) { limit = selectedLimit; } } } else { if (!anyDomain || (bestSelected.Domain.ToLower() == domain)) { limit = 0; } } } if (limit < count) { if (limit <= 0) { result += String.Format(ResHelper.GetString("Import.LimitZero"), ResHelper.GetString("ObjectTasks." + objectType.Replace(".", "_"))); } else { result += String.Format(ResHelper.GetString("Import.LimitExceeded"), ResHelper.GetString("ObjectTasks." + objectType.Replace(".", "_")), limit); } // If better license if ((bestLicense != null) && (bestSelected != null) && LicenseKeyInfoProvider.IsBetterLicense(bestLicense, bestSelected, feature)) { result += " " + ResHelper.GetString("Import.BetterLicenseExists"); } result += "<br />"; } } } } return(result); }
/// <summary> /// Starts import process with given settings. Returns true if import was started successfully, false otherwise (error label is set in this case). /// </summary> /// <param name="settings">Import settings</param> /// <returns>Returns true if import was started successfully, false otherwise.</returns> private bool StartImport(SiteImportSettings settings) { // Check licences string error = ImportExportControl.CheckLicenses(settings); if (!string.IsNullOrEmpty(error)) { SetErrorLabel(error); return false; } // Start asynchronnous Import if (settings.SiteIsIncluded) { settings.EventLogSource = string.Format(settings.GetAPIString("ImportSite.EventLogSiteSource", "Import '{0}' site"), ResHelper.LocalizeString(settings.SiteDisplayName)); } var manager = ImportManager; settings.LogContext = ctlAsyncImport.CurrentLog; manager.Settings = settings; ctlAsyncImport.RunAsync(manager.Import, WindowsIdentity.GetCurrent()); return true; }
void btnOk_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(lstImports.SelectedValue)) { // Init the Mimetype helper (required for the export) MimeTypeHelper.LoadMimeTypes(); siteObject = (exportObj.ObjectSiteID > 0); // Prepare the settings ImportSettings = new SiteImportSettings(CMSContext.CurrentUser); ImportSettings.WebsitePath = Server.MapPath("~/"); ImportSettings.SourceFilePath = GetSelectedFilePath(); if (siteObject) { ImportSettings.SiteId = exportObj.ObjectSiteID; ImportSettings.ExistingSite = true; } // Set the filename lblProgress.Text = string.Format(GetString("RestoreObject.RestoreProgress"), exportObjectDisplayName); pnlDetails.Visible = false; btnOk.Enabled = false; pnlProgress.Visible = true; try { // Export the data ltlScript.Text = ScriptHelper.GetScript("StartTimer();"); ucAsyncControl.RunAsync(RestoreSingleObject, WindowsIdentity.GetCurrent()); } catch (Exception ex) { DisplayError(ex); } } }
/// <summary> /// Imports user object. Called when the "Import object" button is pressed. /// </summary> private bool ImportObject() { // Create site import settings SiteImportSettings settings = new SiteImportSettings(CMSContext.CurrentUser); // Initialize the settings settings.WebsitePath = Server.MapPath("~/"); settings.SourceFilePath = settings.WebsitePath + "\\CMSAPIExamples\\Code\\Tools\\ImportExport\\Packages\\APIExample_User.zip"; settings.ImportType = ImportTypeEnum.All; settings.LoadDefaultSelection(); // Import ImportProvider.ImportObjectsData(settings); // Delete temporary data ImportProvider.DeleteTemporaryFiles(settings, false); return true; }
private SiteImportSettings PrepareSettings(WebTemplateInfo ti) { // Settings preparation var settings = new SiteImportSettings(ImportUser); // Import all, but only add new data settings.ImportType = ImportTypeEnum.AllNonConflicting; settings.ImportOnlyNewObjects = true; settings.CopyFiles = false; // Allow bulk inserts for faster import, web templates must be consistent enough to allow this without collisions settings.AllowBulkInsert = true; settings.IsWebTemplate = true; settings.EnableSearchTasks = false; settings.CreateVersion = false; settings.SiteName = ti.WebTemplateName; settings.SiteDisplayName = ti.WebTemplateDisplayName; if (HttpContext.Current != null) { const string www = "www."; if (hostName.StartsWithCSafe(www)) { hostName = hostName.Remove(0, www.Length); } if (!RequestContext.URL.IsDefaultPort) { hostName += ":" + RequestContext.URL.Port; } settings.SiteDomain = hostName; Domain = hostName; string path = HttpContext.Current.Server.MapPath(ti.WebTemplateFileName); if (File.Exists(path + "\\template.zip")) { // Template from zip file path += "\\" + ZipStorageProvider.GetZipFileName("template.zip"); settings.TemporaryFilesPath = path; settings.SourceFilePath = path; settings.TemporaryFilesCreated = true; } else { settings.SourceFilePath = path; } settings.WebsitePath = HttpContext.Current.Server.MapPath("~/"); } settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_SITE, true); settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_TEMPORARY_FILES, false); return settings; }
/// <summary> /// Procedures which automatically imports the upgrade export package with all WebParts, Widgets, Reports and TimeZones. /// </summary> private static void UpgradeImportPackage() { // Import try { RequestStockHelper.Remove("CurrentDomain", true); var importSettings = new SiteImportSettings(MembershipContext.AuthenticatedUser) { DefaultProcessObjectType = ProcessObjectEnum.All, SourceFilePath = mUpgradePackagePath, WebsitePath = mWebsitePath }; using (var context = new CMSActionContext()) { context.DisableLogging(); context.CreateVersion = false; context.LogIntegration = false; ImportProvider.ImportObjectsData(importSettings); // Regenerate time zones TimeZoneInfoProvider.GenerateTimeZoneRules(); // Delete the files for separable modules which are not install and therefore not needed DeleteWebPartsOfUninstalledModules(); ImportMetaFiles(Path.Combine(mWebsitePath, "App_Data\\CMSTemp\\Upgrade")); } } catch (Exception ex) { EventLogProvider.LogException(EventLogSource, "IMPORT", ex); } }
/// <summary> /// Creates new settings object for Import. /// </summary> private SiteImportSettings GetNewSettings() { SiteImportSettings result = new SiteImportSettings(CMSContext.CurrentUser); result.WebsitePath = Server.MapPath("~/"); result.PersistentSettingsKey = PersistentSettingsKey; return result; }
/// <summary> /// Creates new settings object for Import. /// </summary> private SiteImportSettings GetNewSettings() { SiteImportSettings result = new SiteImportSettings(MembershipContext.AuthenticatedUser); result.WebsitePath = Server.MapPath("~/"); result.PersistentSettingsKey = PersistentSettingsKey; return result; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); if (!RequestHelper.IsPostBack()) { // Initialize import settings ImportSettings = new SiteImportSettings(MembershipContext.AuthenticatedUser) { WebsitePath = Server.MapPath("~/"), PersistentSettingsKey = PersistentSettingsKey }; if (wzdImport.ActiveStep.StepType == WizardStepType.Start) { EnsureTemplateSelection(); } } if (RequestHelper.IsCallback()) { // Stop processing when callback siteDetails.StopProcessing = true; } else { var previousButton = PreviousButton; var nextButton = NextButton; previousButton.Enabled = true; previousButton.Visible = wzdImport.ActiveStepIndex <= 2; nextButton.Enabled = true; // Bind async controls events ctrlAsyncSelection.OnFinished += ctrlAsyncSelection_OnFinished; ctrlAsyncSelection.OnError += ctrlAsyncSelection_OnError; ctlAsyncImport.OnCancel += ctlAsyncImport_OnCancel; ctlAsyncImport.OnFinished += ctlAsyncImport_OnFinished; if (wzdImport.ActiveStepIndex < 2) { siteDetails.Settings = ImportSettings; pnlImport.Settings = ImportSettings; } // Javascript functions var script = $@" function Finished(sender) {{ var errorElement = document.getElementById('{lblError.LabelClientID}'); var errorText = sender.getErrors(); if (errorText != '') {{ errorElement.innerHTML = errorText; document.getElementById('{pnlError.ClientID}').style.removeProperty('display'); }} var warningElement = document.getElementById('{lblWarning.LabelClientID}'); var warningText = sender.getWarnings(); if (warningText != '') {{ warningElement.innerHTML = warningText; document.getElementById('{pnlWarning.ClientID}').style.removeProperty('display'); }} var actDiv = document.getElementById('actDiv'); if (actDiv != null) {{ actDiv.style.display = 'none'; }} BTN_Disable('{CancelButton.ClientID}'); BTN_Enable('{FinishButton.ClientID}'); if ((errorText == null) || (errorText == '')) {{ BTN_Enable('{nextButton.ClientID}'); }} }}"; // Register the script to perform get flags for showing buttons retrieval callback ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Finished", ScriptHelper.GetScript(script)); // Add cancel button attribute CancelButton.Attributes.Add("onclick", ctlAsyncImport.GetCancelScript(true) + "return false;"); wzdImport.NextButtonClick += wzdImport_NextButtonClick; wzdImport.PreviousButtonClick += wzdImport_PreviousButtonClick; wzdImport.FinishButtonClick += wzdImport_FinishButtonClick; } }
private static void Upgrade60Import() { EventLogProvider evp = new EventLogProvider(); // Import try { RequestStockHelper.Remove("CurrentDomain", true); SiteImportSettings importSettings = new SiteImportSettings(CMSContext.CurrentUser) { DefaultProcessObjectType = ProcessObjectEnum.All, SourceFilePath = mUpgradePackagePath, WebsitePath = mWebsitePath }; ImportProvider.ImportObjectsData(importSettings); // Regenerate time zones TimeZoneInfoProvider.GenerateTimeZoneRules(); #region "Separability" String webPartsPath = mWebsitePath + "CMSWebParts\\"; List <String> files = new List <string>(); // Create list of files to remove if (!ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM)) { files.AddRange(GetAllFiles(webPartsPath + "BizForms")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.BLOGS)) { files.AddRange(GetAllFiles(webPartsPath + "Blogs")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY)) { files.AddRange(GetAllFiles(webPartsPath + "Community")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { files.AddRange(GetAllFiles(webPartsPath + "Ecommerce")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.EVENTMANAGER)) { files.AddRange(GetAllFiles(webPartsPath + "Events")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS)) { files.AddRange(GetAllFiles(webPartsPath + "Forums")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MEDIALIBRARY)) { files.AddRange(GetAllFiles(webPartsPath + "MediaLibrary")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGEBOARD)) { files.AddRange(GetAllFiles(webPartsPath + "MessageBoards")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.MESSAGING)) { files.AddRange(GetAllFiles(webPartsPath + "Messaging")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.NEWSLETTER)) { files.AddRange(GetAllFiles(webPartsPath + "Newsletters")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.NOTIFICATIONS)) { files.AddRange(GetAllFiles(webPartsPath + "Notifications")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ONLINEMARKETING)) { files.AddRange(GetAllFiles(webPartsPath + "OnlineMarketing")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.POLLS)) { files.AddRange(GetAllFiles(webPartsPath + "Polls")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.PROJECTMANAGEMENT)) { files.AddRange(GetAllFiles(webPartsPath + "ProjectManagement")); } if (!ModuleEntry.IsModuleLoaded(ModuleEntry.REPORTING)) { files.AddRange(GetAllFiles(webPartsPath + "Reporting")); } // Remove webparts for separated modules foreach (String file in files) { try { File.Delete(file); } catch (Exception ex) { evp.LogEvent("Upgrade to 6.0", "Upgrade", ex); } } #endregion evp.LogEvent("I", DateTime.Now, "Upgrade to 6.0", "Upgrade - Finish"); } catch (Exception ex) { evp.LogEvent("Upgrade to 6.0", "Upgrade", ex); } }
protected void btnHiddenNext_onClick(object sender, EventArgs e) { StepOperation = 1; StepIndex++; switch (wzdInstaller.ActiveStepIndex) { case 0: Password = userServer.DBPassword; // Set the authentication type authenticationType = userServer.WindowsAuthenticationChecked ? SQLServerAuthenticationModeEnum.WindowsAuthentication : SQLServerAuthenticationModeEnum.SQLServerAuthentication; // Check the server name if (userServer.ServerName == String.Empty) { HandleError(ResHelper.GetFileString("Install.ErrorServerEmpty")); return; } // Check if it is possible to connect to the database string res = ConnectionHelper.TestConnection(authenticationType, userServer.ServerName, String.Empty, userServer.DBUsername, Password); if (!string.IsNullOrEmpty(res)) { HandleError(res, "Install.ErrorSqlTroubleshoot", HELP_TOPIC_SQL_ERROR_LINK); return; } // Set credentials for the next step databaseDialog.AuthenticationType = authenticationType; databaseDialog.Password = Password; databaseDialog.Username = userServer.DBUsername; databaseDialog.ServerName = userServer.ServerName; // Move to the next step wzdInstaller.ActiveStepIndex = 1; break; case 1: case 8: // Get database name Database = TextHelper.LimitLength((databaseDialog.CreateNewChecked ? databaseDialog.NewDatabaseName : databaseDialog.ExistingDatabaseName), 100); if (string.IsNullOrEmpty(Database)) { HandleError(ResHelper.GetFileString("Install.ErrorDBNameEmpty")); return; } // Set up the connection string if (ConnectionHelper.IsConnectionStringInitialized) { ConnectionString = ConnectionHelper.ConnectionString; } else { ConnectionString = ConnectionHelper.GetConnectionString(authenticationType, userServer.ServerName, Database, userServer.DBUsername, Password, SqlInstallationHelper.DB_CONNECTION_TIMEOUT, false); } // Check if existing DB has the same version as currently installed CMS if (databaseDialog.UseExistingChecked && !databaseDialog.CreateDatabaseObjects) { string dbVersion = null; try { dbVersion = SqlInstallationHelper.GetDatabaseVersion(ConnectionString); } catch { } if (String.IsNullOrEmpty(dbVersion)) { // Unable to get DB version => DB objects missing HandleError(ResHelper.GetFileString("Install.DBObjectsMissing")); return; } if (dbVersion != CMSVersion.MainVersion) { // Get wrong version number HandleError(ResHelper.GetFileString("Install.WrongDBVersion")); return; } } // Set DB schema string dbSchema = null; if (hdnAdvanced.Value == "1") { dbSchema = databaseDialog.SchemaText; } InstallInfo.DBSchema = dbSchema; // Use existing database if (databaseDialog.UseExistingChecked) { // Check if DB exists if (!DatabaseHelper.DatabaseExists(ConnectionString)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorDatabseDoesntExist"), Database)); return; } // Check if DB schema exists if (!SqlInstallationHelper.CheckIfSchemaExist(ConnectionString, dbSchema)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorDatabseSchemaDoesnotExist"), dbSchema, SqlInstallationHelper.GetCurrentDefaultSchema(ConnectionString))); return; } // Get collation of existing DB string collation = DatabaseHelper.GetDatabaseCollation(ConnectionString); string dbCollation = collation; DatabaseHelper.DatabaseCollation = collation; if (wzdInstaller.ActiveStepIndex != 8) { // Check target database collation (ask the user if it is not fully supported) if (CMSString.Compare(dbCollation, COLLATION_CASE_INSENSITIVE, true) != 0) { lblCollation.Text = ResHelper.GetFileString("install.databasecollation"); rbLeaveCollation.Text = string.Format(ResHelper.GetFileString("install.leavecollation"), collation); rbChangeCollationCI.Text = string.Format(ResHelper.GetFileString("install.changecollation"), COLLATION_CASE_INSENSITIVE); wzdInstaller.ActiveStepIndex = 8; return; } } else { // Change database collation if (!rbLeaveCollation.Checked) { if (rbChangeCollationCI.Checked) { DatabaseHelper.ChangeDatabaseCollation(ConnectionString, Database, COLLATION_CASE_INSENSITIVE); } } } } else { // Create a new database if (!CreateDatabase(null)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorCreateDB"), databaseDialog.NewDatabaseName)); return; } databaseDialog.ExistingDatabaseName = databaseDialog.NewDatabaseName; databaseDialog.CreateNewChecked = false; databaseDialog.UseExistingChecked = true; } if ((!SystemContext.IsRunningOnAzure && writePermissions) || ConnectionHelper.IsConnectionStringInitialized) { if (databaseDialog.CreateDatabaseObjects) { if (DBInstalled && DBCreated) { ucDBAsyncControl.RaiseFinished(this, EventArgs.Empty); } else { // Run SQL installation RunSQLInstallation(dbSchema); } } else { CreateDBObjects = false; // Set connection string if (SettingsHelper.SetConnectionString(ConnectionHelper.ConnectionStringName, ConnectionString)) { // Set the application connection string SetAppConnectionString(); // Check if license key for current domain is present LicenseKeyInfo lki = LicenseKeyInfoProvider.GetLicenseKeyInfo(hostName); wzdInstaller.ActiveStepIndex = (lki == null) ? 4 : 5; ucLicenseDialog.SetLicenseExpired(); } else { ManualConnectionStringInsertion(); } } } else { ManualConnectionStringInsertion(); } break; // After connection string save error case 2: // If connection strings don't match if ((SettingsHelper.ConnectionStrings[ConnectionHelper.ConnectionStringName] == null) || (SettingsHelper.ConnectionStrings[ConnectionHelper.ConnectionStringName].ConnectionString == null) || (SettingsHelper.ConnectionStrings[ConnectionHelper.ConnectionStringName].ConnectionString.Trim() == "") || (SettingsHelper.ConnectionStrings[ConnectionHelper.ConnectionStringName].ConnectionString != ConnectionString)) { HandleError(ResHelper.GetFileString("Install.ErrorAddConnString")); return; } if (CreateDBObjects) { if (DBInstalled) { SetAppConnectionString(); // Continue with next step CheckLicense(); RequestMetaFile(); } else { // Run SQL installation RunSQLInstallation(null); } } else { // If this is installation to existing DB and objects are not created if ((hostName != "localhost") && (hostName != "127.0.0.1")) { wzdInstaller.ActiveStepIndex = 4; } else { wzdInstaller.ActiveStepIndex = 5; } } break; // After DB install case 3: break; // After license entering case 4: try { if (ucLicenseDialog.Visible) { ucLicenseDialog.SetLicenseKey(); wzdInstaller.ActiveStepIndex = 5; } else if (ucWagDialog.ProcessRegistration(ConnectionString)) { wzdInstaller.ActiveStepIndex = 5; } } catch (Exception ex) { HandleError(ex.Message); } break; // Site creation case 5: switch (ucSiteCreationDialog.CreationType) { case CMSInstall_Controls_WizardSteps_SiteCreationDialog.CreationTypeEnum.Template: { if (ucSiteCreationDialog.TemplateName == "") { HandleError(ResHelper.GetFileString("install.notemplate")); return; } // Settings preparation SiteImportSettings settings = new SiteImportSettings(ImportUser); settings.IsWebTemplate = true; settings.ImportType = ImportTypeEnum.AllNonConflicting; settings.CopyFiles = false; settings.EnableSearchTasks = false; settings.CreateVersion = false; if (HttpContext.Current != null) { const string www = "www."; if (hostName.StartsWithCSafe(www)) { hostName = hostName.Remove(0, www.Length); } if (!RequestContext.URL.IsDefaultPort) { hostName += ":" + RequestContext.URL.Port; } settings.SiteDomain = hostName; Domain = hostName; } // Create site WebTemplateInfo ti = WebTemplateInfoProvider.GetWebTemplateInfo(ucSiteCreationDialog.TemplateName); if (ti == null) { HandleError("[Install]: Template not found."); return; } settings.SiteName = ti.WebTemplateName; settings.SiteDisplayName = ti.WebTemplateDisplayName; if (HttpContext.Current != null) { string path = HttpContext.Current.Server.MapPath(ti.WebTemplateFileName); if (File.Exists(path + "\\template.zip")) { // Template from zip file path += "\\" + ZipStorageProvider.GetZipFileName("template.zip"); settings.TemporaryFilesPath = path; settings.SourceFilePath = path; settings.TemporaryFilesCreated = true; } else { settings.SourceFilePath = path; } settings.WebsitePath = HttpContext.Current.Server.MapPath("~/"); } settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_SITE, true); settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_TEMPORARY_FILES, false); SiteName = settings.SiteName; // Init the Mimetype helper (required for the Import) MimeTypeHelper.LoadMimeTypes(); // Import the site asynchronously ImportManager.Settings = settings; ucAsyncControl.RunAsync(ImportManager.Import, WindowsIdentity.GetCurrent()); NextButton.Attributes.Add("disabled", "true"); PreviousButton.Attributes.Add("disabled", "true"); wzdInstaller.ActiveStepIndex = 6; ltlInstallScript.Text = ScriptHelper.GetScript("StartInstallStateTimer('IM');"); } break; // Else redirect to the site import case CMSInstall_Controls_WizardSteps_SiteCreationDialog.CreationTypeEnum.ExistingSite: { AuthenticationHelper.AuthenticateUser("administrator", false); URLHelper.Redirect(UIContextHelper.GetApplicationUrl("cms", "sites", "action=import")); } break; // Else redirect to the new site wizard case CMSInstall_Controls_WizardSteps_SiteCreationDialog.CreationTypeEnum.NewSiteWizard: { AuthenticationHelper.AuthenticateUser("administrator", false); URLHelper.Redirect(UIContextHelper.GetApplicationUrl("cms", "sites", "action=new")); } break; } break; default: wzdInstaller.ActiveStepIndex++; break; } }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Handle Import settings if (!RequestHelper.IsCallback() && !RequestHelper.IsPostBack()) { // Check if any template is present on the disk if (!WebTemplateInfoProvider.IsAnyTemplatePresent()) { selectTemplate.StopProcessing = true; pnlWrapper.Visible = false; ShowError(GetString("NewSite.NoWebTemplate")); } // Initialize import settings ImportSettings = new SiteImportSettings(MembershipContext.AuthenticatedUser); ImportSettings.WebsitePath = Server.MapPath("~/"); ImportSettings.PersistentSettingsKey = PersistentSettingsKey; } if (RequestHelper.IsCallback()) { // Stop processing when callback selectTemplate.StopProcessing = true; selectMaster.StopProcessing = true; } else { selectTemplate.StopProcessing = (!CausedPostback(PreviousButton) || (wzdImport.ActiveStepIndex != 2)) && (wzdImport.ActiveStepIndex != 1); selectMaster.StopProcessing = (wzdImport.ActiveStepIndex != 5); PreviousButton.Enabled = true; PreviousButton.Visible = (wzdImport.ActiveStepIndex <= 4); NextButton.Enabled = true; // Bind async controls events ctrlAsyncSelection.OnFinished += ctrlAsyncSelection_OnFinished; ctrlAsyncSelection.OnError += ctrlAsyncSelection_OnError; ctlAsyncImport.OnCancel += ctlAsyncImport_OnCancel; ctlAsyncImport.OnFinished += ctlAsyncImport_OnFinished; if (wzdImport.ActiveStepIndex < 4) { siteDetails.Settings = ImportSettings; pnlImport.Settings = ImportSettings; } // Javascript functions string script = String.Format( @" function Finished(sender) {{ var errorElement = document.getElementById('{2}'); var errorText = sender.getErrors(); if (errorText != '') {{ errorElement.innerHTML = errorText; document.getElementById('{4}').style.removeProperty('display'); }} var warningElement = document.getElementById('{3}'); var warningText = sender.getWarnings(); if (warningText != '') {{ warningElement.innerHTML = warningText; document.getElementById('{5}').style.removeProperty('display'); }} var actDiv = document.getElementById('actDiv'); if (actDiv != null) {{ actDiv.style.display = 'none'; }} BTN_Disable('{0}'); BTN_Enable('{1}'); if ((errorText == null) || (errorText == '')) {{ BTN_Enable('{6}'); }} }} ", CancelButton.ClientID, FinishButton.ClientID, lblError.LabelClientID, lblWarning.LabelClientID, pnlError.ClientID, pnlWarning.ClientID, NextButton.ClientID ); // Register the script to perform get flags for showing buttons retrieval callback ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Finished", ScriptHelper.GetScript(script)); // Add cancel button attribute CancelButton.Attributes.Add("onclick", ctlAsyncImport.GetCancelScript(true) + "return false;"); wzdImport.NextButtonClick += wzdImport_NextButtonClick; wzdImport.PreviousButtonClick += wzdImport_PreviousButtonClick; wzdImport.FinishButtonClick += wzdImport_FinishButtonClick; } }
protected void btnHiddenNext_onClick(object sender, EventArgs e) { StepOperation = 1; StepIndex++; switch (wzdInstaller.ActiveStepIndex) { case 0: ViewState["install.password"] = txtDBPassword.Text.Trim(); // Set the authentication type authenticationType = radWindowsAuthentication.Checked ? SQLServerAuthenticationModeEnum.WindowsAuthentication : SQLServerAuthenticationModeEnum.SQLServerAuthentication; // Check the server name if (txtServerName.Text.Trim() == "") { HandleError(ResHelper.GetFileString("Install.ErrorServerEmpty")); return; } // Check if it is possible to connect to the database string res = ConnectionHelper.TestConnection(authenticationType, txtServerName.Text.Trim(), "", txtDBUsername.Text.Trim(), ViewState["install.password"].ToString()); if (!string.IsNullOrEmpty(res)) { HandleError(res, "Install.ErrorSqlTroubleshoot", "SQLError"); return; } else { wzdInstaller.ActiveStepIndex = 1; } break; case 1: case 8: // Get database name Database = TextHelper.LimitLength((radCreateNew.Checked ? txtNewDatabaseName.Text.Trim() : txtExistingDatabaseName.Text.Trim()), 100); // Set up the connection string if (SqlHelperClass.IsConnectionStringInitialized) { ConnectionString = SqlHelperClass.ConnectionString; } else { ConnectionString = ConnectionHelper.GetConnectionString(authenticationType, txtServerName.Text.Trim(), Database, txtDBUsername.Text.Trim(), ViewState["install.password"].ToString(), 240, false); } if (Database == "") { HandleError(ResHelper.GetFileString("Install.ErrorDBNameEmpty")); return; } // Check if existing DB has the same version as currently installed CMS if (radUseExisting.Checked && !chkCreateDatabaseObjects.Checked) { string dbVersion = null; try { dbVersion = CMSDatabaseHelper.GetDatabaseVersion(ConnectionString); } catch { } if (String.IsNullOrEmpty(dbVersion)) { // Unable to get DB version => DB objects missing HandleError(ResHelper.GetFileString("Install.DBObjectsMissing")); return; } if (dbVersion != CMSContext.SYSTEM_VERSION) { // Get wrong version number HandleError(ResHelper.GetFileString("Install.WrongDBVersion")); return; } } string dbCollation = null; string dbSchema = "dbo"; if (hdnAdvanced.Value == "1") { dbSchema = txtSchema.Text; } InstallInfo.DBSchema = dbSchema; // Use existing database if (radUseExisting.Checked) { // Check if DB exists if (!ConnectionHelper.DatabaseExists(ConnectionString)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorDatabseDoesntExist"), Database)); return; } // Check if DB schema exists if (!CMSDatabaseHelper.CheckIfSchemaExist(ConnectionString, dbSchema)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorDatabseSchemaDoesnotExist"), dbSchema, CMSDatabaseHelper.GetCurrentDefaultSchema(ConnectionString))); return; } // Check if DB is in correct version // Get collation of existing DB string collation = ConnectionHelper.GetDatabaseCollation(ConnectionString); if (String.IsNullOrEmpty(dbCollation)) { dbCollation = collation; } ConnectionHelper.DatabaseCollation = collation; if (wzdInstaller.ActiveStepIndex != 8) { // Check target database collation (ask the user if it is not fully supported) if (String.Compare(dbCollation, COLLATION_CASE_INSENSITIVE, true) != 0) { lblCollation.Text = ResHelper.GetFileString("install.databasecollation"); rbLeaveCollation.Text = string.Format(ResHelper.GetFileString("install.leavecollation"), collation); rbChangeCollationCI.Text = string.Format(ResHelper.GetFileString("install.changecollation"), COLLATION_CASE_INSENSITIVE); wzdInstaller.ActiveStepIndex = 8; return; } else { // Change collation if needed if (String.Compare(dbCollation, collation, true) != 0) { ConnectionHelper.ChangeDatabaseCollation(ConnectionString, Database, dbCollation); } } } else { // Change database collation if (!rbLeaveCollation.Checked) { if (rbChangeCollationCI.Checked) { ConnectionHelper.ChangeDatabaseCollation(ConnectionString, Database, COLLATION_CASE_INSENSITIVE); } } } } else { // Create a new database if (!CreateDatabase(dbCollation)) { HandleError(string.Format(ResHelper.GetFileString("Install.ErrorCreateDB"), txtNewDatabaseName.Text)); return; } else { txtExistingDatabaseName.Text = txtNewDatabaseName.Text; radCreateNew.Checked = false; radUseExisting.Checked = true; } } if ((!AzureHelper.IsRunningOnAzure && writePermissions) || SqlHelperClass.IsConnectionStringInitialized) { if (chkCreateDatabaseObjects.Checked) { if (DBInstalled && DBCreated) { ucDBAsyncControl.RaiseFinished(this, EventArgs.Empty); } else { InstallInfo.ScriptsFullPath = Server.MapPath("~/App_Data/Install/SQL"); InstallInfo.ConnectionString = ConnectionString; InstallInfo.DBSchema = dbSchema; InstallInfo.ClearLog(); ucDBAsyncControl.RunAsync(InstallDatabase, WindowsIdentity.GetCurrent()); NextButton.Attributes.Add("disabled", "true"); PreviousButton.Attributes.Add("disabled", "true"); wzdInstaller.ActiveStepIndex = 3; ltlInstallScript.Text = ScriptHelper.GetScript("StartInstallStateTimer('DB');"); } } else { CreateDBObjects = false; // Check the DB connection pnlLog.Visible = false; // Set connection string if (SettingsHelper.SetConnectionString("CMSConnectionString", ConnectionString)) { SqlHelperClass.ConnectionString = ConnectionString; // If this is installation to existing BD and objects are not created // Check if license key for current domain is present LicenseKeyInfo lki = LicenseKeyInfoProvider.GetLicenseKeyInfo(hostName); wzdInstaller.ActiveStepIndex = (lki == null) ? 4 : 5; ucLicenseDialog.SetLicenseExpired(); } else { string connStringDisplay = ConnectionHelper.GetConnectionString(authenticationType, txtServerName.Text.Trim(), Database, txtDBUsername.Text.Trim(), ViewState["install.password"].ToString(), 240, true); wzdInstaller.ActiveStepIndex = 2; string message = ResHelper.GetFileString("Install.ConnectionStringError") + " <br/><br/><strong><add name=\"CMSConnectionString\" connectionString=\"" + connStringDisplay + "\"/></strong><br/><br/>"; lblErrorConnMessage.Text = message; // Show troubleshoot link hlpTroubleshoot.Visible = true; hlpTroubleshoot.TopicName = "DiskPermissions"; hlpTroubleshoot.Text = ResHelper.GetFileString("Install.ErrorPermissions"); } } } else { wzdInstaller.ActiveStepIndex = 2; string message = string.Empty; if (AzureHelper.IsRunningOnAzure) { string connStringValue = ConnectionHelper.GetConnectionString(authenticationType, txtServerName.Text.Trim(), Database, txtDBUsername.Text.Trim(), ViewState["install.password"].ToString(), "English", 240, true, true); string connString = "<add name=\"CMSConnectionString\" connectionString=\"" + connStringValue + "\"/>"; string appSetting = "<Setting name=\"CMSConnectionString\" value=\"" + connStringValue + "\"/>"; message = string.Format(ResHelper.GetFileString("Install.ConnectionStringAzure"), connString, appSetting); } else { string connString = ConnectionHelper.GetConnectionString(authenticationType, txtServerName.Text.Trim(), Database, txtDBUsername.Text.Trim(), ViewState["install.password"].ToString(), 240, true); message = ResHelper.GetFileString("Install.ConnectionStringError") + " <br/><br/><strong><add name=\"CMSConnectionString\" connectionString=\"" + connString + "\"/></strong><br/><br/>"; // Show troubleshoot link hlpTroubleshoot.Visible = true; hlpTroubleshoot.TopicName = "DiskPermissions"; hlpTroubleshoot.Text = ResHelper.GetFileString("Install.ErrorPermissions"); } lblErrorConnMessage.Text = message; } break; // After DB install case 3: break; // After connection string save error case 2: //// Restart application to ensure connection string update //try //{ // // Try to restart applicatin by unload app domain // HttpRuntime.UnloadAppDomain(); //} //catch //{ //} // If connectionstrings don't match if ((SettingsHelper.ConnectionStrings["CMSConnectionString"] == null) || (SettingsHelper.ConnectionStrings["CMSConnectionString"].ConnectionString == null) || (SettingsHelper.ConnectionStrings["CMSConnectionString"].ConnectionString.Trim() == "") || (SettingsHelper.ConnectionStrings["CMSConnectionString"].ConnectionString != ConnectionString)) { HandleError(ResHelper.GetFileString("Install.ErrorAddConnString")); return; } else { if (CreateDBObjects) { if (DBInstalled) { ucDBAsyncControl.RaiseFinished(this, EventArgs.Empty); } else { InstallInfo.ScriptsFullPath = Server.MapPath("~/App_Data/Install/SQL"); InstallInfo.ConnectionString = ConnectionString; InstallInfo.DBSchema = InstallInfo.DBSchema; InstallInfo.ClearLog(); ucDBAsyncControl.RunAsync(InstallDatabase, WindowsIdentity.GetCurrent()); NextButton.Attributes.Add("disabled", "true"); PreviousButton.Attributes.Add("disabled", "true"); wzdInstaller.ActiveStepIndex = 3; ltlInstallScript.Text = ScriptHelper.GetScript("StartInstallStateTimer('DB');"); } } else { // If this is installation to existing DB and objects are not created if ((hostName != "localhost") && (hostName != "127.0.0.1")) { wzdInstaller.ActiveStepIndex = 4; } else { wzdInstaller.ActiveStepIndex = 5; } } } break; // After license entering case 4: try { if (ucLicenseDialog.Visible) { ucLicenseDialog.SetLicenseKey(); wzdInstaller.ActiveStepIndex = 5; } else { if (ucWagDialog.ProcessRegistration(ConnectionString)) { wzdInstaller.ActiveStepIndex = 5; } } } catch (Exception ex) { HandleError(ex.Message); return; } break; // Site creation case 5: switch (ucSiteCreationDialog.CreationType) { case CMSInstall_Controls_SiteCreationDialog.CreationTypeEnum.Template: { if (ucSiteCreationDialog.TemplateName == "") { HandleError(ResHelper.GetFileString("install.notemplate")); return; } // Settings preparation SiteImportSettings settings = new SiteImportSettings(ImportUser); settings.ImportType = ImportTypeEnum.All; settings.CopyFiles = false; settings.EnableSearchTasks = false; if (HttpContext.Current != null) { const string www = "www."; if (hostName.StartsWith(www)) { hostName = hostName.Remove(0, www.Length); } if (!URLHelper.Url.IsDefaultPort) { hostName += ":" + URLHelper.Url.Port; } settings.SiteDomain = hostName; Domain = hostName; } // Create site WebTemplateInfo ti = WebTemplateInfoProvider.GetWebTemplateInfo(ucSiteCreationDialog.TemplateName); if (ti == null) { HandleError("[Install]: Template not found."); return; } settings.SiteName = ti.WebTemplateName; settings.SiteDisplayName = ti.WebTemplateDisplayName; if (HttpContext.Current != null) { settings.SourceFilePath = HttpContext.Current.Server.MapPath(ti.WebTemplateFileName); settings.WebsitePath = HttpContext.Current.Server.MapPath("~/"); } settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_SITE, true); settings.SetSettings(ImportExportHelper.SETTINGS_DELETE_TEMPORARY_FILES, false); SiteName = settings.SiteName; // Init the Mimetype helper (required for the Import) MimeTypeHelper.LoadMimeTypes(); // Import the site asynchronously ImportManager.Settings = settings; ucAsyncControl.RunAsync(ImportManager.Import, WindowsIdentity.GetCurrent()); NextButton.Attributes.Add("disabled", "true"); PreviousButton.Attributes.Add("disabled", "true"); wzdInstaller.ActiveStepIndex = 6; ltlInstallScript.Text = ScriptHelper.GetScript("StartInstallStateTimer('IM');"); } break; // Else redirect to the site import case CMSInstall_Controls_SiteCreationDialog.CreationTypeEnum.ExistingSite: { CMSContext.AuthenticateUser("administrator", false); URLHelper.Redirect("~/cmssitemanager/default.aspx?section=sites&action=import"); } break; // Else redirect to the new site wizard case CMSInstall_Controls_SiteCreationDialog.CreationTypeEnum.NewSiteWizard: { CMSContext.AuthenticateUser("administrator", false); URLHelper.Redirect("~/cmssitemanager/default.aspx?section=sites&action=new"); } break; } break; default: wzdInstaller.ActiveStepIndex++; break; } }
private ImportManager CreateManager() { var settings = new SiteImportSettings(ImportUser); settings.IsWebTemplate = true; // Import all, but only add new data settings.ImportType = ImportTypeEnum.AllNonConflicting; settings.ImportOnlyNewObjects = true; settings.CopyFiles = false; // Allow bulk inserts for faster import, web templates must be consistent enough to allow this without collisions settings.AllowBulkInsert = true; settings.EnableSearchTasks = false; ImportManager im = new ImportManager(settings); return im; }