Skip to content

Instantly share code, notes, and snippets.

@alaquitara
Created May 31, 2018 22:38
Show Gist options
  • Select an option

  • Save alaquitara/ca3213d6e106aff58aa4ed60d6c87eb9 to your computer and use it in GitHub Desktop.

Select an option

Save alaquitara/ca3213d6e106aff58aa4ed60d6c87eb9 to your computer and use it in GitHub Desktop.
public void executeUpdate()
{
string q = ConfigurationManager.AppSettings["queue"];
int queue = Convert.ToInt32(q);
string d = ConfigurationManager.AppSettings["doctype"];
int docType = Convert.ToInt32(d);
string e = ConfigurationManager.AppSettings["numimages"];
int numImages = Convert.ToInt32(e);
string f = ConfigurationManager.AppSettings["idqueue"];
int barcodeQueue = Convert.ToInt32(f);
string g = ConfigurationManager.AppSettings["workDir"];
int workFlowDirector = Convert.ToInt32(g);
XDocument XMLresults = new XDocument();
DataTable dTe = new DataTable();
barcodeClassify bc = new barcodeClassify();
int checkDocType = docType;
int docCount = 1;
int beforeDocType;
//check for all docTypes
do
{
beforeDocType = checkDocType;
dTe = bc.getQueueImages(numImages, barcodeQueue, checkDocType);
docCount++;
checkDocType++;
if (checkDocType > 9) checkDocType = 1;
} while ((dTe.Rows.Count == 0) && (docCount <= 9)); //until we've found a good block of images OR have exhaused all possible doctypes
for (int i = 0; i < dTe.Rows.Count; i++){
String idt = dTe.Rows[i][0].ToString();
bcData bcD = new WindowsFormsApplication2.Form1.bcData();
bcD.idt = idt;
bcD = ocrUpdate(dTe.Rows[i][1].ToString(), bcD);
XMLresults = xmldata(bcD);
int id = Convert.ToInt32(dTe.Rows[i][0]);
listBoxAdd("Starting Scan on Transaction ID: " + bcD.idt);
Console.WriteLine(id);
if (bcD.tf == true && XMLresults != null && bcD.results.Substring(0, 1) == "G") //We got good results on the scan
{
listBoxAdd("Successful Scan on Barcode: " + bcD.results);
bc.updateTable(id, bcD.results, XMLresults);
string a = XMLresults.Root.Element("idDocType").Value;
string transID = dTe.Rows[i][0].ToString();
int idDoc = Convert.ToInt32(a);
bc.upDateClassify(id, workFlowDirector, idDoc); //store barcode and xml data in IDC_Transaction
bc.checkAttribute(id); //Store the XML attributes to DB and log
bc.changeDocType(id, workFlowDirector, idDoc);
}
else if (bc.isClassified(Convert.ToInt32(dTe.Rows[i][3]))) //already a docType assigned but a bad scan
{
bc.upDateClassify(id, workFlowDirector, beforeDocType);
bc.changeDocType(id, workFlowDirector, beforeDocType);
listBox1.Items.Add("Failed to read barcode");
listBoxAdd("Failed to read barcode");
}
else //bad scan and unknown doctype
{
docType = 2;
bc.upDateClassify(id, workFlowDirector, docType);
bc.changeDocType(id, workFlowDirector, docType);
listBoxAdd("Failed to read barcode");
}
listBoxAdd("Completed Scan on Transaction ID: " + dTe.Rows[i][0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment