| 1 |
"""
|
| 2 |
|
| 3 |
EEAC
|
| 4 |
|
| 5 |
Created by
|
| 6 |
Emanuel Borges
|
| 7 |
05.31.2018
|
| 8 |
|
| 9 |
This is the UI for performing various admin functions against Eclipse.
|
| 10 |
|
| 11 |
INSTALLED ON 30 and 32 FOR TESTING
|
| 12 |
|
| 13 |
"""
|
| 14 |
|
| 15 |
|
| 16 |
import wx
|
| 17 |
import wx.lib.agw.pybusyinfo as PBI
|
| 18 |
import EclipseSQLLib, EEACViewDialogs
|
| 19 |
|
| 20 |
|
| 21 |
class MyFrame(wx.Frame):
|
| 22 |
def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
|
| 23 |
|
| 24 |
self.db = EclipseSQLLib.Eclipse_Connection()
|
| 25 |
|
| 26 |
wx.Frame.__init__(self, parent, ID, title, pos, size =(550,580))
|
| 27 |
self.panel = wx.Panel(self,-1)
|
| 28 |
self.currentCaseStaticText = wx.StaticText(self.panel, -1, "No case Selected",wx.DefaultPosition)
|
| 29 |
|
| 30 |
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
| 31 |
mainSizer.Add(self.currentCaseStaticText,0,wx.ALL, 50)
|
| 32 |
self.panel.SetSizer(mainSizer)
|
| 33 |
|
| 34 |
self.CreateStatusBar()
|
| 35 |
self.SetStatusText("Ready.")
|
| 36 |
self.CreateMenuBar()
|
| 37 |
|
| 38 |
def NothingYet(self,event):
|
| 39 |
""" A simple place holder function that is used to be a PASS statment when I'm creating controls"""
|
| 40 |
diag = wx.MessageDialog(self,"Nothing here yet!", "Disabled...",wx.OK | wx.ICON_INFORMATION)
|
| 41 |
diag.ShowModal()
|
| 42 |
diag.Destroy()
|
| 43 |
|
| 44 |
def MenuData(self):
|
| 45 |
return(("Case",
|
| 46 |
("Select Case","Alows you to select or change the current case.",self.OnChangeCase,"")),
|
| 47 |
("View",
|
| 48 |
("Field List", "Displays the fields that exist in this database.",self.OnListFields,"")),
|
| 49 |
("General Tools",
|
| 50 |
("Update Batch Reviewed Status", "Updates the batch reviewed status flag for a particular batch set. Currently only Doc Review Desig.",self.OnUpdateBatchReviewedStatus,"")),
|
| 51 |
("Production Tools",
|
| 52 |
("Calculate Prod Size","Returns the size of the production, for a particular volume.",self.OnCalculateProdSize,""),
|
| 53 |
("Populate EndDocs","Copies the evidoxID to the Paper EndDoc with Null values only.",self.NothingYet,"")),
|
| 54 |
("DB Maintenance",
|
| 55 |
("DB Defragement","Performs a database defrag, on the selected DB.",self.OnDBDfrag,"")),
|
| 56 |
("&Help",
|
| 57 |
("&About", "Displays the About Window.", self.NothingYet,"")))
|
| 58 |
|
| 59 |
def CreateMenuBar(self):
|
| 60 |
menuBar = wx.MenuBar()
|
| 61 |
count = 1
|
| 62 |
for eachMenuData in self.MenuData():
|
| 63 |
menuLabel = eachMenuData[0]
|
| 64 |
menuItems = eachMenuData[1:]
|
| 65 |
menuBar.Append(self.CreateMenu(menuItems), menuLabel)
|
| 66 |
count = count + 1
|
| 67 |
self.SetMenuBar(menuBar)
|
| 68 |
|
| 69 |
|
| 70 |
def CreateMenu(self, menuData):
|
| 71 |
menu = wx.Menu()
|
| 72 |
for eachLabel, eachStatus, eachHandler, eachType in menuData:
|
| 73 |
if not eachLabel:
|
| 74 |
menu.AppendSeparator()
|
| 75 |
continue
|
| 76 |
if eachType == "RADIO":
|
| 77 |
menuItem = menu.AppendRadioItem(-1,eachLabel,eachStatus)
|
| 78 |
else:
|
| 79 |
menuItem = menu.Append(-1, eachLabel, eachStatus)
|
| 80 |
if eachType == 'DISABLED':
|
| 81 |
menuItem.Enable(False)
|
| 82 |
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
|
| 83 |
return menu
|
| 84 |
|
| 85 |
def OnChangeCase(self,event):
|
| 86 |
dlg = wx.SingleChoiceDialog(
|
| 87 |
self, 'Please choose a case', 'Case Selection',
|
| 88 |
self.db.caseList,
|
| 89 |
wx.CHOICEDLG_STYLE
|
| 90 |
)
|
| 91 |
|
| 92 |
if dlg.ShowModal() == wx.ID_OK:
|
| 93 |
self.db.SelectCase(dlg.GetStringSelection())
|
| 94 |
|
| 95 |
dlg.Destroy()
|
| 96 |
print dlg.GetStringSelection()
|
| 97 |
self.currentCaseStaticText.SetLabel(dlg.GetStringSelection())
|
| 98 |
|
| 99 |
def OnListFields(self, event):
|
| 100 |
if self.db.currentDatabaseName:
|
| 101 |
dlg = EEACViewDialogs.DatabaseFieldsDialog(self, self.db.fieldList, self.db.currentDatabaseName)
|
| 102 |
dlg.ShowModal()
|
| 103 |
dlg.Destroy()
|
| 104 |
else:
|
| 105 |
errDlg = wx.MessageDialog(self, "Please choose a database first.", "No Database Selected",wx.OK, wx.DefaultPosition)
|
| 106 |
errDlg.ShowModal()
|
| 107 |
errDlg.Destroy()
|
| 108 |
|
| 109 |
def OnCalculateProdSize(self, event):
|
| 110 |
if self.db.currentDatabaseName:
|
| 111 |
preDlg = wx.SingleChoiceDialog(self, 'Please select the production volume field', 'Production Volume Field Selection',self.db.fieldList, wx.CHOICEDLG_STYLE)
|
| 112 |
if preDlg.ShowModal() == wx.ID_OK:
|
| 113 |
prodVolumeFieldName = preDlg.GetStringSelection()
|
| 114 |
preDlg.Destroy()
|
| 115 |
print prodVolumeFieldName
|
| 116 |
message = "Please wait while volumes are gathered..."
|
| 117 |
busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
|
| 118 |
prodVolValuesList = self.db.GetUniqueValues(prodVolumeFieldName)
|
| 119 |
del busy
|
| 120 |
try:
|
| 121 |
prodVolValuesList.remove(None)
|
| 122 |
except:
|
| 123 |
pass
|
| 124 |
|
| 125 |
print prodVolValuesList
|
| 126 |
#dlg = EEACProductionToolDialogs.ProductionSizeDialog(self, preDlg.GetStringSelection(), self.db.currentDatabaseName)
|
| 127 |
volSelectionDlg = wx.SingleChoiceDialog(self, 'Please select the production volume', 'Production Volume Selection', prodVolValuesList, wx.CHOICEDLG_STYLE)
|
| 128 |
if volSelectionDlg.ShowModal() == wx.ID_OK:
|
| 129 |
volumeValue = volSelectionDlg.GetStringSelection()
|
| 130 |
print volumeValue
|
| 131 |
volSelectionDlg.Destroy()
|
| 132 |
message = "Please wait while the size is calculated..."
|
| 133 |
busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
|
| 134 |
prodSizeValue = self.db.GetProductionSize(prodVolumeFieldName, 'NATIVEFILESIZE', volumeValue)
|
| 135 |
del busy
|
| 136 |
responseDlg = wx.MessageDialog(self, "Production size is %s GB."% prodSizeValue, "Production Size Calculated.",wx.OK, wx.DefaultPosition)
|
| 137 |
responseDlg.ShowModal()
|
| 138 |
responseDlg.Destroy()
|
| 139 |
else:
|
| 140 |
volSelectionDlg.Destroy()
|
| 141 |
|
| 142 |
else:
|
| 143 |
preDlg.Destroy()
|
| 144 |
else:
|
| 145 |
errDlg = wx.MessageDialog(self, "Please choose a database first.", "No Database Selected",wx.OK, wx.DefaultPosition)
|
| 146 |
errDlg.ShowModal()
|
| 147 |
errDlg.Destroy()
|
| 148 |
|
| 149 |
def OnUpdateBatchReviewedStatus(self, event):
|
| 150 |
if self.db.currentDatabaseName:
|
| 151 |
if self.db.batchSetList:
|
| 152 |
preDlg = wx.SingleChoiceDialog(self, 'Please select a batch set.', 'Batch Set Selection',self.db.batchSetList, wx.CHOICEDLG_STYLE)
|
| 153 |
if preDlg.ShowModal() == wx.ID_OK:
|
| 154 |
batchSetName = preDlg.GetStringSelection()
|
| 155 |
preDlg.Destroy()
|
| 156 |
print batchSetName
|
| 157 |
message = "Please wait while the bad flags are calculated for this batch set..."
|
| 158 |
busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
|
| 159 |
docsToUpdateCount = self.db.UpdateBatchReviewedStatus(batchSetName)
|
| 160 |
del busy
|
| 161 |
if docsToUpdateCount > 0:
|
| 162 |
confirmationMessage = wx.MessageDialog(self, "This process will update %s values in the dabase.\n\nSelect OK to continue or cancle to exit without changes."% docsToUpdateCount, "Batch Status Update",wx.OK|wx.CANCEL|wx.ICON_WARNING, wx.DefaultPosition)
|
| 163 |
if confirmationMessage.ShowModal() == wx.ID_OK:
|
| 164 |
message = "Please wait while the missing flags are updated, for this batch set..."
|
| 165 |
busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
|
| 166 |
docsUpdatedCount = self.db.UpdateBatchReviewedStatus(batchSetName, False)
|
| 167 |
del busy
|
| 168 |
responseDlg = wx.MessageDialog(self, "%s batch set has been updated.\n%s records were updated."% (batchSetName,docsUpdatedCount), "Batch Sets Updated.",wx.OK, wx.DefaultPosition)
|
| 169 |
responseDlg.ShowModal()
|
| 170 |
responseDlg.Destroy()
|
| 171 |
else:
|
| 172 |
msg = wx.MessageDialog(self, "This batch set is already up to date and no updates are needed.", "Batch Status Update Not Needed",wx.OK|wx.ICON_INFORMATION, wx.DefaultPosition)
|
| 173 |
msg.ShowModal()
|
| 174 |
msg.Destroy()
|
| 175 |
|
| 176 |
else:
|
| 177 |
errDlg = wx.MessageDialog(self, "There are currently NO batch sets in this database.", "Zero Batch Sets",wx.OK, wx.DefaultPosition)
|
| 178 |
errDlg.ShowModal()
|
| 179 |
errDlg.Destroy()
|
| 180 |
else:
|
| 181 |
errDlg = wx.MessageDialog(self, "Please choose a database first.", "No Database Selected",wx.OK, wx.DefaultPosition)
|
| 182 |
errDlg.ShowModal()
|
| 183 |
errDlg.Destroy()
|
| 184 |
|
| 185 |
def OnDBDfrag(self, event):
|
| 186 |
if self.db.currentDatabaseName:
|
| 187 |
msg = wx.MessageDialog(self, "This tool will perform 3 major database optimization functions, which may take up to 20 minutes.\n\nSelect OK to perform these.", "Database Defrag Utilites",wx.OK|wx.CANCEL|wx.ICON_WARNING, wx.DefaultPosition)
|
| 188 |
if msg.ShowModal() == wx.ID_OK:
|
| 189 |
msg.Destroy()
|
| 190 |
message = "Please wait while this database is optimized..."
|
| 191 |
busy = PBI.PyBusyInfo(message, parent=self, title="System Busy: Hold Yer Horses!")
|
| 192 |
self.db.RunDatabaseDefrag()
|
| 193 |
del busy
|
| 194 |
responseDlg = wx.MessageDialog(self, "Optimization functions have all completed.", "Database Optimized.",wx.OK, wx.DefaultPosition)
|
| 195 |
responseDlg.ShowModal()
|
| 196 |
responseDlg.Destroy()
|
| 197 |
else:
|
| 198 |
errDlg = wx.MessageDialog(self, "Please choose a database first.", "No Database Selected",wx.OK, wx.DefaultPosition)
|
| 199 |
errDlg.ShowModal()
|
| 200 |
errDlg.Destroy()
|
| 201 |
|
| 202 |
|
| 203 |
class MyApp(wx.App):
|
| 204 |
def OnInit(self):
|
| 205 |
version = 0.07
|
| 206 |
self.frame = MyFrame(None, -1, "Evidox Elipse Admin Console v %s"% version)
|
| 207 |
self.frame.Show(True)
|
| 208 |
self.SetTopWindow(self.frame)
|
| 209 |
return True
|
| 210 |
|
| 211 |
|
| 212 |
if __name__ == '__main__':
|
| 213 |
app = MyApp(0)
|
| 214 |
app.MainLoop() |