Written by

Enterprise Application Development Consultant at The Ohio State University Wexner Medical Center
MOD
Question Scott Roth · Jan 25, 2018

List of Business Services

Is there a way to get the list of Business Services from a command line call? We are trying to see if there is a way we can automate bring down our Inbound Business Services during a fail over.

Thanks

Scott Roth

The Ohio State University Wexner Medical Center

Comments

Eduard Lebedyuk · Jan 25, 2018

SQL way (query docs, 1 means BS):

SELECT *
FROM Ens_Config.Production_EnumerateConfigItems('Your.Production', 1)

Object way:

set rs = ##class(Ens.Config.Production).EnumerateConfigItemsFunc("Your.Production", 1)
do rs.%Display()

Constants for Business Host Type (defined in EnsConstants.inc):

#define eHostTypeUnknown   0
#define eHostTypeService   1
#define eHostTypeProcess   2
#define eHostTypeOperation 3
#define eHostTypeActor     4
0
Aaron Wassall · Jan 25, 2018

Hello Scott,

I was playing around with the EnumerateConfigItems query in the Ens.Config.Production class, and it seems like it might do what you're asking.  Below is some basic example code to demonstrate, but of course you should test this out yourself and add proper status checking and error handling before putting it to use.

If you are interested in other fields returned by this query, you can take a closer look at its class reference documentation.

#include Ensemble
ListBusinessServices() PUBLIC {
                Set productionName = "Demo.Loan.FindRateProduction"
                Set tStatement = ##class(%SQL.Statement).%New()
                Set pStatus = tStatement.%PrepareClassQuery("Ens.Config.Production","EnumerateConfigItems")
                Set tResult = tStatement.%Execute(productionName,$$$eHostTypeService)
                While tResult.%Next() {
                                Write !,tResult.%Get("ConfigName")
                }
}
0
Kurro Lopez · Jan 25, 2018

Hi,

Check the following code:

Set tProduction="Demo.HL7.MsgRouter.Production"

// Types:
// Empty: Retrieve all items 
// 1: Business Service
// 2: Business Process
// 3: Business Operation

Set tType="1"

Set tRS = ##class(%ResultSet).%New("Ens.Config.Production:EnumerateConfigItems")

Set tStatus = tRS.%Execute(tProduction, tType)

While tRS.%Next(.tStatus) {

   write tRS.%Get("BusinessType")_" : "_tRS.%Get("ConfigName"),!

}

II hope it's useful

Best regards,

Francisco Lopez

0
Scott Roth · Jan 26, 2023

Is there a way to tell when a Config Item was created within Ens_Config?

0
Eduard Lebedyuk  Jan 26, 2023 to Scott Roth

Audit table contains all production item changes you can query it once every X minutes/hours to get new changes.

0
Scott Roth  Jan 26, 2023 to Eduard Lebedyuk

Unfortunately we do not log that Auditing item, as I tried creating a new Operation, but did not see an entry in the Audit log. 

Is there anywhere else a Creation Date/Insert date maybe logged for an object?

0
Eduard Lebedyuk  Jan 26, 2023 to Scott Roth

Enable %Ensemble/%Production/ModifyConfiguration in System Audit Events:

After that you should see these events:

0
Scott Roth  Jan 26, 2023 to Eduard Lebedyuk

How do I connect the %SYS to our Production namespace in SQL to tie the date/times to the Class file?

0
Eduard Lebedyuk  Jan 26, 2023 to Scott Roth

Audit event has a namespace property, filter by that.

Same for timestamp, audit event timestamp and production class compilation timestamp are probably close to each other.

0
Scott Roth  Jan 26, 2023 to Eduard Lebedyuk

I meant how do I inner join across namespaces in SQL? I was trying to write a query or use some of the Cache code above to connect the two together for my boss. Thanks

0
Eduard Lebedyuk  Jan 27, 2023 to Scott Roth

For cross-namespace queries the easiest way is to map packages/globals but that might not be a recommended approach for an audit table.

You can do this:

  1. In your production namespace create a new table with the same structure as your audit select query backed by PPG storage.
  2. Switch to the audit namespace.
  3. Run audit query, iterate the results and write them into the PPG.
  4. Switch into a production namespace.
  5. Run query against your PPG table, joining any local tables.
0
Benjamin De Boe  Jan 27, 2023 to Eduard Lebedyuk

%SYS.Audit already projects to each namespace, but the data is in a privileged database and requires %Admin_Secure:USE privileges, so better not try to circumvent / confuse that through mappings.

I would not create additional temp tables or mappings to try and cling to SQL as that is meant to run in a single namespace as a query language. This sounds more like a procedural thing for ObjectScript, so a stored procedure that loops through the Production namespaces, retrieves all config items in a local variable and then uses that for querying the audit table after switching to %SYS sounds more appropriate. Rather than a PPG, I'd just collect it in the qHandle local variable passed between Execute() and Fetch() methods for your custom query, unless it risks getting too big

0