/Default.aspx.cs
C# | 735 lines | 448 code | 107 blank | 180 comment | 27 complexity | 9268ee0b60d9760a25ff9781437d7d35 MD5 | raw file
- // --------------------------------------------------------------------------------------------------------------------
- // <copyright file="Default.aspx.cs" company="">
- //
- // </copyright>
- // <summary>
- // Defines the _Default type.
- // </summary>
- // --------------------------------------------------------------------------------------------------------------------
-
- using System;
- using System.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- using System.IO;
- using System.Text;
- using System.Web.UI;
-
- using Microsoft.ApplicationBlocks.Data;
-
- /// <summary>
- /// Default class
- /// </summary>
- public partial class Default : Page
- {
- #region Public Methods
-
- /// <summary>
- /// Get Templates Default Doc Type
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// Node ID
- /// </returns>
- public static string GetTemplatesDefaultDocType(string nodeid)
- {
- string rtnText = string.Empty;
- string strSql =
- "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsContentType.alias FROM cmsDocumentType INNER JOIN cmsContentType ON cmsDocumentType.contentTypeNodeId = cmsContentType.nodeId where isDefault=1 and templateNodeId="
- + nodeid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- while (dr.Read())
- {
- rtnText = ": Vega.USiteBuilder.TemplateBase<uSiteBuilderImport.Web.DocumentTypes." + dr["alias"] + ">";
- }
-
- dr.Close();
-
- return rtnText != string.Empty ? rtnText : ": Vega.USiteBuilder.TemplateBase";
-
- // return ": System.Web.UI.MasterPage";
- // return string.Empty;
- }
-
- /// <summary>
- /// The create child doc type.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <param name="alias">
- /// The alias.
- /// </param>
- /// <param name="path">
- /// The path.
- /// </param>
- public void CreateChildDocType(string nodeid, string alias, string path)
- {
- // string strSQL = "SELECT [pk],[nodeId],[alias],[icon],[thumbnail],[description],[masterContentType] FROM [cmsContentType] where masterContentType=" + nodeid + " order by Alias";
- string strSql =
- "SELECT cmsContentType.pk, cmsContentType.nodeId, cmsContentType.alias, cmsContentType.icon, cmsContentType.thumbnail, cmsContentType.description, "
- + "cmsContentType.masterContentType, umbracoNode.text " + "FROM cmsContentType INNER JOIN "
- + "umbracoNode ON cmsContentType.nodeId = umbracoNode.id " + "WHERE cmsContentType.masterContentType = "
- + nodeid + " ORDER BY alias";
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- while (dr.Read())
- {
- // Start file
- var sb = new StringBuilder();
-
- this.Response.Write("Create Doc Type for child " + dr["alias"] + " (" + dr["nodeid"] + ")<br/>");
-
- sb.AppendLine("using System;");
- sb.AppendLine("using System.Collections.Generic;");
- sb.AppendLine("using System.Linq;");
- sb.AppendLine("using System.Web;");
-
- sb.AppendLine("using Vega.USiteBuilder;");
-
- sb.AppendLine("namespace uSiteBuilderImport.Web.DocumentTypes");
- sb.AppendLine("{");
- sb.AppendLine();
- sb.Append(
- "[DocumentType(Name=\"" + dr["text"] + "\",IconUrl=\"" + dr["icon"] + "\""
- + this.GetAllowedTemplates(dr["nodeid"].ToString()));
- sb.Append(GetAllowedContentType(dr["nodeid"].ToString()));
- sb.Append(")]");
- sb.AppendLine();
- sb.AppendLine("public class " + dr["alias"] + " : uSiteBuilderImport.Web.DocumentTypes." + alias);
-
- sb.AppendLine("{");
-
- sb.AppendLine(this.CreateProperties(dr["nodeid"].ToString()));
-
- sb.AppendLine("}");
- sb.AppendLine("}");
-
- if (!Directory.Exists(this.Server.MapPath("DocTypes/")))
- {
- Directory.CreateDirectory(this.Server.MapPath("DocumentTypes/"));
- }
-
- using (var writer = new StreamWriter(path + dr["alias"] + ".cs"))
- {
- writer.Write(sb.ToString());
- }
-
- // Make recursive call
- this.CreateChildDocType(dr["nodeid"].ToString(), dr["alias"].ToString(), path);
- }
-
- dr.Close();
- }
-
- /// <summary>
- /// Create Child Master Pages
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <param name="parentAlias">
- /// The parent alias.
- /// </param>
- public void CreateChildMasterPages(string nodeid, string parentAlias)
- {
- string strSql = "SELECT pk, nodeId, master, alias, design FROM cmsTemplate WHERE master =" + nodeid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- while (dr.Read())
- {
- string alias = dr["alias"].ToString().Replace(" ", string.Empty);
-
- this.Response.Write("Creating Child MasterPage: " + alias + " (" + dr["nodeId"] + ")</br>");
-
- var sb = new StringBuilder();
-
- // Create Master Page
- sb.AppendLine(
- "<%@ Master Language=\"C#\" MasterPageFile=\"~/MasterPages/" + parentAlias
- + ".master\" AutoEventWireup=\"true\" CodeBehind=\"" + alias
- + ".master.cs\" Inherits=\"uSiteBuilderImport.Web.MasterPages." + alias + "\" %>");
-
- // Get Markup
- sb.AppendLine(GetMarkUp(dr["nodeid"].ToString()));
- using (var writer = new StreamWriter(this.Server.MapPath("MasterPages/" + alias + ".Master")))
- {
- writer.Write(sb.ToString());
- }
-
- sb.Length = 0;
-
- // Create Code behind file
- sb.AppendLine("using System;");
- sb.AppendLine("using System.Collections.Generic;");
- sb.AppendLine("using System.Linq;");
- sb.AppendLine("using System.Web;");
- sb.AppendLine("using System.Web.UI;");
- sb.AppendLine("using System.Web.UI.WebControls;");
- sb.AppendLine("namespace uSiteBuilderImport.Web.MasterPages");
- sb.AppendLine("{");
- sb.AppendLine("public partial class " + alias + GetTemplatesDefaultDocType(dr["nodeId"].ToString()));
- sb.AppendLine("{");
- sb.AppendLine(" protected void Page_Load(object sender, EventArgs e)");
- sb.AppendLine("{");
- sb.AppendLine("}");
- sb.AppendLine("}");
- sb.AppendLine("}");
- string path = this.Server.MapPath("MasterPages/");
-
- using (var writer = new StreamWriter(path + alias + ".Master.cs"))
- {
- writer.Write(sb.ToString());
- }
-
- this.CreateChildMasterPages(dr["nodeId"].ToString(), alias);
-
- // Response.Write(getTemplatesDefaultDocType(dr["nodeId"].ToString()));
- }
-
- dr.Close();
- }
-
- /// <summary>
- /// Create Master Pages
- /// </summary>
- public void CreateMasterPages()
- {
- const string StrSQL =
- "SELECT pk, nodeId, master, alias, design FROM cmsTemplate WHERE (master IS NULL) order by alias";
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, StrSQL);
-
- while (dr.Read())
- {
- // string alias = dr["alias"].ToString().Replace(" ", "");
- string alias = dr["alias"].ToString();
-
- this.Response.Write(alias + " (" + dr["nodeId"] + ")</br>");
-
- var sb = new StringBuilder();
-
- // Create Master Page
- sb.AppendLine(
- "<%@ Master Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"" + alias
- + ".master.cs\" Inherits=\"uSiteBuilderImport.Web.MasterPages." + dr["alias"] + "\" %>");
-
- // Get Markup
- sb.AppendLine(GetMarkUp(dr["nodeid"].ToString()));
-
- // Clean MarkUp
- if (!Directory.Exists(this.Server.MapPath("MasterPages/")))
- {
- Directory.CreateDirectory(this.Server.MapPath("MasterPages/"));
- }
-
- using (var writer = new StreamWriter(this.Server.MapPath("MasterPages/") + alias + ".Master"))
- {
- writer.Write(sb.ToString());
- }
-
- sb.Length = 0;
-
- // Create Code behind file
- sb.AppendLine("using System;");
- sb.AppendLine("using System.Collections.Generic;");
- sb.AppendLine("using System.Linq;");
- sb.AppendLine("using System.Web;");
- sb.AppendLine("using System.Web.UI;");
- sb.AppendLine("using System.Web.UI.WebControls;");
- sb.AppendLine("namespace uSiteBuilderImport.Web.MasterPages");
- sb.AppendLine("{");
- sb.AppendLine("public partial class " + alias + GetTemplatesDefaultDocType(dr["nodeId"].ToString()));
- sb.AppendLine("{");
- sb.AppendLine(" protected void Page_Load(object sender, EventArgs e)");
- sb.AppendLine("{");
- sb.AppendLine("}");
- sb.AppendLine("}");
- sb.AppendLine("}");
-
- using (var writer = new StreamWriter(this.Server.MapPath("MasterPages/" + alias + ".Master.cs")))
- {
- writer.Write(sb.ToString());
- }
-
- this.CreateChildMasterPages(dr["nodeId"].ToString(), alias);
- }
-
- dr.Close();
- }
-
- #endregion
-
- #region Methods
-
- /// <summary>
- /// Page Load event
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The event arguments
- /// </param>
- protected void Page_Load(object sender, EventArgs e)
- {
- // Clear and create Directories
- string path = this.Server.MapPath("MasterPages/");
-
- if (Directory.Exists(path))
- {
- Directory.Delete(path, true);
- }
-
- Directory.CreateDirectory(path);
-
- path = this.Server.MapPath("DocumentTypes");
-
- if (Directory.Exists(path))
- {
- Directory.Delete(path, true);
- }
-
- Directory.CreateDirectory(path);
-
- this.Response.Write("<br/>-------------------------------------------------------------<br/>");
- this.Response.Write("Creating MasterPages");
- this.Response.Write("<br/>-------------------------------------------------------------<br/><br/>");
-
- this.CreateMasterPages();
-
- this.Response.Write("<br/>-------------------------------------------------------------<br/>");
- this.Response.Write("Creating DocTypes");
- this.Response.Write("<br/>-------------------------------------------------------------<br/><br/>");
- this.CreateDocTypes();
-
- this.Response.Write("<br/>-------------------------------------------------------------<br/>");
- this.Response.Write("End");
- this.Response.Write("<br/>-------------------------------------------------------------<br/><br/>");
- }
-
- /// <summary>
- /// The get allowed content type.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The allowed content type.
- /// </returns>
- private static string GetAllowedContentType(string nodeid)
- {
- // string strSQL = "SELECT cmsContentTypeAllowedContentType.Id, cmsContentTypeAllowedContentType.AllowedId, umbracoNode.text FROM cmsContentTypeAllowedContentType INNER JOIN umbracoNode ON cmsContentTypeAllowedContentType.AllowedId = umbracoNode.id where cmsContentTypeAllowedContentType.id =" + nodeid;
- string strSql =
- "SELECT cmsContentTypeAllowedContentType.Id, cmsContentTypeAllowedContentType.AllowedId, cmsContentType.alias "
- + "FROM cmsContentTypeAllowedContentType INNER JOIN "
- +
- "cmsContentType ON cmsContentTypeAllowedContentType.AllowedId = cmsContentType.nodeId where cmsContentTypeAllowedContentType.id ="
- + nodeid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- var sb = new StringBuilder();
-
- while (dr.Read())
- {
- sb.Append("typeof(" + dr["alias"] + "),");
-
- // Response.Write("Here's an allowed type " + dr["text"].ToString() + "<br/>");
- }
-
- dr.Close();
-
- if (sb.ToString() != string.Empty)
- {
- return ",AllowedChildNodeTypes = new Type[] {" + sb.ToString().Remove(sb.Length - 1, 1) + "}";
- }
-
- return string.Empty;
- }
-
- /*
- /// <summary>
- /// The get allowed templates old code.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The allowed templates old code.
- /// </returns>
- private string GetAllowedTemplatesOldCode(string nodeid)
- {
- var strSql =
- "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsTemplate.alias "
- + "FROM cmsDocumentType INNER JOIN "
- + "cmsTemplate ON cmsDocumentType.templateNodeId = cmsTemplate.nodeId "
- + "WHERE (cmsDocumentType.IsDefault = 0) AND cmsDocumentType.contentTypeNodeId =" + nodeid;
-
- var dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- var sb = new StringBuilder();
-
- while (dr.Read())
- {
- sb.Append("\"" + dr["alias"] + "\",");
- }
-
- dr.Close();
-
- if (sb.ToString() != string.Empty)
- {
- return ", AllowedTemplates = new string[] {" + sb.ToString().Remove(sb.Length - 1, 1) + "}";
- }
- else
- {
- return string.Empty;
- }
- }
- */
-
- /// <summary>
- /// The get data type.
- /// </summary>
- /// <param name="dataTypeId">
- /// The data type id.
- /// </param>
- /// <returns>
- /// The data type.
- /// </returns>
- private static string GetDataType(int dataTypeId)
- {
- var dt = (Enums.UmbracoPropertyType)dataTypeId;
-
- if (dt.ToString() != dataTypeId.ToString())
- {
- return "UmbracoPropertyType." + dt;
- }
-
- // Custom DataType
- string strSql = "SELECT [text] FROM [umbracoNode] where id=" + dataTypeId;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- string rtnText = string.Empty;
-
- while (dr.Read())
- {
- rtnText = dr["text"].ToString();
- }
-
- dr.Close();
-
- return "UmbracoPropertyType.Other, OtherTypeName=\"" + rtnText + "\"";
- }
-
- /// <summary>
- /// The get default template doc type.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The default template doc type.
- /// </returns>
- private static string GetDefaultTemplateDocType(string nodeid)
- {
- // At the moment this is switched off as default Doc Types is set via the allowed templates.
-
- // string strSQL = "SELECT cmsContentType.nodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsContentType.alias " +
- // "FROM cmsDocumentType INNER JOIN " +
- // "cmsContentType ON cmsDocumentType.contentTypeNodeId = cmsContentType.nodeId " +
- // "WHERE (cmsDocumentType.IsDefault = 1) and nodeid=" + nodeid;
-
- // string strSQL = "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsTemplate.alias " +
- // "FROM cmsDocumentType INNER JOIN " +
- // "cmsTemplate ON cmsDocumentType.templateNodeId = cmsTemplate.nodeId " +
- // "WHERE (cmsDocumentType.IsDefault = 1) and contentTypeNodeID=" + nodeid;
- string strSql =
- "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsContentType.alias "
- + "FROM cmsDocumentType INNER JOIN "
- + "cmsContentType ON cmsDocumentType.contentTypeNodeId = cmsContentType.nodeId "
- + "WHERE (cmsDocumentType.IsDefault = 1) and contentTypeNodeId=" + nodeid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- var sb = new StringBuilder();
-
- while (dr.Read())
- {
- sb.Append(dr["alias"].ToString());
- }
-
- dr.Close();
-
- return string.Empty;
- }
-
- /// <summary>
- /// The get mark up.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The get mark up.
- /// </returns>
- private static string GetMarkUp(string nodeid)
- {
- string rtnText = string.Empty;
- string strSql = "SELECT pk, nodeId, master, alias, design FROM cmsTemplate where nodeid=" + nodeid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- while (dr.Read())
- {
- rtnText = dr["design"].ToString();
- }
-
- dr.Close();
-
- int startPos = rtnText.IndexOf(">");
-
- return rtnText.Substring(startPos + 1);
- }
-
- /// <summary>
- /// The get tab.
- /// </summary>
- /// <param name="tabid">
- /// The tabid.
- /// </param>
- /// <returns>
- /// The tab.
- /// </returns>
- private static string GetTab(string tabid)
- {
- if (tabid != string.Empty)
- {
- string strSql = "SELECT [id],[text],[sortorder] FROM [cmsTab] where id=" + tabid;
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- string tab = string.Empty;
-
- while (dr.Read())
- {
- tab = dr["text"].ToString();
- }
-
- dr.Close();
-
- if (tab != string.Empty)
- {
- return ", Tab=\"" + tab + "\"";
- }
-
- return string.Empty;
- }
-
- return string.Empty;
- }
-
- /// <summary>
- /// The get validation.
- /// </summary>
- /// <param name="isMandatory">
- /// The is mandatory.
- /// </param>
- /// <param name="rgx">
- /// The rgx.
- /// </param>
- /// <returns>
- /// The validation.
- /// </returns>
- private static string GetValidation(string isMandatory, string rgx)
- {
- var sb = new StringBuilder();
-
- sb.Append(isMandatory == "True" ? ",Mandatory=true" : ",Mandatory=false");
-
- if (rgx != string.Empty)
- {
- sb.Append(",ValidationRegExp=\"" + rgx.Replace("\\", "\\\\") + "\"");
- }
-
- return sb.ToString();
- }
-
- /// <summary>
- /// The create doc types.
- /// </summary>
- private void CreateDocTypes()
- {
- string path = this.Server.MapPath("DocumentTypes");
-
- path = path + "\\";
-
- const string StrSql =
- "SELECT cmsContentType.pk, cmsContentType.nodeId, cmsContentType.alias, cmsContentType.icon, cmsContentType.thumbnail, cmsContentType.description, "
- + "cmsContentType.masterContentType, umbracoNode.text FROM cmsContentType INNER JOIN "
- + "umbracoNode ON cmsContentType.nodeId = umbracoNode.id "
- + "WHERE (cmsContentType.masterContentType = 0) " + "ORDER BY cmsContentType.alias";
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, StrSql);
-
- while (dr.Read())
- {
- var sb = new StringBuilder();
- this.Response.Write("Create Doc Type for " + dr["text"] + " (" + dr["nodeid"] + ")<br/>");
-
- sb.AppendLine("using System;");
- sb.AppendLine("using System.Collections.Generic;");
- sb.AppendLine("using System.Linq;");
- sb.AppendLine("using System.Web;");
-
- sb.AppendLine("using Vega.USiteBuilder;");
-
- sb.AppendLine("namespace uSiteBuilderImport.Web.DocumentTypes");
- sb.AppendLine("{");
-
- // AllowedTemplates = new string[] { "Property" }
- sb.Append(
- "[DocumentType(Name=\"" + dr["text"] + "\",IconUrl=\"" + dr["icon"] + "\""
- + this.GetAllowedTemplates(dr["nodeid"].ToString()));
- sb.Append(GetAllowedContentType(dr["nodeid"].ToString()));
-
- sb.AppendLine( ")]");
- sb.AppendLine("public class " + dr["alias"] + " : Vega.USiteBuilder.DocumentTypeBase");
- sb.AppendLine("{");
-
- sb.AppendLine(this.CreateProperties(dr["nodeid"].ToString()));
-
- // Response.Write("Check if any child docs types of " + dr["nodeid"] + "<br/>");
- this.CreateChildDocType(dr["nodeid"].ToString(), dr["alias"].ToString(), path);
-
- sb.AppendLine("}");
- sb.AppendLine("}");
-
- using (var writer = new StreamWriter(path + dr["alias"] + ".cs"))
- {
- writer.Write(sb.ToString());
- }
- }
-
- dr.Close();
- }
-
- /// <summary>
- /// The create properties.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The create properties.
- /// </returns>
- private string CreateProperties(string nodeid)
- {
- string strSql =
- "SELECT [id],[dataTypeId],[contentTypeId],[tabId],[Alias],[Name],[helpText],[sortOrder],[mandatory],[validationRegExp],[Description] FROM [cmsPropertyType] where contentTypeId="
- + nodeid + " order by sortOrder";
-
- var sb = new StringBuilder();
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- while (dr.Read())
- {
- sb.AppendLine(
- "[DocumentTypeProperty(" + GetDataType(Convert.ToInt32(dr["dataTypeId"])) + ",Name=\"" + dr["Name"]
- + "\",Description=\""
- + dr["Description"].ToString().Replace(Environment.NewLine, string.Empty).Replace("\"", "\\\"") + "\""
- + GetTab(dr["tabId"].ToString())
- + GetValidation(dr["mandatory"].ToString(), dr["validationRegExp"].ToString()) + ")]");
-
- sb.AppendLine("public string " + dr["alias"] + " { get; set; }");
-
- // Response.Write("Alias: " + dr["alias"] + " Name: " + dr["name"] + " Description: " + dr["Description"] + " Tab: " + getTab(dr["tabId"].ToString()) + " DataType: " + getDataType(Convert.ToInt32(dr["dataTypeId"])) + "<br/>");
- }
-
- dr.Close();
-
- return sb.ToString();
- }
-
- /// <summary>
- /// The get allowed templates.
- /// </summary>
- /// <param name="nodeid">
- /// The nodeid.
- /// </param>
- /// <returns>
- /// The allowed templates.
- /// </returns>
- private string GetAllowedTemplates(string nodeid)
- {
- // This code is correct from when we were only getting non default Templates, however now we want them all and we'll deal with the default one later
- // string strSQL = "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsTemplate.alias " +
- // "FROM cmsDocumentType INNER JOIN " +
- // "cmsTemplate ON cmsDocumentType.templateNodeId = cmsTemplate.nodeId " +
- // "WHERE (cmsDocumentType.IsDefault = 0) AND cmsDocumentType.contentTypeNodeId =" + nodeid;
- string strSql =
- "SELECT cmsDocumentType.contentTypeNodeId, cmsDocumentType.templateNodeId, cmsDocumentType.IsDefault, cmsTemplate.alias "
- + "FROM cmsDocumentType INNER JOIN "
- + "cmsTemplate ON cmsDocumentType.templateNodeId = cmsTemplate.nodeId "
- + "WHERE cmsDocumentType.contentTypeNodeId =" + nodeid + " order by isDefault desc";
-
- SqlDataReader dr = SqlHelper.ExecuteReader(
- ConfigurationManager.AppSettings["ImportDB"], CommandType.Text, strSql);
-
- var sb = new StringBuilder();
-
- // int x = 0;
- while (dr.Read())
- {
- // x++;
- // if (x == 1)
- // {
- // //Check if this is default if so we mark it as such in the string and deal with it later
- // if (dr["isDefault"].ToString() == "True")
- // { sb.Append("\"xxxxxxxxxx" + dr["templateNodeId3"].ToString() + "\","); }
-
- // else { sb.Append("\"" + dr["alias"].ToString() + "\","); }
- // }
- // else
- // {
- sb.Append("\"" + dr["alias"] + "\",");
-
- // }
- }
-
- dr.Close();
-
- if (sb.ToString() != string.Empty)
- {
- // If there are more than one templates we have to specify default template
- return ", AllowedTemplates = new string[] {" + sb.ToString().Remove(sb.Length - 1, 1) + "}"
- + GetDefaultTemplateDocType(nodeid);
-
- // return string.Empty;
- }
-
- return string.Empty;
- }
-
- #endregion
- }