Skip to content

Instantly share code, notes, and snippets.

View patrick711's full-sized avatar

Patrick Chen patrick711

View GitHub Profile
public class SPS_OrderToCashSetup : CustomizationPlugin
{
//This method executed right after website files were updated, but before website was restarted
//Method invoked on each cluster node in cluster environment
//Method invoked only if runtimecompilation is enabled
//Do not access custom code published to bin folder, it may not be loaded yet
public override void OnPublished()
{
this.WriteLog("OnPublished Event");
}
@patrick711
patrick711 / SecurePage.cs
Created March 21, 2023 17:25
An example of a page that has been secured against use by unauthorized users
#region Constructor
public ISPSOut846SendProcess()
{
Customers.SetProcessAllCaption("Send All");
Customers.SetProcessCaption("Send");
Customers.SetProcessDelegate(SendData);
ISPSCustomerSettings settings = CustomerSettings.Current;
if (!(settings.OutboundInventoryAdviceEnabled ?? false))
{
throw new PXSetupNotEnteredException(ISPSMessages.FeatureNotEnbabled, typeof(ISPSCustomerSettings), "Outbound 846");
try
{
new_package = Packages.Insert(new_package);
}
catch (Exception ex)
{
PXProcessing<SOShipment>.SetError(RowIndex, ex.Message));
return false;
}
//Uh-oh
@patrick711
patrick711 / Check_Field_Lengths_InsertUpdate.cs
Last active March 4, 2022 22:09
Check incoming data for excessive string lengths and then insert/update.
/***************************
Check_Field_Lengths_InsertUpdate - Check incoming data for excessive string lengths and then insert/update.
Inputs
myCache - Data View Cache
mylist - List of DAC objects that corresponds to the myCache
Patrick Chen SPS Commerce
02-2022
***************************/
@patrick711
patrick711 / IEnumerable_scenario_two.cs
Created March 31, 2021 19:49
IEnumerable Scenario II
public void Test2()
{
//Method I
foreach (var cust in PXSelect<BAccount, Where<ISPSCustomerExtension.iSPSEDICust, Equal<True>>>.Select(this))
{
foreach (BAccount child in
PXSelect<BAccount, Where<BAccount.parentBAccountID, Equal<Required<BAccount.parentBAccountID>>>>
.Select(this, mycustomer.BAccountID))
{
}
@patrick711
patrick711 / IEnumberable_scenario_one.cs
Created March 31, 2021 19:17
IEnumerables: Scenario I
public void Test()
{
//Method I
var soLineSplitsLinkedWithCurrentPO =
SelectFrom<SOLineSplit>
.Where<SOLineSplit.pOType.IsEqual<@P.AsString.ASCII>.And<SOLineSplit.pONbr.IsEqual<@P.AsString>>>
.AggregateTo<GroupBy<SOLineSplit.orderType>, GroupBy<SOLineSplit.orderNbr>>
.View.Select(this, row.OrderType, row.OrderNbr);
foreach (var item in soLineSplitsLinkedWithCurrentPO)
{ }
@patrick711
patrick711 / DatabaseOperations.cs
Created August 18, 2020 16:35
Code file for communicating with MS SQL Server in order to perform a restore
/***************************
DatabaseOperations - Code for communicating with MS Sql Server in order to perform a restore from backup.
Patrick Chen SPS Commerce
08-2020
***************************/
namespace TestAcumatica
{
class DatabaseOperations
@patrick711
patrick711 / ISPSMapadocInSiteExtension
Last active June 4, 2020 16:29
This is an example of a DAC Extension Table, linking to the Warehouse table in Acumatica.
[Serializable]
[PXCacheName("Warehouse Trading Partner")]
[PXTable(typeof(INSite.siteID), IsOptional = true)]
public class ISPSMapadocINSiteExtension : PXCacheExtension<INSite>
{
#region Siteid
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Siteid")]
public virtual int? Siteid { get; set; }
public abstract class siteid : PX.Data.BQL.BqlInt.Field<siteid> { }
@patrick711
patrick711 / Mod_RestoreDB
Created April 23, 2020 21:28
Acumatica Test SDK example of MS SQL restore code
/***************************
Mod_RestoreDB - This class encapsulates the process of restoring Acumatica instance to clean state
1. Unpublish customizations to remove Web elements
2. Restore db backup
3. Log into the site
Patrick Chen SPS Commerce
04-2020
***************************/
namespace TestAcumatica
@patrick711
patrick711 / Mod_SetupVars
Created April 23, 2020 21:27
Acumatica Test SDK example for pulling in variables
/***************************
Mod_SetupVars - Codebase that will tale config inputs and create variable object
Patrick Chen SPS Commerce
04-2020
***************************/
namespace TestAcumatica
{
public class Mod_SetupVars