Skip to content

Instantly share code, notes, and snippets.

View yuriycto's full-sized avatar

Yuriy Zaletskyy yuriycto

View GitHub Profile
@yuriycto
yuriycto / deleteAttachment.cs
Created April 21, 2023 21:29
Delete attachment
var fileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
var savedFilesIDs = PXNoteAttribute.GetFileNotes(this.Document.Cache, this.Document.Current);
foreach (var savedFileID in savedFilesIDs)
{
var savedFileInfo = fileUploadGraph.GetFile(fileID);
if (savedFileInfo != null
&& VerifyFileName(savedFileInfo.Name))
{
fileGraph.Files.AllowDelete = true;
fileGraph.Files.Delete(fileUploadGraph.Files.Current);
@yuriycto
yuriycto / ReadInformationInAcumatica.cs
Created April 21, 2023 21:28
Read file attached in Acumatica
var fileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
var savedFilesIDs = PXNoteAttribute.GetFileNotes(this.Document.Cache, this.Document.Current);
foreach (var savedFileID in savedFilesIDs)
{
var savedFileInfo = fileGraph.GetFile(savedFileID);
}
@yuriycto
yuriycto / attachfile.cs
Created April 21, 2023 21:27
AttachFile.cs
public void AttachFile()
{
//Convert your file into BIN format
byte[] fileInBytes = Encoding.UTF8.GetBytes("My best ever file.");
// Generate info about the file
var fileInfo = new PX.SM.FileInfo(Guid.NewGuid(), "OneFile.txt", null, fileInBytes);
// Save file to database
var uploadFileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
uploadFileGraph.SaveFile(oneFileInfo, FileExistsAction.CreateVersion);
// Attach file to the dedicated table
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Customization;
using PX.Data;
using PX.DbServices.Model.ImportExport;
namespace PX.Objects.SO
{
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
#region Event Handlers
public PXAction<SOLine> AddNewDSLine;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Insert Line", Enabled = true, MapEnableRights = PXCacheRights.Select,
MapViewRights = PXCacheRights.Select)]
@yuriycto
yuriycto / TestWebHooks.cs
Created December 9, 2021 14:40
Processing incoming request from Outside world
using Newtonsoft.Json;
using PX.Data;
using PX.Data.Webhooks;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Results;
namespace WebHooksConfiguration
@yuriycto
yuriycto / Program.cs
Created December 9, 2021 14:39
Send to Acumatica
using System;
using System.IO;
using System.Net;
using Newtonsoft.Json;
namespace ConsoleApp1
{
public class ObjectJSON
{
public string Name { get; set; }