#include ab.h
DEFINE Class tutoSets AS awSets OF awPublic.prg
procedure Init
lparameters ;
result;
, toAppHost as awAppHost of awAppHost.fxp
local success as Boolean;
, lcDev, llDev;
, lcThisPrg;
, uException as Exception;
, hSQLconnect as Integer;
, iSQLversion as Integer;
, connectString as String;
, lConnected as Boolean;
, oDefault as abSet of abDev.prg;
success = DoDefault(;
@m.result;
)
#if .F.
with this as awSets of awPublic.prg
#endif
lcDev = Iif(Directory('..\..\_Data\'), '..\', '')
llDev = !Empty(m.lcDev)
SET PATH TO '';
+ Iif(m.llDev;
, '';
+ '.\Progs\;';
+ '.\Progs\Bitmaps\;';
+ '.\Progs\Forms\;';
+ '.\Progs\Menus\' + Iif(this.wlLAN or m.toAppHost.BSlHTMLgen, 'bs\', '') + ';';
+ '..\Classe\;';
+ '..\..\Tastrade\Adapted\Form\;';
;
, '..\_Images\;';
);
+ m.lcDev + '..\_Data\;';
+ m.lcDev + '..\_Libs\FoxyPreviewer\;';
+ m.lcDev + '..\_Libs\xfrx\;';
+ m.lcDev + '..\_Libs\FRX2Any\;';
ADDITIVE
IF !this.lAutomation
ClassLibAdd('';
+ 'ficSample.vcx,';
+ '_reportListener.vcx,';
+ '_gdiPlus.vcx';
)
external class ficSample, _reportListener, _gdiPlus
lcThisPrg = cModuleInfo(Sys(16), 'A')
set procedure to (m.lcThisPrg) additive
ENDIF
if File('foxyPreviewer.app')
set printer to default
try
oDefault = abSet('default', JustPath(FullPath('foxyPreviewer.app')))
do foxyPreviewer.app
_screen.oFoxyPreviewer.lSilent = !m.this.lDevMode
catch to uException
uException = cException(m.uException)
do case
case this.wlLAN
MessageBox([FoxyPreviewer could not load!] + CRLF2 + m.uException)
case Vartype(m.toAppHost) == 'O'
cResultAdd(@m.result, m.uException)
endcase
endtry
oDefault = .null.
endif
local FRX2Any
FRX2Any = 'FRX2Any'
if File(m.FRX2Any + '.app')
set classlib to &FRX2Any in FRX2Any.app additive
else
cResultAdd(@m.result, 'FRX2Any.app could not be found')
endif
set collate to 'MACHINE'
set deleted off
set exact off
set exclusive off
set multilocks on
set reprocess to -2
set safety off
set sysformats on
set talk off
set nulldisplay to 'N/D'
public goApp
goApp = NewObject('ficCstApp', 'ficSample.vcx')
local cAlias
if !File('ficEvent.dbf') or .F. and varSet(@m.cAlias, ExclusiveForce('ficEvent.dbf')) and Used(m.cAlias)
use in select (Evl(m.cAlias, ''))
try
CREATE TABLE ficEvent FREE (;
ID I autoinc unique;
, MODE C(1);
, userID C(10) null;
, FORM C(50);
, NAME C(50);
, EVENT C(50);
, baseClass C(50);
, Class C(50);
, lBufDirty L null;
, timeStamp T;
)
index on userID tag userID collate 'general'
index on form tag form collate 'general'
index on name tag name collate 'general'
index on event tag event collate 'general'
index on baseClass tag baseClass collate 'general'
index on Class tag Class collate 'general'
index on timeStamp tag timeStamp
use
StrToFile('', 'ficEvent' + Iif(m.this.wlWeb,'Web','Lan') + '.log')
cResultAdd(@m.result, 'FoxInCloud Tutorial Event Table created')
catch
endtry
endif
IF m.this.wlLAN
set escape off
ADDPROPERTY(m.this, 'ON_SHUTDOWN', ON('shutdown'))
ON SHUTDOWN CLEAR EVENTS
endif
open database tastrade
do case
case Sys(0) == "THN-W7-32 # ThierryNivelet" and m.this.lDevMode
lConnected = .T.
case m.this.lDevMode
SQLSetProp(0, "DispLogin", DB_PROMPTNEVER)
for iSQLversion = 1 to 2
connectString = "";
+ "Driver=SQL Server Native Client 11.0;";
+ "Server=" + Iif(m.iSQLversion = 1;
, "(localdb)\MSSQLLocalDB";
, "localhost\SQLEXPRESS";
) + ";";
+ "AttachDbFilename=";
+ DOS_AWSAMPLES_DATA + "SQLSERVER\";
+ Iif(m.iSQLversion = 1, '2014\', '');
+ "NorthWind.mdf;";
+ "Database=NorthWind_FiC;";
+ "Trusted_Connection=Yes;";
+ "Connect Timout=5;";
+ "APP=FICtuto;";
+ ""
hSQLconnect = SQLStringConnect(m.connectString)
lConnected = m.hSQLconnect > 0
if m.lConnected
SQLDisconnect(m.hSQLconnect)
DBSetProp('Northwind', "CONNECTION", "ConnectString", m.connectString)
exit
endif
endfor
otherwise
hSQLconnect = SQLconnect('Northwind')
lConnected = m.hSQLconnect > 0 and (SQLdisconnect(m.hSQLconnect) > 0 or .T.)
endcase
cResultAdd(@m.result, "Connection to the 'Northwind' SQLserver database: " + Iif(m.lConnected, 'OK', 'KO -- ' + caError()))
= this.wlLAN;
or cResultAdd(@m.result, "This application is for learning and testing; some errors are intended and triggered purposedly... AVAILABILITY RATIO IS FAR BELOW what a regular production application usually gets.");
or cResultAdd(@m.result, "By default, this FoxInCloud Web Application Dashboard is protected by a secured authentication; it was made public in this very example for the purpose of demonstration.");
or .F.
if !(this.lDevMode and this.wlLAN)
DO tuto.mpr
endif
return m.success
endproc
PROCEDURE Destroy
IF m.this.wlLAN
lcValue = m.this.ON_SHUTDOWN
ON SHUTDOWN &lcValue
endif
release goApp
return DODEFAULT()
endproc
ENDDEFINE
define Class ficGrc as awGrc of awPublic.prg
headerClass = 'ficGrh'
headerClassLibrary = 'tutoSets.fxp'
FontName = "Consolas"
enddefine
define Class ficGrh as awGrh of awPublic.prg
FontName = "Consolas"
Alignment = 2
enddefine
function tutoNavigate(URL, newWindow)
return wNavigate(;
Iif(wlLAN(), 'http://foxincloud.com/tutotest/', '') + m.URL;
, lTrue(m.newWindow);
)
endfunc
function fileDisplay(file)
return tutoNavigate(;
'fileDisplay.tuto?' + m.file;
, .T.;
)
endfunc
procedure custOrderReport
lparameters ;
result;
, lcPDFout;
, customerID;
, lcPDFengine;
local success as Boolean
try
lcPDFout = Textmerge([<<Addbs(Sys(2023))>>customer_<<Trim(m.customerID)>>_<<m.lcPDFengine>>.pdf])
lcPDFengine = Upper(Alltrim(Evl(m.lcPDFengine, 'XFRX')))
do case
* =================================================
case m.lcPDFengine == Upper('XFRX')
local oXFRXlistener as XFRXlistener of xfrx.app
oXFRXlistener = Evaluate("xfrx('XFRX#LISTENER')")
success = Vartype(m.oXFRXlistener) == 'O'
if m.success
result = m.oXFRXlistener.setParams(;
m.lcPDFout;
, ;
, .T.;
, ;
, .T.;
, ;
, 'PDF';
)
success = Empty(m.result)
if m.success
* --------------------------------
REPORT FORM customer;
for customer_ID = m.customerID;
object m.oXFRXlistener
* --------------------------------
else
result = m.oXFRXlistener.ErrorMessage(m.result)
endif
else
result = [could not instantiate XFRX report listener]
endif
* =================================================
case m.lcPDFengine == Upper('FoxyPreviewer')
* --------------------------------
REPORT FORM customer;
for customer_ID = m.customerID;
object type 10;
to file (m.lcPDFout)
* --------------------------------
success = .T.
* =================================================
case m.lcPDFengine == Upper('FRX2any')
local loPDFfile as PDFfile of FRX2Any
loPDFfile = CreateObject('FRX2Any.PDFfile')
success = Vartype(m.loPDFfile) == 'O'
if m.success
with m.loPDFfile as PDFfile of FRX2Any
.Unlock('xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx')
.cExportFileName = JustStem(m.lcPDFout)
.cSaveFolder = JustPath(m.lcPDFout)
.lTranslateFontStyle = .T.
.cForExpression = Textmerge([customer_ID = "<<m.customerID>>"])
* --------------------------------------
result = .Save(FullPath('customer.frx'))
* --------------------------------------
success = Empty(m.result)
result = Iif(m.success, '', Textmerge([FRX2Any returned error #<<m.result>>]))
.Release
endwith
else
result = [could not instantiate FRX2Any.PDFfile]
endif
* =================================================
endcase
catch to m.result
success = .F.
result = cException(m.result)
endtry
return m.success
endproc