Step 6: Creating a DAC with the Configuration Settings

You will now create a DAC with the configuration settings that will be used by the connector. For this DAC, you will add the database table and include it in the customization project.

1. Creating the Database Table and Adding It to the Customization Project

  1. In the database of the instance that you are using for the development of the connector, create a database table with the settings used by the connector. An example of the SQL script for such table is shown below.
    GO
    IF NOT EXISTS (SELECT * FROM SYSOBJECTS WHERE NAME='BCBINDINGWOOCOMMERCE' AND XTYPE='U')
    BEGIN
      CREATE TABLE [dbo].[BCBindingWooCommerce](
    	[CompanyID] [int] NOT NULL,
    	[BindingID] [int] NOT NULL,
    	[StoreBaseUrl] [nvarchar](100) NULL,
    	[StoreXAuthToken] [nvarchar](max) NULL,
    	[StoreXAuthClient] [nvarchar](max) NULL,
    	[StoreAdminUrl] [nvarchar](200) NULL,
    	[WooCommerceStoreTimeZone] [nvarchar](100) NULL,
    	[WooCommerceDefaultCurrency] [nvarchar](12) NULL,
    	[tstamp] [timestamp] NOT NULL,
     CONSTRAINT [PK_BCBindingWooCommerce] PRIMARY KEY CLUSTERED 
    (
    	[CompanyID] ASC,
    	[BindingID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    ALTER TABLE [dbo].[BCBindingWooCommerce] ADD  DEFAULT ((0)) FOR [CompanyID]
    END
  2. Add the table to the customization project as follows:
    1. Open the customization project in the Customization Project Editor.
    2. In the navigation pane, click Database Scripts to open the Database Scripts page.
    3. On the More menu (under Actions), click Add Custom Table Schema.
    4. In the Add Custom Table Schema dialog box, which opens, select the custom table in the Table box, and click OK.

      MYOB Acumatica Customization Platform generates the table schema and adds the schema to the customization project as an Sql item.

2. Creating the DAC

  1. In the Visual Studio project of the extension library, create the DAC that stores the WooCommerce connector settings, as shown in the following code.
    Tip:
    • You can generate the DAC from the table in the database by using the Customization Project Editor (as described in To Create a New DAC) and move it to the extension library (as described in To Move a Code Item to the Extension Library). Alternatively, you can create the DAC directly in the Visual Studio project.
    • You can see this code on GitHub.
    using PX.Commerce.Core;
    using PX.Data;
    using PX.Data.ReferentialIntegrity.Attributes;
    
    namespace WooCommerceTest
    {
        [PXCacheName("WooCommerce Settings")]
        public class BCBindingWooCommerce : PXBqlTable, IBqlTable
        {
            public class PK : PrimaryKeyOf<BCBindingWooCommerce>.
                By<BCBindingWooCommerce.bindingID>
            {
                public static BCBindingWooCommerce Find(PXGraph graph, int? binding) =>
                   FindBy(graph, binding);
            }
    
            #region BindingID
            [PXDBInt(IsKey = true)]
            [PXDBDefault(typeof(BCBinding.bindingID))]
            [PXUIField(DisplayName = "Store", Visible = false)]
            [PXParent(typeof(Select<BCBinding, Where<BCBinding.bindingID, 
                Equal<Current<BCBindingWooCommerce.bindingID>>>>))]
            public int? BindingID { get; set; }
            public abstract class bindingID : PX.Data.BQL.BqlInt.Field<bindingID> { }
            #endregion
    
            //Connection
            #region StoreBaseUrl
            [PXDBString(100, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "API Path")]
            [PXDefault()]
            public virtual string StoreBaseUrl { get; set; }
            public abstract class storeBaseUrl : 
                PX.Data.BQL.BqlString.Field<storeBaseUrl> { }
            #endregion
            #region StoreXAuthClient
            [PXRSACryptString(IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Consumer Key")]
            [PXDefault()]
            public virtual string StoreXAuthClient { get; set; }
            public abstract class storeXAuthClient : 
                PX.Data.BQL.BqlString.Field<storeXAuthClient> { }
            #endregion
            #region StoreXAuthToken
            [PXRSACryptString(IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Consumer Secret")]
            [PXDefault()]
            public virtual string StoreXAuthToken { get; set; }
            public abstract class storeXAuthToken : 
                PX.Data.BQL.BqlString.Field<storeXAuthToken> { }
            #endregion
    
            #region WooCommerceDefaultCurrency
            [PXDBString(12, IsUnicode = true)]
            [PXUIField(DisplayName = "Default Currency", IsReadOnly = true)]
            public virtual string WooCommerceDefaultCurrency { get; set; }
            public abstract class wooCommerceDefaultCurrency : 
                PX.Data.BQL.BqlString.Field<wooCommerceDefaultCurrency> { }
            #endregion
    
            #region WooCommerceStoreTimeZone 
            [PXDBString(100, IsUnicode = true)]
            [PXUIField(DisplayName = "Store Time Zone", IsReadOnly = true)]
            public virtual string WooCommerceStoreTimeZone { get; set; }
            public abstract class wooCommerceStoreTimeZone : 
                PX.Data.BQL.BqlString.Field<wooCommerceStoreTimeZone> { }
            #endregion
    
            #region StoreAdminURL
            [PXDBString(100, IsUnicode = true, InputMask = "")]
            [PXUIField(DisplayName = "Store Admin Path")]
            [PXDefault()]
            public virtual string StoreAdminUrl { get; set; }
            public abstract class storeAdminUrl : 
                PX.Data.BQL.BqlString.Field<storeAdminUrl> { }
            #endregion
    
        }
    }
  2. Build the project.