Varian-Code-Samples icon indicating copy to clipboard operation
Varian-Code-Samples copied to clipboard

How to identify development enviroment within code

Open larpra opened this issue 5 years ago • 3 comments

Is there a way API code can identify whether the code is executed in a clinical system or in a development environment?

larpra avatar May 12 '20 14:05 larpra

It depends on your reason for this check.

If you only want to identify your research system you can simply use standard c# code to look for the pc-name because research systems are most often limited (we have only one): if (Environment.MachineName.ToString().ToLower() == vmstbox) ... else ...

All code that add, modify or delete things in a patient need script approval in clinical systems. Therefore you get errors if you do not approve them. Therefore you can use a try-catch-command to identify this cases. try {modify patient in some way. For instance AddStructure} catch{MessageBox.Show("ScriptApproval is missing")}

Kiragroh avatar May 12 '20 14:05 Kiragroh

You can try some things that are only possible in research mode.

I found out that RemovePlanSetup is only possible in ResearchMOde. Therefore you could create a plan and then try to delete it. If it is not possible your are in clinical mode.

Other possible loops should be possible.

Kiragroh avatar May 19 '20 04:05 Kiragroh

I wonder whether there is a more direct way? ESAPI must know whether it runs on a clinical system because several methods are only possible in Research mode.

larpra avatar May 19 '20 06:05 larpra