Sage100.ObjectManagement 4.31.0

Sage 100 Object Cache Manager

Install-Package Sage100.ObjectManagement -Version 4.31.0
dotnet add package Sage100.ObjectManagement --version 4.31.0
<PackageReference Include="Sage100.ObjectManagement" Version="4.31.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sage100.ObjectManagement --version 4.31.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Example Usage

using Sage100.ObjectManagement;
using Sage100.ObjectManagement.Interfaces;
using System;
using System.Diagnostics;
using System.Net;

namespace ConsoleApp
{
    class Program
    {
	#region Private constants

        private const string Sage100User = "all";
        private const string Sage100Password = "";
        private const string Sage100Company = "ABC";

        #endregion

        #region Private fields

        private static readonly SessionLogon _arSessionLogon = new SessionLogon
        {
            CompanyCode = Sage100Company,
            UserLogon = new NetworkCredential { UserName = Sage100User, Password = Sage100Password },
            ModuleCode = ModuleNames.AccountsReceivable,
            ModuleDate = DateTime.Today
        };

        #endregion

        /// <summary>
        /// Examples
        /// </summary>
        /// <param name="args">The command line arguments</param>
        static void Main(string[] args)
        {
            ObjectManagerSetUser();
            ObjectManagerSetUserEx();
            BusSvcBasicObjects();
        }

        public static void ObjectManagerSetUser()
        {
            ObjectManagerCore.HomeDirectory = Utility.GetSage100HomePath();

            using (var objectManager = (new ObjectManagerFactory()).CreateInstance())
            {
                var session = objectManager.GetSession();

                session.SetUser(Sage100User, Sage100Password);
                session.SetCompany(Sage100Company);

                var salesOrderbus = objectManager.GetBusinessObject<IMasBusinessObject>("SO_SalesOrder_bus", "SO_SalesOrder_ui", "S/O");

                salesOrderbus.MoveFirst();

                var key = salesOrderbus.GetKey();
                var rec = salesOrderbus.GetRecord();
                var orderNo = rec["SalesOrderNo$"];
            }
        }

        public static void ObjectManagerSetUserEx()
        {
            ObjectManagerCore.HomeDirectory = Utility.GetSage100HomePath();

            using (var objectManager = (new ObjectManagerFactory()).CreateInstance())
            {
                var session = objectManager.GetSession();
                var credential = new NetworkCredential(Sage100User, Sage100Password);

                session.SetUserEx(credential);
                session.SetCompany(Sage100Company);

                var customerSvc = objectManager.GetBusinessObject<IMasServiceObject>("AR_Customer_svc", "AR_Customer_ui", "A/R");

                customerSvc.SetKey("01ABF");

                var key = customerSvc.GetKey();
                var rec = customerSvc.GetRecord(true);
                var id = rec["ID$"];
                var code = rec["FORMATTEDCODE$"];
                var name = rec["FORMATTEDNAME$"];
            }
        }

        public static void BusSvcBasicObjects()
        {
            IMasSession sySession = new MasSession();

            try
            {
                sySession.InitSession(_arSessionLogon);

                var names = sySession.PvxObject.GetDynamicMemberNames();

                using (var arCustomerBus = sySession.CreateObject<IMasBusinessObject>("AR_Customer_bus", "AR_Customer_ui", "A/R"))
                { 
                    var ret1 = arCustomerBus.SetKey("01ABF");
                    var rec1 = arCustomerBus.GetRecord(true);
                    var val1 = arCustomerBus.GetValue<string>("CustomerName");
                    var val2 = arCustomerBus.GetValue<double>("CurrentBalance");

                    var ret2 = arCustomerBus.MoveFirst();
                    var ret3 = arCustomerBus.SetValue("CustomerName$", "Unit test");
                    var ret4 = arCustomerBus.Write();

                    arCustomerBus.MoveFirst();
                    arCustomerBus.SetValue("CustomerName$", "American Business Futures");
                    arCustomerBus.Write();

                    var oChild1 = arCustomerBus.GetChildObject("TermsCode");
                    var oChild2 = arCustomerBus.GetChildObject("SalespersonNo");
                    var oChild3 = arCustomerBus.GetChildObject("Foo");
                }
                
                using (var arCustomerSvc = sySession.CreateObject<IMasServiceObject>("AR_Customer_svc", "AR_Customer_ui", "A/R"))
                { 
                    var ret5 = arCustomerSvc.SetKey("01ABF");
                    var rec2 = arCustomerSvc.GetRecord(true);
                    var val6 = arCustomerSvc.GetValue<string>("CustomerName");
                    var val7 = arCustomerSvc.GetValue<double>("CurrentBalance");

                    var ret8 = arCustomerSvc.MoveFirst();
                    var ret9 = arCustomerSvc.GetKey();
                }

                using (var syInstallation = sySession.CreateObject<IMasObject>("SY_Installation", "SY_Options_ui"))
                { 
                    var prop1 = syInstallation.ClassName;
                    var ret10 = syInstallation.PvxObject.nGetStartingVersion();
                    var ret11 = syInstallation.PvxObject.sGetCurrentVersion("PAYROLL");
                    var ret12 = syInstallation.PvxObject.sGetCurrentVersion("SYSTEM");

                    var prop2 = syInstallation.GetProperty("nStartingVersion");
                    var prop3 = syInstallation.GetProperty("sOldVersion");
                }

                var prop4 = sySession.GetProperty("sProductId");
                var prop5 = sySession.PvxObject.sProductId;

                var fileObj = new PvxDynamic(sySession.GetProperty("oFileObj")) as dynamic;
                var colLen = fileObj.nGetColumnLength("AR_Customer", "CustomerNo");

                var arguments = new object[] { "A/R", "Divisions$", "", "XYZ" };

                ((IPvxDynamic)sySession.PvxObject).InvokeMethodByRef("nGetParameter", arguments);

                var ret13 = arguments[2];
                var ret14 = string.Empty;

                sySession.PvxObject.nGetParameter("A/R", "Divisions$", ref ret14, "ABC");

                var ret15 = sySession.PvxObject.nGetBuildNumber();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
            finally
            {
                sySession.Dispose();
            }
        }
    }
}

Example Usage

using Sage100.ObjectManagement;
using Sage100.ObjectManagement.Interfaces;
using System;
using System.Diagnostics;
using System.Net;

namespace ConsoleApp
{
    class Program
    {
	#region Private constants

        private const string Sage100User = "all";
        private const string Sage100Password = "";
        private const string Sage100Company = "ABC";

        #endregion

        #region Private fields

        private static readonly SessionLogon _arSessionLogon = new SessionLogon
        {
            CompanyCode = Sage100Company,
            UserLogon = new NetworkCredential { UserName = Sage100User, Password = Sage100Password },
            ModuleCode = ModuleNames.AccountsReceivable,
            ModuleDate = DateTime.Today
        };

        #endregion

        /// <summary>
        /// Examples
        /// </summary>
        /// <param name="args">The command line arguments</param>
        static void Main(string[] args)
        {
            ObjectManagerSetUser();
            ObjectManagerSetUserEx();
            BusSvcBasicObjects();
        }

        public static void ObjectManagerSetUser()
        {
            ObjectManagerCore.HomeDirectory = Utility.GetSage100HomePath();

            using (var objectManager = (new ObjectManagerFactory()).CreateInstance())
            {
                var session = objectManager.GetSession();

                session.SetUser(Sage100User, Sage100Password);
                session.SetCompany(Sage100Company);

                var salesOrderbus = objectManager.GetBusinessObject<IMasBusinessObject>("SO_SalesOrder_bus", "SO_SalesOrder_ui", "S/O");

                salesOrderbus.MoveFirst();

                var key = salesOrderbus.GetKey();
                var rec = salesOrderbus.GetRecord();
                var orderNo = rec["SalesOrderNo$"];
            }
        }

        public static void ObjectManagerSetUserEx()
        {
            ObjectManagerCore.HomeDirectory = Utility.GetSage100HomePath();

            using (var objectManager = (new ObjectManagerFactory()).CreateInstance())
            {
                var session = objectManager.GetSession();
                var credential = new NetworkCredential(Sage100User, Sage100Password);

                session.SetUserEx(credential);
                session.SetCompany(Sage100Company);

                var customerSvc = objectManager.GetBusinessObject<IMasServiceObject>("AR_Customer_svc", "AR_Customer_ui", "A/R");

                customerSvc.SetKey("01ABF");

                var key = customerSvc.GetKey();
                var rec = customerSvc.GetRecord(true);
                var id = rec["ID$"];
                var code = rec["FORMATTEDCODE$"];
                var name = rec["FORMATTEDNAME$"];
            }
        }

        public static void BusSvcBasicObjects()
        {
            IMasSession sySession = new MasSession();

            try
            {
                sySession.InitSession(_arSessionLogon);

                var names = sySession.PvxObject.GetDynamicMemberNames();

                using (var arCustomerBus = sySession.CreateObject<IMasBusinessObject>("AR_Customer_bus", "AR_Customer_ui", "A/R"))
                { 
                    var ret1 = arCustomerBus.SetKey("01ABF");
                    var rec1 = arCustomerBus.GetRecord(true);
                    var val1 = arCustomerBus.GetValue<string>("CustomerName");
                    var val2 = arCustomerBus.GetValue<double>("CurrentBalance");

                    var ret2 = arCustomerBus.MoveFirst();
                    var ret3 = arCustomerBus.SetValue("CustomerName$", "Unit test");
                    var ret4 = arCustomerBus.Write();

                    arCustomerBus.MoveFirst();
                    arCustomerBus.SetValue("CustomerName$", "American Business Futures");
                    arCustomerBus.Write();

                    var oChild1 = arCustomerBus.GetChildObject("TermsCode");
                    var oChild2 = arCustomerBus.GetChildObject("SalespersonNo");
                    var oChild3 = arCustomerBus.GetChildObject("Foo");
                }
                
                using (var arCustomerSvc = sySession.CreateObject<IMasServiceObject>("AR_Customer_svc", "AR_Customer_ui", "A/R"))
                { 
                    var ret5 = arCustomerSvc.SetKey("01ABF");
                    var rec2 = arCustomerSvc.GetRecord(true);
                    var val6 = arCustomerSvc.GetValue<string>("CustomerName");
                    var val7 = arCustomerSvc.GetValue<double>("CurrentBalance");

                    var ret8 = arCustomerSvc.MoveFirst();
                    var ret9 = arCustomerSvc.GetKey();
                }

                using (var syInstallation = sySession.CreateObject<IMasObject>("SY_Installation", "SY_Options_ui"))
                { 
                    var prop1 = syInstallation.ClassName;
                    var ret10 = syInstallation.PvxObject.nGetStartingVersion();
                    var ret11 = syInstallation.PvxObject.sGetCurrentVersion("PAYROLL");
                    var ret12 = syInstallation.PvxObject.sGetCurrentVersion("SYSTEM");

                    var prop2 = syInstallation.GetProperty("nStartingVersion");
                    var prop3 = syInstallation.GetProperty("sOldVersion");
                }

                var prop4 = sySession.GetProperty("sProductId");
                var prop5 = sySession.PvxObject.sProductId;

                var fileObj = new PvxDynamic(sySession.GetProperty("oFileObj")) as dynamic;
                var colLen = fileObj.nGetColumnLength("AR_Customer", "CustomerNo");

                var arguments = new object[] { "A/R", "Divisions$", "", "XYZ" };

                ((IPvxDynamic)sySession.PvxObject).InvokeMethodByRef("nGetParameter", arguments);

                var ret13 = arguments[2];
                var ret14 = string.Empty;

                sySession.PvxObject.nGetParameter("A/R", "Divisions$", ref ret14, "ABC");

                var ret15 = sySession.PvxObject.nGetBuildNumber();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
            finally
            {
                sySession.Dispose();
            }
        }
    }
}

Release Notes

Initial release of the Sage 100 Object Manager for .NET.

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.31.0 220 9/18/2018
4.8.0 28 10/24/2019
4.4.0 110 1/30/2019