CLEAR ALL

SET SAFETY OFF
SET MEMOWIDTH TO 200

SET PATH TO
SET PROCEDURE TO
SET EXCLUSIVE OFF
SET REPROCESS TO 20 SECONDS

SET ENGINE 70

*SET LIBRARY TO libs\licence_lib
SET LIBRARY TO libs\json ADDITIVE
SET LIBRARY TO libs\TApiExceptionU  ADDITIVE
SET LIBRARY TO libs\json.fll  ADDITIVE

SET PROCEDURE TO libs\datetime_lib  ADDITIVE

_godina = year(date())
__godina = year(date())

orgdrive = "P:"
IF ! DIRECTORY(orgdrive + "\")
 mErrorMessage = "Ne postoji disk " + orgdrive
 throw mErrorMessage
ENDIF

_DB_NOEDIT = ""
_DEFAULTD = ""
AISIFRA = ""
_OZN_LOZ = ""

ON ERROR

SET PATH TO "c:\handystock\licdemo\;c:\handystock\;P:\VINFO16\GLOBAL\;P:\VINFO16\FIN\PR01\;P:\VINFO16\PEVID\PEV01\;P:\VINFO16\MAIN\;P:\VINFO16\PEVID\"

*==========================================================================*

?
? "KREIRANJE LICENCE"
?

LOCAL mKomitentId
*mKomitentId = "1034" && Infosys
*mKomitentId = "0935"
*mKomitentId = "0678" && pons
*mKomitentId = "0007"
mKomitentId = "A010"
*mKomitentId = "M999"
 

LOCAL mLicenceEnvelope
mLicenceEnvelope = NEWOBJECT ("TLicenceEnvelope", "..\libs\tlicenceenvelope.prg", null)
mLicenceFile = mLicenceEnvelope.PrepareLicence(mKomitentId,"", .T.)

? "Komitent: " + mKomitentId 
? "Checksum: " + mLicenceEnvelope.checksum
? "Output: " + mLicenceFile

*==========================================================================*

?
?
? "UCITAVANJE LICENCE"
?


LOCAL mLicenceEnvelopeLoad
mLicenceEnvelopeLoad = NEWOBJECT ("TLicenceEnvelope", "..\libs\tlicenceenvelope.prg", null)

*mKomitentId = "A010"

LOCAL mLocationId
mLocationId = "000008"

? "LOAD: Komitent: [" + mKomitentId + "] lokacija: " + mLocationId

LOCAL mSegmentId
mSegmentId = 'API'

LOCAL mModulId
mModulId = 'SYSTEM'

LOCAL mKlijentId
mKlijentId = 'DEMO'

LOCAL mAPIVerzija
mAPIVerzija = 1

LOCAL mFunkcija
mFunkcija = "TEST"

LOCAL mLicence
mLocationLicence = mLicenceEnvelopeLoad.LoadLicence (mKomitentId, mLocationId)

LOCAL mKomitent
mKomitent = mLocationLicence.GetKomitent()

  ? "LICENCED TO: Komitent: [" + mKomitent.id + "] " + mKomitent.naziv + " PIB: " + mKomitent.pib
  
  ? "Lokacija: [" + mLocationLicence.id + "] " + mLocationLicence.naziv + " Status: " + mLocationLicence.GetStatus()

  LOCAL mClient
  mClient = mLocationLicence.GetClient(mKlijentId)

  ? "Klijent: [" + mClient.id + "] API version: " + ALLTRIM (STR (mClient.api_version)) + " Proizvodjac: [" + mClient.proizvodjac_id + "] " + mClient.proizvodjac
  ? " Status: " + mClient.GetStatus(mFunkcija, mAPIVerzija)
  
  LOCAL mSegmentStatus
  mSegmentStatus = mLocationLicence.GetSegmentStatus (mSegmentId)
  ? "Status Segmenta: " + mSegmentStatus
    
  LOCAL mModulStatus
  mModulStatus = mLocationLicence.GetModulStatus(mModulId)
  ? "Status Modula: " + mModulStatus

  LOCAL mKlijentStatus
  mKlijentStatus = mLocationLicence.GetClientStatus(mKlijentId, mAPIVerzija, mFunkcija)
  ? "Status klijenta " + mKlijentId + ": " + mKlijentStatus
  
  

*==========================================================================*

ON ERROR


*******************
PROCEDURE _ERROR
	PARAMETERS p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19
  
  ON ERROR
  
  LOCAL j
  LOCAL mResult
  
  ?
  ? "========================================================="
  ? "ERROR INFO"
  ?
  
  FOR j = 1 TO 19
    mParamName = "p" + ALLTRIM (STR (j))

    ? mParamName + ": "
    ?? EVAL(mParamName)
    
  ENDFOR
    
  ? 
  ? "========================================================="
  ?
  
ENDPROC