Log an application info event¶
Callers record an application info/audit event by calling one of the two CreateNewAppInfo factory overloads on clsAppInfo — one that accepts a framework AuditInfoStruct and one that accepts discrete field values. Both overloads populate the same set of fields on a new clsAppInfo instance, immediately call Save(), and rely on BeforeInsert to stamp a retention purge date independent of the caller's input.
| Field | Value |
|---|---|
| Operation ID | OP-LV-05 |
| Trigger | Caller calls clsAppInfo.CreateNewAppInfo(inDPI, inAuditStruct) or clsAppInfo.CreateNewAppInfo(inDPI, inAppName, inEnvironment, inAuditDate, inDataText, inMachineName, inPageName, inMessageText, inUserName) |
| Inputs | IDataPortalInfo; either a SAIF.Framework.Logging.AuditInfoStruct or the eight discrete fields (AppName, Environment, CreateDate/AuditDate, DataText, MachineName, PageName, MessageText, UserName) |
| Outputs | Saved clsAppInfo instance with AppInfoSeqNum populated and Purge_Date set 30 days ahead; an InsertError business-object message if the insert did not affect exactly one row |
| Primary components | clsAppInfo.CreateNewAppInfo (both overloads), clsAppInfo.BeforeInsert, clsAppInfo.AfterInsert |
| Entry point | Application\SAIF.Application.LogView\clsAppInfo.vb |
Steps¶
- Allocate a new object. Both
CreateNewAppInfooverloads build aclsAppInfo.Criteriafrom the suppliedIDataPortalInfoand callinDPI.DataAccessLayer.CreateObject(Crit), running the BOFCreate()lifecycle method, which seeds fields to empty strings,CreateDatetoNow, andPurgeDatetoNowbefore the factory overwrites them. - Populate fields from the caller's input.
- Struct overload: copies
ApplicationName,Environment,AuditDate(intoCreateDate),DataText,MachineName,PageName,MessageText, andUserNamefrom theAuditInfoStruct. - Discrete-parameter overload: copies the eight caller-supplied arguments directly onto the same set of properties.
- Save the object. Both overloads call
temp.Save()immediately after populating fields, routing to the insert path for the new object. - Build the insert request (
BeforeInsert). ANonQuerydata request is configured withMyCriteria.InsertSQL(SQL-004, App_Info) and bound parameters@App_Name,@Create_Date(or aDbType.DateTimenull placeholder whenCreateDateisDate.MinValue),@Environment,@Machine_Name,@Page_Name,@Data_Text,@Purge_Date,@User_Name, and@Message_Text. @Purge_Dateis always bound fromNow.AddDays(30)computed at insert time, independent of anyPurgeDatevalue the caller may have set on the object (BR-007).- A second scalar data request is queued with
SQLStatement = "Select @@IDENTITY"(SQL-002) to retrieve the generated sequence number in the same round trip. - Evaluate the insert result (
AfterInsert). The rows-affected value from the first data request is read. - If
RowsAffected <> 1: add theInsertErrorbusiness-object message (BR-006). - Otherwise: read the
@@IDENTITYscalar result, cast it toInteger, assign it toAppInfoSeqNum, and callMarkOld(). - Return the saved object. Both factory overloads return the same
tempreference, now populated withAppInfoSeqNumon success.
Process flow¶
The following diagram visualizes the two-overload create-and-save flow, including the fixed 30-day purge-date stamp.
flowchart TD
Start([Caller calls CreateNewAppInfo]) --> Which{Struct or discrete<br>parameter overload?}
Which -->|Struct| MapStruct[Map AuditInfoStruct fields<br>to clsAppInfo properties]
Which -->|Discrete| MapDiscrete[Map discrete arguments<br>to clsAppInfo properties]
MapStruct --> Save[Call Save]
MapDiscrete --> Save
Save --> Insert[BeforeInsert: build InsertSQL,<br>stamp Purge_Date = Now + 30 days]
Insert --> Exec[Execute insert and<br>identity scalar request]
Exec --> Rows{RowsAffected = 1?}
Rows -->|No| Err([AddErrorMessage InsertError])
Rows -->|Yes| Identity[Read @@IDENTITY,<br>set AppInfoSeqNum, MarkOld]
Identity --> Done([Saved clsAppInfo returned])
Failure and edge-case behavior¶
- The 30-day purge date is computed fresh in
BeforeInsertfromNow.AddDays(30)every time, so anyPurgeDatevalue the caller set beforehand (including through the object's public setter) has no effect on the persisted row (BR-007). - If
CreateDateis left atDate.MinValue,BeforeInsertbinds@Create_Dateas an explicitDbType.DateTimenull rather than a value. - A
RowsAffectedvalue other than1is treated uniformly as an insert failure;AppInfoSeqNumremains unset and the object is not marked old. clsAppInfo.AddBusinessRules()registers no rules, so no field-level validation blocks the insert.*
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
Application\SAIF.Application.LogView\clsAppInfo.vb