Last active
December 1, 2023 12:15
-
-
Save Gerhard-ZA/3b67ba2ff66fdd606d930a366218583f to your computer and use it in GitHub Desktop.
Utility Process Button Click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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