Hi all,
My customer reported an issue today with merging dw's and pdf's. In the main window, he opens a salesorder with 100 workorders, then selects the Merge Each radio button and clicks Merge on the toolbar. The merge function loops through each workorder and merges the associated documents then saves. wf_merge_each loops through, calling wf_merge_one on each pass. Customer said if he does something else, like open Word or Excel, while he's waiting, wf_merge_each doesn't merge all 100 workorders.
Here's the code for the two windows functions:
//wf_merge_each
integer li_CertCount, li_ThisCert, li_x, li_rc
//Loop through all of the Certs in the ddlb
li_CertCount = ddlb_certs.TotalItems()
for li_x = 1 to li_CertCount
ddlb_certs.SelectItem(li_x)
ddlb_certs.Event SelectionChanged(li_x)
li_rc = wf_merge_one()
if li_rc = -1 then
return
end if
next
//wf_merge_one
PDFDocument lpdf_doc
string ls_docName, ls_filename, ls_docDir
long ll_rowcount, ll_thisrow, ll_attachmentCount, ll_thisAttachment, ll_rc
ib_cancel = FALSE
lpdf_doc = Create PDFDocument
//Add Cert to PDF and/or Maintenance Record to pdf
if dw_1.RowCount() > 0 then
ll_rc = lpdf_doc.importdatawindow( dw_1)
end if
if cbx_maintenance.checked then
if dw_2.RowCount() > 0 then
ll_rc = lpdf_doc.importdatawindow( dw_2 )
end if
end if
// Add attachments
ll_attachmentCount = dw_attachments.Retrieve(il_WorkOrder)
ls_fileName = is_pdfSO + "Cert" + string(il_workorder) + ".pdf"
if ll_attachmentCount > 0 then
ls_docDir = is_docDir + string(il_workorder) + '\'
for ll_thisAttachment = 1 to ll_attachmentCount
ls_docName = ls_docDir + dw_attachments.GetItemString(ll_ThisAttachment, "filename")
// Check to see if document exists
if FileExists(ls_docname) then
ll_rc = lpdf_doc.importpdf( ls_docName )
else
ll_rc =MessageBox("Merge Documents", "The following attachment does not exist:~r~n" + ls_docname + "~r~nContinue?", Question!, YesNo!)
if ll_rc = 2 then
destroy lpdf_doc
RETURN -1
end if
end if
next
end if
ll_rc = lpdf_doc.save( ls_filename )
if ll_rc < 0 then
MessageBox("Save Error", "An error occurred saving the merged PDF file.~r~nError: " + string(ll_rc), StopSign!)
end if
destroy lpdf_doc
return 1
It works fine if he does not do something else in the meantime. Any advice?
~~~Tracy
That is a good suggestion. If there is a good amount of RAM, then another good test might be to try compiling the App into a 64 bit EXE. Then the address space would be a lot larger at runtime.
Regards .. Chris