public int prGetGTIN(out string gtin, out string barcodeType) { gtin = ""; barcodeType = ""; try { if (_doc.IsValid()) { int type = -1; gxVariant pdoc = _doc.ToVariant(); gxVariant v = new gxVariant(); if (pdoc.GetChild(v, (int)GX_VARIANT_FLAGS.GX_VARIANT_BY_ID, (int)PR_VAR_ID.PRV_BARCODE, 0)) { type = v.GetInt(); v.Dispose(); } barcodeType = System.Enum.GetName(typeof(PR_BCTYPE), type); barcodeType = barcodeType.Substring(barcodeType.LastIndexOf("_") + 1); gtin = _doc.Field((int)PR_DOCFIELD.PR_DF_BC1) as string; } } catch (gxException e) { return(_helper.GetErrorMessage(e, out _errorMessage)); } catch (Exception e) { _errorMessage = e.Message + " --- prGetBarcodeData()"; return(1305); } return(0); }
public int prGetBarcodeData(System.Collections.IList list) { try { if (_doc.IsValid()) { /* Searching for the barcode and displaying it */ int type = -1; gxVariant pdoc = _doc.ToVariant(); gxVariant v = new gxVariant(); if (pdoc.GetChild(v, (int)GX_VARIANT_FLAGS.GX_VARIANT_BY_ID, (int)PR_VAR_ID.PRV_BARCODE, 0)) { type = v.GetInt(); v.Dispose(); } string barcodeType = System.Enum.GetName(typeof(PR_BCTYPE), type); barcodeType = barcodeType.Substring(barcodeType.LastIndexOf("_") + 1); list.Add(String.Format("TYPE: {0}", barcodeType)); //barcode type list.Add(String.Format( // checksum "CHECKSUM: {0}", _doc.FieldStatus((int)PR_DOCFIELD.PR_DF_BC1) == 0 ? "Ok" : "No checksum")); if (barcodeType == "PDF417") { string fieldName, text; int j = "PR_DF_".Length; System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (int i in Enum.GetValues(typeof(PR_DOCFIELD))) { if (i <= (int)PR_DOCFIELD.PR_DF_FORMATTED) { continue; } fieldName = Enum.GetName(typeof(PR_DOCFIELD), i); if (fieldName.StartsWith("PR_DF_")) { text = _doc.Field(i).Trim(); if (!string.IsNullOrEmpty(text)) { text = fieldName.Substring(j).Replace('_', ' ') + ": " + text; list.Add(text); } } } } else { list.Add("DATA: " + _doc.Field((int)PR_DOCFIELD.PR_DF_BC1) as string); } } } catch (gxException e) { return(_helper.GetErrorMessage(e, out _errorMessage)); } catch (Exception e) { _errorMessage = e.Message + " --- prGetBarcodeData()"; return(1305); } return(0); }