What’s the best way to sync desktop app data with webapi?

Asked

Viewed 445 times

3

I have my desktop application that needs to send data (just send) to a webapi, this data cannot be sent repeatedly and also after sent, not send again, the desktop app will be on. net(wpf) the webapi also Asp.net webapi.

The desktop application will be on a machine with precarious internet, so there may be failure of sending at all times, fully unstable connection.

Is there a library that helps me in this synchronization? Remembering that it is only sending(after sent, no more sending).

  • @Tmc your issue changes the meaning of the question, do not remove comments from the author unless these are irrelevant to the question. And this was not the case.

1 answer

2

A library, I don’t know if it exists. But it’s easy to get around it.

You will need to create an identifier (if it no longer exists) and a property to know if it has already been sent. When you submit an item, just make sure it hasn’t already been synchronized. Otherwise it has been sent, send, if all goes well, change the property stating that the item has already been sent.

public class ObjetoSincronizado
{
    public ObjetoSincronizado()
    {
        this.SyncId = Guid.NewGuid();
    }

    public Guid SyncId { get; set; }

    public bool Sincronizado { get; set; }
}

On the API side, whenever you receive an object, check that it no longer exists by the identifier, in the above case, the Syncid property, if it already exists, you ignore the information. So there will be no problem if receive twice the same item.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.