<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <appSettings>
    <add key="CcaIPAddress" value="localhost"/>
    <add key="ExternalCcaIPAddress" value="localhost"/>
    <add key="CcaPort" value="980"/>
    <add key="Timeout" value="55000"/>
    <add key="DefaultCcaWorkspace" value="7"/>
    <add key="DefaultCcaLocation" value="-1"/>
    <add key="AllowedDomains" value="*"/>
    <add key="ClientSettingsProvider.ServiceUri" value=""/>
    <add key="Company" value="MyForce"/>
  </appSettings>
  <system.web>
    <!-- disable shadow copies for dynamical loading of AskiaCore -->
    <hostingEnvironment shadowCopyBinAssemblies="false"/>
    <compilation>
      <assemblies>
        <remove assembly="AskiaCoreInternal32"/>
        <remove assembly="AskiaCoreInternal64"/>
      </assemblies>
    </compilation>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
      </providers>
    </roleManager>
  </system.web>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Critical, Error, Warning">
        <listeners>
          <add name="ServiceModelTraceListener">
            <filter type=""/>
          </add>
        </listeners>
      </source>
      <!--
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="ServiceModelMessageLoggingListener">
            <filter type=""/>
          </add>
        </listeners>
      </source>-->
    </sources>
    <sharedListeners>
      <add initializeData="c:\log\Tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, 
      Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type=""/>
      </add>
      <!--
      <add initializeData="c:\log\Messages.svclog"
      type="System.Diagnostics.XmlWriterTraceListener, System, 
      Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type=""/>
      </add>-->
    </sharedListeners>
    <trace autoflush="true"/>
  </system.diagnostics>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <serviceHostingEnvironment>
      <serviceActivations>
        <add relativeAddress="CcaAPI.Service.svc" service="CcaAPI.Service"/>
      </serviceActivations>
    </serviceHostingEnvironment>
    <extensions>
      <behaviorExtensions>
        <add name="crossOriginResourceSharingBehavior" type="CcaAPI.Helpers.EnableCrossOriginResourceSharingBehavior, CcaAPI"/>
      </behaviorExtensions>
    </extensions>
    <bindings>
      <basicHttpBinding>
        <binding name="TheBasicBindingConfig" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed">
          <readerQuotas maxArrayLength="2147483647"/>
        </binding>
      </basicHttpBinding>
      <wsDualHttpBinding>
        <binding name="TheDualBindingConfig" textEncoding="utf-8" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="2.00:00:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647"/>
          <reliableSession inactivityTimeout="2.00:00:00"/>
          <security mode="None"/>
        </binding>
      </wsDualHttpBinding>
      <wsHttpBinding>
        <binding name="TheBindingConfig" closeTimeout="00:01:05" openTimeout="00:01:05" sendTimeout="00:01:05" maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647"/>
          <security mode="None"/>
        </binding>
      </wsHttpBinding>
      <webHttpBinding>
        <binding name="WebjsonHttp" transferMode="Streamed" contentTypeMapper="CcaAPI.RawContentTypeMapper, CcaAPI,Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" crossDomainScriptAccessEnabled="true"/>
      </webHttpBinding>
      <netTcpBinding>
        <binding name="TheTcpBinding" sendTimeout="00:01:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
    <client/>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="CcaAPI.Service">
        <!-- DISABLED in debug only (IIS uses web.config), because it causes large delays on debug startup
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="TheBasicBindingConfig" name="Service.Basic" contract="CcaAPI.Interfaces.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="TheBasicBindingConfig" name="Objects.Basic" contract="CcaAPI.Interfaces.ICcaObjects">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="TheBasicBindingConfig" name="Reports.Basic" contract="CcaAPI.Interfaces.ICcaReports">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="TheBasicBindingConfig" name="Quota.Basic" contract="CcaAPI.Interfaces.ICcaQuota">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="TheBasicBindingConfig" name="AgentService.Basic" contract="CcaAPI.Interfaces.IAgentService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        -->
        <endpoint binding="wsDualHttpBinding" bindingConfiguration="TheDualBindingConfig" name="Service" contract="CcaAPI.Interfaces.IDuplexService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint binding="wsDualHttpBinding" bindingConfiguration="TheDualBindingConfig" name="Objects" contract="CcaAPI.Interfaces.IDuplexCcaObjects">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint binding="wsDualHttpBinding" bindingConfiguration="TheDualBindingConfig" name="Reports" contract="CcaAPI.Interfaces.IDuplexCcaReports">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint binding="wsDualHttpBinding" bindingConfiguration="TheDualBindingConfig" name="Quota" contract="CcaAPI.Interfaces.IDuplexCcaQuota">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint binding="wsDualHttpBinding" bindingConfiguration="TheDualBindingConfig" name="AgentService" contract="CcaAPI.Interfaces.IDuplexAgentService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" name="MetaData" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/CcaAPI/Service/"/>
            <add baseAddress="net.tcp://localhost:8001/Design_Time_Addresses/CcaAPI/Service/"/>
          </baseAddresses>
        </host>
        <endpoint behaviorConfiguration="" binding="netTcpBinding" bindingConfiguration="TheTcpBinding" name="Service.TCP" contract="CcaAPI.Interfaces.IDuplexService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint behaviorConfiguration="" binding="netTcpBinding" bindingConfiguration="TheTcpBinding" name="Objects.TCP" contract="CcaAPI.Interfaces.IDuplexCcaObjects">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint behaviorConfiguration="" binding="netTcpBinding" bindingConfiguration="TheTcpBinding" name="Reports.TCP" contract="CcaAPI.Interfaces.IDuplexCcaReports">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint behaviorConfiguration="" binding="netTcpBinding" bindingConfiguration="TheTcpBinding" name="Quota.TCP" contract="CcaAPI.Interfaces.IDuplexCcaQuota">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint behaviorConfiguration="" binding="netTcpBinding" bindingConfiguration="TheTcpBinding" name="AgentService.TCP" contract="CcaAPI.Interfaces.IDuplexAgentService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="JsonBehavior">
          <webHttp helpEnabled="true" automaticFormatSelectionEnabled="false"/>
          <crossOriginResourceSharingBehavior/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>        
        <behavior name="ServiceBehavior">
          <useRequestHeadersForMetadataAddress/>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>       
      </serviceBehaviors>
    </behaviors>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="2147483647" maxSizeOfMessageToLog="2147483647"/>
    </diagnostics>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
  </startup>
  <log4net>
    <root>
      <level value="ALL"/>
      <appender-ref ref="LogFileAppender"/>
    </root>
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="C:\MyForce\Logging\CcaAPI\"/>
      <param name="AppendToFile" value="true"/>
      <rollingStyle value="Date"/>
      <maxSizeRollBackups value="20"/>
      <staticLogFileName value="false"/>
      <datePattern value="yyyy-MM-dd'.log'"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%utcdate{HH:mm:ss.fff} [%thread] %-5level %message%newline"/>
      </layout>
    </appender>
  </log4net>
</configuration>
