cEnumeration

The cEnumeration class is used to retrieve, cache and use complete domain information

The domain information, or database enumerations, are defined in the database storage and must be retrieved for each session to get the correct translation of each enumeration item. Retrieving this static data can be done using DbPLSQLBlocks for each domain. However, using this class will make the enumeration be retrieved once for each session and cached. By caching the result, the IEE process can reuse the static data in other windows and other IEE threads, not having to make unneccessary roundtrips to the database retrieveing the same static data over and over again.

// Retrieves the client value for the IID 'PurchaseReceiveCase' - using DB item 'ARRINV'.

// Using DbPLSQLBlock: A database call is made each time this block executes.
DbPLSQLBlock("{0} := &AO.Purchase_Receive_Case_API.Decode('ARRINV');", this.QualifiedVarBindName("sReceiveInArrival"));

// Using cEnumeration: The database call is made only once, caching and reusing the information for the current IEE process.
cEnumeration enumPurchaseReceiveCase = cEnumeration.Get("PurchaseReceiveCase");
this.sReceiveInArrival = enumPurchaseReceiveCase.Decode("ARRINV");

Methods

Properties

Example

// Slow implementation: Performing two database calls upon every instantiation of the form.
private void frmPurchaseReceipt_OnSAM_Create(object sender, WindowActionsEventArgs e)
{
   e.Handled = true;
   Sal.SendClassMessage(Sys.SAM_Create, Sys.wParam, Sys.lParam);

   // Fetch client values for domains PrintedFlag & PurchaseReceiveCase.
   this.DbPLSQLBlock("BEGIN " +
      ":i_hWndFrame.frmPurchaseReceipt.sIsPrinted := &AO.PRINTED_FLAG_API.Decode('Y'); " +
      ":i_hWndFrame.frmPurchaseReceipt.sIsNotPrinted := &AO.PRINTED_FLAG_API.Decode('N'); " +
      ":i_hWndFrame.frmPurchaseReceipt.sReceiveCase := &AO.Purchase_Receive_Case_API.Decode('INVDIR'); " +
      "END;");

   // Fetch client values for domain PartConfiguration.
   this.DbPLSQLBlock("BEGIN " +
      ":i_hWndFrame.frmPurchaseReceipt.sIsConfigured := &AO.Part_Configuration_API.Get_Client_Value(0);" +
      ":i_hWndFrame.frmPurchaseReceipt.sIsNotConfigured := &AO.Part_Configuration_API.Get_Client_Value(1); " +
      "END;");
}
// Preferred implementation: One (or none) database call is made upon the first instantiation of the form.
protected override void OnPamCreate()
{
   base.OnPamCreate();

   // Fetch client values for all three domains: PrintedFlag, PurchaseReceiveCase & PartConfiguration.
   // If the domains were already fetched and cached earlier within the current IEE session, the database call is excluded
   // and the result is then fetched directly from the client memory.
   IDictionary<string, cEnumeration> enumDict = cEnumeration.GetMulti("PrintedFlag", "PurchaseReceiveCase", "PartConfiguration");
   cEnumeration enumPrintedFlag = enumDict["PrintedFlag"];
   cEnumeration enumPurchaseReceiveCase = enumDict["PurchaseReceiveCase"];
   cEnumeration enumPartConfiguration = enumDict["PartConfiguration"];
   sIsPrinted = enumPrintedFlag.Decode("Y");
   sIsNotPrinted = enumPrintedFlag.Decode("N");
   sReceiveCase = enumPurchaseReceiveCase.Decode("INVDIR");

   // Avoid indexing when fetching database or client values from a domain/enumeration since the ordering can change, the database values do not...
   //lsIsConfigured = enumPartConfiguration.GetClientValue(0);
   //lsIsNotConfigured = enumPartConfiguration.GetClientValue(1);

   // ...for why using Decode providing a fixed database value is preferred!
   sIsConfigured = enumPartConfiguration.Decode("IO");
   sIsNotConfigured = enumPartConfiguration.Decode("SO");
}