Skip to content

UserGuide_Leaders

nishi_74322014 edited this page Nov 3, 2026 · 1 revision

Open Touryo UserGuide (Leaders Edition)

This is a English page.
Click here for Japanese version of this file.

Updated in July 2026

Introduction

Target audience

  • SEs and developers who develop applications with Open Touryo

Overview

This document summarizes the points that the "development leader" should know. The "development leader" is a person who understands the processing method of the target project and takes the task of implementing common processing in the development infrastructure (base class 2).

Trademarks

Company names and product names in this document are trademarks or registered trademarks of their respective companies.

Legend in the figures:

  • Red frame: code blocks that must be implemented
  • Red frame (dashed): code blocks that require attention when implementing
  • Blue text: code blocks that can be implemented freely

Table of contents

1. Configuration files and external files

2. Carrying over common information

3. B layer framework

4. D layer framework

5. P layer framework

6. Others

7. Adding controls (events) supported by P layer event processing

1. Configuration files and external files

This chapter describes the settings of various configuration files and external files.

For the list of configuration files and external files, see chapter 3.2 of the "Common edition": "Checking external files". For information on the config parameters used by the framework (list, default values, required / optional, ranges, etc.), see "1b_config_parameter_list.xls".

1.1 web.config file

This section describes the settings of web.config. The web.config file defines the operation settings of ASP.NET. An example of the settings of the web.config file is shown below.

<?xml version="1.0" encoding="utf-8"?>
<!--
    For more information on how to configure your ASP.NET application,
    visit https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
  <!-- Ajax settings (be careful about versions, etc.) -->
  <!-- appSettings settings -->
  <appSettings file="app.config" />
  <!-- connectionStrings settings -->
  <connectionStrings>
    <!-- For SQL Server / SQL Client -->
    <add name="ConnectionString_SQL" connectionString="Data Source=localhost;Initial Catalog=Northwind;User ID=sa;Password=seigi@123;Encrypt=false;" />
    <!-- For Multi-DB / OLEDB.NET -->
    <add name="ConnectionString_OLE" connectionString="Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
    <!-- For Multi-DB / ODCB.NET -->
    <add name="ConnectionString_ODBC" connectionString="Dsn=odbc_test1" />
    <!-- For Oracle / ODP.NET -->
    <add name="ConnectionString_ODP" connectionString="User Id=SCOTT;Password=tiger;Data Source=localhost/XE;" />
    <!-- For MySQL / MySQL Connector/NET -->
    <add name="ConnectionString_MCN" connectionString="Server=localhost;Database=test;User Id=root;Password=seigi@123;" />
  </connectionStrings>
  <!-- ASP.NET parameters -->
  <!--
    For a description of web.config changes, see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.8" />
      </system.Web>
  -->
  <system.web>
    <!-- Change to debug="false" at release. -->
    <compilation debug="true" targetFramework="4.8" />
    <!--
            Globalization
            globalization element
            http://msdn2.microsoft.com/en-us/library/hy4kkhe0.aspx
            http://msdn2.microsoft.com/en-us/library/hy4kkhe0(VS.80).aspx
            CultureInfo class
            http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
            http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo(VS.80).aspx
            Difference between CultureInfo("ja") and CultureInfo("ja-JP")
            http://blogs.wankuma.com/ogiogi/archive/2007/12/10/112403.aspx
        -->
    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" responseHeaderEncoding="utf-8" culture="ja-JP" uiCulture="ja-JP" />
    <!--
            Session settings
            Consider the parameters of this setting separately.
            Attribute    : Purpose
            timeout      : Sets the time (in minutes) allowed between requests before the session state provider terminates the session.
            cookieless   : Sets whether to embed the session ID in the URL (true) or store it in a cookie (false).
            mode         : Sets the current session state mode.
      
            For details, see the URLs below.
            http://msdn2.microsoft.com/en-us/library/h6bb9cz9.aspx
            http://msdn2.microsoft.com/en-us/library/h6bb9cz9(VS.80).aspx
        -->
    <!-- In-process -->
    <!--sessionState timeout="20" cookieless="false" mode="InProc"></sessionState-->
    <!--
            State server (when using it, start the ASP.NET State Service from the administrative tool "Services".)
            If the state server is selected in the development phase, the production environment can support any mode.
        -->
    <sessionState timeout="20" cookieless="false" mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" />
    <!--
            SQL server (when using it, run the following scripts)
            C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
            ・InstallSqlState.sql (UninstallSqlState.sql)
            ・InstallPersistSqlState.sql (UninstallPersistSqlState.sql)
            
            [HOWTO]: How to configure persistent SQL Server session state management in ASP.NET
            http://support.microsoft.com/default.aspx?kbid=311209
            [HOWTO]: How to configure ASP.NET session state management with SQL Server
            http://support.microsoft.com/kb/317604/ja
            
            ↓Use the following tool to build the environment.
            
            ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe)
            http://msdn.microsoft.com/en-us/library/ms229862%28VS.80%29.aspx
            
            ※ The Express Edition cannot be used because, since SQL Server 2005, it does not include the SQL Server Agent.
        -->
    <!--sessionState timeout="20" cookieless="false" mode="SQLServer" 
            sqlConnectionString="Data Source=seigi-cmn-pc4;User ID=sa;Password=sa;"/-->
    <!--
            Oracle server (when using it, run the following scripts)           
            C:\app\Administrator\product\11.1.0\client_1\ASP.NET\SQL
            ・InstallOracleSessionState.sql(UninstallOracleSessionState.sql)
            ・InstallOracleSessionState92.sql(UninstallOracleSessionState92.sql)
            
            Oracle Providers for ASP.NET Developer's Guide > Installing Oracle Providers for ASP.NET
            http://otndnld.oracle.co.jp/document/products/oracle11g/111/windows/E06106-01/IntroInstallation.htm
            Oracle Providers for ASP.NET Developer's Guide > OracleSessionStateStore class
            http://otndnld.oracle.co.jp/document/products/oracle11g/111/windows/E06106-01/OracleSessionStateStoreClass.htm
        -->
    <!--sessionState timeout="20" cookieless="false" mode="Custom" customProvider="MyOracleSessionStateStore">
            <providers>
                <add name="MyOracleSessionStateStore"
                     type="Oracle.Web.SessionState.OracleSessionStateStore, 
                           Oracle.Web, Version=2.111.6.20, Culture=neutral, 
                     PublicKeyToken=89b483f429c47342"
                     connectionStringName="ConnectionString_ODP"/>
            </providers>
        </sessionState-->
    <!--
            Authentication settings 
            
            This section configures the authentication policy of the application.
            The available modes are "Windows", "Forms", "Passport" and "None".
            
            For details, see the URLs below.
            http://msdn2.microsoft.com/en-us/library/532aee0e.aspx
            http://msdn2.microsoft.com/en-us/library/532aee0e(VS.80).aspx
        -->
    <!-- Windows authentication -->
    <!--authentication mode="Windows"/-->
    <!-- Forms authentication -->
    <authentication mode="Forms">
      <!--
                Consider the parameters of this setting separately.
                Attribute                 : Purpose
                name                      : Used as the name of the cookie that stores the authentication ticket.
                loginUrl                  : URL of the login form
                defaultUrl                : Defines the default URL used for redirection after authentication.
                timeout                   : Validity period of the ticket (unit: minutes).
                protection                : Specifies whether the cookie is encrypted and validated (recommended value: "All")
                path                      : Path of the cookie (default: "/").
                domain                    : Specifies the optional domain to set on the forms authentication cookie.
                requireSSL                : Specifies whether an SSL connection is required to send the authentication cookie (default: "false").
                slidingExpiration         : Specifies whether sliding expiration is enabled (default and recommended: "true").
                enableCrossAppRedirects   : Enables forms authentication across applications.
                cookieless                : Defines whether cookies are used and how cookies behave. 
                
                For details, see the URLs below.
                http://msdn2.microsoft.com/en-us/library/1d3t3c61.aspx
                http://msdn2.microsoft.com/en-us/library/1d3t3c61(VS.80).aspx
            -->
      <forms name="formauth" loginUrl="Aspx/Start/login.aspx" defaultUrl="Aspx/Start/menu.aspx" timeout="10" protection="All" path="/" domain="" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile" />
    </authentication>
    <!--
            Authorization settings
            This section configures the authorization policy of the application.
            With this setting, access to application resources can be allowed
            or denied by user or role.
            Wildcards: "*" means everyone, "?" means anonymous (unauthenticated) users.
            
            For details, see the URLs below.
            http://msdn2.microsoft.com/en-us/library/8d82143t.aspx
            http://msdn2.microsoft.com/en-us/library/8d82143t(VS.80).aspx
        -->
    <authorization>
      <!-- Allow all users -->
      <!--<allow users="*"/>-->
      <!-- Deny anonymous users -->
      <deny users="?" />
      <!--
            <allow  users="[comma-separated list of users]"
                roles="[comma-separated list of roles]"/>
            <deny  users="[comma-separated list of users]"
                roles="[comma-separated list of roles]"/>-->
    </authorization>
    <!-- Enable the following for impersonation -->
    <!-- identity impersonate="true" userName="xxxx" password="xxxx" / -->
    <!--
            The <customErrors> section enables configuration of what to do if an unhandled error occurs during the execution of a request.
            Specifically, it allows developers to configure HTML error pages to be displayed instead of a stack trace error.
            ※ All exceptions that occur in the application are handled by Application_Error.
            ※ To set the HTML corresponding to HTTP status codes, configure it here.
            
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            
            For details, see the URLs below.
            customErrors tag
            http://msdn2.microsoft.com/en-us/library/h0hfz6fc.aspx
            http://msdn2.microsoft.com/en-us/library/h0hfz6fc(VS.80).aspx
            error tag
            http://msdn2.microsoft.com/en-us/library/s2f4e3e7.aspx
            http://msdn2.microsoft.com/en-us/library/s2f4e3e7(VS.80).aspx
        -->
    <!-- 
            Configure the ASP.NET processing method and runtime settings.
            ・maxRequestLength: Maximum size of POST data (default is 4,096 KB (4 MB))
            ・executionTimeout: Sets the execution timeout of POST processing (default is 90 seconds)
            For details, see the URLs below.
            http://msdn2.microsoft.com/en-us/library/e1f13641.aspx
            http://msdn2.microsoft.com/en-us/library/e1f13641(VS.80).aspx
        -->
    <httpRuntime targetFramework="4.8" maxRequestLength="4096" executionTimeout="90" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
  </system.web>
  <!-- Exclude files from Forms authentication -->
  <!--Folder bundling JS/CSS-->
  <location path="bundles">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
  <!--External login callback-->
  <location path="Aspx/OAuth2">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
  <system.serviceModel>
    <services>
      <service name="WebForms_Sample.JSONService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="MyBehavior" contract="WebForms_Sample.IJSONService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="MyBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="WSHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <!--address is defined in the configuration file of the communication control component.-->
      <!--basicHttpBinding-->
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="Transmission.IWCFHTTPSvcForFx" name="Transmission.WCFHTTPSvcForFx" />
      <!--wsHttpBinding-->
      <!--endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding" contract="Transmission.IWCFHTTPSvcForFx" name="Transmission.WCFHTTPSvcForFx" /-->
      <!--netTcpBinding-->
      <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="Touryo.Infrastructure.Framework.Transmission.IWCFTCPSvcForFx" name="Touryo.Infrastructure.Business.Transmission.WCFTCPSvcForFx" />
    </client>
  </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>...</dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Figures 1.1-1 to 5 web.config

1.1.1 appSettings section

In the appSettings section of web.config, write a link to the app.config file [1]. Details of the settings in the app.config file are described in the next section.

  <!-- appSettings settings -->
  <appSettings file="app.config" />

Figure 1.1.1 appSettings section

1.1.2 connectionStrings section

Connection strings to the DB can be set in the connectionStrings section of web.config.

  <!-- connectionStrings settings -->
  <connectionStrings>
    <!-- For SQL Server / SQL Client -->
    <add name="ConnectionString_SQL" connectionString="Data Source=localhost;Initial Catalog=Northwind;User ID=sa;Password=seigi@123;Encrypt=false;" />
    <!-- For Multi-DB / OLEDB.NET -->
    <add name="ConnectionString_OLE" connectionString="Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
    <!-- For Multi-DB / ODCB.NET -->
    <add name="ConnectionString_ODBC" connectionString="Dsn=odbc_test1" />
    <!-- For Oracle / ODP.NET -->
    <add name="ConnectionString_ODP" connectionString="User Id=SCOTT;Password=tiger;Data Source=localhost/XE;" />
    <!-- For MySQL / MySQL Connector/NET -->
    <add name="ConnectionString_MCN" connectionString="Server=localhost;Database=test;User Id=root;Password=seigi@123;" />
  </connectionStrings>SampleLogConfMobile

Figure 1.1.2-1 Implementation example of the connectionStrings section

The connection strings set in the connectionStrings section can be obtained from the application with the GetConfigParameter.GetConnectionString("(key)") method. The logic for establishing a connection with the DBMS is implemented in the "UOC method for creating the data access control class" of the "business code parent class 2" (see section 3.2 of this document: "Implementing DB initialization").

The connectionStrings section can also be encrypted with the following commands.

  1. Create a key pair by specifying the name of a custom RSA key container.
    > aspnet_regiis -pc "MyKeys" -exp
  2. Add permission to access the custom RSA key container to the ASP.NET execution account.
    > aspnet_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"
    ※ "NT AUTHORITY\NETWORK SERVICE" is the default ASP.NET execution account in IIS 6.0.
  3. Add to the web.config file the "MyProvider" instance of the "RsaProtectedConfigurationProvider" class, which encrypts and decrypts using the created "MyKeys" custom RSA key container.
<configProtectedData>
 <providers>
 <add name="MyProvider"
 type="System.Configuration.RsaProtectedConfigurationProvider,
 System.Configuration, Version=2.0.0.0, Culture=neutral,
 PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
 keyContainerName="MyKeys" useMachineContainer="true" />
 </providers>
</configProtectedData>

Figure 1.1.2-2 Adding the configProtectedData section

  1. Run the following command to encrypt the connectionStrings section of the web.config file.
    > aspnet_regiis -pe "connectionStrings" -app "/(Web site name)" -prov "MyProvider"
<connectionStrings configProtectionProvider="MyProvider">
 <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
 <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
 <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
 <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
 <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
 <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
 <KeyName>Rsa Key</KeyName>
 </KeyInfo>
 <CipherData>
 <CipherValue>X+eV/t4UbqQIU/L1a8pS5vl0DTTVC(omitted)q2se9sY8tuAtfzUv6gOiDE8NfV3D4=</CipherValue>
 </CipherData>
 </EncryptedKey>
 </KeyInfo>
 <CipherData>
 <CipherValue>mGDl6aJliUXkfRFM4TFHm61Gvy6q(omitted)5cJ0IztRp84cT4QyunGWT13lDhKntdI8MJ98=</CipherValue>
 </CipherData>
 </EncryptedData>
</connectionStrings>

Figure 1.1.2-3 Encrypted connectionStrings section

To decrypt, run > aspnet_regiis -pd "connectionStrings" -app "/(Web site name)". For other details such as importing and exporting custom RSA key containers, see Walkthrough: Creating and Exporting an RSA Key Container.

1.1.3 sessionState section

This section describes the settings of the sessionState section of web.config. The sessionState section allows settings related to sessions.

<sessionState timeout="20" cookieless="false" mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" />

Figure 1.1.3 Implementation example of the sessionState section

The basic attributes of the sessionState section are the following three.

Table 1.1.3 sessionState section

No. Attribute Purpose
1 timeout Sets the time (in minutes) allowed between requests before the session state provider terminates the session.
2 cookieless Sets whether to embed the session ID in the URL (true) or store it in a cookie (false).
3 mode Sets the current session state mode.

Note that other parameters must also be set depending on the session state mode. During development, it is good to use mode="StateServer" (because it can be changed to various modes after going live). In this case, the URL to the state server must be set in the stateConnectionString attribute. References: Session-State Modes, sessionState element.

1.1.4 authentication and authorization sections

This section describes the settings of the authentication section of web.config. The authentication section allows settings related to authentication. After configuring this section, the authorization section that denies access to anonymous users must also be configured to allow access only to authenticated users. The following is an implementation example of the authentication and authorization sections when Forms authentication is used.

<!-- Forms authentication -->
<authentication mode="Forms">
 <forms name="formauth" loginUrl="(login page)" defaultUrl="(top page)" timeout="10"
 protection="All" path="/" domain="" requireSSL="false"
 slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile"/>
</authentication>
<authorization>
 <deny users="?"/><!-- Deny anonymous users -->
</authorization>

Figure 1.1.4 Implementation example of the authentication and authorization sections

The description of the attributes of the forms section is shown in Table 1.1.4 below.

Table 1.1.4 forms section (Forms authentication)

No. Attribute Purpose
1 name Used as the name of the cookie that stores the authentication ticket.
2 loginUrl URL of the login form.
3 defaultUrl Defines the default URL used for redirection after authentication.
4 timeout Validity period of the ticket (unit: minutes).
5 protection Specifies whether the cookie is encrypted and validated (recommended value: "All").
6 path Path of the cookie (default: "/").
7 requireSSL Specifies whether an SSL connection is required to send the authentication cookie (default: "false").
8 slidingExpiration Specifies whether sliding expiration is enabled (default and recommended: "true").
9 enableCrossAppRedirects Enables forms authentication across applications.
10 cookieless Defines whether cookies are used and how cookies behave.
11 domain Specifies the optional domain to set on the forms authentication cookie.

References: authorization element, forms element of authentication.

1.2 app.config file

This section describes the settings of app.config. In the appSettings section of app.config, define the parameters used by the framework and common components.

1.2.1 Parameters used by the framework

The parameters used by the framework are shown below.

<?xml version="1.0" encoding="utf-8"?>
<appSettings>
 <!-- After changing parameters, run the iisreset command. -->
 <!-- Parameters used by the framework - start -->
 <!-- Control prefixes -->
 <add key="FxPrefixOfButton" value="btn"/>
 <add key="FxPrefixOfLinkButton" value="lbn"/>
 <add key="FxPrefixOfImageButton" value="ibn"/>
 <add key="FxPrefixOfImageMap" value="imp"/>
 <add key="FxPrefixOfTextBox" value="txt"/>
 <add key="FxPrefixOfDropDownList" value="ddl"/>
 <add key="FxPrefixOfListBox" value="lbx"/>
 <add key="FxPrefixOfRadioButton" value="rbn"/>
 <add key="FxPrefixOfRadioButtonList" value="rbl"/>
 <add key="FxPrefixOfCheckBoxList" value="cbl"/>
 <add key="FxPrefixOfRepeater" value="rpt"/>
 <add key="FxPrefixOfGridView" value="gvw"/>
 <add key="FxPreficOfListView" value="lvw"/>
 <!-- Infrastructure screen paths -->
 <add key="FxErrorScreenPath" value="/(site name)/Aspx/Common/ErrorScreen.aspx"/>
 <add key="FxOKMessageDialogPath" value="/(site name)/Aspx/FrameWork/myOKMessageDialog.aspx"/>
 <add key="FxYesNoMessageDialogPath" value="/(site name)/Aspx/FrameWork/myYesNoMessageDialog.aspx"/>
 <add key="FxDialogFramePath" value="/(site name)/Aspx/Framework/DialogFrame.htm"/>
 <!-- Icon paths -->
 <add key="FxInformationIconPath" value="/(site name)/Framework/img/information.ico"/>
 <add key="FxWarningIconPath" value="/(site name)/Framework/img/warning.ico"/>
 <add key="FxErrorIconPath" value="/(site name)/Framework/img/error.ico"/>
 <add key="FxQuestionIconPath" value="/(site name)/Framework/img/question.ico"/>
 <!-- Default screen styles -->
 <add key="FxDefaultFxDialogStyle" value="dialogWidth:450px;dialogHeight:250px;status:no;" />
 <add key="FxDefaultBusinessDialogStyle" value="dialogWidth:640px;dialogHeight:480px;status:no;" />
 <add key="FxDefaultNormalScreenStyle" value="width=960,height=700,scrollbars=yes" />
 <!-- On / off of the session timeout detection function -->
 <add key="FxSessionTimeOutCheck" value="on"/>
 <!-- On / off of the double submission prevention function -->
 <add key="FxDoubleTransmissionCheck" value="on"/>
 <!-- On / off of the illegal operation prevention function (maximum number of operation histories) -->
 <add key="FxRequestTicketGuidMaxQueueLength" value="100"/>
 <!-- Maximum length of the queue that holds the button history -->
 <add key="FxButtonhistoryMaxQueueLength" value="20"/>
 <!-- On / off of the automatic deletion function of session areas per parent screen (maximum number of scopes) -->
 <add key="FxScreeenGuidMaxQueueLength" value="30"/>
 <!-- On / off of the automatic deletion function of session areas per window screen (maximum number of scopes) -->
 <add key="FxWindowGuidMaxQueueLength" value="10"/>

 <!-- Specify the screen transition method (T: Transfer, R: Redirect, off) -->
 <add key="FxScreenTransitionMode" value="off"/>
 <!-- On / off of the screen transition check function -->
 <add key="FxScreenTransitionCheck" value="off"/>
 <!-- Path to the message definition -->
 <add key="FxXMLMSGDefinition" value="C:\root\files\resource\Xml\MSGDefinition.xml"/>
 <!-- Path to the screen transition definition -->
 <add key="FxXMLSCDefinition" value="C:\root\files\resource\Xml\SCDefinition.xml"/>
 <!-- Path to the transaction control definition -->
 <add key="FxXMLTCDefinition" value="C:\root\files\resource\Xml\TCDefinition.xml"/>
 <!-- Paths to the name resolution definitions -->
 <add key="FxXMLTMProtocolDefinition" value="C:\root\files\resource\Xml\TMProtocolDefinition.xml"/>
 <add key="FxXMLTMInProcessDefinition" value="C:\root\files\resource\Xml\TMInProcessDefinition.xml"/>
 <!-- Parameters used by the framework - end -->

Figure 1.2.1 Implementation example of the appSettings section (parameters used by the framework)

Table 1.2.1 appSettings section (parameters used by the framework)

No. Category Attribute Purpose
1 Control prefixes FxPrefixOfButton Button control
1-2 FxPrefixOfLinkButton LinkButton control
1-3 FxPrefixOfImageButton ImageButton control
1‐4 FxPrefixOfImageMap ImageMap control
1‐5 FxPrefixOfTextBox TextBox control
1-6 FxPrefixOfDropDownList DropDownList control
1-7 FxPrefixOfListBox ListBox control
1-8 FxPrefixOfRadioButton RadioButton control
1-9 FxPrefixOfRadioButtonList RadioButtonList control
1-10 FxPrefixOfCheckBoxList CheckBoxList control
1-11 FxPrefixOfRepeater Repeater control
1-12 FxPrefixOfGridView GridView control
1-13 FxPrefixOfListView ListView control
2 Paths to infrastructure screens (virtual paths) FxErrorScreenPath Specifies the path to the error screen.
2-2 FxYesNoMessageDialogPath Path to the [Yes]/[No] message dialog.
2-3 FxOKMessageDialogPath Path to the [OK] message dialog.
2-4 FxDialogFramePath Path to the dialog frame.
3 Paths to icons (virtual paths) FxInformationIconPath [Information] icon of the [OK] message dialog.
3-2 FxWarningIconPath [Warning] icon of the [OK] message dialog.
3-3 FxErrorIconPath [Error] icon of the [OK] message dialog.
3-4 FxQuestionIconPath [?] icon of the [Yes]/[No] message dialog.
4 Default styles FxDefaultFxDialogStyle Style of the [OK] / [Yes]/[No] message dialogs.
4-2 FxDefaultBusinessDialogStyle Style of business modal screens.
4-3 FxDefaultNormalScreenStyle Style of business modeless screens.
5 ON/OFF switches of functions FxSessionTimeOutCheck Specifies whether the session timeout detection function is enabled or disabled with [on] / [off].
5-2 FxDoubleTransmissionCheck Specifies whether the double submission prevention function is enabled or disabled with [on] / [off] [2].
5-3 FxRequestTicketGuidMaxQueueLength Specifies the maximum number of operation histories per screen for the illegal operation prevention function [3]. 0 or less: OFF, greater than 0: ON.
5-4 FxButtonhistoryMaxQueueLength Sets the maximum length of the queue that holds button history information. 0 or less: OFF, greater than 0: ON.
5-5 FxScreeenGuidMaxQueueLength On / off of the automatic deletion function of session areas per parent screen (maximum number of scopes).
5-6 FxWindowGuidMaxQueueLength On / off of the automatic deletion function of session areas per window (maximum number of scopes).
6 Screen transition function FxScreenTransitionMode Sets the screen transition mode to [Transfer], [Redirect] or [off].
6-2 FxScreenTransitionCheck Specifies whether the screen transition check function is enabled or disabled with [on] / [off].
7 Other definition files FxXMLMSGDefinition Definition file of the message acquisition function.
7-2 FxXMLSCDefinition Definition file of the screen transition control function.
7-3 FxXMLTCDefinition Definition file of the transaction control function.
7-4 FxXMLTMProtocolDefinition Definition file of the communication control component (call protocol selection).
7-5 FxXMLTMInProcessDefinition Definition file of the communication control component (in-process call).

※ For details such as default values and cases that cause setting errors, see the attached "1b_config_parameter_list.xls".

1.2.2 Parameters used by common components

The parameters used by common components are shown below.

<!-- Parameters used by common components - start -->

 <!-- Path to the Log4Net configuration file -->
 <add key="FxLog4NetConfFile" value="C:\root\files\resource\Log\SampleLogConf.xml"/>

 <!-- On / off of the SQL trace log output function of the D layer -->
 <add key="FxSqlTraceLog" value="on"/>
 <!-- On / off of the SQL statement cache function of the D layer -->
 <!-- Set to off by default in consideration of the development phase -->
 <add key="FxSqlCacheSwitch" value="off"/>
 <!-- Specifies the encoding when loading SQL in the D layer (shift_jis, utf-8, etc.) -->
 <add key="FxSqlEncoding" value="shift_jis"/>
 <!-- Specifies the command timeout value of the D layer (seconds) -->
 <add key="FxSqlCommandTimeout" value="30"/>
 <!-- Parameters used by common components - end -->

Figure 1.2.2 Implementation example of the appSettings section (parameters used by common components)

Table 1.2.2 appSettings section (parameters used by common components)

No. Attribute Purpose
1 FxLog4NetConfFile Specifies the path to the log4net configuration file.
3 FxSqlTraceLog Specifies the SQL trace log output function with [on] / [off].
4 FxSqlCacheSwitch Specifies whether to cache loaded SQL with [on] / [off].
5 FxSqlEncoding Specifies the encoding when loading SQL.
6 FxSqlCommandTimeout Specifies the command timeout value (seconds).

1.2.3 Parameters used by the application (samples)

The parameters used by the application (samples) are shown below.

 <!-- Parameters used by common components - start -->

 <!-- Path to the Log4Net configuration file -->
 <add key="FxLog4NetConfFile" value="C:\root\files\resource\Log\SampleLogConf.xml"/>

 <!-- On / off of the SQL trace log output function of the D layer -->
 <add key="FxSqlTraceLog" value="on"/>
 <!-- On / off of the SQL statement cache function of the D layer -->
 <!-- Set to off by default in consideration of the development phase -->
 <add key="FxSqlCacheSwitch" value="off"/>
 <!-- Specifies the encoding when loading SQL in the D layer (shift_jis, utf-8, etc.) -->
 <add key="FxSqlEncoding" value="shift_jis"/>
 <!-- Specifies the command timeout value of the D layer (seconds) -->
 <add key="FxSqlCommandTimeout" value="30"/>
 <!-- Parameters used by common components - end -->

Figure 1.2-2 Implementation example of the appSettings section (parameters used by common components)

※ The shaded parts are specific to the test programs and are not used.

<!-- Parameters used by the application - start -->

 <!-- Path to the SQL files (folder) -->
 <add key="SqlTextFilePath" value="C:\ files\resource\Sql"/>

 <!-- Parameters used by the test programs - start -->

 <!-- Browser title -->
 <add key="BrowserTitle" value="Framework test screen"/>

 <!-- Screen transition method (1 is Transfer, 2 is Redirect) -->
 <add key="ScreenTransitionMethod" value="1"/>

 <!-- Control prefix (added) -->
 <add key="FxPrefixOfCheckBox" value="cbx"/>

 <!-- Path to the files (folder) -->
 <add key="TestFilePath" value="C:\ files\resource\test"/>

 <!-- Parameters used by the test programs - end -->

 <!-- Parameters used by the application - end -->

Figure 1.2.3 Implementation example of the appSettings section (parameters used by the application)

Table 1.2.3 appSettings section (parameters used by the application)

No. Category Attribute Purpose
1 Reusable SqlTextFilePath Sets the path to the folder where SQL is stored (reusable).
1-2 BrowserTitle Title shown in the WWW browser.
1-3 ScreenTransitionMethod Specifies the screen transition method when the screen transition control function is OFF.
2 Reusable: control prefix FxPrefixOfCheckBox CheckBox control.

For how to add controls on content pages that are processed by the framework, see chapter 7 of this document: "Adding controls (events) supported by P layer event processing".

1.3 log4net

This section describes the settings of log4net. This framework uses an external file in XML format for the settings related to log output by log4net. The following is a configuration sample attached to the framework.

1.3.1 Defining appenders

This section describes the appender settings of log4net. In an appender, various settings tied to the log output destination (mainly files) are made. The setting items include the log output destination, the append / overwrite setting, the filter setting, individual settings for each destination and the message format setting.

<?xml version="1.0" encoding="utf-8" ?>
<!-- Section of the log4net configuration settings -->

<log4net debug="true"><!-- ← When debug="true", console output for debugging is enabled. -->

    <!-- The log output destination can be changed by selecting the appender. -->

    <!--
        Examples of appenders

        FileAppender        : Outputs to a file.
        RollingFileAppender : Outputs to a file. With a rolling function.
        EventLogAppender    : Outputs to the event viewer (local PC only)
        ConsoleAppender     : Outputs to the console
        ※ FileAppender and RollingFileAppender can also output to shared folders and network drives on the network
    -->
    
    <!--
        Patterns that can be specified in PatternLayout
        Pattern         Description
        %logger         Name of the logger that performed the log output
        %appdomain      Application domain name
        ●%date         Outputs the date and time. Detailed specifications such as "%date{yyyy/MM/dd HH:mm:ss,fff}" are also possible.
        ●%level        Log level (Fatal/Error, etc.)
        ●%t            Thread that generated the log
        ●%message      Message
        ●%newline      Newline character
        %literal{-}     Literal (for outputting % as is, etc.)
        %file           File name
        %class          Class name
        %method         Method name
        %line           Line number
        %location       Function name and full path of the file when the log was output
        ※ %file to %location have a high processing load, so do not use them unless necessary.
        http://d.hatena.ne.jp/shima111/20060703
    -->
    
    <!-- Appender for rolling log file output -->
    <appender name="(★appender name 1)" type="log4net.Appender.RollingFileAppender">
        <param name="File" value="(★file path)" />
        <!-- Rolling settings -->
        <param name="StaticLogFileName" value="false" />
        <param name="RollingStyle" value="date " />
        <param name="DatePattern" value='"."yyyy-MM-dd".log"' />
        <!-- Write settings (append or overwrite, output encoding) -->
        <param name="AppendToFile" value="true" />
        <encoding value="utf-8" />
        <!-- Message format -->
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="[%date{yyyy/MM/dd HH:mm:ss,fff}],[%-5level],[%thread],%message%newline" />
        </layout>
        <!-- Filter (range) settings -->
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="DEBUG" />
            <levelMax value="FATAL" />
        </filter>
    </appender>
        
    <!-- Appender for rolling log file output -->
    <appender name="(★appender name 2)" type="log4net.Appender.RollingFileAppender">
        <param name="File" value="(★file path)" />
        <!-- Rolling settings -->
        <param name="StaticLogFileName" value="false" />
        <param name="RollingStyle" value="date " />
        <param name="DatePattern" value='"."yyyy-MM-dd".log"' />
        <!-- Write settings (append or overwrite, output encoding) -->
        <param name="AppendToFile" value="true" />
        <encoding value="utf-8" />
        <!-- Message format -->
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="[%date{yyyy/MM/dd HH:mm:ss,fff}],[%-5level],[%thread],%message%newline" />
        </layout>
        <!-- Filter (range) settings -->
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="DEBUG" />
            <levelMax value="FATAL" />
        </filter>
    </appender>
    
    <!-- Appender for log file output -->
    <appender name="(★appender name 3)" type="log4net.Appender.FileAppender">
        <param name="File" value="(★file path)" />
        <!-- Write settings (append or overwrite, output encoding) -->
        <param name="AppendToFile" value="true" />
        <encoding value="utf-8" />
        <!-- Message format -->
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="[%date{yyyy/MM/dd HH:mm:ss,fff}],[%-5level],[%thread],%message%newline" />
        </layout>
        <!-- Filter (range) settings -->
        <filter type="log4net.Filter.LevelRangeFilter">
            <levelMin value="DEBUG" />
            <levelMax value="FATAL" />
        </filter>
    </appender>

Figure 1.3.1-1 Example of defining appenders in the log4net configuration file [4]

When reusing the design of the sample programs, the files SampleLogConf.xml (for ASP.NET Web applications) and SampleLogConfWebService.xml (for 3-tier applications [5]) can be used as they are. The above defines the following four appenders and outputs logs.

  • ACCESS log → access trace log
  • SQLTRACE log → SQL trace log
  • Operation log → operation log
  • SERVICE-IF log → service interface log

1.3.2 Defining loggers

This section describes the logger settings of log4net. In a logger, the behavior at the time of log output is configured (the program outputs logs using the logger name). The setting items include the definition of the Root logger and individual loggers, the log output level of each logger and the correspondence between each logger and appenders.

    <!--
        Create loggers.
        For a logger, set the logger name, appenders and output level.
        To output only logs of a specific level,
        use the filter (range) function.
        -->
    <!--
        ↑Output level: high
        Fatal         Fatal failure that stops the system
        Error         Failure that does not stop the system but is a problem
        Warn          Caution or warning that is not a failure
        Info          Information such as operation logs
        Debug         Debug messages for development
        All           All levels
        ↓Output level: low
    -->
    <!--
        Create the Root logger (set n appenders and the output level).
        All logs are output to the Root logger.
    -->
    <root>
        <level value="DEBUG" /> 
        <appender-ref ref="(★appender name 1)" /> 
        <appender-ref ref="(★appender name 2)" /> 
        <appender-ref ref="(★appender name 3)" /> 
    </root>
    <!--
        Create individual loggers (set the logger name, n appenders and the output level).
        Logs for which an individual logger name is specified from the program are processed by that individual logger.
    -->
    <logger name="(★logger name 1)">
        <level value="DEBUG" /> 
        <appender-ref ref="(★appender name 1)" /> 
        <appender-ref ref="(★appender name 2)" /> 
        <appender-ref ref="(★appender name 3)" /> 
    </logger>
    <logger name="(★logger name 2)">
        <level value="DEBUG" /> 
        <appender-ref ref="(★appender name 1)" /> 
        <appender-ref ref="(★appender name 2)" /> 
        <appender-ref ref="(★appender name 3)" /> 
    </logger>
    <logger name="(★logger name 3)">
        <level value="DEBUG" /> 
        <appender-ref ref="(★appender name 1)" /> 
        <appender-ref ref="(★appender name 2)" /> 
        <appender-ref ref="(★appender name 3)" /> 
    </logger>

</log4net>

Figure 1.3.2 Example of defining loggers in the log4net configuration file

In the SampleLogConf.xml file of the sample programs, a logger is defined for each appender.

1.3.3 References

For details on log4net and its settings, see the log4net site or related sites.

1.3.4 Option settings

This section describes the option settings of log4net.


In log4net, how to configure rolling with a fixed number of backups, which substitutes for rolling between system 1 and system 2, is often hard to find in information on the Web, but it is introduced in detail on the reference sites. An example definition of rolling with a fixed number of backups is shown below.

<!-- Appender for rolling log file output-->
<appender name="(★appender name)" type="log4net.Appender.RollingFileAppender">
 <param name="File" value="(★file path)" />
 <!-- Rolling settings-->
 <param name="StaticLogFileName" value="true" />
 <param name="RollingStyle" value="size" />
 <param name="MaximumFileSize" value="10MB" />
 <param name="MaxSizeRollBackups" value="2" />
 <param name="CountDirection" value="-1" />
 <!-- Write settings (append or overwrite, output encoding)-->
 <param name="AppendToFile" value="true" />
 <encoding value="utf-8" />
 <!-- Message format-->
 <layout type="log4net.Layout.PatternLayout">
   <param name="ConversionPattern" value="~(omitted)~" />
 </layout>
 <!-- Filter (range) settings-->
 <filter type="log4net.Filter.LevelRangeFilter">
   <levelMin value="DEBUG" />
   <levelMax value="FATAL" />
 </filter>
</appender>

Figure 1.3.4 Example definition of rolling with a fixed number of backups

The above settings roll every 10MB in size and keep two backups [6] ((log file name) → log currently being output, (log file name).1 → past log backup (old), (log file name).2 → past log backup (oldest)). When rolling by both date and size, set the DatePattern value carefully [7].

<!-- Rolling settings -->
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="composite" />
<param name="DatePattern" value='"."yyyy"-"MM"-"dd".log"' />
<param name="MaximumFileSize" value="10MB" />
<param name="MaxSizeRollBackups" value="10" />
<param name="CountDirection" value="-1" />

Figure 1.3.4 Example definition of rolling with a fixed number of backups

  • filter setting: A filter is optional (no filter).
  • logger level setting: A logger level is optional (treated as ALL if absent).
  • filter and logger level settings: Both apply, and the stricter setting takes effect.

  • Lockingmodel tag: Writing
<lockingmodel type="log4net.Appender.FileAppender+MinimalLock">

as a child node of the appender tag allows multiple processes to output logs to a single file (however, logs may be lost when there is much contention [8]).
type attribute:

  • log4net.Appender.FileAppender+ExclusiveLock (exclusive lock. Default value. Writing from multiple processes is not possible)

  • log4net.Appender.FileAppender+MinimalLock (minimal lock. Writing from multiple processes is possible but performance degrades).

  • ImmediateFlush tag: Writing

<ImmediateFlush value="False" />

as a child node of the appender tag makes it buffer before flushing (log output).
value attribute:

  • True (flushes immediately without buffering. Default. All logs are output even in a crash)
  • False (flushes after buffering. Reduces the load of Disk I/O).

2. Carrying over common information

This chapter describes how to define common information to carry over and how it is carried over.

2.1 Information carried across screens

Information carried across screens is collected in the "user information class 2" (MyUserInfo) of the [Touryo].Infrastructure.Business.Util namespace and carried over by storing it in the Session.

  • The timing of setting the information is at logon, etc.
  • Basically, one "user information class 2" is created per system.
  • The class name can be changed to any name.
  • If the user information is lost due to a session timeout, etc., either send the user to the error screen to log in again, or, if the authentication ticket of Forms authentication or the execution account of Windows authentication can be obtained, regenerate the user information based on that information.

The "user information class 2" (MyUserInfo) is provided as a template, so customize it to suit the system. You can refer to the implementation of the following classes attached to the sample programs.

  • Storing in and getting from the session: the UserInfoHandle class
  • Generation processing at authentication: the login screen "login.aspx", "login.aspx.cs" and "Aspx_Start_login"
  • Regeneration when lost: the "GetUserInfo" method called from the page load UOC method of the "screen code parent class 2" (MyBaseController)

2.2 Information carried over to the B and D layers

Information carried over to the B and D layers is carried across the B and D layers by storing it in the "parameter parent class 2" and "return value parent class 2".

  • The timing of setting is at B layer creation, etc.
  • Basically, one "parameter parent class 2" and one "return value parent class 2" are created per system.
  • The class names can be changed to any name.

The implementation template of the "parameter parent class 2" is shown below (you can refer to the sample "MyParameterValue" class).

using System;
using Touryo.Infrastructure.Business.Util;
using Touryo.Infrastructure.Framework.Common;

namespace Touryo.Infrastructure.Business.Common
{
    /// <summary>Parameter parent class 2</summary>
    /// <remarks>
    /// Make it serializable (WS support). Can be used freely (with extension).
    /// </remarks>
    [Serializable()]
    public class MyParameterValue : BaseParameterValue
    {
        #region Instance variables

        /// <summary>User information</summary>
        private MyUserInfo _user;

        #endregion

        #region Constructor

        /// <summary>Constructor</summary>
        /// <param name="screenId">Screen ID</param>
        /// <param name="controlId">Control ID</param>
        /// <param name="actionType">Action type</param>
        /// <param name="user">User information</param>
        /// <remarks>
        /// Constructors are not inherited, so they must be called in the derived class.
        /// ※ Constructors are executed in the order base class → derived class
        /// ※ In VB.NET, call MyBase.New() from the constructor of the derived class.
        /// Can be used freely (to maintain compatibility).
        /// </remarks>
        public MyParameterValue(string screenId, string controlId, string actionType, MyUserInfo user)
            : base(screenId, controlId, actionType)
        {
            // User information
            this._user = user;
        }
        
        /// <summary>Constructor</summary>
        /// <param name="screenId">Screen ID</param>
        /// <param name="controlId">Control ID</param>
        /// <param name="methodName">Method name</param>
        /// <param name="actionType">Action type</param>
        /// <param name="user">User information</param>
        /// <remarks>
        /// Constructors are not inherited, so they must be called in the derived class.
        /// ※ Constructors are executed in the order base class → derived class
        /// ※ In VB.NET, call MyBase.New() from the constructor of the derived class.
        /// Can be used freely.
        /// </remarks>
        public MyParameterValue(string screenId, string controlId, string methodName, string actionType, MyUserInfo user)
            : base(screenId, controlId, methodName, actionType)
        {
            // User information
            this._user = user;
        }

        #endregion

        #region Properties

        /// <summary>User information (read-only)</summary>
        /// <remarks>Can be used freely.</remarks>
        public MyUserInfo User
        {
            get
            {
                return this._user;
            }
        }

        #endregion        
    }
}

Figure 2.2-1 Implementation template of the "parameter parent class 2"

The implementation template of the "return value parent class 2" is shown below (you can refer to the sample "MyReturnValue" class).

namespace Touryo.Infrastructure.Business.Common
namespace Touryo.Infrastructure.Business.Common
{
  /// <summary>Return value parent class 2</summary>
  /// <remarks>
  /// Make it serializable (WS support). Can be used freely (with extension).
  /// </remarks>
  [Serializable()]
  public class MyReturnValue : BaseReturnValue
  {
    #region Instance variables
    private string _Output1;
    private string _Output2;
    #endregion
    
    #region Properties
    public string Output1
    {
      set
      {
        this._Output1 = value;
      }
      get
      {
        return this._Output1;
      }
    }
    
    public string Output2
    {
      set
      {
        this._Output2 = value;
      }
      get
      {
        return this._Output2;
      }
    }
    #endregion
  }
}

Figure 2.2-2 Implementation template of the "return value parent class 2"

3. B layer framework

3.1 Preparing the "business code parent class 2"

The "business code parent class 2" can implement the following common B layer processing.

Table 3.1 Common B layer processing that can be implemented in the "business code parent class 2"

No. Processing Method Section
1 DB initialization UOC_ConnectionOpen (DB connection, blockade check, isolation level setting, transaction start, etc.) Section 3.2
2 Start processing UOC_PreAction (measuring processing time, outputting access logs, etc.) Section 3.3
3 Automatic dispatching of business processing methods UOC_DoAction (automatic dispatching of business processing methods) Section 3.5
4 End processing UOC_AfterAction (measuring processing time, outputting access logs, etc.) Section 3.3
5 End processing 2 UOC_AfterTransaction (post-processing after transaction completion (COMMIT). Measuring processing time, outputting access logs, etc.) Section 3.4
7 Exception handling UOC_ABEND (exception replacement, access log output, error log output, etc.) Section 3.6

Basically, one "business code parent class 2" is created per system (the class name can be changed). The implementation template is shown below (you can refer to the sample "MyFcBaseLogic" class).

#region using
// System~
using System;
~
using Touryo.Infrastructure.Business.Util;
#endregion
namespace Touryo.Infrastructure.Business.Business
{
 /// <summary>
 /// Business code parent class 2 (template)
 /// </summary>
 public abstract class MyFcBaseLogic : BaseLogic
 {
 }
}

Figure 3.1 Implementation template of the "business code parent class 2"

3.2 Implementing "DB initialization"

"DB initialization" must be implemented. To implement this processing, override the "UOC_ConnectionOpen" method in the "business code parent class 2". In this UOC method, implement the creation of the "data access control class", DB connection, blockade check, isolation level setting, transaction start, etc.

/// <summary>Implements the creation of the data access control class (DAM), establishing the connection and starting the transaction</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="iso">Isolation level (set it after understanding the differences in isolation levels between DBMSs)</param>
protected override void UOC_ConnectionOpen(
BaseParameterValue parameterValue,
DbEnum.IsolationLevelEnum iso)
{
  // Create the data access control class (DAM)
  BaseDam dam = new Touryo.Infrastructure.Public.Db.DamSqlSvr();
  
  // Load the connection string
  string connstring = GetConfigParameter.GetConnectionString("ConnectionString_SQL");
  
  // Open the connection.
  dam.ConnectionOpen(connstring);
  
  // If necessary, implement blockade check processing, etc. ---------------------
  // ---------------------------------------------------------------------
  
  // Set the isolation level.
  if (iso == DbEnum.IsolationLevelEnum.User)
  {
    // Change to the user-specified isolation level.
    iso = DbEnum.IsolationLevelEnum.DefaultTransaction;
  }
  
  // Start the transaction.
  dam.BeginTransaction(iso);
  
  // Set the dam.
  this.SetDam(dam);
}

Figure 3.2 Implementation example of "DB initialization"

By placing the Dam that has been created, connected to the DB and had its transaction started under the framework's management with the "SetDam" method, the corresponding transaction termination (commit / rollback) and DB disconnection are handled automatically by the framework ("business code parent class 1").

3.3 Implementing "start and end processing of B layer processing"

"Start and end processing of B layer processing" must be implemented. Override the "UOC_PreAction" and "UOC_AfterAction" methods in the "business code parent class 2" and implement measuring processing time, access log output, etc.

/// <summary>Implements the start processing of the B layer</summary>
/// <param name="parameterValue">Parameter class</param>
protected override void UOC_PreAction(BaseParameterValue parameterValue)
{
 // Implement the start processing of the B layer.
 //TODO:
}
/// <summary>Implements the end processing of the B layer</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
protected override void UOC_AfterAction(BaseParameterValue parameterValue, BaseReturnValue returnValue)
{
 // Implement the end processing of the B layer.
 //TODO:
}

Figure 3.3 Implementation example of "start and end processing of B layer processing"

3.4 Implementing "transaction end processing"

"Transaction end processing" must be implemented. Override the "UOC_AfterTransaction" method in the "business code parent class 2" to implement processing to run after transaction processing completes (such as message output and message sending).

/// <summary>Implements the end processing after the commit of the B layer transaction</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
protected override void UOC_AfterTransaction(BaseParameterValue parameterValue, BaseReturnValue returnValue)
{
 // Implement the end processing after the commit of the B layer transaction.
 //TODO:
}

Figure 3.4 Implementation example of "transaction end processing"

3.5 Implementing automatic dispatching of business processing methods

"Automatic dispatching of business processing methods" must be implemented (it used to be optional, but it is now the recommended method). Override the "UOC_DoAction" method in the "business code parent class 2".

/// <summary>Automatic dispatching</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
protected override void UOC_DoAction(BaseParameterValue parameterValue, ref BaseReturnValue returnValue)
{
 // Generate the method name
 string methodName = "UOC_" + parameterValue.MethodName;
 #region Late binding
 object[] paramSet = new object[] { parameterValue };
 try
 {
   // Latebind
   Latebind.InvokeMethod(this, methodName, paramSet);
 }
 catch (System.Reflection.TargetInvocationException rtEx)
 {
   // Save the stack trace of the InnerException (because it is erased by the rethrow below).
   this.OriginalStackTrace = rtEx.InnerException.StackTrace;
   // Rethrow the InnerException.
   throw rtEx.InnerException;
 }
 finally
 {
   // In late binding,
   // ・ For return values (in), the return value instance created below is not returned.
   // ・ For return values (ref, out), the return value instance is not returned when an exception occurs.
   // are problems.
   // ∴ (especially to handle the latter,)
   // return the return value instance using a member variable.
   returnValue = this.ReturnValue;
 }
 #endregion
}

Figure 3.5 Implementation example of "automatic dispatching of business processing methods"

3.6 Implementing "exception handling"

"Exception handling" must be implemented. Override the following three "UOC_ABEND" methods in the "business code parent class 2".

Table 3.6 The three "UOC_ABEND" methods that can be implemented in the "business code parent class 2"

No. Corresponding exception Method signature
1 Business exception UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue, BusinessApplicationException baEx)
2 System exception UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue, BusinessSystemException bsEx)
3 Other general exceptions UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue, Exception ex)

In these UOC methods, distinguish the kinds of exceptions and implement exception replacement, access log output, error log output, etc.

  • Exception handling of business exceptions: The feature is that the exception is not rethrown after processing. "Access log output" can be implemented here.
/// <summary>UOC method that implements the post-processing of abnormal termination due to a business exception in the B layer.</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
/// <param name="baEx">BusinessApplicationException</param>
protected override void UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue,
BusinessApplicationException baEx)
{
 // Implement the processing when a business exception occurs
 // TODO:
}

Figure 3.5-1 Implementation example of "exception handling of business exceptions"

  • Exception handling of system exceptions: The feature is that the "system exception" is rethrown after processing. "Error log output" can be implemented here.
/// <summary>UOC method that implements the post-processing of abnormal termination due to a system exception in the B layer.</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
/// <param name="bsEx">BusinessSystemException</param>
protected override void UOC_ABEND(BaseParameterValue parameterValue, BaseReturnValue returnValue,
BusinessSystemException bsEx)
{
 // Implement the processing when a system exception occurs
 // TODO:
}

Figure 3.5-2 Implementation example of "exception handling of system exceptions"

  • Exception handling of other general exceptions: The feature is that the exception is not rethrown after processing (in order to replace "other general exceptions" with "system exceptions" or "business exceptions"). In addition to "error log output" and "access log output", "exception replacement" processing can be implemented. When replacing with a "business exception", output the "access log"; when replacing with "other general exceptions" or a "system exception", output the "error log".
/// <summary>UOC method that implements the post-processing of abnormal termination due to a general exception in the B layer.</summary>
/// <param name="parameterValue">Parameter class</param>
/// <param name="returnValue">Return value class</param>
/// <param name="ex">Exception</param>
protected override void UOC_ABEND(BaseParameterValue parameterValue, ref BaseReturnValue returnValue,
Exception ex)
{
 // Implement the processing when a general exception occurs
 // TODO:
 // Exception replacement processing
 if (ex.Message == "identify the exception to replace from the error type, message, etc.")
 {
   // Replace with a business exception
   returnValue.ErrorFlag = true;
   returnValue.ErrorMessageID = "error message ID after replacement";
   returnValue.ErrorMessage = "error message after replacement";
   returnValue.ErrorInfo = "-";
 }
 else if (ex.Message == "identify the exception to replace from the error type, message, etc.")
 {
   // Replace with a system exception
   // Rethrow
   throw new BusinessSystemException("error message ID after replacement", "error message after replacement");
 }
 else
 {
   // Rethrow
   throw ex;
 }
}

Figure 3.5-3 Implementation example of "exception handling of other general exceptions"

4. D layer framework

4.1 Preparing the "data access parent class 2"

The "data access parent class 2" can implement the following common D layer processing.

Table 4.1 Common D layer processing that can be implemented in the "data access parent class 2"

No. Processing Method
1 Start processing UOC_PreQuery (measuring processing time, etc.)
2 End processing UOC_AfterQuery (measuring processing time, SQL trace log output, error log output, exception replacement, etc.)

Basically, one "data access parent class 2" is created per system. The implementation template is shown below (you can refer to the sample "MyBaseDao" class).

#region using
// System~
using System;
~
using Touryo.Infrastructure.Business.Util;
#endregion
namespace Touryo.Infrastructure.Business.Dao
{
 /// <summary>
 /// Data access parent class 2 (template)
 /// </summary>
 public abstract class MyBaseDao : BaseDao
 {
 }
}

Figure 4.1 Implementation template of the "data access parent class 2"

4.2 Implementing "start and end processing of data access processing"

"Start and end processing of data access processing" must be implemented. Override the "UOC_PreQuery" and "UOC_AfterQuery" methods in the "data access parent class 2" and implement measuring processing time, SQL trace log output, error log output, exception replacement, etc.

/// <summary>Common UOC method that implements the SQL execution start processing</summary>
protected override void UOC_PreQuery()
{
 // Implement the SQL execution start processing.
 //TODO:
}
/// <summary>Common UOC method that implements the SQL execution end processing (normal case)</summary>
/// <param name="sql">Information of the executed SQL</param>
protected override void UOC_AfterQuery(string sql)
{
 // Implement the SQL execution end processing (normal case).
 //TODO:
}
/// <summary>Common UOC method that implements the SQL execution end processing (abnormal case)</summary>
/// <param name="sql">Information of the executed SQL</param>
/// <param name="ex">Error information</param>
protected override void UOC_AfterQuery(string sql, Exception ex)
{
 // Implement the SQL execution end processing (abnormal case).
 //TODO:
}

Figure 4.2 Implementation example of "start and end processing of data access processing"

5. P layer framework

5.1 Preparing the "screen code parent class 2"

The "screen code parent class 2" can implement the following common P layer processing.

Table 5.1 Common P layer processing that can be implemented in the "screen code parent class 2"

No. Processing Method Section
1 Initial processing (page load processing) UOC_CMNFormInit, UOC_CMNFormInit_PostBack (custom authentication, authority check, blockade check, cache invalidation setting, page title setting, access log output, etc.) Section 5.1.1
2 Pre- and post-processing of P layer event processing: start processing UOC_PreAction (measuring processing time, outputting access logs, etc.) Section 5.1.2
3 End processing UOC_AfterAction (measuring processing time, outputting access logs, etc.) Section 5.1.2
4 Screen transition UOC_Screen_Transition (defines the screen transition method) Section 5.1.3
5 End processing 2 UOC_Finally (final processing, etc.) -
6 Exception handling UOC_ABEND (message editing, common message display, access log and error log output, etc.) Section 5.1.4
7 Common P layer event processing of controls on the master page UOC_(master page file name)(control name)(event name) Section 5.2.2

Basically, one "screen code parent class 2" is created per system. The implementation template is shown below (you can refer to the sample "MyBaseController" class).

#region using
// System~
using System;
~
using Touryo.Infrastructure.Business.Util;
#endregion
namespace Touryo.Infrastructure.Business.Presentation
{
 /// <summary>
 /// Screen code parent class 2
 /// </summary>
 public abstract class MyBaseController : BaseController
 {
 }
}

Figure 5.1 Implementation template of the "screen code parent class 2"

5.1.1 Implementing "page load processing"

"Page load processing" must be implemented. Override the "UOC_CMNFormInit" and "UOC_CMNFormInit_PostBack" methods in the "screen code parent class 2", and, distinguishing the first load from postbacks, implement custom authentication, authority check / blockade check, cache invalidation setting, page title setting, access log output, etc.

/// <summary>UOC method for page load (common: first load)</summary>
/// <remarks>Must be implemented</remarks>
protected override void UOC_CMNFormInit()
{
 // Implement the processing to run at form initialization (first load)
 // TODO:
}
/// <summary>UOC method for page load (common: postback)</summary>
/// <remarks>Must be implemented</remarks>
protected override void UOC_CMNFormInit_PostBack()
{
 // Implement the processing to run at form initialization (postback)
 // TODO:
}

Figure 5.1.1 Implementation example of "page load processing"

5.1.2 Implementing "start and end processing of P layer event processing"

"Start and end processing of P layer event processing" must be implemented. Override the "UOC_PreAction" and "UOC_AfterAction" methods in the "screen code parent class 2" and implement measuring processing time, access log output, etc.

#region UOC methods for start and end processing of the framework's target control events
/// <summary>Implements the start processing of the framework's target control events</summary>
/// <param name="fxEventArgs">Common argument of the event handler</param>
protected override void UOC_PreAction(FxEventArgs fxEventArgs)
{
 // Implement the start processing of the framework's target control events
 // TODO:
}
/// <summary>Implements the end processing of the framework's target control events</summary>
/// <param name="fxEventArgs">Common argument of the event handler</param>
protected override void UOC_AfterAction(FxEventArgs fxEventArgs)
{
 // Implement the end processing of the framework's target control events
 // TODO:
}
#endregion

Figure 5.1.2 Implementation example of "start and end processing of P layer event processing"

5.1.3 Implementing "screen transition processing"

"Screen transition processing" must be implemented.

Override the "UOC_Screen_Transition" method in the "screen code parent class 2".

  • This UOC method is called by the framework with the URL (path) returned by the P layer event processing specified as the argument.

  • By implementing a method that transitions screens using this URL (path), the screen transition method can be unified across the whole system.

  • Note that the screen transition control function provided by the framework can be used for screen transitions (see the "Individual functions edition" for details).

  • When using the screen transition control function

    • ScreenTransition method
    • TransitionMethod property
  • When not using the screen transition control function

    • FxTransfer method
    • FxRedirect method
#region Screen transition methods
/// <summary>Implements the screen transition processing after the end of a button click event</summary>
/// <param name="url">URL when transitioning screens</param>
protected override void UOC_Screen_Transition(string url)
{
  // If url is empty, it does not transition anywhere and becomes a postback.
  if (url == "")
  {
    // Do nothing.
  }
  else
  {
    if (MyBaseController.TransitionMethod == FxLiteral.OFF)
    {
      // When not using the screen transition control component
      // Get the screen transition method (parameter for the test programs)
      string screenTransitionMethod =
      GetConfigParameter.GetConfigValue("ScreenTransitionMethod");
      if (screenTransitionMethod == "1")
      {
        // Screen transition under the framework's management (Transfer)
        this.FxTransfer(url);
      }
      else if (screenTransitionMethod == "2")
      {
        // Screen transition under the framework's management (Redirect)
        this.FxRedirect(url);
      }
      else
      {
        // Parameter specification mistake
      }
    }
    else
    {
      // Transition the screen using the screen transition control component
      this.ScreenTransition(url);
    }
  }
}
#endregion

Figure 5.1.3 Implementation example of "screen transition processing"

5.1.4 Implementing "exception handling"

"Exception handling" must be implemented. Override the following three "UOC_ABEND" methods in the "screen code parent class 2".

Table 5.1.4-a The three "UOC_ABEND" methods that can be implemented in the "screen code parent class 2"

No. Corresponding exception Method signature
1 Business exception UOC_ABEND(BusinessApplicationException baEx, FxEventArgs fxEventArgs)
2 System exception UOC_ABEND(BusinessSystemException bsEx, FxEventArgs fxEventArgs)
3 Other general exceptions UOC_ABEND(Exception ex, FxEventArgs fxEventArgs)

In these UOC methods, distinguish the kinds of exceptions and implement message editing, common message display, access log output, error log output, etc.

  • Exception handling of business exceptions: The exception is not rethrown after processing. "Message editing" and "common message display" using the "business exception" can be implemented.
// <summary>Implements the processing when a business exception occurs</summary>
/// <param name="baEx">BusinessApplicationException</param>
/// <param name="fxEventArgs">Common argument of the event handler</param>
protected override void UOC_ABEND(BusinessApplicationException baEx, FxEventArgs fxEventArgs)
{
 // Implement the processing when a business exception occurs
 // TODO:
}

Figure 5.1.4-1 Implementation example of "exception handling of business exceptions"

  • Exception handling of system exceptions: The "system exception" is rethrown after processing. "Error log output" can be implemented (the error message display processing is implemented in the "common error screen display processing").
/// <summary>Implements the processing when a system exception occurs</summary>
/// <param name="bsEx">BusinessSystemException</param>
/// <param name="fxEventArgs">Common argument of the event handler</param>
protected override void UOC_ABEND(BusinessSystemException bsEx, FxEventArgs fxEventArgs)
{
 // Implement the processing when a system exception occurs
 // TODO:
}

Figure 5.1.4-2 Implementation example of "exception handling of system exceptions"

  • Exception handling of other general exceptions: Rethrown after processing. "Error log output" can be implemented.
/// <summary>Implements the processing when a general exception occurs</summary>
/// <param name="ex">Exception object</param>
/// <param name="fxEventArgs">Common argument of the event handler</param>
protected override void UOC_ABEND(Exception ex, FxEventArgs fxEventArgs)
{
 // Implement the processing when a general exception occurs
 // TODO:
}

Figure 5.1.4-3 Implementation example of "exception handling of other general exceptions"

  • Implementing the "common error screen display processing": For the "common error screen display processing" called from the aforementioned "exception handling of system exceptions" and "exception handling of other general exceptions", you can refer to the sample "TransferErrorScreen" method.
/// <summary>Transitions to the error screen when an exception occurs</summary>
private void TransferErrorScreen(Exception ex) {
  if (this.AjaxExtensionStatus == FxEnum.AjaxExtStat.IsAjaxExtension){
    // In the case of Ajax Extension, do not return the error screen!
    throw ex;
  }
  else if (this.IsClientCallback) {
    // In the case of Client Callback, do not return the error screen!
    throw ex;
  }
  else {
    #region Determine the exception type and get the error message ID
    // Error message
    string err_msg;
    // Get the error information from the session
    string err_info;
    // Error type
    string[] arrErrType = ex.GetType().ToString().Split('.');
    string errType = arrErrType[arrErrType.Length - 1];
    // Error message ID
    string errMsgId = "";
    if (errType == "BusinessSystemException") {
      // System exception
      BusinessSystemException bsEx = (BusinessSystemException)ex;
      errMsgId = bsEx.messageID;
    }
    else if (errType == "FrameworkException") {
      // Framework exception
      FrameworkException fxEx = (FrameworkException)ex;
      errMsgId = fxEx.messageID;
    }
    else {
      // Other exceptions
      errMsgId = "-";
    }
    #endregion
    #region Added processing to make business continuable without releasing the session on error.
    // Illegal operation error
    if (errMsgId == "IllegalOperationCheckError") {
      // Do not clear the session
      HttpContext.Current.Items.Add(FxHttpContextIndex.SESSION_ABANDON_FLAG, false);
    }
    else {
      // Clear the session
      HttpContext.Current.Items.Add(FxHttpContextIndex.SESSION_ABANDON_FLAG, true);
    }
    #endregion
    #region Create the error information to display on the error screen
    err_msg = System.Environment.NewLine +
    "Error message ID: " + errMsgId + System.Environment.NewLine +
    "Error message: " + ex.Message.ToString();
    err_info = System.Environment.NewLine +
    "Target URL: " + Request.Url.ToString() + System.Environment.NewLine +
    "Stack trace:" + ex.StackTrace.ToString() + System.Environment.NewLine +
    "Exception.ToString():" + ex.ToString();
    // To output the Form information, change the transition method to Server.Transfer.
    // Also, change the information passing to HttpContext.
    HttpContext.Current.Items.Add(FxHttpContextIndex.SYSTEM_EXCEPTION_MESSAGE, err_msg);
    HttpContext.Current.Items.Add(FxHttpContextIndex.SYSTEM_EXCEPTION_INFORMATION, err_info);
    #endregion
    // Get the path to the error screen --- No check needed (already checked in the base class)
    string errorScreenPath = GetConfigParameter.GetConfigValue(FxLiteral.ERROR_SCREEN_PATH);
    // Transition to the error screen
    Server.Transfer(errorScreenPath);
  }
}

Figure 5.1.4-4 Implementation example of the "common error screen display processing"

For exceptions that escape up to ASP.NET, the exception can also be caught in the "Application_Error" event handler of "Global.asax" to launch the "common error screen".

  • "Common error screen": For development, the "common error screen for development" can use "ErrorScreen.aspx", "ErrorScreen.aspx.cs" and "Aspx_Common_ErrorScreen" attached to the samples as they are.
Figure 5.1.4-5 "Common error screen for development"

This "common error screen for development" is designed to make debugging easy, for example by outputting the message ID and message of the exception, the target URL and stack trace, the keys and values of the Form information contained in the HTTP request, and the keys and values of the Session information contained in the HTTP session. When moving to the production environment, this "common error screen display processing" must be modified to replace the "common error screen for development" with the "common error screen for production" [9] (be careful not to break the infrastructure processing).

/// <summary>Event handler executed when the screen starts</summary>
protected void Page_Load(object sender, EventArgs e) {
  // Display the error message and error information on the screen----------------------------
  // Get the error message from the HTTP context
  // Get the error information from the HTTP context
  // Display the error message on the screen
  // Display the error information on the screen
  // ------------------------------------------------------------------------
  // Display the form information on the screen--------------------------------------------
  // Display the session information on the screen------------------------------------------
  // ------------------------------------------------------------------------
  // Delete the session information------------------------------------------------
  if ((bool)HttpContext.Current.Items[FxHttpContextIndex.SESSION_ABANDON_FLAG]) {
    // Erase the cookie for session timeout detection
    // ※ Because Remove does not work properly, setting the value to an empty string = erasing
    // Respond with the Set-Cookie HTTP header
    Response.Cookies.Set(FxCmnFunction.DeleteCookieForSessionTimeoutDetection());
    try {
      // Erase the session
      Session.Abandon();
    }
    catch (Exception ex2) {
      // When an error occurs
      // If execution passes through this coverage,
      // the path of the launched screen is probably wrong.
    }
  }
}

Figure 5.1.4-6 "Code-behind of the error screen"

  • Where to implement the common processing that generates and displays messages for users is summarized in Table 5.1.4-b below.

Table 5.1.4-b Where to implement the common processing that generates and displays messages for users

No. Exception Message content / implementation location
1 Business exception Messages for retryable exceptions (output to the business screen). The UOC method for "exception handling of business exceptions" in the "screen code parent class 2".
2 System exception Messages for non-retryable exceptions (output to the common error screen). The "TransferErrorScreen" method of "MyBaseController", the "Application_Error" event handler of "Global.asax" and the "common error screen".
3 Other general exceptions Messages for non-retryable exceptions (output to the common error screen). The "TransferErrorScreen" method of "MyBaseController", the "Application_Error" event handler of "Global.asax" and the "common error screen".

To implement the common processing that generates and displays messages, use the "GetMessage" class of the [Touryo].Infrastructure.Framework.Util namespace provided as the message acquisition function (see the "Individual functions edition" for details).

5.2 Preparing the "master page"

A "master page" is created to extract the common design and button layout from each screen and share it. Basically, multiple master pages can be created per system (module names can be changed).

5.2.1 Implementing the "master page"

The implementation template of the "master page" is shown below. Master pages can be nested, but the root master page must always be implemented as follows (the number and placement of ContentPlaceHolders can be changed freely by the user).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
 <title>Untitled Page</title>
 
 <!-- Set up links to the JavaScript required by the framework, JavaScript files, project-common CSS files, etc.-->
 
 <!--FxCode: add-start-->
 <script type="text/javascript" src="/(site name)/Framework/js/common.js"></script>
 <script type="text/javascript" src="/(site name)/Framework/js/ie_key_event.js"></script>
 
 <!-- Disable the onhelp event.-->
 <script language="javascript" for="document" event="onhelp">
   event.returnValue = false;
 </script>

 <link rel="stylesheet" href="/(site name)/Css/style.css" type="text/css"/>
 <!--FxCode: add-end-->
</head>

<!--FxCode: add-js-event--><!-- Set up the JavaScript events required by the framework.-->
<body onload=" Fx_Document_OnLoad();" onunload="Fx_Document_OnClose();">

 <!-- Specify autocomplete -->
 <form id="form1" runat="server" autocomplete="on">

 <!--SampleCode: add-start-->
 <!--SampleCode: Contents--><!-- Define the ContentPlaceHolder.-->
 <asp:contentplaceholder id="ContentPlaceHolderA" runat="Server">
 This is Default Content -- Override on Page
 </asp:contentplaceholder>
 <!--SampleCode: add-end-->
 
 <!--FxCode: add-start--><!-- Set up the Hidden fields required by the framework.-->
 <asp:HiddenField ID="ChildScreenType" runat="server" Value="0" />
 <asp:HiddenField ID="ChildScreenUrl" runat="server" Value="0" />
 <asp:HiddenField ID="CloseFlag" runat="server" Value="0" />
 <asp:HiddenField ID="SubmitFlag" runat="server" Value="0" />
 <asp:HiddenField ID="ScreenGuid" runat="server" Value="0" />
 <asp:HiddenField ID="FxDialogStyle" runat="server" Value="0" />
 <asp:HiddenField ID="BusinessDialogStyle" runat="server" Value="0" />
 <asp:HiddenField ID="NormalScreenStyle" runat="server" Value="0" />
 <asp:HiddenField ID="NormalScreenTarget" runat="server" Value="0" />
 <asp:HiddenField ID="DialogFrameUrl" runat="server" Value="0" />
 <asp:HiddenField ID="WindowGuid" runat="server" Value="0" />
 <asp:HiddenField ID="RequestTicketGuid" runat="server" Value="0" />
 <!--FxCode: add-end-->
 </form>
</body>
</html>

Figure 5.2.1 Implementation template of the "master page" 1

The following is the template of the code-behind file (code file).

Inherit BaseMasterController, which is the "master base page".

using Touryo.Infrastructure.Framework.Presentation;
/// <summary>Blank master page</summary>
protected partial class Aspx_Common_TestBlankScreen : BaseMasterController
{
}

Figure 5.2.1 Implementation template of the "master page" 2

5.2.2 Implementing "common event processing of controls on a master page"

To implement the "common event processing of controls on a master page", follow these steps.

  1. Place a control ([prefix] + any string) on the "master page".
  2. Implement the UOC methods.
    • Implement the UOC method UOC_(master page file name)_[prefix]anyString_(event name) in the "screen code parent class 2".
    • Implement the UOC method UOC_[prefix]anyString_(event name) on the "master page".
  • Placing a control on the "master page" (example when the custom button control is selected)
<cc1:WebCustomButton ID="btnMasterCommon" runat="server" Text="Master common button" Width="220px" /><br />

Figure 5.2.2-1 Implementation example of a control on the "master page"

  • Implementing the UOC methods: The signature of the event handler of a control event is protected string eventHandlerName(FxEventArgs fxEventArgs). As an exception, the GridView RowUpdating / RowDeleting / PageIndexChanging / Sorting events take the original EventArgs as another event argument, and the signature becomes protected string eventHandlerName(FxEventArgs fxEventArgs, EventArgs e).
    • Implement the UOC method in the "screen code parent class 2" (when the master page file name = "TestScreen.master")

Implement the event processing. ※ If a URL is returned, the screen transitions. ※ If an empty string is returned, it does not transition and becomes a postback.

The UOC method is called by late binding from the common event handler, so it must be defined as "public" or "protected" ("private" in aspx.cs(vb) is special and cannot be late-bound).

protected string UOC_TestScreen_btnMasterCommon_Click(FxEventArgs fxEventArgs)
{
 // TODO:
 // For a postback without screen transition, set the url to an empty string
 return "";
}

Figure 5.2.2-2 Implementation example of an event handler in the "screen code parent class 2"

  • Implement the UOC method on the "master page"

Here the master page name is not needed in the method name.

protected string UOC_btnMasterCommon_Click(FxEventArgs fxEventArgs)
{
 // TODO:
 // For a postback without screen transition, set the url to an empty string
 return "";
}

Figure 5.2.2-3 Implementation example of an event handler on the "master page"

5.3 Preparing the "user control"

A "user control" is created to extract the common design and button layout from each screen and share it. Basically, multiple user controls can be created per system (module names can be changed).

5.3.1 Implementing "common event processing of controls on a user control"

Follow these steps.

  1. Place a control ([prefix] + any string) on the "user control".
  2. Implement the UOC methods.
    • Implement the UOC method UOC_(user control name)_[prefix]anyString_(event name) in the "screen code parent class 2".
    • Implement the UOC method UOC_[prefix]anyString_(event name) on the "user control".
  • Placing a control on the "user control" (example when the custom button control is selected)
<cc1:WebCustomButton ID="btnControlCommon" runat="server" Text="UC common button" Width="220px" /><br />

Figure 5.3.1-1 Implementation example of a control on the "user control"

  • Implementing the UOC methods (the signature is the same as in 5.2.2)
    • Implement the UOC method in the "screen code parent class 2" (when the user control name = "sampleControl1")

Implement the event processing. ※ If a URL is returned, the screen transitions. ※ If an empty string is returned, it does not transition and becomes a postback.

The UOC method is called by late binding from the common event handler, so it must be defined as "public" or "protected" ("private" in aspx.cs(vb) is special and cannot be late-bound).

protected string UOC_sampleControl1_btnControlCommon_Click(FxEventArgs fxEventArgs)
{
 // TODO:
 // For a postback without screen transition, set the url to an empty string
 return "";
}

Figure 5.3.1-2 Implementation example of an event handler in the "screen code parent class 2"

  • Implement the UOC method on the "user control"

Here the user control name is not needed in the method name.

protected string UOC_btnMasterCommon_Click(FxEventArgs fxEventArgs)
{
 // TODO:
 // For a postback without screen transition, set the url to an empty string
 return "";
}

Figure 5.3.1-3 Implementation example of an event handler on the "user control"

6. Others

6.1 Message IDs and message definition classes for exception classes

The system-specific exceptions are the "business exception" and "system exception", and the kinds of these exceptions are defined by message IDs and messages rather than by deriving classes. To define kinds of exceptions, create the "MyBusinessApplicationExceptionMessage" class for "business exceptions" and the "MyBusinessSystemExceptionMessage" class for "system exceptions" in the [Touryo].Infrastructure.Business namespace, and define the message IDs and messages in them.

Each time a kind of exception is added, define the corresponding message ID and message.

namespace Touryo.Infrastructure.Business.Exceptions
{
  /// <summary>Constant class that defines the string constants used for
  /// the message ID and message of business exceptions (for users)</summary>
  public class MyBusinessApplicationExceptionMessage
  {
    /// <summary>
    /// String constants used for the message ID and message of a sample business exception
    /// </summary>
    public static readonly string[] SAMPLE_ERROR = new string[] { "MessageID_SampleError", "Message_SampleError" };
  }
}

Figure 6.1-1 Class that defines the message IDs and messages of "business exceptions"

// xxx error
throw new BusinessApplicationException(
 MyBusinessApplicationExceptionMessageMessage.SAMPLE_ERROR[0],
 MyBusinessApplicationExceptionMessageMessage.SAMPLE_ERROR[1]);

Figure 6.1-2 Throwing a "business exception"

Each time a kind of exception is added, define the corresponding message ID and message.

namespace Touryo.Infrastructure.Business.Exceptions
{
  /// <summary>Constant class that defines the string constants used for
  /// the message ID and message of system exceptions (for users)</summary>
  public class MyBusinessSystemExceptionMessage
  {
    /// <summary>
    /// String constants used for the message ID and message of a sample system exception
    /// </summary>
    public static readonly string[] SAMPLE_ERROR
    = new string[] { "MessageID_SampleError", "Message_SampleError" };
  }
}

Figure 6.1-3 Class that defines the message IDs and messages of "system exceptions"

// xxx error
throw new BusinessSystemException(
 MyBusinessSystemExceptionMessage.SAMPLE_ERROR[0],
 MyBusinessSystemExceptionMessage.SAMPLE_ERROR[1]);

Figure 6.1-4 Throwing a "system exception"

To manage messages in an external file, use the "message acquisition function" together (see the "Individual functions edition" for details).

6.2 Loading dialog during double submission prevention

When the double submission prevention function is enabled and there is no response for the specified time or longer after a postback, the following loading dialog is displayed.

Figure 6.2 Loading dialog

To change the wait time until this loading dialog is displayed, its UI (appearance), etc., the JavaScript file must be modified directly. The places to modify are shown below.

Table 6.2 Changes to the loading dialog display and the corresponding places to modify

No. Change File / place to modify
1 Wait time until display ~\root\programs\C#\Samples\WebApp_sample\WebForms_Sample\Framework\Js\common.js. The parameter (milliseconds) specified for the setTimeout method in the Fx_OnSubmit method. Also, if the Fx_DisplayProgressDialog method is not set, the loading dialog is no longer displayed.
2 UI (appearance) ~\root\programs\C#\Samples\WebApp_sample\WebForms_Sample\Framework\Js\common.js. Various properties of the DIV element generated in the Fx_InitProgressDialog method.

6.3 Customizing the key event suppression function

The key event suppression function is enabled automatically by linking to ie_key_event.js. It implements suppression of submitting with Enter, disabling back navigation with BackSpace, disabling back navigation with alt key + ← / →, suppression of right-click (context menu display), and a map (template) between shortcut / function keys and buttons on the screen. To suppress right-click or map shortcut / function keys, modify (customize) the JavaScript file directly.

Table 6.3 Places to modify for the key event suppression function

No. Change File / place to modify
1 Suppress right-click (context menu display) ~\root\programs\C#\Samples\WebApp_sample\WebForms_Sample\Framework\Js\ie_key_event.js. Uncomment the code below the part commented "Suppress right-click (context menu display)".
2 Map shortcuts and PF keys to buttons on the screen ~\root\programs\C#\Samples\WebApp_sample\WebForms_Sample\Framework\Js\ie_key_event.js. Add the implementation to the code (template) below the comment (the "implementation template for mapping a PF key to a button on the screen" and the "implementation template for an original shortcut (ctrl + shift + ○ key)").

7. Adding controls (events) supported by P layer event processing

As described in the "Common edition", the P layer event processing function of this framework supports the events (nine) of the following controls [10].

Table 7 Control events supported by the P layer event processing function

No. Control Event
1 Button Click event
2 LinkButton
3 ImageButton
4 ImageMap
5 TextBox TextChanged event
6 DropDownList SelectedIndexChanged event
7 ListBox
8 RadioButton CheckedChanged event
9 RadioButtonList SelectedIndexChanged event
10 CheckBoxList
11 Repeater ItemCommand event
12 GridView RowCommand / SelectedIndexChanged / RowUpdating / RowDeleting events
13 ListView PagePropertiesChanged / ItemUpdating / ItemDeleting / ItemCommand events

However, some projects use more events than the above. To add events, implement extension processing of the P layer event processing function in the "screen code parent class 2" of the business framework (Business) namespace (you can refer to the sample "MyBaseController" class. The sample supports the CheckedChanged event of the CheckBox control).

First, from the "page load processing" of the "screen code parent class 2", call the "addControlEvent" method of the "MyBaseController" class for "event addition processing" in the following sequence.

Figure 7-1 Calling "event addition processing" from the "page load processing" of the "screen code parent class 2"

The "addControlEvent" method needs an implementation that calls the "GetCtrlAndSetClickEventHandler" method of the "MyCmnFunction" class (the latest version uses the "GetCtrlAndSetClickEventHandler2" method). The following is an example of processing that adds the CheckedChanged event of the CheckBox control to the control events supported by the P layer event processing function.

First, a "common (aggregated) event handler" is needed for each control event. If it exists in the "BaseController" class it can be reused, but if it does not exist, the following implementation is needed in the "MyBaseController" class.

Currently, the aggregated event handler for the CheckedChanged event is implemented as standard on the BaseController side.

#region Aggregated event handlers
/// <summary> Aggregated event handler for the CheckedChanged event</summary>
protected void Check_CheckedChanged(object sender, System.EventArgs e) {
 // Create the common argument of the event handler
 FxEventArgs fxEventArgs = new FxEventArgs(
 ((System.Web.UI.Control)(sender)).ID,
 0, 0, "",
 this.GetMethodName(((System.Web.UI.Control)(sender)).ID,
 FxLiteral.UOC_METHOD_FOOTER_CHECKED_CHANGED));
 // Common method for click event processing
 this.CMN_Event_Handler(fxEventArgs);
}
#endregion

Figure 7-2 Implementation example of a "common (aggregated) event handler"

Here, the "common argument of the event handler" to pass to the "common method of event processing" and the "UOC method of event processing" is created, and the "common method of event processing" of the "screen code parent class 1" (the "CMN_Event_Handler" method of the "BaseController" class) is called. The rest of the processing is handled by the framework, so P layer event processing can be implemented and processed in the same way as for events of existing controls.

To add more control events, implement the processing by referring to the code above.

/// <summary>Event addition processing</summary>
private void addControlEvent() {
 // CHECK BOX
 MyCmnFunction.GetCtrlAndSetClickEventHandler(
 this, GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX),
 new System.EventHandler(this.Check_CheckedChanged), this.ControlHt);
 ・・・
}

Figure 7-3 Implementation example of "event addition processing" (1)

When using the "GetCtrlAndSetClickEventHandler2" method, the implementation is as follows.

To add more control events, implement the processing by referring to the "// CHECK BOX" code.

/// <summary>Event addition processing</summary>
private void addControlEvent() {
 // Prefix
 string prefix = "";
 // Create a dictionary of prefixes and event handlers
 Dictionary<string, object> prefixAndEvtHndHt = new Dictionary<string, object>();
 // CHECK BOX
 prefix = GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX);
 if (!string.IsNullOrEmpty(prefix)) {
 prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Check_CheckedChanged));
 }
 ・・・
 // Search for controls & set event handlers
 MyCmnFunction.GetCtrlAndSetClickEventHandler2(this, prefixAndEvtHndHt, this.ControlHt);
}

Figure 7-3 Implementation example of "event addition processing" (2)

The "GetCtrlAndSetClickEventHandler" method of the "MyCmnFunction" class called from here recursively gets the controls on the page and registers them with the "common (aggregated) event handler" corresponding to the event.

To add more control events, implement the processing by referring to the following "if - else if" code block.

/// <summary>Get controls & set event handlers</summary>
internal static void GetCtrlAndSetClickEventHandler(
Control ctrl, string prefix, object eventHandler, Hashtable ControlHt) {
  [Check processing]
  #region Get controls & set event handlers
  // Omitted ~
  // Set the event handler.
  if (prefix == GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX)) {
    // CHECK BOX
    CheckBox checkBox = null;
    try {
      // Can be cast
      checkBox = (CheckBox)ctrl;
    }
    catch (Exception ex) {
      // Cannot be cast
      throw new FrameworkException(
      FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
      String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1], prefix, ctrl.GetType().ToString()), ex);
    }
    checkBox.CheckedChanged += (EventHandler)eventHandler;
    // Store in the dictionary
    // ControlHt.Add(ctrl.ID, ctrl);
    ControlHt[ctrl.ID] = ctrl; // 2009/08/10 - this line
  }
  else if
  ・・・
  // Omitted ~
  #endregion
  [Recursion]
}

Figure 7-4 Implementation example of "event addition processing" (1)

The "GetCtrlAndSetClickEventHandler2" method needs an implementation like the following.

To add more control events, implement the processing by referring to the following "if - else if" code block.

/// <summary>Get controls & set event handlers</summary>
internal static void GetCtrlAndSetClickEventHandler(
Control ctrl, string prefix, object eventHandler, Hashtable ControlHt) {
  [Check processing]
  #region Get controls & set event handlers
  // Omitted ~
  // Set the event handler.
  if (prefix == GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_BUTTON)) {
    // BUTTON
    Button button = null;
    if(ctrl is Button) {
      // Can be cast
      button = (Button)ctrl;
    }
    else {
      // Cannot be cast
      throw new FrameworkException(
      FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
      String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
      prefix, ctrl.GetType().ToString()));
    }
    button.Click += (EventHandler)eventHandler;
    // Store in the dictionary
    controlHt[ctrl.ID] = ctrl;
    reak;
  }
  else if
  ・・・
  // Omitted ~
  #endregion
  [Recursion]

Figure 7-4 Implementation example of "event addition processing" (2)

Footnotes

  1. Write a link to the app.config file (<appSettings file="app.config">).
  2. Double submission prevention function.
  3. Maximum number of operation histories per screen for the illegal operation prevention function.
  4. Example of appender definitions in the log4net configuration file.
  5. 3-tier application (via the service interface).
  6. Rolls every 10MB in size and keeps two backups.
  7. When rolling by both date and size, take care with the DatePattern value.
  8. Logs may be lost when there is much contention.
  9. In the production environment, replace the "common error screen for development" with the "common error screen for production".
  10. See also section 2.2.4 of the "Common edition".

-End-

Clone this wiki locally