예제 #1
0
        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();
        }
예제 #2
0
        /// <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");
        }
예제 #3
0
        /// <summary>
        /// Get source data from XML
        /// </summary>
        private void PrepareSiteNames()
        {
            siteLog.Add("Start getting source site information");
            siteInfoOld = new IhSiteBuilderInfo();
            foreach (XmlNode nodeInfo in Util.LoadXml(szSiteXML, "site_info"))
            {
                foreach (XmlNode nodeSite in nodeInfo.XmlNodes)
                {
                    switch (nodeSite.Name)
                    {
                        //case "site_name":
                        //    siteLog.Add("Site root name: " + nodeSite.Attributes["original_name"]);
                        //    oldSiteInfo.SiteRootName = nodeSite.Attributes["original_name"];
                        //    break;
                        case "site_root":
                            siteLog.Add("SiteRoot name: " + nodeSite.Attributes["name"]);
                            siteLog.Add("SiteRoot path: " + nodeSite.Attributes["path"]);
                            siteLog.Add("SiteRoot parent: " + nodeSite.Attributes["parent"]);

                            siteInfoOld.SiteRootName = nodeSite.Attributes["name"];
                            siteInfoOld.SiteRootPath = nodeSite.Attributes["path"];
                            siteInfoOld.SiteRootParent = nodeSite.Attributes["parent"];
                            break;
                        case "site_model":
                            siteLog.Add("Model root name: " + nodeSite.Attributes["name"]);
                            siteLog.Add("Model root path: " + nodeSite.Attributes["path"]);

                            siteInfoOld.ModelName = nodeSite.Attributes["name"];
                            siteInfoOld.ModelPath = nodeSite.Attributes["path"];
                            break;
                        case "site_template":
                            siteLog.Add("Template root name: " + nodeSite.Attributes["name"]);
                            siteLog.Add("Template root path: " + nodeSite.Attributes["path"]);

                            siteInfoOld.TemplateName = nodeSite.Attributes["name"];
                            siteInfoOld.TemplatePath = nodeSite.Attributes["path"];
                            break;
                        //case "site_collection_name":
                        //    siteLog.Add("Collection name: " + nodeSite.Attributes["original_name"]);
                        //    siteInfoOld.CollectionPath = "/" + nodeSite.Attributes["original_name"];
                        //    siteInfoOld.CollectionName = nodeSite.Attributes["original_name"];
                        //    break;
                        case "site_nav_wrap":
                            siteLog.Add("NavWrap Path: " + nodeSite.Attributes["path"]);

                            siteInfoOld.NavWrapPath = nodeSite.Attributes["path"];
                            break;
                        case "site_project":
                            siteLog.Add("Project name: " + nodeSite.Attributes["name"]);
                            siteLog.Add("Project path: " + nodeSite.Attributes["path"]);
                            siteLog.Add("Project parent: " + nodeSite.Attributes["parent"]);
                            siteInfoOld.ProjectName = nodeSite.Attributes["name"];
                            siteInfoOld.ProjectPath = nodeSite.Attributes["path"];
                            siteInfoOld.ProjectParent = nodeSite.Attributes["parent"];
                            break;
                        case "site_library":
                            siteLog.Add("Library path: " + nodeSite.Attributes["path"]);

                            siteInfoOld.LibraryPath = nodeSite.Attributes["path"];
                            break;
                        case "site_namespace":
                            siteLog.Add("Namespace: " + nodeSite.Attributes["name"]);

                            siteInfoOld.Namespace = nodeSite.Attributes["name"];
                            break;
                        case "site_client_name":
                            siteInfoOld.ClientName = nodeSite.XmlValue;
                            break;
                    }
                }
                break;
            }
            siteLog.Add("End getting source site info");
        }