Standalone application access to database

Nov 30, 2015 at 10:37 PM
I have created a standalone application that logs in to the Eclipse database, selects a patient, and reads patient data directly into a windows form application. It works fine when the application is sitting on the desktop of an Eclipse terminal, but I would like to run it over the network or on my laptop. What files does it need? When I download "VMS.TPS.COMMON.MODEL.dll", "VMS.TPS.COMMON.MODEL.TYPES (.INTERFACE and .API).dll" and make them references to my C# project, the application throws an error:

Could not load file of assembly 'VMS.TPS.Common.Model.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

The code I used was the same as used by Rex Cardan "Building ESAPI Applications with Window Forms" and fails in "Context = Application.CreateApplication(null,null)"
Dec 2, 2015 at 5:22 PM
Edited Dec 2, 2015 at 5:23 PM
You can't build a standalone app over a network (easily), because those dlls depend on the real VMS dlls on your Eclipse box. You can't take all of them with you. That is the real answer. But just in case you are pretty advanced, here is how you would do it (maybe I can record a demo sample of how this would work).

The basic idea is you have to have json serializable classes that replicate the ESAPI stack. So for example, you would need a Patient class that contains first name, last name, etc. You would use a library like Automapper to map (copy property values) from the ESAPI instance to your replicate class. Once you do that, the data is free to move across threads and serializable across a network. You would need a messaging service, like RabbitMQ (see EasyNetQ .NET implementation). You install that and you now have a network "relay" that can sling the classes anywhere you want on the network. Its pretty complicated, but the benefit is : it becomes language agnostic. You could program against that relay with any RabbitMQ client which are available in Java, C#, Ruby, Python, etc.
Marked as answer by rexcardan on 12/2/2015 at 9:24 AM
May 31, 2016 at 10:21 PM
I don't know what kind of access you need in your application, but I added a tutorial on how to gain ESAPI like access to Aria directly (not a publicly supported API...FYI). You don't get all the fancy method helpers and the API is not as intuitive as the designed API. However, you can use this anywhere on the network for the time being. I imagine Varian might shut down this type of easy access in future Aria iterations, for security reasons. In the meantime, check out:
May 31, 2016 at 11:02 PM
Great video!

I've also talked about this topic in the form of blog posts:

Access the ARIA Database with the Entity Framework
Get the MLC Leaf Widths Using the Entity Framework
Sep 17, 2016 at 1:00 AM
rexcardan and redcurry, thank you for the helpful video and posts about the entity framework.

I am writing a plugin script that requires the prescription that is linked to the plan setup. I could not find this in the Eclipse API, but was able to follow the AriaQ video and find the prescriptions in the database.

It works well from the console application in AriaQ, but when I use the Eclipse API wizard to create a binary plugin, add AriaQ as a second project to the solution, build, and then run from Eclipse, I get an error from External Beam Planning : "could not find variansystemEntities connection string in the app config file". I verified that I copied the connection string from the AriaQ app config and pasted into the BinaryPlug-in app config file.

I could really use some help with figuring out what I've done wrong with the plumbing here! Thanks in advance for any help.
Sep 17, 2016 at 9:56 PM
Edited Sep 17, 2016 at 10:02 PM
You can copy the connection string from the app config and paste it into the constructor of the AriaContext class or whatever you called your database class. The app config thing I don't know how to get to work, but I can confirm it does work if you copy it DIRECTLY into the constructor. I hinted at that technique in my video but I didn't show how to do it. Try that and see if it works for you.
 private const string _ariaConn = "metadata=res://*/ARIA.csdl|res://*/ARIA.ssdl|res://*/ARIA.msl;provider=System.Data.SqlClient;provider connection string='data source=YOURIPADDRESSHERE;initial catalog=variansystem;user id=reports;password=reports;multipleactiveresultsets=True;App=EntityFramework'";

        public Aria()
            : base(_ariaConn)  
Sep 18, 2016 at 3:23 PM
I've also had problems getting binary plug-ins to read the App.config file. They appear to read the Eclipse App.config file instead. As you said, it works fine if it's a console application or a stand-alone script. Rex's suggestion will work.
Sep 22, 2016 at 7:41 PM
rexcardan, Thank you for connecting the dots for me on your hint. I was getting a "Keyword not supported: data source" error, but some stack overflow posts alerted me to changing the " to a ' in my string (you have the ' too), and that fixed the error. My binary plug-in is now working very well. Thanks again for your response and for your willingness to share your knowledge on this forum and youtube.
Sep 22, 2016 at 7:43 PM
redcurry, Thanks for explaining how Eclipse uses its own app config file. I greatly appreciate all of your expertise on this forum and your blog!