Sage.Dispatch 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sage.Dispatch --version 1.5.0
NuGet\Install-Package Sage.Dispatch -Version 1.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sage.Dispatch" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sage.Dispatch --version 1.5.0
#r "nuget: Sage.Dispatch, 1.5.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sage.Dispatch as a Cake Addin
#addin nuget:?package=Sage.Dispatch&version=1.5.0

// Install Sage.Dispatch as a Cake Tool
#tool nuget:?package=Sage.Dispatch&version=1.5.0

Sage.Dispatch

Example usage


using Sage.Dispatch;
using System;
using System.Diagnostics;

namespace TestSageDispatch
{
   class Program
   {
       static void Main(string[] args)
       {
           var homePath = @"C:\Sage\Sage 100 Advanced\MAS90\Home";
           var company = "ABC";
           var user = "all";
           var password = "";

           try
           {
               using (dynamic pvxScript = new ComDynamic("ProvideX.Script"))
               {
                   pvxScript.Init(homePath);
                   pvxScript.Execute("SET_PARAM 'NE'=0");

                   using (dynamic sySession = pvxScript.NewObject("SY_Session"))
                   {
                       if ((int)sySession.nSetUser(user, password) != 1) throw new ApplicationException($"Failed to set user. {sySession.sLastErrorMsg}");
                       if ((int)sySession.nSetCompany(company) != 1) throw new ApplicationException($"Failed to set company. {sySession.sLastErrorMsg}");
                       if ((int)sySession.nSetDate("S/O", DateTime.Today.ToString("yyyyMMdd")) != 1) throw new ApplicationException($"Failed to set date for S/O. {sySession.sLastErrorMsg}");
                       if ((int)sySession.nSetModule("S/O") != 1) throw new ApplicationException($"Failed to set module to S/O. {sySession.sLastErrorMsg}");

                       int taskId = (int)sySession.nLookupTask("SO_Invoice_ui");
                       if (taskId == 0) throw new ApplicationException("Failed to lookup task SO_Invoice_ui. {sySession.sLastErrorMsg}");

                       using (dynamic sySecurity = sySession.oSetProgram(taskId, "SO_Invoice_ui"))
                       {
                           if (sySecurity == null) throw new ApplicationException($"Failed to set program to SO_Invoice_ui. {sySession.sLastErrorMsg}");
                       }

                       using (dynamic soInvoice = pvxScript.NewObject("SO_Invoice_bus", sySession))
                       {
                           var batchEnabled = ((int)soInvoice.nBatchEnabled != 0);

                           if (batchEnabled)
                           {
                               var batchNo = string.Empty;
                               if ((int)soInvoice.nSelectNewBatch(ref batchNo, "N", "BOL " + DateTime.Today.ToString("MM/dd/yyyy")) != 1) throw new ApplicationException($"Failed to  batch number. {soInvoice.sLastErrorMsg}");
                           }

                           var invoiceNo = string.Empty;
                           if ((int)soInvoice.nGetNextInvoiceNo(ref invoiceNo) != 1) throw new ApplicationException($"Failed to get the next invoice number. {soInvoice.sLastErrorMsg}");
                           if ((int)soInvoice.nSetKey(invoiceNo) != 2) throw new ApplicationException($"Failed to create a new invoice. {soInvoice.sLastErrorMsg}");

                           soInvoice.nSetValue("ARDivisionNo$", "01");
                           soInvoice.nSetValue("CustomerNo$", "ABF");

                           soInvoice.oLines.nAddLine();
                           soInvoice.oLines.nSetValue("ItemCode$", "1001-HON-H252");
                           soInvoice.oLines.nSetValue("QuantityOrdered", 1);

                           if ((int)soInvoice.oLines.nWrite() != 1) throw new ApplicationException($"Failed to write the line.  {soInvoice.oLines.sLastErrorMsg}");

                           if ((int)soInvoice.nWrite() != 1) throw new ApplicationException($"Failed to write the invoice.  {soInvoice.sLastErrorMsg}");

                           Trace.WriteLine($"New invoice {invoiceNo} was created.");
                       }

                       sySession.nCleanup();
                   }
               }
           }
           catch (Exception exception)
           {
               Trace.WriteLine(exception.Message);
           }
       }
   }
}
Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.7.0 434 12/12/2022
1.5.0 409 6/30/2022
1.4.0 412 6/30/2022