I have windows application Inventory management system and E-commerce site.i want to integrate both system to synchronize inventory at both side.If i sold one product from web then the inventory of windows application should be update and If i sold one product from windows application then the inventory of E-commerce site should be update.how to achieve this scenario??The Inventory data should be kept in xml formate on a domain and a from there that XML is read by windows application.So How to achieve this thing.and whole process is automated.please help.
-
and if the last item is sold from both apps at the same time? As @TheEvilMetal says, you need to move storage that supports transactions and locking. XML doesn't do that. You could probably find a library that does it for you in XML, but XML does not scale for this purpose. – Nick.Mc May 02 '17 at 06:27
1 Answers
Generally a database would be better suited to this as you'd have access to things such as stored procedures and transactions that would make updating things a lot easier. If you need to change something in one place then you would only need to update the stored procedure to update it in all places and you don't risk 'forgetting' to update the other place and you reduce the odds of a mistake going unnoticed.
Transactions on the other hand will help if there's any errors or situations that should cause a rollback to happen, for the changes to be undone and not committed.
If you insist on using an XML based inventory system you'd need to have a standardized way of interacting with the XML that accounts for the other end of the system already changing it. If the inventory is being updated because of new stock, but someone is trying to buy something from the website there will very likely be conflict.
It might be because the file is currently in use by a another program (the inventory management system adding new stock). You could always have the website/management system wait until the file is available for use, but that adds a lot of unnecessary delays and is far from clean.
If you absolutely have to use XML then there's a few good tools out there already that help parse and manage XML reading/writing: How do I read and parse an XML file in C#?

- 1
- 1

- 323
- 2
- 14
-
But how to made this process automated.For e.g. regular interval of 5 or 10 minutes. – shah harshil May 02 '17 at 06:33
-
By limiting when the XML is updated by which program you can avoid conflicts between the 2 programs, but you'd still need to account for changes in the document and limitations. Automation could be done with a separate thread that just writes values to the file or with a separate service. Other people could probably give a better answer with scheduling the updates. But ultimately a database would be easier to maintain and update and would be my first choice. – TheEvilMetal May 02 '17 at 06:47