I am looking into writing a sales order imported form scratch for Interprise and wanted to see how it works from a fundamentals point of view. The following describes how to programmatically read data from a remote Interprise server using just DLLs and code.
This does not require the SDK or Interprise Plug-In Guidance module.
Creating the console project
I am using Visual Studio 2010, go File –> New Project

Right-click on the project, select Properties and change the Target Framework from “.NET Framework 4 Client Profile” to “.NET Framework 4” and close the window.

Adding References
Add the following references to the project. I am not sure they are all required, but I needed each of them at some point during my troubleshooting, so why not.
- From the GAC (I.E. just in the list)
- From C:\Program Files (x86)\Interprise Solutions\Interprise Suite 6.0
- Interprise.Business.Base
- Interprise.Business.Customer
- Interprise.Connectivity.Database.Configuration.Design
- Interprise.Extendable.Base
- Interprise.Extendable.Customer
- Interprise.Facade.Base
- Interprise.Facade.Customer
- Interprise.Facade.Utility
- Interprise.Framework.Base
- Interprise.Framework.Customer
- Interprise.Licensing.Base
- Microsoft.Practices.EnterpriseLibrary.Caching
- Microsoft.Practices.EnterpriseLibrary.Common
- Microsoft.Practices.EnterpriseLibrary.Data
- Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
- Microsoft.Practices.EnterpriseLibrary.Logging
- Microsoft.Web.Services3
Finally, Add the following to the top of your Program.cs:
using Interprise.Facade.Base;
using Interprise.Facade.Customer;
using Interprise.Framework.Base.Shared;
using Interprise.Framework.Customer.DatasetGateway;
Configuration and Sign-in
In Program.cs, replace the Main method with the following:
static void Main(string[] args) {
try {
SimpleFacade.Instance.SignIn();
//Run();
}
finally {
SimpleFacade.Instance.SignOut();
}
}
This logic signs into Interprise using the information in your project’s app.config file. The process looks like this (as far as I can tell):
- Look for a cached executible config
- If that is not found, copy the current config file to the cache directory
- Load the values
- Sign-in
I want to call out a note on the cache. The directory where the cache happens is : C:\ProgramData\Interprise Suite\1.0.0.0\Debug (with the version being your application’s version). It is important to note that if you make changes to your app.config, you must delete the cached version of the file.
As for what to put in your app.config file, you can use the AppConfig tool included with Interprise. Or you can steal it out of the current cached copy (C:\ProgramData\Interprise Suite\6.0.6.10\Interprise Suite 6.0\InterpriseSuite.exe.config) and paste it into your app.config.
Troubleshooting: Add the following line of code before the sign-in:
var MyConfig = InterpriseConfiguration.Instance;
using a breakpoint, inspect the values in MyConfig for sanity. If they are not what you would expect, something is wrong with your config file.
Getting Some Data
Now for the big moment, getting some data. Add the following method to Program.cs:
static void Run()
{
using (var MyShipToDataset = new ShipToDatasetGateway())
{
using (var MyShipToFacade = new ShipToFacade(MyShipToDataset))
{
var Commands = new[] {
new[] { MyShipToDataset.CustomerShipToView.TableName
, StoredProcedures.READCUSTOMERSHIPTO }
};
var Params = new[] {
new [] {"@CustomerCode", "CUST-000001"},
new [] {"@ShipToCode", "SHIP-000002"}
};
var Result = MyShipToFacade.LoadDataSet(Commands, Params
, Interprise.Framework.Base.Shared.Enum.ClearType.None);
var MyShipTo = MyShipToDataset.CustomerShipToView[0];
}
}
}
So the first step, loading your dataset and façade is pretty simple and there is not that much logic here.
The next step is to have the façade load the desired rows from the database into the data set. The Commands variable tells it what table and stored procedures to use. I don’t yet know a good way to look these up, so be prepared to get REALLY good at using SQL Server Management Studio (SSMS). Once you have the stored procedure, you can add the required params. Again, use SSMS to look these up.
Finally, we call LoadDataSet to populate the database and view the result. Simple.