1
votes

I have an entityManager containing entities with entityStatus: "Added". When website is offline I want to add new entities and export them to the LocalStorage. When the website goes online again I need to import entities back to a manager and send them to server DB.

I've got this working except one thing: If I have several browser windows open in offline mode breeze trying to send data from all the pages. And when internet connection appears all scripts in open browser windows send the same data at the same time. Thus I have several records in my database that are the same.

UPDATE: deleting saved entry in local storage is not the best solution because sending could fail and I will lose data. Deleting local storage entry in a send callback doesn't solve the problem as well because at that time all open windows would be already fed with data from local storage and will send duplicates to DB

What is the strategy to avoid multiple saving from several pages?

1

1 Answers

1
votes

Not entirely sure I understand the problem. At little more detail would be helpful. But based on what you've said, I'm assuming that the first step when a client first starts up is to retrieve an exported set of entities from localStorage and then try to save it. My suggestion would be that each client should immediately clear the localStorage after reading it in so that any other clients don't try to replay the same changes and then only write data back out to localStorage if the client cannot make a connection to the server.

Not sure if this is your issue though.