Module cDistributedBusinessProcess.pkg
1//****************************************************************************
2//
3// $File name : cDistributedBusinessProcess.pkg
4// $Author : Janne Wassberg
5// Created : 97-10-01 @ 17.27.59
6//
7//
8// Confidential Trade Secret.
9// Copyright 1998-1999 Data Access Corporation, Miami FL, USA
10// All Rights reserved
11// DataFlex is a registered trademark of Data Access Corporation.
12//
13//
14// $Description
15//
16// $Rev History
17//
18//
19// JJT 1998-09-15 Added/changed support for ReportAllErrors, ReportLastError, ClearErrors
20// ErrorCount, ReportErrorItem, ErrorQueueStart, ErrorQueueEnd
21// Changed Errors to call LogErrorEvent (gens error and event error).
22// removed AdminErrorLog
23// JJT 1998-08-06 Added support to ShowEntryError_State when sending field_entry.
24// JJT 1998-08-05 Changed RequestUpdateData so that it uses the Main_dd and not the
25// passed DD (which was not working with parent finds).
26// JW 1998-07-08 Added a new hook procedure for this class, DoLogEvent.
27// DoLogEvent is used to redirect errors to the ISO layer.
28//
29// JW 1998-07-08 Changed all procedures/functions with error messages to
30// use the property for event logging
31//
32// JW 1998-07-08 Added a new property (AdminErrorLog) Default=False
33// If the property is set to True the critical errors in
34// this class will the be written to VDFInternet Server Admin
35// error log.
36//
37// JW 1998-07-08 VDF Internet Server Version 0.8-215
38//
39// JW 1998-06-27 Source Merge for Internet by Janne Wassberg
40//
41// JW 1998-06-27 Version 0.8-201
42//
43// JW 98-03-10 Version 110
44//
45// JW 98-02-18 Version 105
46//
47// JW 97-10-01 File header created.
48//
49//****************************************************************************
50
51Use Windows.pkg
52
53// Create a Business Process class with the basics for handling
54// remote data updates and refreshes. This makes no assumptions about
55// how the data is obtained. The procedures do that here are stubbed out and
56// must be provided in a sub-class.
57
58{ ClassLibrary=WebApp ClassType=Abstract }
59{ HelpTopic=cDistributedBusinessProcess }
60Class cDistributedBusinessProcess is a cObject
61
62 Procedure Construct_Object
63 Forward Send Construct_Object
64
65 { DesignTime=False }
66 Property Handle Main_DD 0
67
68 // when moving data from remote object to DD buffer should
69 // we display or ignore errors (like bad dates and numbers)
70 { Category="Error Handling" }
71 { PropertyType=Boolean }
72 Property Integer pbShowEntryError False
73
74 // this adds an extra layer of safety with process pooling. It is disabled
75 // to get maximum speed and because it is usually not needed. Prior to
76 // vdf10, this property did not exist and the clear always happened.
77 { Category=Data }
78 Property Boolean pbClearDDOsOnDetach False
79 End_Procedure //Construct_Object
80
81 // With the merge of VDF and WebApp, we need to support main_dd as this
82 // is the property that the IDE uses. Older webApp may use this
83 { MethodType=Property Visibility=Private Obsolete=True }
84 Procedure set phMainDD Handle hDD
85 Set Main_dd to hDD
86 end_Procedure
87
88 { MethodType=Property Visibility=Private Obsolete=True }
89 Function phMainDD returns handle
90 Function_Return (Main_dd(Self))
91 end_function
92
93 //*************************************************************************
94 //*** Abstract Interace. Sub-classes or objects must provide augmentations
95 // to perform the following functions. When the ISO layer is added these
96 // messages will be augmented to provide functionality.
97 //*************************************************************************
98
99 Procedure ReportAllErrors string sHdr
100 End_Procedure
101
102 Procedure ReportLastError Integer bClearError
103 End_Procedure
104
105 Procedure ClearErrors
106 End_Procedure
107
108 Function ErrorCount Returns Integer
109 End_Function
110
111 Procedure ReportErrorItem
112 End_Procedure
113
114 Procedure ErrorQueueStart
115 End_Procedure
116
117 Procedure ErrorQueueEnd
118 End_Procedure
119
120 Procedure RequestFileRecords
121 End_Procedure
122
123 Procedure RequestFileFieldValues
124 End_Procedure
125
126 // We need this so we can redirect specific errors to the Administrator event log
127 Procedure LogEvent Integer iEventType String lpszEvent
128 End_Procedure
129
130
131
132 //*************************************************************************
133 //*** Low Level Support interface.
134 //*************************************************************************
135
136 // At this level we simply assume a one to one translation. That we are passed
137 // a file and field number. Sub-classes can do their own tricky translation by
138 // augmenting these two functions
139 //
140 Function Search_File_Name string sFileName returns integer
141 Function_Return (integer(sFileName))
142 End_Function
143
144 Function Search_Field_Name integer iFile string sFieldName Returns integer
145 Function_Return (integer(sFieldName))
146 End_Function
147
148
149 // Pass FileName and return FileNumber. Ret 0 if error
150 // good for augmentation
151 Function MapToFileNumber string sFileName string sFieldName returns integer
152 integer iFile
153 Get Search_File_Name sFileName To iFile
154 If iFile eq 0 Begin
155 Send LogErrorEvent DFERR_WEBAPP_FILEFIELD_NAME_NOT_FOUND (SFormat(C_$BadFileName, sFileName))
156 End
157 Function_return iFile
158 End_Procedure
159
160 // good for augmentation
161 Function MapToFieldNumber Integer iFile String sFieldName Returns Integer
162 integer iField
163 Get Search_Field_Name iFile sFieldName to iField
164 If (iField=-1) Begin
165 Send LogErrorEvent DFERR_WEBAPP_FILEFIELD_NAME_NOT_FOUND (SFormat(C_$BadFieldNameForFile, sFieldName, iFile ))
166 End
167 Function_return iField
168 End_Procedure
169
170 // Pass filename and return the DD that owns the file. If filename is blank and
171 // bCanUseMain is true, use the Main_dd. return 0, if no file
172 // This will report all errors it encounters.
173 //
174 Function MapFileNameToDD string sFilename integer bCanUseMain returns integer
175 Integer iFile
176 Integer hMainDD hDD
177 integer bErr
178 Get Main_dd to hMainDD
179 If (hMainDD=0) Begin
180 // this is a program error, so we just report error...not log it
181 Error DFERR_PROGRAM C_$NoDefinedMainDD
182 Move 1 to bErr
183 End
184 Else Begin
185 // if filename is not blank, find it
186 If (sFileName='') Begin
187 if bCanUseMain ;
188 Move hMainDD to hDD
189 else Begin
190 Send LogErrorEvent DFERR_WEBAPP_DDO_NOT_FOUND_FOR_FILE C_$NoFileNameSpecified
191 Move 1 to bErr
192 End
193 end
194 Else Begin
195 Get MaptoFileNumber sFileName '' To iFile // also return (ERR)
196 If (iFile=0) ;
197 Move 1 to bErr // error already declared
198 Else Begin
199 Get Data_Set of hMainDD iFile to hDD
200 If (hDD=0) Begin
201 Send LogErrorEvent DFERR_WEBAPP_DDO_NOT_FOUND_FOR_FILE (SFormat(C_$CouldNotFindDDForFileName, sFileName))
202 Move 1 to bErr
203 End
204 end
205 End
206 End
207 Function_return hDD
208 End_Function
209
210 // Refind all records. Pass: DD that controls the operation
211 // Return: True if error occurred.
212 // The updates both rowids and recnums. We assume that you'd never mix these. The
213 // recnum update is provided for backwards compatibility and only works on recnum tables. Use RowIds!
214 // Record Ids are passed from the OCX.
215 // This assumes that there are no errors when this is started!!!!
216 { Visibility=Private }
217 Function RequestUpdateRecords integer hDD returns integer
218 Send Clear_All of hDD // Clear the entire structure
219 Send RequestFileRecords // Get all Rowids and Recnums from ASP (errors are possible) -- recnum usuage is obsolete
220 Send Find_Records of hDD // Find Records as Needed. Use DD as start point
221 Function_Return (ErrorCount(self)) // errors can occur during synch and find
222 End_function
223
224 // ReSynch all data
225 // This assumes that there are no errors when this is started!!!!
226 { Visibility=Private }
227 Function RequestUpdateFileFieldValues integer hDD returns Integer
228 integer hOldMain
229 // This operation is Main-DD centric. The passed DD
230 // determines how this is used (SetFileFieldValue uses MainDD).
231 Get Main_dd to hOldMain
232 Set Main_dd to hDD
233 Send RequestFileFieldValues // Get all field field values from ASP (errors are possible)
234 Set Main_dd to hOldMain
235 Function_Return (ErrorCount(self)) // errors can occur during synch and find
236 End_function
237
238 // Update all Data from Entry-object to DD Buffer
239 //
240 // First refind all existing records, Then update all changed values
241 // Returns: zero if no error.
242 //
243 { Visibility=Private }
244 Function RequestUpdateData integer hDD Returns integer
245 integer bErr hMain
246 // this has been changed so that the Main_dd is the source of all updating.
247 // If we don't do this the main file is not refound when a find operation
248 // occurs on a parent. This assumes that there is a single Main_dd and the it is
249 // the child-most DD in the structure
250 Get Main_dd to hMain
251 If hMain eq 0 Move hDD to hMain
252 Send ClearErrors // just in case
253 Get RequestUpdateRecords hMain to bErr // refind all records from ASP file
254 If not bErr ;
255 Get RequestUpdateFileFieldValues hMain to bErr // Get all Field values from ASP (will autofind) (errors possible)
256 Function_Return bErr
257 End_Function
258
259
260// JJT: DoSetFileRecordId and DoSetFilrRowId moved to cIneternetSessionBusinessProcess . DoSetFileFieldValue was already there
261// // These two messages are sent by the Remote DEO (e.g. the OCX) that is
262// // is processing a request to update Record values or file/field values.
263// // They returns Err if the operation failed
264// //
265// // Move Passed Value for fieldname fieldname to the appropriate DD.
266// // The remote object should send this message in response to
267// // RequestFileFieldValues
268// //
269// //Doc/ Visibility=Private
270// Procedure DoSetFileFieldValue String sFile String sField String sValue
271// Integer iField iFile
272// Handle hMain hDD
273
274// Get Main_dd to hMain
275
276// If hMain eq 0 Procedure_Return // error should already be declared
277
278// Get MaptoFileNumber sFile sField To iFile // also return (ERR)
279
280// if (iFile > 0) ;
281// Get MaptoFieldNumber iFile sField To iField
282
283// // We send this to Main-DD. This allows us to support Foreign field logic
284// If (iFile>0 AND iField>=0) begin
285// Get data_set Of hMain iFile To hDD
286// If (hDD=0) Begin
287// Send LogErrorEvent DFERR_WEBAPP_DDO_NOT_FOUND_FOR_FILE (SFormat(C_$CouldNotFindDDForFileName, sFile))
288// End
289// Else Begin
290// Set File_Field_Entry of hMain iFile iField (pbShowEntryError(self)) to sValue
291// End
292// end
293// Indicate Err as (iFile=0 OR iField<0 OR hDD=0) // set error indicator
294// End_Procedure
295
296// // Move Passed record num for fieldname to the appropriate DD.
297// // The remote object should send this message in response to
298// // RequestSetFileRecords
299// //
300// // We expect that this message is sent by the Client (OCX) passing a
301// // filename and file number (we call it ID so we can move away from recnums).
302// // Sets Err if error occurs
303// //Doc/ Visibility=Private
304// Procedure DoSetFileRecordId string sFileName string sRecordId
305// integer hDD
306// Get MapFileNametoDD sFileName False to hDD // Must find the file
307// If hDD ;
308// Set Find_record_id of hDD to (integer(sRecordID))
309// Indicate Err as (hDD=0) // set error indicator
310// End_procedure
311
312// //Doc/ Visibility=Private
313// Procedure DoSetFileRowId string sFileName string sRowId
314// integer hDD
315// Get MapFileNametoDD sFileName False to hDD // Must find the file
316// If hDD ;
317// Set Find_RowId of hDD to (DeserializeRowId(sRowId))
318// Indicate Err as (hDD=0) // set error indicator
319// End_procedure
320
321
322 { MethodType=Event }
323 Procedure OnDetachProcess
324 End_procedure
325
326 { Visibility=Private }
327 Procedure DoClearDDOs
328 handle hMainDD
329 Get Main_dd to hMainDD
330 If hMainDD Send Clear_All of hMainDD
331 end_procedure
332
333 { Visibility=Private }
334 Procedure DoDetachProcess
335 Boolean bClearDDOsOnDetach
336 // we only clear ddos if the property is set. This is new as of
337 // vdf10 and was added to speed up PP operations
338 get pbClearDDOsOnDetach to bClearDDOsOnDetach
339 If bClearDDOsOnDetach begin
340 Send DoClearDDOs
341 end
342 Send OnDetachProcess
343 End_procedure
344
345
346 { MethodType=Event }
347 Procedure OnAttachProcess
348 End_procedure
349
350 { Visibility=Private }
351 Procedure DoAttachProcess
352 Send OnAttachProcess
353 End_procedure
354
355
356End_Class
357