<%	string rootNamespaceToUse = _executingGenerator.RootNamespaceToUse;
	Project currentProject = _executingGenerator.ProjectDefinition;
	string[] rolesList = SDE_GeneralUtils.GetSecurityRoleNames(_executingGenerator);
	bool securityEnabled = SDE_GeneralUtils.SecurityEntitiesLoaded(_executingGenerator);
	
	string rolCatalog = string.Empty;
	// Get Security entities catalog
	if (securityEnabled)
	{
		EntityDefinition rolEntity = _executingGenerator.Entities.First(e => e.Name == "BaseProfile");
		EntityMapping entityMapping = currentProject.GetGroupableModelElementMapping(rolEntity, _executingGenerator.DriverID) as EntityMapping;
		rolCatalog = entityMapping.MappedTarget.ContainingSchema.ParentCatalog.CatalogName;
	}
%><?xml version="1.0"?>
<configuration>
	<!--
		add catalog/schema name overwrite config sections HERE. See	  the generated code / Application configuration through config files for details.
		Also be sure you add the proper elements with the actual name overwriting data.
		An example (for sqlserver) is given below.

		NOTE: the example below is for .NET 2.0. Be aware that if you're	  .NET 4, you've to change the 2.0.0.0 to 4.0.0.0 instead.
		-->
	<!-- START EXAMPLE -->
	<!--
	<configSections>
		<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
	</configSections>
	<sqlServerCatalogNameOverwrites>
		<add key="SecurityDB" value="New_SecurityDB" />
	</sqlServerCatalogNameOverwrites>
	-->
<%	if (securityEnabled)
{%>  <configSections>
	<section name="Genera.Manager" type="Genera.Manager.SupportClasses.GeneraManagerConfiguration, Genera.Manager.GeneraProvider" />
  </configSections>
  <!-- TODO xmlns="http://www.ctt.org/schemas/Genera.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
    <!-- CHANGE FOR DEBUGGING supportedAuthenticationTypes="Anonymous" -->
    <!-- TESORO 
	validateCertificateClassQualifiedName="Utiles_Tesoro_2010.Certificados.Certificado, Utiles_Tesoro_2010"
	-->
  <Genera.Manager
	applicationName="<%=_executingGenerator.ProjectDefinition.ProjectName%>"
	baseProfileClassQualifiedName="<%=rootNamespaceToUse%>.EntityClasses.BaseProfileEntity, <%=rootNamespaceToUse%>"
	defaultLanguageCode="es"
	supportedAuthenticationTypes="ClientCertificate,Windows"
  />
<%}
%>	<appSettings>
		<!-- SQL Server 2000
		<add key="SqlServerDQECompatibilityLevel" value="1" />
		-->
		<!-- SQL Server 2005/2008/2008 R2 -->
		<add key="SqlServerDQECompatibilityLevel" value="2" />
		<add key="SessionValidationKey" value="<%=System.Guid.NewGuid().ToString().ToUpper()%>" />
	</appSettings>
	<!-- END EXAMPLE -->

	<connectionStrings>
		<!-- please adjust the connection string embedded in the element below to target the proper catalog / server	  the proper user / password combination -->
<%	if (securityEnabled)
{%>	  <add name="ConnectionString.Genera.Manager" connectionString="<%=currentProject.CreateConnectionStringForDatabase(_executingGenerator.DriverID)%>" />
<%}
%>		<add name="<%=currentProject.CreateConnectionStringKeyNameForDatabase(_executingGenerator.DriverID)%>" connectionString="<%=currentProject.CreateConnectionStringForDatabase(_executingGenerator.DriverID)%>" />
	</connectionStrings>

	<system.web>
		<sessionState timeout="20" cookieless="UseCookies" />
		<globalization uiCulture="auto" culture="auto" enableClientBasedCulture="true"/>

		<!--
			Set compilation debug="true" to insert debugging
			symbols into the compiled page. Because this
			affects performance, set this value to true only
			during development.
		-->
		<compilation debug="true">
			<assemblies>
		        <!--<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>-->
			</assemblies>
		</compilation>
		<!--
			The <authentication> section enables configuration
			of the security authentication mode used by
			ASP.NET to identify an incoming user.
		-->
		<authentication mode="Forms"/>
		<!--
			The <customErrors> section enables configuration
			of what to do if/when an unhandled error occurs
			during the execution of a request. Specifically,
			it enables developers to configure html error pages
			to be displayed in place of a error stack trace.

		<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
			<error statusCode="403" redirect="NoAccess.htm" />
			<error statusCode="404" redirect="FileNotFound.htm" />
		</customErrors>
		-->

<%	if (securityEnabled)
	{%> <!-- SECURITY ENTITIES LOADED -->
		<siteMap enabled="true" defaultProvider="CustomSiteMapProvider">
			<providers>
				<add name="CustomSiteMapProvider" type="Genera.Manager.Providers.CustomSiteMapProvider"
				 description="Custom XmlSiteMapProvider to hide nodes based on rol"
				 siteMapFile="Web.sitemap"
				 securityTrimmingEnabled="<%=(securityEnabled)? "true" : "false"%>" />
			</providers>
		</siteMap>
<%	} else { %> <!-- NO SECURITY ENTITIES LOADED -->
		<siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
			<providers>
				<add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider "
				 description="Default SiteMap provider."
				 siteMapFile="Web.sitemap"
				 securityTrimmingEnabled="false" />
			</providers>
		</siteMap>
<%  } // END IF SECURITY ENTITIES LOADED %>
		<!--
		<authorization>
<%		if (rolesList.Any())
		{
			foreach (string currentRol in rolesList)
			{
%>				<allow roles="<%=currentRol%>" />
<%			}
%>			<deny users="*"/>
<%		}
		else
		{
%>			<allow users="*" />
<%		}
%>		</authorization>
	   -->

		<pages theme="Tesoro">
			<controls>
				<add assembly="<%=rootNamespaceToUse%>_GUI" namespace="GUI.Controls" tagPrefix="gui" />
				<add assembly="SD.LLBLGen.Pro.ORMSupportClasses.Web" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagPrefix="llblgenpro"/>
				<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
								namespace="Microsoft.Reporting.WebForms" tagPrefix="rsweb" />
			</controls>
			<namespaces>
				<add namespace="<%=rootNamespaceToUse%>" />
			</namespaces>
		</pages>

		<httpHandlers>
	  		<add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
		</httpHandlers>
		<httpModules>
<% if (securityEnabled)
{%>		  <add name="ProfileModule" type="Genera.Manager.Modules.ProfileModule, Genera.Manager.GeneraProvider"/>
<%}
%>		</httpModules>
	</system.web>

	<system.webServer> <!-- IIS 7.0 -->
			<validation validateIntegratedModeConfiguration="false" />
		<handlers>
		<add
				name="ReportViewerWebControl" preCondition="integratedMode"
				path="Reserved.ReportViewerWebControl.axd" verb="*"
				type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
		/>
		</handlers>
		<modules>
<% if (securityEnabled)
{%>		  <add name="ProfileModule" type="Genera.Manager.Modules.ProfileModule, Genera.Manager.GeneraProvider"/>
<%}
%>		</modules>
	</system.webServer>

	<!-- Trace switches. Only uncomment if you use them. Otherwise, comment the switches out to avoid performance hits.
	<system.diagnostics>
		<switches>
			<add name="SqlServerDQE" value="0" />
			<add name="AccessDQE" value="0" />
			<add name="OracleDQE" value="0" />
			<add name="FirebirdDQE" value="0" />
			<add name="MySqlDQE" value="0" />
			<add name="DB2DQE" value="0" />
			<add name="PostgreSqlDQE" value="0" />
			<add name="ORMGeneral" value="0" />
			<add name="ORMStateManagement" value="0" />
			<add name="ORMPersistenceExecution" value="0" />
		</switches>
	</system.diagnostics>
	-->

</configuration>
