PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio â†’ WINDEV 2024 â†’ replication alternatives
replication alternatives
Iniciado por guest, 11,abr. 2014 18:57 - 14 respuestas
Publicado el 11,abril 2014 - 18:57
I start this post to gather info about replication, because there seems to be issues with the builtin replication of HFCS.
And to get away from the WXlive webinar-post.
Publicado el 11,abril 2014 - 18:57
@James


Every POS systems uses a local hfcs database. It has a database-uid saved in one of the tables.
On startup this UID is checked and if it is zero it's filled with day-of-year + seconds-since-midnight
(the chance you start 2 new systems at the exact same time is very minimal - but every replication I first check if the master and subscriber UID are different - to be sure)

The same table holds the last id for every table I want to replicate. One field for the invoiceID, one for invoice-lineID, one for orderID, etc
On every HAdd I increment it's value using triggers and a lock (to avoid creating duplicates in a multiuser stuation).
Then I use this id TOGETHER with the database UID as a new unique key in the tables for invoices, orders,etc.

These keyfields are not autoID fields, but plain 8-byte numerics (still unique indexed of course). I create and fill them myself, with numbers which are unique across all databases.

Not completely generic but certainly useable in my situation.

say db1 has a UID of 123182432
say db2 has a UID of 124172341
I create an invoice record in db1 with a keyvalue of 12318243200000001
I create an invoice record in db2 with a keyvalue of 12417234100000001
After uploading to a 3rd db (or from db1 to db2) this db3 holds 2 records
12318243200000001
12417234100000001
No collission what so ever.

NOTE: if pcsofts replication IS working 100% one day I can switch without any change, because it requires 8-byte-int as well !!
Publicado el 11,abril 2014 - 19:16
Thank you Arie for your ideas and your help.

James
Publicado el 11,abril 2014 - 19:24
Don't hesitate to ask more questions or send me a PM
Publicado el 11,abril 2014 - 19:41
Hi Arie,

I thought of a possible little optimization of your code to make it even more simple.

At first system start, calculate your unique ID (as you do right now). Then for every file you want to replicate, create an Auto-ID int8 and set the starting point of the Auto-ID at the value of your unique ID. Then let WD do the job itself. The end result is that you will have Auto-ID managed BY WinDev and also unique IDs for replication.

Using your example:
- DB1 has a UID of 123182432
- Starting point should be 12318243200000000 for all files
- Call HAdd with hSetIdAuto to that value. Then delete the record.
- Next time you call HAdd(), the first ID will be 12318243200000001, etc.

You have the advantage of not having to manage the Auto-ID at all; just set it once at system start. (This is better than GUID because since it's not yet available in WD19, you would have to manage them manually. At least your solution can be managed automatically with a super simple setup at system start.)

Best regards,
Alexandre Leclerc
Publicado el 11,abril 2014 - 20:12
Thanks Arie, I aprecciate your help.

I have to develop a least 2 more (complicated) modules to add to my system (asked by my client) before first of may and now I have this replica problem...

I will see what I can do this weekend.

once more thank you.

James
Publicado el 11,abril 2014 - 20:29
Alexandre

Brilliant and simple!
I'm going to use that for sure.
Publicado el 11,abril 2014 - 23:00
Hi

Well I wanted to implement the replication as well . Iam glad I havenot started with it so no time is lost haha. Thanks for this discussion. For sure iam going to implement something like this.


Regards
Publicado el 12,abril 2014 - 14:55
Hi Arie

just wanted to know if you received my pm?

Thanks

james
Publicado el 12,abril 2014 - 17:21
yes
Publicado el 13,abril 2014 - 02:01
Hi everybody

just wanted to remind anybody who's reading this post that there is a limitation in the size of INT you can use in webdev browser code (or in ANY browser code, as it is a JS limitation)...

So while the use of int on 8 for unique ID is the way PCSoft has chosen, and while Alexandre idea is certainly very clever, this will NOT work correctly if at any point you have to send on of those huge values to the browser side of a webdev site (and work on them as integer)

Best regards
Publicado el 13,abril 2014 - 13:00
Hi,

In WinDev I Used a similar scheme for my replicate class using MyCustomerID+TheirSiteID+LocalRecordnr in my trigger code.

I Use a webservice to deliver the "MyCustomer"+"TheirSite id" numbers.

After putting a very long number into a decimal 38 digits field I got problems then tried 32, - but then relation between tables in the queries failed (reported to PC Soft)

- Nowdays I use a 50 length text field for my primarykey, not shure how mutch impact it will have on speed however, when the amount of data builds up.



Cheers
Tor-Bjarne
Publicado el 13,abril 2014 - 15:27
I came across this tool http://www.symmetricds.org/ which is an open source database replication tool.
But, only if you are NOT using HyperfileSQL. It does support several common databases like MySQL, MSSQL, Oracle and so on.
Publicado el 14,abril 2014 - 09:53
I have used SymmetricDS for a .NET project with MSSQL Express a few years back. Still running without a problem without meantenance. First time setup was complex, but maybe they have worked out those issues in a newer version.
Clients are mobile workers with a Portable and they sync over Mobile Network and Wifi.

They replicate as a star or waterfall or a combination of those. Just check the website Arie has mentioned.

Danny
Publicado el 23,junio 2015 - 16:03
Hi

I have been struggling in understanding replication and came across you comments about Symmetric.

I wondered if you could shed any light on how to integrate this into a Win Mobile app for Android using SQlite

If you could provide any info that would be fabulous

Thanks

T