Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pack
Message
De
30/03/2004 08:58:10
 
 
À
30/03/2004 03:06:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Re: Pack
Divers
Thread ID:
00890674
Message ID:
00890733
Vues:
30

DO NOT USE THIS CODE IN A LIVE ENVIRONMENT
SAMPLE ONLY



If you must pack your tables this is a technique that can be explored. This code is NO tested nor is it an example of a known solution. I am providing it here just as an example of a coding technique which can be experimented with, and if found to be usable it may be of some value to you and others. DO NOT use this code as-is in a production environment, it is presented only to stimulate your creative skills.



SAMPLE CODE FOR STUDY ONLY

#Define minutes 60
#Define hrs minutes * 60
#Define days Hours * 24
#Define Secs 1000

IF NOT FILE('packlist.dbf')
	CREATE TABLE packlist (tablename c(60), nextrun t, lastrun t)
	use
ENDIF 

lo = CREATEOBJECT('packer')
IF VARTYPE(lo) = 'O'
	lo.Packfiles()
ENDIF 


Define Class packer As Relation
	CollPacklist	=	''

	Function Init
		Local oPackfile, oCollPacklist As Collection
		Set Safety Off
		Set Talk Off
		Set Deleted On

		Declare Sleep In kernel32 Integer dwMilliseconds

		This.ColPacklist = Createobject('collection')
		Use packlist
		Scan
			Scatter Memo Name oPackfile
			oCollPacklist = This.CollPacklist
			oCollPacklist.Add(oPackfile,oPackfile.TableName)
		Endscan
		Use
		Set Exclusive On

	Function PackFiles
		Do While This.CheckEscape()

			Now = Datetime()
			For Each oPackfile In This.CollPacklist
				If oPackfile.nextrun < Now
					Try
						Use (oPackfile.TableRef) Exclusive Alias packer
						lExcl = .T.
					Catch
						lExcl = .F.
					Endtry
					If lExlc
						Try
							Copy To (Addbs(Getenv("TEMP"))+Justfname(Dbf()))
							ZAP
							try
								Append From (Addbs(Getenv("TEMP"))+Justfname(Dbf()))
								oPackfile.nextrun = oPackfile.nextrun + oPackfile.DayInterval+days +oPackfile+hrsInterval+hrs
								oPackfile.lastrun = DATETIME()
							CATCH
								STRTOFILE('Pack failed '+DBF(),'PackFail.txt',2)
								oPackfile.nextrun = DTOT(DATE({^2500/12/31}))	&& Do not allow file to pack again until repaired
								this.emailoperator()
							endtry
						Catch
						Endtry
						Use
					Endif
				Endif
				If Not This.CheckEscape()
					Exit
				Endif
			Endfor
			If Not This.CheckEscape()
				Exit
			Endif
			Sleep(Secs*minutes*5) && Sleep 5 minutes
		Enddo

	Function CheckEscape
		Return Not File(Getenv("TEMP")+'\PackerKill.txt')
	Endfunc

	Function Destroy
		Use packlist
		For Each oPackfile In This.CollPacklist
			Locate For packlist.TableName = oPackfile.TableName
			If Found()
				Gather Name oPackfile Memo
			Endif
		Endfor
		USE
	
	FUNCTION emailoperator
		* Put logic here to submit email with failure notice
	endfun
Enddefine
Glenn


>Hello,
>
>if you can help me, how i can make (pack) for my table in the midnight
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform