diff --git a/.gitignore b/.gitignore
index 21ea954..11c0b27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ __pycache__/
# Settings files with secrets
settings.ini
vfp/settings.ini
+vfp/output/
diff --git a/vfp/ApplicationSetup.prg b/vfp/ApplicationSetup.prg
index 9a25ebc..2dedc8c 100644
--- a/vfp/ApplicationSetup.prg
+++ b/vfp/ApplicationSetup.prg
@@ -119,14 +119,14 @@ DEFINE CLASS ApplicationSetup AS Custom
*-- Functie pentru validarea setarilor obligatorii
PROCEDURE ValidateSettings
- PARAMETERS toSettings
+ LPARAMETERS toSettings
LOCAL llValid, lcErrors
- IF ISNULL(toSettings)
+ IF PCOUNT() = 0
toSettings = THIS.oSettings
ENDIF
- IF ISNULL(toSettings)
+ IF TYPE('toSettings') <> 'O' OR ISNULL(toSettings)
RETURN .F.
ENDIF
@@ -202,14 +202,14 @@ DEFINE CLASS ApplicationSetup AS Custom
*-- Functie pentru afisarea informatiilor despre configuratie
PROCEDURE DisplaySettingsInfo
- PARAMETERS toSettings
+ LPARAMETERS toSettings
LOCAL lcInfo
- IF ISNULL(toSettings)
+ IF PCOUNT() = 0
toSettings = THIS.oSettings
ENDIF
- IF ISNULL(toSettings)
+ IF TYPE('toSettings') <> 'O' OR ISNULL(toSettings)
RETURN .F.
ENDIF
diff --git a/vfp/gomag-adapter.prg b/vfp/gomag-adapter.prg
index 626a8e5..5f84b80 100644
--- a/vfp/gomag-adapter.prg
+++ b/vfp/gomag-adapter.prg
@@ -18,21 +18,13 @@ Local lcStatusText, lnStatusCode, loError
Local lnLimit, lnCurrentPage, llHasMorePages, loAllJsonData, lnTotalPages, lnTotalProducts
Local lcOrderApiUrl, loAllOrderData, lcOrderCsvFileName, lcOrderJsonFileName
Local ldStartDate, lcStartDateStr
-Local lcIniFile, loSettings
+Local lcIniFile
LOCAL llGetProducts, llGetOrders
-PRIVATE gcAppPath, loJsonData, gcLogFile, gnStartTime, gnProductsProcessed, gnOrdersProcessed
+PRIVATE loJsonData, gcLogFile, gnStartTime, gnProductsProcessed, gnOrdersProcessed
-
-gcAppPath = ADDBS(JUSTPATH(SYS(16,0)))
-SET DEFAULT TO (m.gcAppPath)
-lcPath = gcAppPath + 'nfjson;'
-SET PATH TO (m.lcPath) ADDITIVE
-
-SET PROCEDURE TO utils.prg ADDITIVE
-SET PROCEDURE TO ApplicationSetup.prg ADDITIVE
-SET PROCEDURE TO nfjsonread.prg ADDITIVE
-SET PROCEDURE TO nfjsoncreate.prg ADDITIVE
+*-- Include utilitare necesare
+SET PROCEDURE TO regex.prg ADDITIVE
*-- Initializare logging si statistici
gnStartTime = SECONDS()
@@ -47,39 +39,49 @@ IF !DIRECTORY(lcOutputDir)
MKDIR (lcOutputDir)
ENDIF
-*-- Creare și inițializare clasa setup aplicație
+*-- Creare si initializare clasa setup aplicatie
LOCAL loAppSetup
loAppSetup = CREATEOBJECT("ApplicationSetup", gcAppPath)
*-- Setup complet cu validare
IF !loAppSetup.Initialize()
- LogMessage("EROARE: Setup-ul aplicației a eșuat sau necesită configurare!", "ERROR", gcLogFile)
+ LogMessage("EROARE: Setup-ul aplicatiei a esuat sau necesita configurare!", "ERROR", gcLogFile)
RETURN .F.
ENDIF
-*-- Obținere setări din clasă
-loSettings = loAppSetup.GetSettings()
-
*-- Configurare API din settings.ini
-lcApiBaseUrl = loSettings.ApiBaseUrl
-lcOrderApiUrl = loSettings.OrderApiUrl
-lcApiKey = loSettings.ApiKey
-lcApiShop = loSettings.ApiShop
-lcUserAgent = loSettings.UserAgent
-lcContentType = loSettings.ContentType
-lnLimit = loSettings.Limit
-llGetProducts = loSettings.GetProducts
-llGetOrders = loSettings.GetOrders
+lcApiBaseUrl = goSettings.ApiBaseUrl
+lcOrderApiUrl = goSettings.OrderApiUrl
+lcApiKey = goSettings.ApiKey
+lcApiShop = goSettings.ApiShop
+lcUserAgent = goSettings.UserAgent
+lcContentType = goSettings.ContentType
+lnLimit = goSettings.Limit
+llGetProducts = goSettings.GetProducts
+llGetOrders = goSettings.GetOrders
lnCurrentPage = 1 && Pagina de start
llHasMorePages = .T. && Flag pentru paginare
loAllJsonData = NULL && Obiect pentru toate datele
*-- Calculare data pentru ultimele X zile (din settings.ini)
-ldStartDate = DATE() - loSettings.OrderDaysBack
+ldStartDate = DATE() - goSettings.OrderDaysBack
lcStartDateStr = TRANSFORM(YEAR(ldStartDate)) + "-" + ;
RIGHT("0" + TRANSFORM(MONTH(ldStartDate)), 2) + "-" + ;
RIGHT("0" + TRANSFORM(DAY(ldStartDate)), 2)
+*******************************************
+*-- Sterg fisiere JSON comenzi anterioare
+lcDirJson = gcAppPath + "output\"
+lcJsonPattern = m.lcDirJson + goSettings.JsonFilePattern
+lnJsonFiles = ADIR(laJsonFiles, lcJsonPattern)
+FOR lnFile = 1 TO m.lnJsonFiles
+ lcFile = m.lcDirJson + laJsonFiles[m.lnFile,1]
+ IF FILE(m.lcFile)
+ DELETE FILE (m.lcFile)
+ ENDIF
+ENDFOR
+*******************************************
+
*-- Verificare daca avem WinHttp disponibil
TRY
loHttp = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
@@ -254,7 +256,7 @@ ENDIF
*-- SECTIUNEA COMENZI - se executa doar daca llGetOrders = .T.
IF llGetOrders
LogMessage("[ORDERS] =======================================", "INFO", gcLogFile)
- LogMessage("[ORDERS] RETRIEVING ORDERS FROM LAST " + TRANSFORM(loSettings.OrderDaysBack) + " DAYS", "INFO", gcLogFile)
+ LogMessage("[ORDERS] RETRIEVING ORDERS FROM LAST " + TRANSFORM(goSettings.OrderDaysBack) + " DAYS", "INFO", gcLogFile)
LogMessage("[ORDERS] Start date: " + lcStartDateStr, "INFO", gcLogFile)
LogMessage("[ORDERS] =======================================", "INFO", gcLogFile)
@@ -432,7 +434,7 @@ CloseLog(gnStartTime, gnProductsProcessed, gnOrdersProcessed, gcLogFile)
PROCEDURE SaveProductsArray
PARAMETERS tloAllData, tcFileName
-LOCAL lcJsonContent, lnPropCount, lnIndex, lcPropName, loProduct
+LOCAL lcJsonContent, lnPropCount, lnIndex, lcPropName, loProduct, lcProductJson
*-- Incepe array-ul JSON
lcJsonContent = "[" + CHR(13) + CHR(10)
@@ -451,7 +453,7 @@ IF TYPE('tloAllData.products') = 'O'
lcJsonContent = lcJsonContent + "," + CHR(13) + CHR(10)
ENDIF
- *-- Serializeaza produsul cu nfjsoncreate
+ *-- Serializeaza produsul cu nfjsoncreate standard
lcProductJson = nfJsonCreate(loProduct, .F.)
lcJsonContent = lcJsonContent + " " + lcProductJson
ENDIF
@@ -470,7 +472,7 @@ ENDPROC
PROCEDURE SaveOrdersArray
PARAMETERS tloAllData, tcFileName
-LOCAL lcJsonContent, lnPropCount, lnIndex, lcPropName, loOrder
+LOCAL lcJsonContent, lnPropCount, lnIndex, lcPropName, loOrder, lcOrderJson
*-- Incepe array-ul JSON
lcJsonContent = "[" + CHR(13) + CHR(10)
@@ -489,7 +491,7 @@ IF TYPE('tloAllData.orders') = 'O'
lcJsonContent = lcJsonContent + "," + CHR(13) + CHR(10)
ENDIF
- *-- Serializeaza comanda cu nfjsoncreate
+ *-- Serializeaza comanda cu nfjsoncreate standard
lcOrderJson = nfJsonCreate(loOrder, .F.)
lcJsonContent = lcJsonContent + " " + lcOrderJson
ENDIF
@@ -504,6 +506,7 @@ STRTOFILE(lcJsonContent, tcFileName)
ENDPROC
+
*-- Functie pentru unirea produselor din toate paginile (versiune simpla)
PROCEDURE MergeProducts
PARAMETERS tloAllData, tloPageData
diff --git a/vfp/output/gomag_all_products_20250909_193919.json b/vfp/output/gomag_all_products_20250909_193919.json
deleted file mode 100644
index c6560e2..0000000
--- a/vfp/output/gomag_all_products_20250909_193919.json
+++ /dev/null
@@ -1,817 +0,0 @@
-[
- {"alloworderswhenoutofstock":"0","attributes":["_EMPTY_ARRAY_FLAG_"],"base_price":"1.0000","brand":"Wittenborg","bundleitems":["_EMPTY_ARRAY_FLAG_"],"canonical_url":"https:\\/\\/www.coffeepoint.ro\\/piese-schimb-aparate-cafea\\/surub-sita-piston-9g-necta-wittenborg.html","categories":[[{"id":"10","name":"Piese aparate cafea"},{"id":"11","name":"Grupuri de cafea"}]],"created":"2021-04-23 10:02:41","currency":"RON","customsearchkeys":"","delivery_time":null,"delivery_time_type":"text","description":"","ean":"","ecotax":"0.0000","enabled":"1","feeddescription":"","files":null,"group_key":"","html_description":"Surub sita piston 9g Necta\\/Wittenborg","html_title":"Surub sita piston 9g Necta\\/Wittenborg","id":"10","images":["https:\\/\\/gomagcdn.ro\\/domains\\/coffeepoint.ro\\/files\\/product\\/original\\/surub-sita-piston-9g-necta-wittenborg-10-685063.png"],"name":"Surub sita piston 9g Necta\\/Wittenborg","parent":"10","parent_sku":"094508","price":"1.0000","short_description":"","sku":"094508","stock":"0","stockmanagement":"0","stock_status":"instock","um":null,"updated":"2024-08-30 09:00:33","url":"https:\\/\\/www.coffeepoint.ro\\/surub-sita-piston-9g-necta-wittenborg.html","vat":"21","vat_included":1,"videos":null,"weight":"0.1"},
- {"alloworderswhenoutofstock":"0","attributes":[{"id":"4","name":"Capacitate","type":"dropdown","value":"8oz"}],"base_price":"170.0000","brand":"RLP","bundleitems":["_EMPTY_ARRAY_FLAG_"],"canonical_url":"https:\\/\\/www.coffeepoint.ro\\/oferte\\/pahar-carton-8oz-albastru-rlp-bax-1000buc.html","categories":[[{"id":"56","name":"Oferte"},{"id":"47","name":"Baxuri Pahare"}]],"created":"2021-04-23 10:02:47","currency":"RON","customsearchkeys":"","delivery_time":null,"delivery_time_type":"text","description":"Acest tip de pahar este recomandat pentru automatele vending cu pahare automat. Sunt produse din material tratat antistatic, rezistent si cu un design frumos.
\\r\\nPahar carton 230ml\\/8oz.
\\r\\nMod ambalare: 50\\/set, iar o cutie contine 20 seturi.Pretul afisat este pentru un bax de 1000buc.","ean":"","ecotax":"0.0000","enabled":"1","feeddescription":"","files":null,"group_key":"","html_description":"","html_title":"","id":"101","images":["https:\\/\\/gomagcdn.ro\\/domains\\/coffeepoint.ro\\/files\\/product\\/original\\/pahar-carton-8oz-albastru-rlp-bax-1000buc-315976.webp"],"name":"Pahar carton 8oz Albastru RLP bax 1000buc","parent":"101","parent_sku":"58912111224","price":"137.0000","short_description":"","sku":"58912111224","stock":"0","stockmanagement":"0","stock_status":"instock","um":null,"updated":"2024-08-30 09:00:57","url":"https:\\/\\/www.coffeepoint.ro\\/pahar-carton-8oz-albastru-rlp-bax-1000buc.html","vat":"21","vat_included":1,"videos":null,"weight":"10"},
- {"alloworderswhenoutofstock":"0","attributes":["_EMPTY_ARRAY_FLAG_"],"base_price":"89.0000","brand":"Kimbo","bundleitems":["_EMPTY_ARRAY_FLAG_"],"canonical_url":"https:\\/\\/www.coffeepoint.ro\\/cafea\\/kimbo-extra-cream-cafea-boabe-1kg.html","categories":[[{"id":"8","name":"Cafea"},{"id":"24","name":"Cafea Boabe"}]],"created":"2024-05-14 12:36:15","currency":"RON","customsearchkeys":"","delivery_time":null,"delivery_time_type":"text","description":"Kimbo Extra Cream Medium Roast<\\/em> este o cafea boabe premium, care încântă simțurile cu arome bogate și o cremă catifelată. Această cafea italiană autentică face parte din linia Kimbo Espresso Bar pentru profesioniști și oferă o experiență de degustare intensă, cu note profunde de piper negru și lemn dulce, echilibrate perfect de o aciditate delicată. Boabele sunt meticulos selecționate și prăjite cu grijă pentru a extrage maximul de arome și a obține o cremă bogată și persistentă în fiecare ceașcă.<\\/span>\\r\\nCaracteristici:<\\/b><\\/span><\\/span><\\/span><\\/h2>\\r\\n\\r\\n\\r\\n\\t- Note – <\\/b>piper, lemn dulce<\\/span><\\/span><\\/span><\\/li>\\r\\n\\t
- Aromă – <\\/b>Intens<\\/span><\\/span><\\/span><\\/li>\\r\\n\\t
- Corp — <\\/strong>Mediu<\\/span><\\/span><\\/span><\\/li>\\r\\n\\t
- Originea boabelor de cafea – <\\/b>Brazilia, India si Columbia<\\/span><\\/span><\\/span><\\/li>\\r\\n\\t
- Nivel de prăjire – <\\/b>Mediu (Medium Roast)<\\/span><\\/span><\\/span><\\/li>\\r\\n\\t
- Recomandată pentru – <\\/b>espressor, mocha pot, filtru<\\/span><\\/span><\\/span><\\/li>\\r\\n<\\/ul>\\r\\n \\r\\n\\r\\n
Mod de ambalare:<\\/b><\\/span><\\/span><\\/span><\\/h2>\\r\\n
\\r\\nCafeaua boabe Kimbo Extra Cream medium roast<\\/em> este ambalată în pungi de 1 kg iar un bax conține 6 pungi.<\\/span><\\/span><\\/span>","ean":"8002200148157","ecotax":"0.0000","enabled":"1","feeddescription":"","files":null,"group_key":"","html_description":"","html_title":"","id":"1014","images":["https:\\/\\/gomagcdn.ro\\/domains\\/coffeepoint.ro\\/files\\/product\\/original\\/lavazza-qualita-oro-cafea-boabe-1kg-copie-885012.webp"],"name":"Kimbo Extra Cream Cafea Boabe 1kg","parent":"1014","parent_sku":"8002200148157-1893","price":"83.9900","short_description":"
\\r\\n