ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Trunk/MCP_Console.py
Revision: 496
Committed: Fri Dec 20 15:52:59 2013 UTC (12 years, 3 months ago) by nino.borges
Content type: text/x-python
File size: 37105 byte(s)
Log Message:
Moved the main mcp code to the trunk, for easier versioning.

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