I have an Excel file which uses VSTO to retrieve and update data. This is deployed to various environments (Development, Staging, Production,...).
I want to make sure that a user who downloads a sheet from Staging isn't sending data to Production, because the sheet is using the (locally installed) VSTO which came from Production.
Is开发者_如何学编程 there a way to prevent this?
The whole concept of prod/staging/test is a definition thing that software won't magically understand so really the only way to deal with this is to code whatever logic you use into your vsto add-in.
The way we deal with this is that the add-in will check each sheet for a custom property named like: MYADDIN_ISTEST. If this property is found then the add-in will connect to the test database (for that sheet) and if not it will connect to the production database. You can think of all sort of variations to this theme depending on what makes sense for your environment but the reason for us to do it this way is that renaming or moving a file (with testdata) can be easily done by anyone without him/her realising the consequences. Going into the document's custom properties and removing that test property is something you will only do on purpose.
精彩评论