Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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