Copying Documents

Copying Documents
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5
 6cust = db.customers.find_by_code("ACME CORP")
 7
 8if cust is not None:
 9    docs = cust.documents
10
11    if docs is None:
12        ot.add("No customer document support in the database")
13    else:
14        ot.add("customer document support is enabled in this database")
15
16        doc = docs.item("Acme Corporation Specifications.docx")
17
18        if not doc.isNone():
19            ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
20
21            # copy the document to a fully qualified name
22            dest = r"C:\\Documents\\AcmeSpec.docx"
23
24            if doc.copy_to(dest):
25                ot.add("Successfully copied document to '" + str(dest) + "'")
26            else:
27                ot.add("Unable to copy the document to '" + str(dest) + "'")
28
29            # copy the document into a folder
30            dest = "c:\\Documents\\"
31
32            if doc.copy_to(dest):
33                ot.add("Successfully copied document to '" + dest + doc.name + "'")
34            else:
35                ot.add("Unable to copy the document to '" + dest + doc.name + "'")
36
37        else:
38            ot.add("Unable to locate document")
39else:
40    ot.add("Unable to locate a customer")
41
42