ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidoxTaskListLib.py
Revision: 633
Committed: Wed Mar 28 13:54:39 2018 UTC (8 years ago) by nino.borges
Content type: text/x-python
File size: 4665 byte(s)
Log Message:
A folder for my Evidox programs

File Contents

# User Rev Content
1 nino.borges 633 """
2    
3     EvidoxTaskListLib
4    
5     Created by:
6     Emanuel Borges
7     09.07.2017
8    
9     A class for interacting with the taskList.
10    
11     """
12    
13     import win32com.client
14     from collections import namedtuple
15    
16     class TaskListDBConnection:
17     def __init__(self, accessDB):
18     daoEngine = win32com.client.Dispatch('DAO.DBEngine.120')
19     self.daoDB = daoEngine.OpenDatabase(r'C:\Users\eborges\Desktop\TaskList.accdb')
20     self.empMatrix = self._UpdateEmployeeMatrix()
21    
22     def CloseTaskListConnection(self):
23     """Closes the entire connection and not just the RS"""
24     self.daoDB.Close()
25    
26     def _UpdateEmployeeMatrix(self):
27     """Internal method that updates the empMatrix. Simple ID = Firstname Lastname"""
28     empMatrix = {}
29     daoRSObj = self.daoDB.OpenRecordset("SELECT * FROM [Employees] ")
30     daoRSObj.MoveLast()
31     fullCount = daoRSObj.RecordCount
32     daoRSObj.MoveFirst()
33     for i in range(fullCount):
34     empMatrix[daoRSObj.Fields('ID').Value] = "%s %s"% (daoRSObj.Fields('Firstname').Value,daoRSObj.Fields('Lastname').Value)
35     daoRSObj.MoveNext()
36     daoRSObj.Close()
37     return empMatrix
38    
39     def GetOpenAndClosedJobs(self, clmNumb):
40     """Returns a named tuple of the open and closed jobs for that clmNumb"""
41     jobsDict = {}
42     ds = namedtuple('job_number',['task_type','closed_date','assigned_to','description'])
43     daoRSObj = self.daoDB.OpenRecordset("SELECT * FROM [Task List] WHERE clientmatterID = %s "% clmNumb)
44     ## First check to see if records were returned.
45     if daoRSObj.EOF:
46     print "No records were returned!"
47     else:
48     daoRSObj.MoveLast()
49     fullCount = daoRSObj.RecordCount
50     daoRSObj.MoveFirst()
51     for i in range(fullCount):
52     jobsDict[daoRSObj.Fields('Jobnumber').Value] = ds(daoRSObj.Fields('TaskType').Value,
53     daoRSObj.Fields('DateCompleted').Value,
54     daoRSObj.Fields('AssignedTo').Value,
55     daoRSObj.Fields('Task').Value)
56     daoRSObj.MoveNext()
57     daoRSObj.Close()
58     return jobsDict
59    
60     def GetOpenJobs(self, clmNumb):
61     """Returns a named tuple of the open jobs for that clmNumb"""
62     jobsDict = {}
63     ds = namedtuple('job_number',['task_type','closed_date','assigned_to','description'])
64     daoRSObj = self.daoDB.OpenRecordset("SELECT * FROM [Task List] WHERE clientmatterID = %s and DateCompleted IS NULL "% clmNumb)
65     ## First check to see if records were returned.
66     if daoRSObj.EOF:
67     print "No records were returned!"
68     else:
69     daoRSObj.MoveLast()
70     fullCount = daoRSObj.RecordCount
71     daoRSObj.MoveFirst()
72     for i in range(fullCount):
73     jobsDict[daoRSObj.Fields('Jobnumber').Value] = ds(daoRSObj.Fields('TaskType').Value,
74     daoRSObj.Fields('DateCompleted').Value,
75     daoRSObj.Fields('AssignedTo').Value,
76     daoRSObj.Fields('Task').Value)
77     daoRSObj.MoveNext()
78     daoRSObj.Close()
79     return jobsDict
80    
81     def GetClosedJobs(self, clmNumb):
82     """Returns a named tuple of the closed jobs for that clmNumb"""
83     jobsDict = {}
84     ds = namedtuple('job_number',['task_type','closed_date','assigned_to','description'])
85     daoRSObj = self.daoDB.OpenRecordset("SELECT * FROM [Task List] WHERE clientmatterID = %s and DateCompleted IS NOT NULL "% clmNumb)
86     ## First check to see if records were returned.
87     if daoRSObj.EOF:
88     print "No records were returned!"
89     else:
90     daoRSObj.MoveLast()
91     fullCount = daoRSObj.RecordCount
92     daoRSObj.MoveFirst()
93     for i in range(fullCount):
94     jobsDict[daoRSObj.Fields('Jobnumber').Value] = ds(daoRSObj.Fields('TaskType').Value,
95     daoRSObj.Fields('DateCompleted').Value,
96     daoRSObj.Fields('AssignedTo').Value,
97     daoRSObj.Fields('Task').Value)
98     daoRSObj.MoveNext()
99     daoRSObj.Close()
100     return jobsDict