of_refresh


pfcapsrv.pbl   >   pfc_n_cst_dwcache   >   of_refresh   

Full name pfc_n_cst_dwcache.of_refresh
Access public
Extend of long
Return value long
Prototype public function long of_refresh(string)

Name Datatype
No Data

Name Datatype
la_args Any[20]
li_cnt Integer
li_id Integer
li_rc Integer
li_upper Integer
ll_rows Long

public function long of_refresh (string as_id);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_Refresh
//
//	Access:  protected
//
//	Arguments:
//	as_id		The ID for the object that needs to be refreshed.
//
//	Returns:  long
//	number of rows refreshed.
//	0 this datastore could not be refreshed.
//	-1 error.
//
//	Description:
//	Refresh the object in the service.
//	*Note: All registered methods have the capabilitty of being refreshed.
//		On certain circustances registered objects cannot be refreshed. 
//		(i.e. The transaction is no longer connected.)
//
//		 Register Method - RETRIEVE
//			Validates the transaction object.
//			Confirms the transaction object is still connected to the db.
//			Refreshes by performing a retrive to the database.
//
//		 Register Method - DATAOBJECTDATA
//			Refreshes to the original data as of the time of registering.
//			
//		 Register Method - POWEROBJECT
//			Refreshes to the original data as of the time of registering.
//			
//		 Register Method - DATAWINDOWCONTROL
//			Validates that the original control source is still available.
//			Validates that the original control source is still holding the same dataobject.
//			Refreshes by getting the current data that is being held on the original control.
//			
//		 Register Method - DATASTORECONTROL
//			Validates that the original control source is still available.
//			Validates that the original control source is still holding the same dataobject.
//			Refreshes by getting the current data that is being held on the original control.
//			
//		 Register Method - IMPORTFILE
//			Validates that the file is still in existance.
//			Refreshes by importing the current contents of the file.
//			
//		 Register Method - SQL
//			Validates the transaction object.
//			Confirms the transaction object is still connected to the db.
//			Refreshes by performing a retrive to the database.
//			
//			
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
// 5.0.04 Corrected arguments being passed twice to the retrieve function.			
// 6.0 	Enhanced to support refresh capabilities on all registering methods.
// 6.0 	Added support for new register methods.
// 7.0	Changed the li_rows variable to Long (ll_rows).
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer	li_rc
Integer 	li_upper=0
Integer	li_cnt=0
Long		ll_rows=0
Integer	li_id
Any		la_args[20]

// Check arguments
If IsNull(as_id) or Len(Trim(as_id))=0 Then
	Return -1
End If

// Trim and Convert the ID to lower case.
as_id = Trim(Lower(as_id))

// Find the matching ID.
li_upper = UpperBound(inv_cachelist)
For li_cnt = 1 to li_upper
	If as_id = inv_cachelist[li_cnt].s_id Then 
		// The ID was found.
		li_id = li_cnt
		Exit
	End If
Next
		
// Make sure an ID was found.		
If li_id = 0 Then
	// The ID was not found.
	Return -1
End If

// ---------------------------------------------------------------------------
// -- Refresh operation will be attempted.
// ---------------------------------------------------------------------------

// Validate the cached datastore.
If IsNull(inv_cachelist[li_id].ds_obj) Or &
	Not IsValid(inv_cachelist[li_id].ds_obj) Then
	// At this point the ds_obj should always be valid.
	Return -1
End If
		
// Check for the method and use the appropriate Refresh functionality.		
Choose Case inv_cachelist[li_id].s_method
		
	Case RETRIEVE, SQL		
		// Confirm that the transaction objects is good for a retrieve.
		If IsNull(inv_cachelist[li_id].tr_obj) Or & 
			Not IsValid(inv_cachelist[li_id].tr_obj) Then Return -1
		If Not inv_cachelist[li_id].tr_obj.of_IsConnected() Then Return -1
			
		// Refresh the data.
		la_args = inv_cachelist[li_id].a_args
		ll_rows = inv_cachelist[li_cnt].ds_obj.Retrieve(la_args[1], la_args[2], &
				la_args[3], la_args[4], la_args[5], la_args[6], la_args[7], &
				la_args[8], la_args[9], la_args[10], la_args[11], la_args[12], &
				la_args[13], la_args[14], la_args[15], la_args[16], la_args[17], &
				la_args[18], la_args[19], la_args[20])
		Return ll_rows
	
	Case DATAOBJECTDATA
		// Refresh the data to the original data.
		inv_cachelist[li_id].ds_obj.DataObject = ''
		inv_cachelist[li_id].ds_obj.DataObject = inv_cachelist[li_id].s_originaldataobject
		Return inv_cachelist[li_id].ds_obj.RowCount()
	
	Case DATAWINDOWCONTROL
		// Validate that the source is still available.
		If IsNull(inv_cachelist[li_id].dw_originalcontrol) or Not IsValid(inv_cachelist[li_id].dw_originalcontrol) Then
			Return -1
		End If
		// Validate the dataobjects still match.		
		If inv_cachelist[li_id].dw_originalcontrol.DataObject <> inv_cachelist[li_id].ds_obj.DataObject Then 
			Return -1	 			
		End If

		// Refresh the data.
		inv_cachelist[li_id].ds_obj.Reset()
		li_rc = inv_cachelist[li_id].dw_originalcontrol.RowsCopy (1, inv_cachelist[li_id].dw_originalcontrol.RowCount(), Primary!, &
						inv_cachelist[li_id].ds_obj, 1, Primary!)			
		If li_rc > 0 Then
			Return inv_cachelist[li_id].ds_obj.RowCount()
		End If
		Return -1
	
	Case DATASTORECONTROL
		// Validate that the source is still available.
		If IsNull(inv_cachelist[li_id].ds_originalcontrol) or Not IsValid(inv_cachelist[li_id].ds_originalcontrol) Then
			Return -1
		End If
		// Validate the dataobjects still match.		
		If inv_cachelist[li_id].ds_originalcontrol.DataObject <> inv_cachelist[li_id].ds_obj.DataObject Then 
			Return -1	 			
		End If
			
		// Refresh the data.
		inv_cachelist[li_id].ds_obj.Reset()			
		li_rc = inv_cachelist[li_id].ds_originalcontrol.RowsCopy (1, inv_cachelist[li_id].ds_originalcontrol.RowCount(), Primary!, &
						inv_cachelist[li_id].ds_obj, 1, Primary!)			
		If li_rc > 0 Then
			Return inv_cachelist[li_id].ds_obj.RowCount()
		End If
		Return -1

	Case POWEROBJECT
		// Check for a valid powerobject object.
		If IsNull(inv_cachelist[li_id].po_originaldata) Then 
			Return -1
		End If
		If UpperBound(inv_cachelist[li_id].po_originaldata) = 0 Then 
			Return -1
		End If	
		// Refresh the data to the original data.
		// *Note: if the po_originaldata does not match the data requirements
		// of the datawindow object, Powerbuilder will provide immediate
		//	error feedback.			
		inv_cachelist[li_id].ds_obj.object.data = inv_cachelist[li_id].po_originaldata
		Return 1
	
	Case IMPORTFILE
		// Validate the import file.
		If IsNull(inv_cachelist[li_id].s_filename) or &
			Not FileExists(inv_cachelist[li_id].s_filename) Then
			Return -1
		End If
			
		// Refresh the data.
		inv_cachelist[li_id].ds_obj.Reset()
		ll_rows = inv_cachelist[li_id].ds_obj.ImportFile(inv_cachelist[li_id].s_filename)
		If ll_rows > 0 Then
			Return ll_rows
		End If
		Return -1
End Choose

// Cache does not support Refresh operations.
Return 0
end function

     
Name Owner
pfc_n_cst_tvsrv_levelsource.of_retrieve pfc_n_cst_tvsrv_levelsource
pfc_n_cst_lvsrv_datasource.of_Retrieve pfc_n_cst_lvsrv_datasource
pfc_n_cst_dwcache.of_refresh pfc_n_cst_dwcache
pfc_n_cst_dwcache.of_register pfc_n_cst_dwcache

     
Name Owner
datawindow.rowcount datawindow
datawindow.rowscopy datawindow
datastore.importfile datastore
datastore.reset datastore
datastore.rowcount datastore
datastore.rowscopy datastore
systemfunctions.fileexists systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.len systemfunctions
systemfunctions.lower systemfunctions
systemfunctions.trim systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_tr.of_IsConnected pfc_n_tr

     
Full name
No Data

     
Name Scope
No Data