JDBMaterial mat = new JDBMaterial(getHostID(), getSessionID());
JDBCustomer cust = new JDBCustomer(getHostID(), getSessionID());
inter.getInterfaceProperties("Label Data", "Output");
String device = inter.getDevice();
String format = inter.getFormat();
JDBLabelData labdata = new JDBLabelData(getHostID(), getSessionID());
if (labdata.getProperties(unique))
{
try
{
if (format.equals("CSV"))
{
if (device.equals("Disk"))
{
String heading[] = labdata.getDataArray(unique, "heading");
String data[] = labdata.getDataArray(unique, "data");
path = inter.getRealPath();
path = path.replace("\\", java.io.File.separator);
path = path.replace("/", java.io.File.separator);
if (path.length() > 0)
{
if (path.substring(path.length() - 1).equals(java.io.File.separator) == false)
{
path = path + java.io.File.separator;
}
}
String filename = path + "LabelData_"+labdata.getLine() + "_" + unique + ".csv";
CSVWriter writer = new CSVWriter(new FileWriter(filename), ',');
writer.writeNext(heading);
writer.writeNext(data);
writer.close();
result = true;
il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", filename);
setErrorMessage("");
}
}
if (format.equals("XML"))
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element message = (Element) document.createElement("message");
Element hostUniqueID = addElement(document, "hostRef", Common.hostList.getHost(getHostID()).getUniqueID());
message.appendChild(hostUniqueID);
Element messageRef = addElement(document, "messageRef", unique);
message.appendChild(messageRef);
Element messageType = addElement(document, "interfaceType", "Label Data");
message.appendChild(messageType);
Element messageInformation = addElement(document, "messageInformation", "UniqueID=" + unique);
message.appendChild(messageInformation);
Element messageDirection = addElement(document, "interfaceDirection", "Output");
message.appendChild(messageDirection);
Element messageDate = addElement(document, "messageDate", JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime()));
message.appendChild(messageDate);
Element labelData = (Element) document.createElement("labelData");
Element unq = addElement(document, "uniqueID", unique);
labelData.appendChild(unq);
Element lt = addElement(document, "labelType", labdata.getLabelType());
labelData.appendChild(lt);
Element line = addElement(document, "line", labdata.getLine());
labelData.appendChild(line);
Element printDate = addElement(document, "printDate", JUtility.getISOTimeStampStringFormat(labdata.getPrintDate()));
labelData.appendChild(printDate);
Element user = addElement(document, "userID", labdata.getUserID());
labelData.appendChild(user);
Element workstation = addElement(document, "workstation", labdata.getWorkstationID());
labelData.appendChild(workstation);
Element material = addElement(document, "material", labdata.getMaterial());
labelData.appendChild(material);
if (mat.getMaterialProperties(labdata.getMaterial()))
{
Element materialDesc = addElement(document, "materialDescription", mat.getDescription());
labelData.appendChild(materialDesc);
}
Element materialType = addElement(document, "materialType", labdata.getMaterialType());
labelData.appendChild(materialType);
Element po = addElement(document, "processOrder", labdata.getProcessOrder());
labelData.appendChild(po);
Element rr = addElement(document, "requiredResource", labdata.getRequiredResource());
labelData.appendChild(rr);
Element location = addElement(document, "location", labdata.getLocationID());
labelData.appendChild(location);
Element batch = addElement(document, "batch", labdata.getBatchNumber());
labelData.appendChild(batch);
Element batchPrefix = addElement(document, "batchPrefix", labdata.getBatchPrefix());
labelData.appendChild(batchPrefix);
Element ovbatchPrefix = addElement(document, "overrideBatchPrefix", labdata.getOverrideBatchPrefix());
labelData.appendChild(ovbatchPrefix);
Element batchSuffix = addElement(document, "batchSuffix", labdata.getBatchSuffix());
labelData.appendChild(batchSuffix);
Element prodquantity = addElement(document, "prodQuantity", labdata.getProdQuantity().toString());
labelData.appendChild(prodquantity);
Element produom = addElement(document, "prodUom", labdata.getProdUom());
labelData.appendChild(produom);
Element prodEAN = addElement(document, "prodEAN", labdata.getProdEAN());
labelData.appendChild(prodEAN);
Element prodVar = addElement(document, "prodVariant", labdata.getProdVariant());
labelData.appendChild(prodVar);
Element basequantity = addElement(document, "baseQuantity", labdata.getBaseQuantity().toString());
labelData.appendChild(basequantity);
Element baseuom = addElement(document, "baseUom", labdata.getBaseUom());
labelData.appendChild(baseuom);
Element baseEAN = addElement(document, "baseEAN", labdata.getBaseEAN());
labelData.appendChild(baseEAN);
Element baseVar = addElement(document, "baseVariant", labdata.getBaseVariant());
labelData.appendChild(baseVar);
Element dom = addElement(document, "dateOfManufacture", JUtility.getISOTimeStampStringFormat(labdata.getDateofManufacture()));
labelData.appendChild(dom);
Element ovdom = addElement(document, "overrideDateofManufacture", labdata.getOverrideDateofManufacture());
labelData.appendChild(ovdom);
Element expiry = addElement(document, "expiryDate", JUtility.getISOTimeStampStringFormat(labdata.getExpirtDate()));
labelData.appendChild(expiry);
Element ovexpiry = addElement(document, "overrideExpiryDate", labdata.getOverrideExpiryDate());
labelData.appendChild(ovexpiry);
Element expiryMode = addElement(document, "expiryMode", labdata.getExpiryMode());
labelData.appendChild(expiryMode);
Element custid = addElement(document, "customer", labdata.getCustomer());
labelData.appendChild(custid);
if (cust.getCustomerProperties(labdata.getCustomer()))
{
Element custName = addElement(document, "customerName", cust.getName());
labelData.appendChild(custName);
}
Element copies = addElement(document, "copies", labdata.getPrintCopies().toString());
labelData.appendChild(copies);
Element queueName = addElement(document, "queueName", labdata.getPrintQueue());
labelData.appendChild(queueName);
Element module = addElement(document, "moduleID", labdata.getModuleID());
labelData.appendChild(module);
Element messageData = (Element) document.createElement("messageData");
messageData.appendChild(labelData);
message.appendChild(messageData);
document.appendChild(message);
JXMLDocument xmld = new JXMLDocument();
xmld.setDocument(document);
gmh.decodeHeader(xmld);
if (device.equals("Disk") | device.equals("Email"))
{
path = inter.getRealPath();
if (fio.writeToDisk(path, document, -1, labdata.getLine() + "_" + unique + "_LabelData.xml") == true)
{
result = true;
il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename());
setErrorMessage("");