Skip to content

Instantly share code, notes, and snippets.

@Gerhard-ZA
Last active December 1, 2023 12:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gerhard-ZA/3b67ba2ff66fdd606d930a366218583f to your computer and use it in GitHub Desktop.
Save Gerhard-ZA/3b67ba2ff66fdd606d930a366218583f to your computer and use it in GitHub Desktop.
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")
{
try
{
string[] fileEntries = Directory.GetFiles(txtFolderLocation.Text);
foreach (string file in fileEntries)
{
FileInfo fi = new FileInfo(file);
string id = FileProcessor.ProcessDocument(rs, fi.FullName, fi.Name, Convert.ToDecimal(fi.Length / 1000), "Open", fi.DirectoryName, txtUsername.Text);
FileProcessor.AddFilesToTransaction(rs, id, fi.FullName,fi.Name, "DataFile");
}
}
catch (Exception error)
{
result = "#" + error.Message;
}
finally
{
rs.Logout();
}
}
else
{
rs.Logout();
MessageBox.Show("Authorisation with the Acumatica EndPoints could not be establised, please try again.", "Logon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment