Repository navigation
UserGuide_BetterUse&FAQ
This is a English page.
Click here for Japanese version of this file.
Updated in July 2026
- SEs and developers who develop applications with Open Touryo
This document summarizes better use of the framework.
Company names and product names in this document are trademarks or registered trademarks of their respective companies.
5. ASP.NET Mobile Web development
- B layer for event processing: Basically create one per screen. It is good to use the control name as the method name for each event processing. (Figure 1.1.1)
- B layer for common components: Basically create one per system, or one per category of common components. It is good to use the category name as the method name. (Figure 1.1.2)
Figure 1.1.1 Example of splitting B layer classes (event processing)
Figure 1.1.2 Example of splitting B layer classes (common components)
- For event processing: Basically create one per screen, and for complex screens with many events it is good to create several classes.
- For common components: Basically create one per category of common components, or one per common component.
It is good to follow the criteria below for creating D layer (Dao) classes.
- Use an individual Dao class: If an intelligent D layer class [1] is needed, implement a "custom Dao class" for each function.
- Use a general-purpose Dao class: For SQL that can be executed by simply setting the input parameters as they are, use the "common Dao class" that has a general-purpose interface (see section 4.6).
- Use an automatically generated Dao class: Generate table-level CRUD components with the D layer automatic generation tool and use these "automatically generated Dao classes" for update processing.
- When consolidating: A "Dao consolidation class" that consolidates and uses the "common Dao class" and "automatically generated Dao classes" from the B layer is also possible. The "data access control class" must be passed on.
/// <summary>Example of the base class of a Dao consolidation class</summary>
public class BaseConsolidateDao {
/// <summary>Data access control class</summary>
private BaseDam _dam;
/// <summary>Data access control class</summary>
protected BaseDam Dam {
get { return this._dam; }
}
/// <summary>Constructor</summary>
/// <param name="dam">Data access control class</param>
public BaseConsolidateDao(BaseDam dam) {
this._dam = dam;
}
}Figure 1.3 Example of the base class of a Dao consolidation class
- 2.1 Events not covered by P layer event processing: Server-side events by ClientCallback, etc. In this case, call the B layer and D layer directly from the event processing (the error handling, transaction management and log output of the B layer work normally).
- 2.2 Adding control events covered by P layer event processing: By reusing the sample, it can be used with support for the CheckedChanged event of the CheckBox control.
-
2.3 Localizing the illegal operation prevention function: The
CanCheckIllegalOperationflag allows localization per page or per button.
/// <summary>Localizing the illegal operation prevention function</summary>
void Page_Init(object sender, EventArgs e) {
foreach (string key in Request.Form.Keys) {
if (key.IndexOf("btnIllegalOperationCheckOFF") != -1) {
// When submitted by the btnIllegalOperationCheckOFF button,
// turn the illegal operation prevention function OFF.
this.CanCheckIllegalOperation = false;
}
}
}Figure 2.3-1 Example of localizing the illegal operation prevention function. How to disable it only for some buttons; useful for postback download processing, etc.
/// <summary>Localizing the illegal operation prevention function</summary>
void Page_Init(object sender, EventArgs e) {
// Turn the illegal operation prevention function ON only for this screen (*.config is set to OFF).
this.CanCheckIllegalOperation = true;
foreach (string key in Request.Form.Keys) {
if (key.IndexOf("btnIllegalOperationCheckON") != -1) {
// When submitted by the btnIllegalOperationCheckON button,
// turn the illegal operation prevention function ON.
this.CanCheckIllegalOperation = true;
}
}
}Figure 2.3-2 Example of localizing the illegal operation prevention function. How to enable it only for some buttons; useful when you want to apply it only to update buttons, etc.
- 2.4 Temporarily disabling the "Please wait" dialog: For postback download processing, etc., suppress it by implementing JavaScript on the postback button that performs the download.
<cc1:WebCustomButton ID="btnButton33" runat="server"
Text="Download" Width="220px" OnClientClick="IsDownload = true;" />Figure 2.4 Example of temporarily disabling the "Please wait" dialog
- 2.5 Download processing to an IFRAME (temporarily disabling the double submission prevention function): When downloading to an IFRAME, if operations continue to be suppressed by the "double submission prevention function", implement processing to cancel it temporarily.
this.Form.Attributes.Remove("onSubmit");Figure 2.5 Temporarily disabling the double submission prevention function
-
2.6 How to delete a session: When using the "session timeout detection function", calling
Session.Abandon()always causes a session timeout exception. To avoid the exception, usethis(BaseController).FxSessionAbandon(), which deletes the detection cookie [2] before releasing the session. However, a postback on the same screen after execution causes an "illegal operation prevention function" error, so after releasing the session, transition to the menu screen, etc. by a GET.
this.FxSessionAbandon(); // Deletes the cookie for session timeout detection and then releases the session.Figure 2.6 How to delete a session
Table 2.7 Recommended methods for download processing (FAQ excerpt)
| No. | Problem | Solution |
|---|---|---|
| 1 | After downloading a file, the Loading... dialog does not disappear. | Caused by the JavaScript Loading... dialog display function. Disable this function with JavaScript before the download (the latest version can temporarily disable it with a flag; see section 2.4). Alternatively, respond with the file to a request from another window / IFRAME (EnableViewState=False). |
| 2 | An illegal operation exception occurs for operations after the download. | Caused by the illegal operation prevention function. Disable it in the config settings (the latest version can localize it with a page property; see section 2.3). Alternatively, use another window / IFRAME. |
| 3 | When downloading by clicking Yes/No in the Yes/No dialog, the Yes/No event handler also runs on the next PostBack. | Occurs because the Submit flag is not updated. Use another window / IFRAME (the Submit flag can be used to localize the illegal operation prevention function). |
| 4 | After the download, the file cannot be opened with an arbitrary application. | The HTTP header that disables caching may have been added. Before the download, clear the HTTP headers with Response.Clear() and then set the cache control HTTP headers again. |
| 5 | After updating an IFRAME, the parent screen of the IFRAME can no longer be operated. | Caused by the double submission prevention function continuing to suppress operations because readyState becomes interactive instead of complete. Can be handled with the method in section 2.5. |
| 6 | A postback occurs when displaying another window / dialog. | By specification, a flag is set with ShowNormalScreen() / ShowModalScreen() and launched from the client side. The latest version adds GetScriptToShowNormalScreen() / GetScriptToShowModalScreen(), which launch directly from client-side JS. |
For manual transaction management, or when a second connection is needed in 2-tier C/S, manually create the data access control class (Dam) and manage the connection and transaction. try...catch...finally may be used for the release processing of the transaction and connection (the CommitTransaction and ConnectionClose methods), but when they are released normally by GC, the transaction is rolled back and the connection is closed (or returned to the connection pool).
/// <summary>Implements the business processing</summary>
/// <param name="testParameter">Parameter class</param>
private void UOC_methodName(TestParameterValue testParameter)
{
// A type derived from BaseParameterValue can be defined for the method argument.
// Create the return value class and set it as the return value in advance.
TestReturnValue testReturn = new TestReturnValue();
this.ReturnValue = testReturn;
// ↓Business processing-----------------------------------------------------
// Data access control class (Dam)
// Manually create the Dam for SQL Server / SQL Client
BaseDam dam = new DamSqlSvr();
// Load the connection string
string connstring = GetConfigParameter.GetConnectionString("ConnectionString_SQL");
// Open the connection.
dam.ConnectionOpen(connstring);
// Manual transaction (default isolation level)
dam.BeginTransaction(DbEnum.IsolationLevelEnum.ReadCommitted);
// Individual Dao
LayerD myDao = new LayerD(dam);
//myDao.xxxx(testParameter, ref testReturn);
// Common Dao
CmnDao cmnDao = new CmnDao(dam);
cmnDao.ExecSelectScalar();
// Release the transaction and connection
dam.CommitTransaction();
dam.ConnectionClose();
// ↑Business processing-----------------------------------------------------
}Figure 3.1 Example of manually creating the data access control class (Dam) and managing the connection and transaction
Dynamic parameterized queries are effective for dynamic SQL. Even complex SQL such as conditional search + fuzzy search can easily be handled with an SQL definition (XML) and a program.
<?xml version="1.0" encoding="shift_jis" ?>
<ROOT>
SELECT
A, B, C
FROM T
WHERE
<IF>AND A = @A</IF>
<IF name="A_LIKE">AND A LIKE @LIKE_A</IF>
<IF>AND B = @B</IF>
<IF name="B_LIKE">AND B LIKE @LIKE_B</IF>
<IF>AND C = @C</IF>
ORDER BY <IF name="SEQUENCE">A<ELSE>B</ELSE></IF>
</ROOT>
Figure 4.1-1 SQL definition (XML)' Read from a file
Me.SetSqlByFile2("KO0200_Get_Customer.xml")
' Set parameters
' Parameter A
If PV.A <> "" Then
If PV.A_IsAimai Then
' LIKE prefix match search
Me.SetParameter("LIKE_A", PV.A & "%")
Else
' Normal = exact match search
Me.SetParameter("A", PV.A)
End If
End If
' Parameter B
If PV.B <> "" Then
If PV.B_IsAimai Then
' LIKE prefix match search
Me.SetParameter("LIKE_B", PV.B & "%")
Else
' Normal = exact match search
Me.SetParameter("B", PV.B)
End If
End If
' Parameter C
Me.SetParameter("C", PV.C)
' Sort order
Me.SetParameter("SEQUENCE ", PV.SEQ)
' Get the result set
RV.dt = New DataTable()
Me.ExecSelectFill_DT(RV.dt)Figure 4.1-2 D layer program (VB)
4.2 Dealing with performance degradation caused by "implicit type conversion" when executing parameterized queries
When the "data type of the parameter" in the search condition does not match the "data type of the DB column" [3], the column data is cast to the data type of the parameter before searching ("implicit type conversion"). When this occurs, indexes are not used properly and performance degrades significantly.
SELECT * FROM AAA WHERE BBB = @P1
In this framework, the data type of a parameter can be specified from the SetParameter method, but explicitly specifying the data type is necessary only when "implicit type conversion" occurs. Normally, we recommend not specifying the data type explicitly, and, when performance degradation is confirmed, editing the external SQL file (casting the parameter data type in the SQL) [4].
SELECT * FROM AAA WHERE BBB = CONVERT(varchar, @P1)
※ When the "LIST tag" of the dynamic parameterized query is used, the parameters are expanded automatically, so editing the SQL file cannot address this. In this case, either specify the data type explicitly from the API, or use the "VAL tag" instead of the "LIST tag" and embed as many parameters as needed, each wrapped with the conversion function of the DBMS.
The DataAdapter for batch update automatically generated by the .NET CommandBuilder has problems: it supports only SELECT per table, it cannot identify rows with timestamp mismatches, it includes IDENTITY columns in INSERT, and optimistic locking by comparing all columns causes performance problems. This framework therefore does not support it (it is effective within limited scope such as master maintenance).
Instead, implement batch updates using the AcceptChanges method [5], the RowState property of DataRow (Added / Modified / Deleted) and DataRowVersion.Original [6].
dr["(column name)", DataRowVersion.Original] (dr is a DataRow)
It is even easier with the automatically generated CRUD Dao. The sample is in ~\root\programs\C#\Samples\2CS_sample\DenDaoAndBatUpd_sample. A caution is that on the Web, when editing data across multiple postbacks, the DataSet or DataTable being edited must be kept in Session, etc., so be careful about the consumption of server memory.
This framework can also execute stored procedures. For example, for a "return value", specify ParameterDirection.ReturnValue for the Parameter.Direction property (.Output / .InputOutput for output parameters). In the latest version, parameters can also be obtained with the GetParameter method without directly referencing the command object.
/// <summary>Executes the "sp_help" stored procedure.</summary>
/// <param name="objectName">String to specify for the "objname" parameter of the "sp_help" stored procedure</param>
/// <param name="ds">Result sets returned by the "sp_help" stored procedure (multiple are returned)</param>
/// <returns>Return value of the "sp_help" stored procedure (success: "", failure: "")</returns>
public int sp_help(string objectName, out DataSet ds)
{
// Specify the stored procedure.
this.SetSqlByCommand("sp_help", CommandType.StoredProcedure);
// Set the argument parameters.
this.SetParameter("objname", objectName);
// Set the return value parameter.
this.SetParameter("ret", null, null, -1, ParameterDirection.ReturnValue);
// Execute the stored procedure and return a data reader.
SqlDataReader drd = (SqlDataReader)this.ExecSelect_DR();
// Get the result sets
ds = new DataSet();
// Multiple result sets can be obtained
do
{
// Create a DataTable
DataTable dt = new DataTable();
// Load the result from the data reader
dt.Load(drd);
// Store the DataTable
ds.Tables.Add(dt);
} while (!drd.IsClosed);
// Close the data reader.
drd.Close();
// Get the value of the return value parameter of the stored procedure.
return (int)((DamSqlSvr)this.GetDam()).DamSqlCommand.Parameters["ret"].Value;
}Figure 4.4-1 Sample of executing a stored procedure (example with SqlClient)
This framework can also execute the "array bind [7]" supported by ODP.NET.
// Create the array data
object[] temp1 = new string[] { "aaa", "bbb", "ccc" };
object[] temp2 = new string[] { "aaa", "bbb", "ccc" };
object[] temp3 = new string[] { "aaa", "bbb", "ccc" };
// For ODP.NET array binds, specify ArrayBindCount
((DamOraOdp)this._dam).DamOracleCommand.ArrayBindCount = temp.Length;
// Array bind (type information is required)
((BaseDam)this._dam).SetParameter("P1", temp1, OracleDbType.Varchar2);
((BaseDam)this._dam).SetParameter("P2", temp2, OracleDbType.Varchar2);
((BaseDam)this._dam).SetParameter("P3", temp3, OracleDbType.Varchar2);Figure 4.5 Sample of executing an array bind (ODP.NET)
How to get the Dam: ((DamOraOdp)this.GetDam()) in the B layer, ((DamOraOdp)this.Dam) in a "Dao consolidation class", and ((DamOraOdp)this._dam) in a "custom Dao class". Customization is required to perform array binds with the "common Dao class" and "automatically generated Dao classes".
The "common Dao class" (CmnDao) in the [Touryo].Infrastructure.Business.Dao namespace can be used as a general-purpose Dao class. It mainly executes reference processing and can be customized as necessary. It can also execute stored procedures (reference / update).
- SQL setting: SQLFileName, SQLText methods
- SQL parameter setting: SetUserParameter, SetParameter, GetParameter, ClearParameters methods
- Query execution: ExecSelectScalar, ExecSelectFill_DT, ExecSelectFill_DS, ExecSelect_DR, ExecInsUpDel_NonQuery methods
// Execute reference SQL with the common Dao
CmnDao cmnDao = new CmnDao(this.GetDam());
// Specify dynamic SQL
cmnDao.SQLFileName = "ShipperSelect.xml";
// Dynamically set values for the parameters of the parameterized query.
cmnDao.SetParameter("P1", testParameter.ShipperID);
// Return value dt
DataTable dt = new DataTable();
// Execute the common Dao
cmnDao.ExecSelectFill_DT(dt);Figure 4.6-1 Usage sample of the common Dao class
// Execute a stored procedure with the common Dao
CmnDao cmnDaoSP = new CmnDao(this.GetDam());
// Specify the stored procedure
cmnDaoSP.SQLText = "sp_help";
// Specify the parameters (input, output).
cmnDaoSP.SetParameter("objname", "Shippers");
cmnDaoSP.SetParameter("ret", null, null, -1, ParameterDirection.ReturnValue);
// Execute the common Dao
SqlDataReader drd = (SqlDataReader)cmnDaoSP.ExecSelect_DR();
// Get the result sets
DataSet ds = new DataSet();
// Multiple result sets can be obtained
do {
// Create a DataTable
DataTable dt = new DataTable();
// Load the result from the data reader
dt.Load(drd);
// Store the DataTable
ds.Tables.Add(dt);
} while (!drd.IsClosed);
// Close the data reader.
drd.Close();
// Get the return value
int i = (int)cmnDaoSP.GetParameter("ret");Figure 4.6-2 Usage sample of the common Dao class (stored procedure)
Dynamic parameterized queries involve XML editing, so performance may degrade when there are many tags (100 tags or more is a guide). Once executed, the XML is converted into SQL internally, so reusing the Dam that holds this SQL can improve the performance of consecutive executions. However, since parameters remain in the Command object after one execution, they must be cleared with Command.Parameters.Clear() before being set again. Since the "common Dao class" and "automatically generated Dao classes" reset the SQL on every execution, either execute with a "custom Dao class" or additionally implement a method that does not reset the SQL [8].
object obj;
// When loading dynamic SQL.
this.SetSqlByFile2("DaoShippers_D1_Insert.xml");
// In this state it is dynamic SQL (check the IsDPQ property).
System.Diagnostics.Debug.WriteLine(this.GetDam().IsDPQ.ToString());
// First execution
this.SetParameter("CompanyName", "1st");
this.SetParameter("Phone", "1st");
obj = this.ExecInsUpDel_NonQuery();
// From here on it is static SQL (check the IsDPQ property).
System.Diagnostics.Debug.WriteLine(this.GetDam().IsDPQ.ToString());
// Clear the parameters (Command.Parameters) set in the previous execution.
((DamSqlSvr)this.GetDam()).DamSqlCommand.Parameters.Clear();
// Second execution
this.SetParameter("CompanyName", "2nd");
this.SetParameter("Phone", "2nd");
obj = this.ExecInsUpDel_NonQuery();
// Clear the parameters (Command.Parameters) set in the previous execution.
((DamSqlSvr)this.GetDam()).DamSqlCommand.Parameters.Clear();
// Third execution
// ・・・Figure 4.7 Example of executing dynamic parameterized queries consecutively with performance in mind
Execution via the framework has an overhead of about 0.5 ms per row, so consider Transact-SQL, direct ADO.NET execution, array binds, or batch execution of INSERT / UPDATE as necessary. As classes and methods supporting these, the Touryo.Infrastructure.Public.Db.SQLUtility class and the Touryo.Infrastructure.Framework.Dao.BaseDao.ExecGenerateSQL method have been added (currently SQL Server only; Oracle and HiRDB use array binds).
INSERT INTO XXXX(xxx, yyy, zzz) VALUES(xxx, yyy, zzz);
INSERT INTO XXXX(xxx, yyy, zzz) VALUES(xxx, yyy, zzz);
INSERT INTO XXXX(xxx, yyy, zzz) VALUES(xxx, yyy, zzz);
UPDATE SET xxx=xxx, yyy=yyy, zzz=zzz, WHERE id = 1;
UPDATE SET xxx=xxx, yyy=yyy, zzz=zzz, WHERE id = 2;
UPDATE SET xxx=xxx, yyy=yyy, zzz=zzz, WHERE id = 3;
Figure 4.8 Writing SQL such as INSERT and UPDATE consecutively
Specifying multiple values in an INSERT statement - Takahiro Matsumoto Blog (SQL Server Tips) (Japanese) http://d.hatena.ne.jp/matu_tak/20100113/1263856222
INSERT INTO [t1]
VALUES
( 1, 'AAA' ),
( 2, 'BBB' ),
( 3, 'CCC' ),
( 4, 'DDD' )-
4.8.1 SQLUtility class: The
GetInsertSQLPartsandGetUpdateSQLPartsmethods can generate SQL parts for batch processing.
// Create the data table
DataTable dt = new DataTable();
・・・Data creation code omitted・・・
// Generate the SQL parts
// The 2nd and 3rd arguments can be omitted (the default of the 2nd is nvarchar).
SQLUtility su = new SQLUtility(DbEnum.DBMSType.SQLServer, "varchar", "yyyy/MM/dd");
string[] strs = su.GetInsertSQLParts(dt);
// Assemble the SQL parts
string collist = "";
StringBuilder sb = new StringBuilder();
foreach (string str in strs)
{
if (string.IsNullOrEmpty(collist))
{
collist = str;
}
else
{
sb.Append(str + ",");
}
}
// Trim the last comma.
string temp = sb.ToString();
temp = temp.Substring(0, temp.Length - 1);
// Batch insert with the common Dao
CmnDao cd = new CmnDao(this.GetDam());
cd.SQLText = string.Format("INSERT INTO XXX{0} VALUES{1}", collist, temp);
cd.ExecInsUpDel_NonQuery();INSERT INTO XXX
([aaa],[bbb],[ccc],[ddd],[eee],[fff])
VALUES
(Convert(varchar,'a'),Convert(varchar,'aaa'),0xFF,0xFFFFFF,'2013/09/20',1),
(Convert(varchar,'b'),Convert(varchar,'bbb'),0xFE,0xFEFEFE,'2013/09/20',2),
(Convert(varchar,'c'),Convert(varchar,'ccc'),0xFD,0xFDFDFD,'2013/09/20',3)Figure 4.8.1-1 Example of batch insert using the GetInsertSQLParts method of the SQLUtility class
// Create the data table
DataTable dt = new DataTable("XXX");
・・・Data creation code omitted・・・
// Generate the SQL parts
// The 2nd and 3rd arguments can be omitted (the default of the 2nd is nvarchar).
SQLUtility su = new SQLUtility(DbEnum.DBMSType.SQLServer, "varchar", "yyyy/MM/dd");
string[] strs = su.GetUpdateSQLParts(dt, new string[] { "aaa" });
// Assemble the SQL parts
StringBuilder sb = new StringBuilder();
foreach (string str in strs)
{
sb.Append("UPDATE " + dt.TableName + " " + str + ";");
}
// Batch update with the common Dao
CmnDao cd = new CmnDao(this.GetDam());
cd.SQLText = sb.ToString();
cd.ExecInsUpDel_NonQuery();UPDATE XXX
SET [bbb] = Convert(varchar,'aaa'),[ccc] = 0xFF,[ddd] = 0xFFFFFF,[eee] = '2013/09/20',[fff] = 1
WHERE [aaa] = Convert(varchar,'a');
UPDATE XXX
SET [bbb] = Convert(varchar,'bbb'),[ccc] = 0xFE,[ddd] = 0xFEFEFE,[eee] = '2013/09/20',[fff] = 2
WHERE [aaa] = Convert(varchar,'b');
UPDATE XXX
SET [bbb] = Convert(varchar,'ccc'),[ccc] = 0xFD,[ddd] = 0xFDFDFD,[eee] = '2013/09/20',[fff] = 3
WHERE [aaa] = Convert(varchar,'c');Figure 4.8.1-2 Example of batch update using the GetUpdateSQLParts method of the SQLUtility class
-
4.8.2 ExecGenerateSQL method: The
ExecGenerateSQLmethod of theBaseDamclass [9] can generate only the SQL without executing it (see RerunnableBatch_sample2 for details).
// Add multiple rows to the Orders2 table at once.
StringBuilder sb = new StringBuilder();
for (int index = 0; index < dataTable.Rows.Count; index++)
{
DataRow row = dataTable.Rows[index]; // Data for one row
//todo: editing processing, etc.
// ↓DB access-----------------------------------------------------
// Create the automatically generated Dao
DaoOrders2 dao = new DaoOrders2(this.GetDam());
// Set the parameters
dao.PK_OrderID = row["OrderID"];
dao.CustomerID = row["CustomerID"];
dao.EmployeeID = row["EmployeeID"];
・・・
dao.ShipRegion = row["ShipRegion"];
dao.ShipPostalCode = row["ShipPostalCode"];
dao.ShipCountry = row["ShipCountry"];
// Execute the automatically generated Dao
sb.Append(dao.ExecGenerateSQL(
"DaoOrders2_S1_Insert.sql", new SQLUtility(DbEnum.DBMSType.SQLServer)) + ";\r\n");
// ↑DB access-----------------------------------------------------
}
// Batch insert with the common Dao
CmnDao cd = new CmnDao(this.GetDam());
cd.SQLText = sb.ToString();
cd.ExecInsUpDel_NonQuery();INSERT INTO [Orders2]
( [OrderID], [CustomerID], [EmployeeID], [OrderDate], [RequiredDate], [ShippedDate], [ShipVia],
[Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode], [ShipCountry] )
VALUES
( 10248, Convert(nvarchar,'VINET'), 5, '1996/07/04 00:00:00.000', '1996/08/01 00:00:00.000', '1996/07/16 00:00:00.000',
3, 32.3800, Convert(nvarchar,'Vins et alcools Chevalier'), Convert(nvarchar,'59 rue de l''Abbaye'),
Convert(nvarchar,'xxxxxx'), NULL, Convert(nvarchar,'51100'), Convert(nvarchar,'France'));
INSERT INTO [Orders2]
( [OrderID], [CustomerID], [EmployeeID], [OrderDate], [RequiredDate], [ShippedDate], [ShipVia],
[Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode], [ShipCountry] )
VALUES
( 10249, Convert(nvarchar,'TOMSP'), 6, '1996/07/05 00:00:00.000', '1996/08/16 00:00:00.000', '1996/07/10 00:00:00.000',
1, 11.6100, Convert(nvarchar,'Toms Spezialitäten'), Convert(nvarchar,'Luisenstr. 48'),
Convert(nvarchar,'Münster'), NULL,Convert(nvarchar,'44087'), Convert(nvarchar,'Germany'));
・・・Figure 4.8.2 Example of batch insert using the ExecGenerateSQL method of the BaseDam class
While debugging D layer processing, etc., the message A first chance exception of type 'System.Xml.XmlException' occurred in System.Xml.dll (Japanese environments show the equivalent localized message) may be displayed. This message is output when a command that violates the XML format (such as normal SQL or a static parameterized query) is specified in the check logic of the dynamic parameterized query, and there is no problem with quality.
Discontinued
The ACCESS log is output in normal-case and abnormal-case formats. The stack trace output on the P layer side does not include the stack trace information of the B layer, so when an error occurs in the B layer, check the stack trace of the error information on the B side.
[(log header)],[INFO],[1],(USER name),(IP),-,(ScreenID)
[(log header)],[INFO],[1],(USER name),(IP),--->,(ScreenID),(controlId)
[(log header)],[INFO],[1],(USER name),(IP),--->>,(ScreenID),(controlId),(ActionType)
[(log header)],[INFO],[1],(USER name),(IP),<<---,(ScreenID),(controlId),(ActionType),(execution time),(CPU time)
[(log header)],[INFO],[1],(USER name),(IP),<---,(ScreenID),(controlId),(execution time),(CPU time)
[(log header)],[INFO],[1],(USER name),(IP),-,(ScreenID)
[(log header)],[INFO],[1],(USER name),(IP),--->,(ScreenID),(controlId)
[(log header)],[INFO],[1],(USER name),(IP),--->>,(ScreenID),(controlId),(ActionType)
[(log header)],[INFO],[1],(USER name),(IP),<<---,(ScreenID),(controlId),(ActionType),(execution time),(CPU time)
[(log header)],[INFO ],[1],(USER name),(IP),<---,(ScreenID),(controlId),(execution time),(CPU time)
Figure 6.1-1 ACCESS log (normal case)
[(log header)],[INFO],[1],(USER name),(IP),-,(ScreenID)
[(log header)],[INFO],[1],(USER name),(IP),--->,(ScreenID),(controlId)
[(log header)],[INFO],[1],(USER name),(IP),--->>,(ScreenID),(controlId),(ActionType)
[(log header)],[ERROR],[1],(USER name),(IP),<<---,(ScreenID),(controlId),(ActionType),(execution time),(CPU time),
message ID, message
at (stack trace information 1) :line xxx
at (stack trace information 2) :line xxx
at (stack trace information 3) :line xxx
at (stack trace information ...) :line xxx
[(log header)],[ERROR],[1],(USER name),(IP),<---,(ScreenID),(controlId),(ActionType),(execution time),(CPU time),
message ID, message
at (stack trace information 1) :line xxx
at (stack trace information 2) :line xxx
at (stack trace information 3) :line xxx
at (stack trace information ...)
Figure 6.1-2 ACCESS log (abnormal case)
The SQL trace log is also output in normal-case and abnormal-case formats. Logs at the time of errors are also output, so it can be used for debugging and for checking whether there is a problem with the SQL being sent to the DBMS.
- Normal case
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:INSERT INTO Shippers (CompanyName, Phone) VALUES (@P2, @P3),[commandParameter]:P2=@@@,P3=@@@,
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:SELECT COUNT(*) FROM Shippers,[commandParameter]:
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:SELECT * FROM Shippers,[commandParameter]:
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:SELECT ShipperID, CompanyName, Phone FROM Shippers WHERE ShipperID = @P1,[commandParameter]:P1=6,
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:UPDATE Shippers SET CompanyName = @P2, Phone = @P3 WHERE ShipperID = @P1,[commandParameter]:P1=6,P2=%%%,P3=%%%,
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:SELECT * FROM Shippers,[commandParameter]:
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:DELETE Shippers WHERE ShipperID = @P1,[commandParameter]:P1=6,
[(log header)],[INFO ],[1],(execution time),(CPU time),[(〇) Normal end],
[commandText]:SELECT * FROM Shippers,[commandParameter]:
Figure 6.2-1 SQL trace log (normal case)
- Abnormal case
[(log header)],[INFO ],[1],(execution time),(CPU time),[(×) Abnormal end],
[commandText]:INSERT INTO Shippers (CompanyName, Phone) VALUES (@P2, @P3),[commandParameter]:P2=;XXX,P3=XXX,
Figure 6.2-2 SQL trace log (abnormal case)
To map SQL files to the log, it is a good idea to put the SQL file name in an SQL comment.
Below are the handling methods for each requirement and inquiries turned into an FAQ. Open Touryo is highly flexible and can handle most requirements.
| Question | Answer |
|---|---|
| Does it support Web applications with multiple screens? | Any pattern is supported. Functions that support multi-screen development can be used. |
| Does it support cross-browser use? | Operation was confirmed on IE6/7/8, Firefox, Safari, Chrome and Opera. Restriction: only the display of business modal dialogs is limited to IE (the OK and Yes/No message dialogs are cross-browser, but Opera does not support dialogs). For controls that use __doPostBack() in href, such as LinkButton and ImageMap, the double submission prevention function is not effective only on IE6. |
| I want processing to continue even when the Session times out on the Internet. | This can be handled by turning OFF both the session timeout detection function and the framework functions that continuously use Session (automatic deletion of session areas, button history recording, illegal operation prevention). |
| After failover in a load-balanced cluster, can business continue? | It is possible by selecting either the SQL Server or Oracle Session mode and newly setting up a dedicated server to hold Session state (StateServer, which cannot be made redundant, is excluded from the options). |
| Is the use of master pages mandatory? | Yes, because the infrastructure definitions are held in the master page. However, an empty master page apart from the infrastructure definitions is fine. |
| Are nested master pages supported? | Supported in the latest version. |
| I want to add controls supported by the P layer event processing function. | Since controls are handled by their prefix, they can be added by customizing the control acquisition processing and the relay event handler in base class 2. |
| I want to cancel the P layer event processing function. | It can be canceled by specifying empty prefixes for each control in *.config. |
| A Session timeout exception occurs on the login screen. | The P layer framework requires Session, so either do not use it for login screens in an Internet environment, or use Windows authentication or a dedicated authentication infrastructure (such as SiteMinder). Setting the IsNoSession flag to true turns OFF button history recording and illegal operation prevention for that screen. |
| Download related (#10 to 14) | See section 2.7. |
| Line breaks are not applied in OK and Yes/No dialog messages. | Change the line break codes in the message string to <br/>. |
| Where is the HTML title specified? | It is set to this.Page.Title in the CMN_FormInit method of base class 2. |
| Tab switching with Ajax or jQuery does not work well. | Since there is no ViewState, initialization is needed on every postback. A workaround is needed such as calling Fx_Document_OnLoad() from the initialization with a time lag using SetTimeout() (handled in the latest version). |
| Does the P layer event processing function support Web user controls? | Supported in the latest version. Consider adding prefixes, etc. so that control names do not conflict between the page and the Web user control / master page. |
| An unexpected Session timeout exception occurs. | In addition to Session.Abandon(), also delete the cookie for session timeout detection (consolidated into this.FxSessionAbandon() in the latest version). |
| Does it support the new HTML output of ASP.NET 4.0? | Add <pages controlRenderingCompatibilityVersion="3.5" /> to web.config, or replace common.js with the other bundled one. clientIDMode="AutoID" is assumed. |
| Does it support ASP.NET MVC? | Not supported. The B layer and D layer frameworks, the communication control function, etc., other than the P layer, can be used. |
| Question | Answer |
|---|---|
| Does it support rich clients? | Windows Forms, WPF/XBAP, Silverlight and Windows Store apps are supported. Of these, the P layer framework supports only Windows Forms. |
| The number of controls and events supported by the Windows Forms P layer event processing becomes too large. | They can be added by customizing base class 2, but the customization volume becomes large, so it is also possible to raise a Click event with the DoClick method of a hidden button (HiddenButton) from a standard .NET event handler. |
| Does the P layer event processing function support MenuItem control events? | Supported. Since the search method differs from the others, do not customize base class 2; instead, set a common Click event handler (Item_Click) to the Click event of the MenuItem in UOC_FormInit. |
| Question | Answer |
|---|---|
| Does it end up being one method per class? | The default entry point is only DoBusiness(), but you can dispatch with if/select inside, or use base class 2 with the dispatch function by late binding (the one with the dispatch function is now the default). |
| Setting up the B and D layers is troublesome. | The P layer can also create a Dam directly and access data (P layer only or P and D layers). Using the common Dao / automatically generated Dao for the D layer lets you skip developing custom Daos. |
| How is transaction management implemented? | A transaction is started in UOC_ConnectionOpen() of B layer base class 2, and the framework automatically commits or rolls back when B layer processing completes (automatic rollback on exceptions). In 2-tier C/S, only the start is automated. |
| Is split commit possible? | It is possible by calling this.GetDam().CommitTransaction(); and this.GetDam().BeginTransaction(); from the B layer. |
| Is manual transaction management possible? | It is possible by creating a Dam directly and accessing data. The framework for 2-tier C/S allows a second connection. |
| Question | Answer |
|---|---|
| How are bind variables bound? | Only name binding is supported. Ordinal binding is not supported. With OLEDB, ODBC and HiRDB, it does not work correctly if a comment contains the same string as a parameter name including the parameter symbol. |
| Can stored procedures and anonymous PL/SQL blocks be executed and return values obtained? | In the latest version, the dynamic parameterized query function can be used. |
| Are array binds of ODP.NET and HiRDB supported? | Supported. |
| Are LINQ to SQL/Oracle/Entities supported? | Not supported. Use of the D layer framework is recommended (LINQ other than DB access, such as LINQ to Object/XML/DataSet, is fine). |
| I want to specify multiple parameters in an IN clause. | Use the LIST tag of the dynamic parameterized query (string replacement with SetUserParameter() can also substitute). |
| I want to make the IN clause (subquery) of the search condition dynamic but get an error. | Use the SUB tag, which can nest tags, instead of the IF tag. |
| I want to retry exceptions such as deadlocks, lock timeouts and duplicate keys. | Customize the exception handling of B layer base class 2, replace the exceptions to retry with business exceptions and return a normal return value to the P layer. |
| How do I set the command timeout value? | In the latest version, a common command timeout value can be set in *.config. |
| Implicit type conversion occurs in SQL and degrades performance. | The type and size can be specified with the overloads of SetParameter(). It can also be handled by explicitly casting the type in the SQL definition file (see section 4.2). |
| Does performance degrade depending on the size of the XML file, etc.? | Performance starts to degrade when one XML has 150 tags or more, so do not write unnecessary tags. For batch updates, also use array binds to reduce round trips. PARAM/DIV tags do not cause performance degradation. |
| Is fuzzy search using the Like clause supported? | Supported. Pass a Like search condition that includes wildcards in the parameter (the output of the D layer automatic generation tool does not support it). |
| Basics of parameterized queries | Like search is supported in standard and dynamic parameterized queries. To pass null, use DBNull (in dynamic queries, null is a special control parameter). When in-text parameters and in-tag parameters are mixed, in-text parameters take precedence. |
| Question | Answer |
|---|---|
| Are proxy access and proxy authentication supported? | Supported. The URL and Credentials of the proxy can be specified in the XML definition file (they can also be specified directly from the API). |
| Is SSO using Windows authentication supported? | Supported. Kerberos authentication is supported, and double to triple hops are possible (the base client security model is normally not recommended). |
| Are communication protocols such as WCF-TCP/IP supported? | Supported. It can be handled by additionally developing a service interface and a service proxy. |
| Question | Answer |
|---|---|
| Can rolling between system 1 and system 2 be realized with the log output function? | Substitute it with similar functions of log4net (MaxSizeRollBackups, CountDirection). |
| Can the log output write different files per user? | For rich clients (especially terminal services), write <param name="File" value="${USERPROFILE}\Log\ACCESS" /> in the appender settings for file output. |
| How can multiple launches per process be supported? | Use variables such as environment variables or the PID (such as %processid of log4net.Util.PatternString). |
| Can a different directory per user be specified as the storage location of rich client definition files? | The data storage location can be selected using environment variables (specify %USERPROFILE%\AppData for the path of the resource loader component). |
| When are changes to web.config / app.config of ASP.NET reflected? | When web.config is changed, IIS restarts automatically and the change is reflected immediately. IIS does not restart for app.config, so reflect it manually with the iisreset command. |
| JS files, etc. cannot be referenced before Forms authentication login. | Add <allow users="*"/> with <location path="Framework/Js"> to web.config so that JavaScript files are excluded from authentication. |
| It cannot run and compile with the .NET Framework Client Profile. | The Client Profile is not supported (because many non-existent server-side APIs are used. The Client Profile was dropped in 4.5). |
- Intelligent D layer (Dao) classes.
- Deletes the cookie for session timeout detection.
- The "parameter data type" (nvarchar) and the "DB column data type" (varchar) do not match.
- Conversion function of SQL Server Transact-SQL.
- The AcceptChanges method of DataSet / DataTable.
- Gets the original data used for optimistic locking.
- Array bind supported by ODP.NET.
- Modify the common Dao / automatically generated Dao (templates).
- The BaseDam class.
-End-
Copyright © 2007,2017, Hitachi Solutions, Ltd.