Checking Active User¶
Checking Active User¶
1ot = impact.gui.output_toolbox
2db = impact.active_database
3
4
5def display_active_user(doc):
6 if doc.is_checked_out:
7 ot.add("Current Active User: " + str(doc.active_user.login_id))
8
9 active_doc = doc.active_checkout
10
11 ot.add(" Checked out: " + str(active_doc.modified_date_time))
12 else:
13 ot.add("No Active User")
14
15
16ot.clear()
17
18cust = db.customers.find_by_code("ACME CORP")
19
20if cust is not None:
21 docs = cust.documents
22
23 if docs is None:
24 ot.add("No customer document support in the database")
25 else:
26 ot.add("customer document support is enabled in this database")
27
28 doc = docs.item("Acme Corporation Specifications.docx")
29
30 if not doc.isNone():
31 ot.add("Document: '" + doc.name + "', impact.creator: " + str(doc.added_by.login_id) + ", Size: " + str(doc.size) + " bytes")
32
33 display_active_user(doc)
34
35 ot.add("Checking out document for modification")
36
37 if doc.checkout():
38 display_active_user(doc)
39
40 ot.add("Cancelling checkout")
41
42 if doc.active_checkout.cancel_checkout():
43 display_active_user(doc)
44
45 else:
46 ot.add("Unable to cancel checkout")
47
48 else:
49 ot.add("Unable to checkout document")
50
51 for item in doc.history:
52 ot.add(" Operation: " + str(item.operation_as_string) + " by " + str(item.modified_by.login_id) + " at " + str(item.modified_date_time))
53 if len(item.details) > 0:
54 ot.add(" " + str(item.details))
55
56 else:
57 ot.add("Unable to locate document")
58else:
59 ot.add("Unable to locate a customer")