Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transactions and remote methods
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
00412104
Message ID:
00412106
Vues:
17
>I have a VFP 6.0 Orders Processing application which is currently being converted to the Web. I'm using ASP+VFP COM DLLs and my front-end is a web browser. During the conversion some customers demanded an off-line application which could be used in replacement of the on-line version. In my Business objects (VFP COM DLLs) I have two methods that handle the insertion of Orders and their details. e.g:
>
>InsertOrder() -> Inserts the order handle. and
>InsertItem() -> Inserts **ONE** item each time
>
>Both methods are stateless and my data are DBF free tables.
>
>My problem is that I can't assure transaction between the call to InsertOrder() and the various calls the InsertItem().
>
>I'm having problems with my off-line version in guaranteeing ACID properties for my business process (some Orders are beeing inserted with the wrong number of items -less than the correct).
>
>I could think about using MTS and the object context, but as my methods are stateless and VFP isn't DTS-aware, I'm very confused.
>I thought of XML messages which would contain both the header and the detail lines to be received by the methods and from there use VFP native transactions.
>I'd like some suggestions from you about a feasible strategy. Can you help me?

You are right, with VFP not being DTS-aware you cannot use MTS transactions. (It maybe time to move your database to SQL Server.) With your COM being stateless you will need to call the InsertItem's from within the InsertOrder to take advantage of VFP native transactions (or ADO transactions). Or the following:

The trick is to send all the info you need updated in one call to the COM. The way that I have done this is to gather all the records that need updating into ADO recordsets. First I dimension an array with 3 columns. For each row, the first column stores the name of the table to be updated, the second stores the key field information and the third holds the record to be updated as an ADO recordsets. Each row of the array holds info for each record that needs to be updated as part of a transaction. I then pass this array to the VFP COM. (The COM has to be VFP as each app reads arrays differently.)

The COM then does something like this:
this.oConn.BeginTrans
FOR i = 1 to ALEN(taArray,1)
  * iterate through each element of the array and does the following:
  * retrieve data that matches the key from the database as recordset (this.ORs).
  * update the retrieved RS from the passed RS then
  this.oRs.Update  && or UpdateBatch of opened in batch mode.
  this.oRs.Close
NEXT i
* IF any failure then
  this.oConn.RollBackTrans
  RETURN .F.
* ELSE
  this.oConn.CommitTrans
  RETURN .T.
* ENDIF
George
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform