/// <summary> /// Creates the site structure based on the options provided /// </summary> public static void ReplicateSite( Asset asset, string siteXML, string collectionPath, string siteName = "", string projectName = "", string workflowName = "", string clientName = "", bool childProject = false, bool mobileOutput = false, bool createTemplate = true, bool createModel = true, bool createSite = true, bool createBinary = true, bool createWrapper = true, bool renewInternalLinks = true, bool allowOverwrite = false, IhSiteBuilderLog siteLog = null ) { siteLog.Add("Replicate site started"); // Gather site creation/update parameters IhSiteBuilderInfo siteInfoNew = new IhSiteBuilderInfo(); string[] arrCollectionPath = collectionPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); siteInfoNew.CollectionName = arrCollectionPath.Last(); if (arrCollectionPath.Count() > 1) { siteInfoNew.CollectionPath = collectionPath; } else { siteInfoNew.CollectionPath = "/" + siteInfoNew.CollectionName; } siteLog.Add("New info collection name: " + siteInfoNew.CollectionName); siteLog.Add("New info collection path: " + siteInfoNew.CollectionPath); siteInfoNew.SiteRootName = siteName; siteInfoNew.ClientName = clientName; siteInfoNew.SiteRootParent = siteInfoNew.CollectionPath; siteInfoNew.SiteRootPath = siteInfoNew.CollectionPath + "/" + siteName; if (!string.IsNullOrWhiteSpace(projectName)) { siteInfoNew.ProjectName = projectName; if (childProject) { siteInfoNew.ProjectParent = siteInfoNew.SiteRootPath; siteInfoNew.ProjectPath = siteInfoNew.SiteRootPath + "/" + projectName; siteInfoNew.ProjectNested = true; } else { siteInfoNew.ProjectParent = siteInfoNew.CollectionPath; siteInfoNew.ProjectPath = siteInfoNew.CollectionPath + "/" + projectName; siteInfoNew.ProjectNested = false; } } else { siteInfoNew.TemplatePath = string.Format("/System/Templates/{0}/{1}", siteInfoNew.CollectionName, siteInfoNew.SiteRootName); siteInfoNew.ModelPath = string.Format("/System/Models/{0}/{1}", siteInfoNew.CollectionName, siteInfoNew.SiteRootName); } siteInfoNew.WorkflowName = workflowName; // Begin creation/update of site IhSiteBuilderModel siteModels = new IhSiteBuilderModel(); if (!string.IsNullOrWhiteSpace(siteXML)) { siteLog.Add("Site XML found and running"); IhSiteBuilderImportSiteRoot siteImport = new IhSiteBuilderImportSiteRoot(siteXML, siteInfoNew, siteModels, allowOverwrite, siteLog); siteImport.CreateSiteRoot(); if (!string.IsNullOrWhiteSpace(projectName)) siteImport.CreateProject(); if (createTemplate) { siteImport.CreateTemplate(); } if (createModel) { siteImport.CreateModel(); } if (createSite) { siteImport.CreateSite(); } if (createBinary) { siteImport.CreateBinaryFile(siteXML); } if (createWrapper) { siteImport.CreateBinaryWrapper(siteXML); } if (!string.IsNullOrWhiteSpace(projectName)) { siteImport.CreateLibrary(); #region *** IH Custom Code *** siteImport.CreateLibraryReferences(); #endregion } if (renewInternalLinks) { siteImport.RenewAllContentAsset(); } siteLog.Add("Import DONE"); //Util.Email("Import Script Finished", DateTime.Now.ToString(), "*****@*****.**"); } else siteLog.Add("Site XML Empty or not loaded correctly"); }
public IhSiteBuilderImportSiteRoot(string siteXML, IhSiteBuilderInfo newSiteInfo, IhSiteBuilderModel siteModels = null, bool allowOverwrite = false, IhSiteBuilderLog siteLog = null) { this.siteLog = siteLog; siteLog.Add("SiteBuilder Import class inizialized"); this.szSiteXML = siteXML; this.allowOverwrite = allowOverwrite; this.siteInfoNew = newSiteInfo; if (siteModels.Equals(null)) this.siteModels = new IhSiteBuilderModel(); else this.siteModels = siteModels; if (!string.IsNullOrWhiteSpace(siteInfoNew.ProjectName)) { if (siteInfoNew.ProjectNested) { siteInfoNew.Namespace = IhSiteBuilderHelper.ReformatName(siteInfoNew.SiteRootName) + "." + IhSiteBuilderHelper.ReformatName(siteInfoNew.ProjectName) + ".Library"; } else { siteInfoNew.Namespace = IhSiteBuilderHelper.ReformatName(siteInfoNew.ProjectName) + ".Library"; } } else { siteInfoNew.Namespace = "CrownPeak.CMSAPI.CustomLibrary"; } siteLog.Add("New Namespace: " + siteInfoNew.Namespace); PrepareSiteNames(); }