Skip to content

Instantly share code, notes, and snippets.

View Gerhard-ZA's full-sized avatar

Gerhard van den Heever Gerhard-ZA

  • FBA Software
  • Cape Town
View GitHub Profile
[PXSelector(typeof(
Search<CSAttributeDetail.valueID,
Where<CSAttributeDetail.attributeID, Equal<Attributes.CSAnswer.poInternalType>,
And<CSAttributeDetail.disabled, Equal<False>>>>),
typeof(CSAttributeDetail.valueID),
typeof(CSAttributeDetail.description),
DescriptionField = typeof(CSAttributeDetail.description))]
@Gerhard-ZA
Gerhard-ZA / UploadFileService.cs
Created February 13, 2022 12:43
Upload file to Acumatica
public string PutFile(string entityName, string keys, string fileName, Stream file)
{
var response = _httpClient.PutAsync(_httpClient.BaseAddress + entityName + "/" + keys + "/files/" + fileName, new StreamContent(file)).Result;
if (!response.IsSuccessStatusCode)
{
return response.Content.ReadAsStringAsync().Result;
}
else return response.Content.ReadAsStringAsync().Result;
}
@Gerhard-ZA
Gerhard-ZA / ConvertFileToMemory.cs
Created February 13, 2022 12:40
Convert files to byte array memory objects
public static string AddFilesToTransaction(RestService rs, string docNbr, string filePath, string fileName, string entity)
{
string result = "#UPLOADING DOCS";
try
{
byte[] filedata;
using (FileStream file = File.Open(filePath, FileMode.Open))
{
filedata = new byte[file.Length];
@Gerhard-ZA
Gerhard-ZA / LogEntry.cs
Created February 13, 2022 12:37
Creating Log Entry
public static string ProcessDocument(RestService rs, string fileLocation, string fileName, decimal fileSizeMb, string fileStatus, string folder, string uploadedBy)
{
string result = "";
string entityAsString = JsonConvert.SerializeObject(new
{
FileLocation = new { value = fileLocation.Replace(@"\\", @"\") },
FileName = new { value = fileName },
FileSizeMb = new { value = fileSizeMb },
FileStatus = new { value = fileStatus },
@Gerhard-ZA
Gerhard-ZA / FileProcessing.cs
Last active December 1, 2023 12:15
Utility Process Button Click
private void btnProcess_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
string result = "#Processing...";
using (RestService rs = new RestService(txtAcumaticaURL.Text, txtEndPoint.Text))
{
//Log in to Acumatica ERP
string logonStatus = rs.Login(txtUsername.Text, txtPswrd.Text, txtCompany.Text, null);
if (logonStatus == "OK")
@Gerhard-ZA
Gerhard-ZA / ExtAppointmentEntry.cs
Created February 26, 2021 06:04
Acumatica Field Services - Extending Appointments to connect to Power Automate
public class ExtAppointmentEntry : PXGraphExtension<AppointmentEntry>
{
public static bool IsActive() { return true; }
public delegate IEnumerable StartAppointmentDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable StartAppointment(PXAdapter adapter, StartAppointmentDelegate baseMethod)
{
//send request to Microsoft PowerFlow
var client = new RestClient("https:/***.azure.com:443/workflows/");
@Gerhard-ZA
Gerhard-ZA / ExtenderServices_updateWebConfig.cs
Last active January 27, 2021 06:40
Update WebConfig Method
public void updateWebConfig()
{
var configuration = WebConfigurationManager.OpenWebConfiguration("~");
ServiceModelSectionGroup secgroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
bool hasBasicPartyService = false;
bool hasWsPartyService = false;
bool hasUpdate = false;
//Verify if the BasicHttpBinding element exist
@Gerhard-ZA
Gerhard-ZA / myServiceAdd.cs
Created January 20, 2021 12:39
AcumaticaPlugIn_CallExtenderService
using System;
using PX.Data;
using Customization;
namespace AddingServiceReferences
{
//Customization plugin is used to execute custom actions after customization project was published
public class myServiceAdd : CustomizationPlugin
{
//This method executed right after website files were updated, but before website was restarted
@Gerhard-ZA
Gerhard-ZA / ExtenderSercices_References.cs
Created January 20, 2021 12:33
ExtenderSercices_References
using System.Web.Configuration;
using System.ServiceModel.Configuration;
using System.ServiceModel;
@Gerhard-ZA
Gerhard-ZA / ExtenderServices.cs
Created January 19, 2021 17:57
AddingServiceReferences
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.Api;
using PX.Data;
using PX.Data.BQL;
using PX.Objects.AP;
using PX.Objects.CA;