What better way to synchronize desktop app data with webapi?

Posted on

Question :

I have my desktop application that needs to send data (only send) to a webapi, this data can not be sent repeatedly and also after sent, not send again, the desktop app will be in .net (wpf) the webapi also asp .net webapi.

The desktop application will be on a machine with poor internet, so there may be a failure to send at all times, totally unstable connection.

Is there a library that will help me with this synchronization? Remembering that it is just shipping (after shipped, do not ship anymore).


Answer :

A library, I do not know if it exists. But it’s easy to get around that.

You will need to create an identifier (if it does not already exist) and a property to see if it has already been sent. When you submit an item, just check that it has not already been synced. If not sent, send, if everything works, 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 case above, the SyncId property, if it already exists, you ignore the information. So it will not be a problem if you get the same item twice.


Leave a Reply

Your email address will not be published. Required fields are marked *