ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/MCP_Console.py
Revision: 454
Committed: Wed Sep 11 18:57:31 2013 UTC (12 years, 6 months ago) by nino.borges
Content type: text/x-python
File size: 30906 byte(s)
Log Message:
Added a new view called My Active Cases, filtering the case list to only show your active cases for all modules.

File Contents

# Content
1 """
2
3 MCP_Console
4
5 Created by
6 Emanuel Borges
7 08.28.2010
8
9 This will be the interface to add, edit and archive cases.
10
11 Should this work as one large GUI and you pick the below or read from argv and let you
12 just call it with what you want, making these three look like separate apps.
13
14
15 """
16
17 import MCP_Lib,os,shutil,ConcordanceHelperTools, time,directorySize2
18
19 class MainConsole:
20 def __init__(self):
21 ## Gather the case list
22
23 print "connecting to matter tracking access db..."
24 ## Production version
25 self.accessDB = MCP_Lib.AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
26 self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo()
27 #responsibleCases,casesDir = MCP_Lib.GetCaseList('',self.accessDB)
28 myCases, myActiveCases,officeCases, allCases,casesDir= MCP_Lib.GetCaseList('',self.accessDB)
29
30 ## Testing version
31 #self.accessDB = MCP_Lib.AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
32 #responsibleCases,casesDir = MCP_Lib.GetCaseList(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP",self.accessDB)
33 #self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP")
34
35 print "connected to DB."
36
37 self.responsibleCasesList = myCases
38 self.casesDir = casesDir
39
40
41 def AddNewCase(self, caseName, clientMatter, chargable = False, reviewPlatform = "", responsibleProcessingVendor = "",
42 responsibleScanningVendor = "",responsibleHostingVendor = ""):
43 ## TODO: add a verification somehwere where it verify that the proposed name does not include characters that cant be used in a folder name.
44 ## Add the local folders The GUI should test that the clm is 10 digits and has hyphen.
45 template = os.path.join(self.casesDir,'_Template_')
46 new = os.path.join(self.casesDir, caseName + '_(%s)'%clientMatter)
47 if os.path.exists(new):
48 print "ERROR: This case already exists!!"
49 else:
50 #print template
51 #print new
52 os.mkdir(new)
53 for file in os.listdir(template):
54 shutil.copy2(os.path.join(template,file),new)
55 ## Check the H drive for the supplemental folders and the matter folder, only if they select Concordance.
56 self.SetCaseNameAndCLM(caseName,clientMatter)
57 self.AddCaseToAccessDB(caseName,clientMatter)
58
59 def ChangeCaseName(self,caseName,newCaseName,newClientMatter):
60 """This method will allow for editing the case name and number. This is different than settign the casename"""
61 ## Test that there is only one entry for this clm in access.
62 clientMatter = caseName.split("_(")[1]
63 clientMatter = clientMatter[:-1]
64 clientMatter = clientMatter.replace('-','.')
65 accessCaseName = self.accessDB.GetCaseName(clientMatter)
66 localCasesPath = self.casesDir
67 if os.path.exists(os.path.join(localCasesPath,caseName)):
68 if clientMatter != newClientMatter:
69 if newCaseName != caseName.split("_("):
70 ## change both
71 self.accessDB.UpdateCaseName(clientMatter,newCaseName)
72 self.accessDB.UpdateClientMatterNum(clientMatter,newClientMatter)
73 os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,newCaseName + '_(%s)'%newClientMatter.replace(".","-")))
74 else:
75 ## change just client matter
76 self.accessDB.UpdateClientMatterNum(clientMatter,newClientMatter)
77 os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,caseName + '_(%s)'%newClientMatter.replace(".","-")))
78 elif newCaseName != caseName.split("_("):
79 ## change just the casename
80 self.accessDB.UpdateCaseName(clientMatter,newCaseName)
81 os.rename(os.path.join(localCasesPath,caseName),os.path.join(localCasesPath,newCaseName + '_(%s)'%clientMatter.replace(".","-")))
82
83 ## verify that the proposed name does not include characters that cant be used in a folder name.
84 ## Change the name and or clm in access
85
86 ## Test that it was changed in access
87 ## change the folder name in cases.
88 else:
89 ## That case dir cant be found. They can't change other's casenames.
90 err = 1
91
92
93 def AddCaseToAccessDB(self, caseName):
94 ## First test to see if it's already in the DB.
95 fullClientMatterList = self.accessDB.RetrieveAllCaseList()
96 clientMatter = clientMatter.replace("-",".")
97 if clientMatter in fullClientMatterList:
98 print "This client matter already exists in the database. Skipping."
99 else:
100 print "New client matter. Adding."
101 self.accessDB.AddNewCase(caseName, clientMatter, self.tPMName,self.tPMID,responsibleOffice = self.tPMOffice)
102 print "Added!"
103
104 def EditCaseData(self,caseName,chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice, caseStatus):
105 clientMatter = caseName.split("_(")[1]
106 clientMatter = clientMatter[:-1]
107 clientMatter = clientMatter.replace('-','.')
108 self.accessDB.UpdateChargable(clientMatter,chargeableBool)
109 self.accessDB.UpdateResponsibleAttorney(clientMatter,respAttorney)
110 self.accessDB.UpdateResponsibleParalegal(clientMatter,respParalegal)
111 self.accessDB.UpdateReviewPlatform(clientMatter,revPlatform)
112 self.accessDB.UpdateResponsibleTPM(clientMatter,respTPM)
113 self.accessDB.UpdatePrimaryOffice(clientMatter,respOffice)
114 self.accessDB.UpdateResponsibleVendors(clientMatter,respVendorTpl)
115 self.accessDB.UpdateCaseStatus(clientMatter, caseStatus)
116
117 def GetCaseData(self, caseName):
118 #use this to get the data on the selected case, to populate your GUI
119 clientMatter = caseName.split("_(")[1]
120 clientMatter = clientMatter[:-1]
121 clientMatter = clientMatter.replace('-','.')
122 chargeableBool = self.accessDB.GetChargable(clientMatter)
123 respAttorney = self.accessDB.GetResponsibleAttorney(clientMatter)
124 respParalegal = self.accessDB.GetResponsibleParalegal(clientMatter)
125 respVendorTpl = self.accessDB.GetResponsibleVendorTpl(clientMatter)
126 revPlatform = self.accessDB.GetReviewPlatform(clientMatter)
127 respTPM = self.accessDB.GetResponsibleTPM(clientMatter)
128 respOffice = self.accessDB.GetPrimaryOffice(clientMatter)
129 caseStatus = self.accessDB.GetCaseStatus(clientMatter)
130 uploadCost = self.accessDB.GetUploadCostRate(clientMatter)
131 storageCost = self.accessDB.GetStorageCostRate(clientMatter)
132 disclosureLetterBool,disclosureLetterPath = self.accessDB.GetDisclosureLetter(clientMatter)
133 return (chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice,caseStatus,uploadCost,storageCost,disclosureLetterBool)
134
135 def GetPossibleProducedToEntities(self,caseName):
136 """Returns the possible produced to entities for a case"""
137 clientMatter = caseName.split("_(")[1]
138 clientMatter = clientMatter[:-1]
139 clientMatter = clientMatter.replace('-','.')
140 possibleProducedToEntities = self.accessDB.GetProducedToEntities(clientMatter)
141 return possibleProducedToEntities
142
143 def GetPossibleProdReqByNames(self,caseName):
144 """Returns the possible requested by names for a case"""
145 clientMatter = caseName.split("_(")[1]
146 clientMatter = clientMatter[:-1]
147 clientMatter = clientMatter.replace('-','.')
148 possibleProdReqByNames = self.accessDB.GetProductionRequestedByNames(clientMatter)
149 return possibleProdReqByNames
150
151
152 def AddProductionEntry(self, CLM,prodID,prodProcessedDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword):
153 """This method adds one production entry to the case."""
154 errRpt = True
155 if CLM:
156 if prodID:
157 if prodProcessedDate:
158 if begBates:
159 if endBates:
160 if prodDocCount:
161 if prodPageCount:
162 if prodNotes:
163 self.accessDB.UpdateProductionDetail(CLM,prodID,prodProcessedDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword)
164 errRpt = False
165 return errRpt
166
167 def AddDataUpload(self,CLM, reviewPlatform, reportSize):
168 """This method will add one case upload."""
169 ## TODO: one day change it so that copy up requst calls this instead
170 ## of it being internal to that prog.
171 epoch = str(int(time.time()))
172 self.accessDB.UpdateCaseUpload(CLM,reviewPlatform,{epoch:(time.strftime('%m/%d/%Y'),reportSize)})
173
174 def RemoveDataUpload(self,CLM,UEPOCH):
175 """This method calls DeleteCaseUpload and removes just one case upload. """
176 err = self.accessDB.DeleteCaseUpload(CLM,UEPOCH)
177 if err:
178 print "ERROR: An Error occured and this value was not removed!"
179 else:
180 print "%s Removed"% UEPOCH
181
182 def GetUploadData(self, caseName):
183 # Used to get upload data, on the selected case, to populate the upload dialog
184 clientMatter = caseName.split("_(")[1]
185 clientMatter = clientMatter[:-1]
186 clientMatter = clientMatter.replace('-','.')
187 uploadList = self.accessDB.RetrieveUploadsByCLM(clientMatter)
188 return uploadList
189
190 def GetProductionData(self,caseName):
191 clientMatter = caseName.split("_(")[1]
192 clientMatter = clientMatter[:-1]
193 clientMatter = clientMatter.replace('-','.')
194 productionMatrix = self.accessDB.RetrieveProductionsByCLM(clientMatter)
195 return productionMatrix
196
197 def GetProductionTotal(self,productionList):
198 """Using the above productionList, this returns the total docs and pages produced"""
199 pgCountTotal = 0
200 docCountTotal = 0
201 for i in productionList:
202 pageCount = i[-7]
203 docCount = i[-8]
204 if 'None' in pageCount:
205 pass
206 else:
207 #print pageCount
208 pgCountTotal = pgCountTotal+int(pageCount)
209 if 'None' in pageCount:
210 pass
211 else:
212 #print docCount
213 docCountTotal = docCountTotal+int(docCount)
214 return pgCountTotal,docCountTotal
215
216 def ExportProductionDataToExcel(self,CaseName,pathToCSV):
217 """Exports the production data to a csv file"""
218 productionList = self.GetProductionData(CaseName)
219 #print productionList
220 outputFile = open(pathToCSV,'w')
221 outputFile.write('Production ID,Production Completed Date,Production Sent Date,Start Bates,End Bates,Document Count,Page Count,Produced To,Requested By,Production Media,ProductionMediaPassword,Production Sources,Notes\n')
222 for i in productionList:
223 for x in i:
224 outputFile.write(x+",")
225 outputFile.write("\n")
226 outputFile.close()
227
228 def GetUploadTotal(self,uploadList):
229 """ Using the above uploadList, this will return the total uploaded """
230 count = 0.
231 for i in uploadList:
232 size = i[-1]
233
234 if 'None' in size:
235 pass
236 else:
237 rawSize = directorySize2.prettyToUnpretty_Filesize(size)
238 count = count + rawSize
239 prettySizeFinal = directorySize2.pretty_filesize2(count)
240 return prettySizeFinal
241
242 def MakeCaseDormant(self, caseAndCLM):
243 """Moves the case to the Dormant folder"""
244 print "Making %s case dormant..."
245 os.rename(os.path.join(self.casesDir,caseAndCLM),os.path.join(self.casesDir,os.path.join('zzzz_dormant_', caseAndCLM)))
246 print "Case has been archived."
247
248
249 def ViewCaseNotes(self,caseName,office):
250 """Trys to open the case notes file,in the case folder, for the active case, regardless who owns it."""
251 caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
252 clientMatter = caseName.split("_(")[1]
253 clientMatter = clientMatter[:-1]
254 if "." in clientMatter:
255 clientMatter = clientMatter.replace('.','-')
256 folderMatrix = {}
257 #caseFolderLocation = os.path.join(caseFolderLocation,case)
258 err = False
259 if caseFolderLocation:
260 if os.path.exists(caseFolderLocation):
261 for f in os.listdir(caseFolderLocation):
262 if "_(" in f:
263 folderClientMatter = f.split("_(")[1]
264 folderClientMatter = folderClientMatter[:-1]
265 folderMatrix[folderClientMatter] = f
266 try:
267 folderName = folderMatrix[clientMatter]
268 os.startfile(os.path.join(caseFolderLocation, folderName)+"/Gen_Notes.txt")
269 except:
270 err = True
271 else:
272 err = True
273 else:
274 print "A case folder for this case was not found."
275 err = True
276 return err
277
278 def ViewProdSpec(self,caseName,office):
279 """Trys to open the prod spec file,in the case folder, for the active case, regardless who owns it."""
280 caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
281 clientMatter = caseName.split("_(")[1]
282 clientMatter = clientMatter[:-1]
283 if "." in clientMatter:
284 clientMatter = clientMatter.replace('.','-')
285 folderMatrix = {}
286 #caseFolderLocation = os.path.join(caseFolderLocation,case)
287 err = False
288 if caseFolderLocation:
289 if os.path.exists(caseFolderLocation):
290 for f in os.listdir(caseFolderLocation):
291 if "_(" in f:
292 folderClientMatter = f.split("_(")[1]
293 folderClientMatter = folderClientMatter[:-1]
294 folderMatrix[folderClientMatter] = f
295 try:
296 folderName = folderMatrix[clientMatter]
297 os.startfile(os.path.join(caseFolderLocation, folderName+"/Production_Spec.txt"))
298 except:
299 err = True
300 else:
301 err = True
302 else:
303 print "A case folder for this case was not found."
304 err = True
305 return err
306
307 def CreateProductionReport(self,caseName,office):
308 """Creates a html production report in the altMediaPath folder"""
309 err = False
310 clientMatter = caseName.split("_(")[1]
311 clientMatter = clientMatter[:-1]
312 clientMatter = clientMatter.replace('-','.')
313 altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
314 productionMatrix = self.GetProductionData(caseName)
315 if os.path.exists(os.path.join(altMediaPath,'__MCP_Data')):
316 pass
317 else:
318 os.mkdir(os.path.join(altMediaPath,'__MCP_Data'))
319 reportFile = open(os.path.join(os.path.join(altMediaPath,'__MCP_Data'),'MCP_Production_Report.html'),'w')
320 reportFile.write('''<html>\n<head>\n <title>MCP: %s Production Report</title>\n <style type="text/css" media="screen">\n\n'''%caseName)
321 reportFile.write(r'''div#Rsidebar {
322 float: right;
323 width: 20%;
324 }
325 div#Lsidebar {
326 float: left;
327 width:20%;
328 height:380px;
329 }
330
331 </style>''')
332 reportFile.write('''
333 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
334 <meta name="author" content="Emanuel Borges">
335 </head>
336 <body>
337
338 <h3><br>
339 </h3>
340 <center><h2>%s Production Report</h2></center>'''%caseName)
341 reportFile.write(r'''<center><hr width="40%"></center>''')
342 for k in productionMatrix.keys():
343 productionList = productionMatrix[k]
344 reportFile.write("<h4>%s Productions</h3>" % k)
345 reportFile.write('''<center><table border=1 cellspacing=0 cellpadding=5 width=1800>\n<tr><th>Production ID</th><th>Processed Date</th><th>Sent Date</th><th>Start Bates</th><th>End Bates</th><th>Document Count</th><th>Page Count</th><th>Requested By</th><th>Production Media</th><th>Media Password</th><th>Production Sources</th><th>Notes</th></tr>''')
346 for i in productionList:
347 reportFile.write("<tr>")
348 count = 1
349 for x in i:
350 if count == 8:
351 count = count + 1
352 else:
353 reportFile.write("<td>%s</td>"%x)
354 count = count +1
355 reportFile.write("</tr>")
356
357 reportFile.write('</table></center>\n\n')
358 reportFile.write('''<div id="footer">
359 <p><span>&copy; 2012 <a href="#">Emanuel Borges</a></span><br />
360 Website automatically generated by the MCP program.</p></div>''')
361 reportFile.write('</body></html>\n')
362 reportFile.close()
363 return err
364
365 def OpenAlternateMediaFolder(self,caseName,office,testOnly=False):
366 """Trys to open the Alternate media folder, for the active case, regardless who owns it.
367 If testOnly is set to True, it will only test that it exists and not open the folder."""
368 clientMatter = caseName.split("_(")[1]
369 clientMatter = clientMatter[:-1]
370 clientMatter = clientMatter.replace('-','.')
371 altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
372 err = False
373 if altMediaPath:
374 if os.path.exists(altMediaPath):
375 if testOnly:
376 pass
377 else:
378 os.startfile(altMediaPath)
379 else:
380 print "An alternate media folder for this case was not found."
381 err = True
382 else:
383 err = True
384 return err
385
386 def SetAlternateMediaFolder(self,caseName,altMediaPath):
387 """Sets the alternate Media Path"""
388 clientMatter = caseName.split("_(")[1]
389 clientMatter = clientMatter[:-1]
390 clientMatter = clientMatter.replace('-','.')
391 self.accessDB.UpdateAlternateMediaPath(clientMatter,altMediaPath)
392
393 def GetVendorFolders(self,caseName):
394 """Returns the current list of vendor folders, for one case"""
395 clientMatter = caseName.split("_(")[1]
396 clientMatter = clientMatter[:-1]
397 clientMatter = clientMatter.replace('-','.')
398 vendorFolders = self.accessDB.GetVendorFolderPath(clientMatter)
399 #print "V%s "%vendorFolders
400 return vendorFolders
401
402 def SetVendorFolders(self,caseName, vendorFolders):
403 """Sets the Vendor Folder"""
404 clientMatter = caseName.split("_(")[1]
405 clientMatter = clientMatter[:-1]
406 clientMatter = clientMatter.replace('-','.')
407 self.accessDB.UpdateVendorFolderPath(clientMatter,vendorFolders)
408
409 def GetVendorFoldersList(self):
410 """Returns a list of all vendorFolders"""
411 ## Change this so that it actually grabs the current ones from ln. Dont know if I should grab from a table in access.
412 vendorFolderList = ["None"]
413 for n in range(1,61):
414 vendorFolderList.append("mwevendor%0*d"%(2,n))
415 return vendorFolderList
416
417 def GetDisclosureLetterData(self,caseName):
418 """Returns the the bool of if a case has a disclosure letter and if so the path."""
419 clientMatter = caseName.split("_(")[1]
420 clientMatter = clientMatter[:-1]
421 clientMatter = clientMatter.replace('-','.')
422 disclosureLetterSet, disclosureLetterPath = self.accessDB.GetDisclosureLetter(clientMatter)
423 return disclosureLetterSet, disclosureLetterPath
424
425 def SetDisclosureLetterData(self,caseName,disclosureLetterPath):
426 """Sets the disclosure letter path and checks it as true in the database"""
427 clientMatter = caseName.split("_(")[1]
428 clientMatter = clientMatter[:-1]
429 clientMatter = clientMatter.replace('-','.')
430 self.accessDB.UpdateDisclosureLetter(clientMatter,True,disclosureLetterPath)
431
432 def GetCasePathsData(self,caseName, office):
433 clientMatter = caseName.split("_(")[1]
434 clientMatter = clientMatter[:-1]
435 clientMatter = clientMatter.replace('-','.')
436 altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
437 caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
438 caseFolderLocation = os.path.join(caseFolderLocation,caseName)
439 return altMediaPath, caseFolderLocation
440
441 def SetUploadAndStorageCosts(self, caseName,uploadCost,storageCost):
442 clientMatter = caseName.split("_(")[1]
443 clientMatter = clientMatter[:-1]
444 clientMatter = clientMatter.replace('-','.')
445 if uploadCost:
446 self.accessDB.UpdateUploadCostRate(clientMatter,uploadCost)
447 if storageCost:
448 self.accessDB.UpdateStorageCostRate(clientMatter,storageCost)
449
450 def OpenCaseFolder(self,caseName,office):
451 """Trys to open the case folder for the active case, regardless who owns it."""
452 caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
453 clientMatter = caseName.split("_(")[1]
454 clientMatter = clientMatter[:-1]
455 if "." in clientMatter:
456 clientMatter = clientMatter.replace('.','-')
457 folderMatrix = {}
458 #caseFolderLocation = os.path.join(caseFolderLocation,case)
459 err = False
460 if caseFolderLocation:
461 if os.path.exists(caseFolderLocation):
462 for f in os.listdir(caseFolderLocation):
463 if "_(" in f:
464 folderClientMatter = f.split("_(")[1]
465 folderClientMatter = folderClientMatter[:-1]
466 folderMatrix[folderClientMatter] = f
467 try:
468 folderName = folderMatrix[clientMatter]
469 os.startfile(os.path.join(caseFolderLocation, folderName))
470 except:
471 err = True
472 else:
473 err = True
474 else:
475 print "A case folder for this case was not found."
476 err = True
477 return err
478
479
480 def SetCaseNameAndCLM(self, newCaseName, newClientMatterNumber):
481 """Used when setting up a new case. Should have both or nothing"""
482 self.caseName = newCaseName
483 self.clientMatter = newClientMatterNumber
484 #print self.clientMatter
485
486 def SetChargableCase(self, chargBool):
487 """sets or clears the chargable case settings"""
488 pass
489 def SetResponsibleVendor(self, vendorInfo):
490 """Sets the vendor name that is responsible for the case"""
491 pass
492 def SetReviewPlatform(self, reviewPlatform):
493 """Sets the review platform chosen for this case"""
494 if reviewPlatform == "Concordance":
495 print "Concordance selected. Creating DIS directories..."
496 hDrivePath = ConcordanceHelperTools.ParseClientMatter(self.clientMatter)
497 os.mkdir(hDrivePath)
498 print "Matter folder created."
499 os.mkdir(os.path.join(hDrivePath,'Match'))
500 os.mkdir(os.path.join(hDrivePath,'Tag_Databases'))
501 print "Supplemental folders created."
502 print "DIS directories done!"
503
504 def GetDatabaseList(self,caseName):
505 """Returns the list of databases in the database list file."""
506 return ['datbase1','database2','database3']
507
508 def SyncWithAccessDB(self,case = 'ALL'):
509 """Syncs your cases with the access database. This might only get run once when you first install
510 the program though..."""
511 ## So this syncs 'your' databases only. even though you are looking at a list of eeryone's databases
512 ## it will only sync yours. even if you did an upload for another tpm, that wouldnt get synced unles
513 ## the owner did a sync all. for 2 way sync to work, you should check, in access, that they have the case name
514 ## (with no funky characters) populated, before they run this for the first time.
515 if case == 'ALL':
516 ## verify that all your cases are up there, if not add it. but have support for cases where is should be
517 ## yours but is assigned to someone else...
518 fullClientMatterList = self.accessDB.RetrieveAllCaseList()
519 myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
520 myLocalClientMatterList = []
521
522 ## Sync cases from my local to access
523 for case in self.responsibleCasesList:
524 localCaseName,clientMatter = case.split("_(")
525 clientMatter = clientMatter.replace(")","")
526 clientMatter = clientMatter.replace("-",".")
527 myLocalClientMatterList.append(clientMatter)
528 for clm in myLocalClientMatterList:
529 if clm in myAccessClientMatterList:
530 print "%s exists"% clm
531 elif clm in fullClientMatterList:
532 print "%s cant be added to your cases because it's owned by someone else..."% clm
533 else:
534 print "%s does not exist in the database. Adding it..."% clm
535 self.AddCaseToAccessDB(localCaseName,clientMatter)
536
537 ## Sync cases from Access to my local
538
539
540 uploadReportMatrix = {}
541 for caseName in self.responsibleCasesList:
542 print "now processing %s"% caseName
543 casePath = os.path.join(self.casesDir,caseName)
544 if os.path.exists(os.path.join(casePath,"UploadReport.txt")):
545 print "yup"
546 caseUploadContents = open(os.path.join(casePath,"UploadReport.txt")).readlines()
547 clientMatter = caseName.split("_(")[1]
548 clientMatter = clientMatter.replace(")","")
549 clientMatter = clientMatter.replace("-",".")
550 for i in caseUploadContents:
551 i = i.replace("\n","")
552 i = i.replace(" | ","|")
553 try:
554 uploadReportMatrix[clientMatter].append(("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3]))
555 except:
556 uploadReportMatrix[clientMatter] = [("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3])]
557 #print uploadReportMatrix
558
559 accessMyCaseUploads = self.accessDB.RetrieveMyCaseUploads('09756')
560 for x in uploadReportMatrix.keys():
561 localCaseUploadList = uploadReportMatrix[x]
562 tempMatrix = {}
563 try:
564 accessCaseUploadList = accessMyCaseUploads[x]
565 #print accessCaseUploadList
566 for y in localCaseUploadList:
567 epoch = y[0]
568 if int(epoch) > 1298462400:
569 #print epoch
570 reviewPlatform = y[1]
571 reportSize = y[3]
572 #print "."
573 #print accessCaseUploadList
574 if epoch in accessCaseUploadList:
575 print "%s, in the %s case, is already in there, skipping."%(y,x)
576 else:
577 print "%s, in the %s case, is missing. Will be added..."%(y,x)
578 date = y[2]
579 date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
580
581 self.accessDB.UpdateCaseUpload(x,reviewPlatform,{epoch:(date,reportSize)})
582 #tempMatrix[epoch] = [platform,(date,size)]
583 else:
584 #print "This entry is pre cutover"
585 pass
586 except KeyError:
587 print "nothing for this one"
588 for z in localCaseUploadList:
589 print "%s, in the %s case, is missing. Will be added..."%(z,x)
590 date = z[0]
591 date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
592 #try:
593 # tempMatrix[date].append(z[1])
594 #except:
595 # tempMatrix[date] = [z[1]]
596 #print tempMatrix
597 #if tempMatrix:
598 # #print tempMatrix
599 # self.accessDB.UpdateCaseUpload(x,'Concordance DIS', tempMatrix)
600 #pass
601
602
603 #print myLocalClientMatterList
604 ## verify that all of your uploads are up there, if not, add it.
605 self.accessDB.CloseAccessConnection()
606
607 else:
608 fullClientMatterList = self.accessDB.RetrieveAllCaseList()
609 myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
610
611