1 ////////////////////////////////////////////////////////////////////////// 2 // 3 // pgAdmin III - PostgreSQL Tools 4 // 5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team 6 // This software is released under the PostgreSQL Licence 7 // 8 // pgaJob.h - PostgreSQL Agent Job 9 // 10 ////////////////////////////////////////////////////////////////////////// 11 12 #ifndef PGAJOB_H 13 #define PGAJOB_H 14 15 #include "schema/pgServer.h" 16 17 18 class pgaJobFactory : public pgServerObjFactory 19 { 20 public: 21 pgaJobFactory(); 22 virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent); 23 virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString); 24 virtual pgCollection *CreateCollection(pgObject *obj); GetDisabledId()25 int GetDisabledId() 26 { 27 return disabledId; 28 } 29 30 protected: 31 int disabledId; 32 }; 33 extern pgaJobFactory jobFactory; 34 35 class pgaJob : public pgServerObject 36 { 37 public: 38 pgaJob(const wxString &newName = wxT("")); 39 40 int GetIconId(); 41 void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); 42 void ShowStatistics(frmMain *form, ctlListView *statistics); 43 pgObject *Refresh(ctlTree *browser, const wxTreeItemId item); 44 bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded); 45 46 wxString GetTranslatedMessage(int kindOfMessage) const; GetJobclass()47 wxString GetJobclass() const 48 { 49 return jobclass; 50 } iSetJobclass(const wxString & s)51 void iSetJobclass(const wxString &s) 52 { 53 jobclass = s; 54 } GetEnabled()55 bool GetEnabled() const 56 { 57 return enabled; 58 } iSetEnabled(const bool b)59 void iSetEnabled(const bool b) 60 { 61 enabled = b; 62 } GetCreated()63 wxDateTime GetCreated() const 64 { 65 return created; 66 } iSetCreated(const wxDateTime & d)67 void iSetCreated(const wxDateTime &d) 68 { 69 created = d; 70 } GetChanged()71 wxDateTime GetChanged() const 72 { 73 return changed; 74 } iSetChanged(const wxDateTime & d)75 void iSetChanged(const wxDateTime &d) 76 { 77 changed = d; 78 } GetNextrun()79 wxDateTime GetNextrun() const 80 { 81 return nextrun; 82 } iSetNextrun(const wxDateTime & d)83 void iSetNextrun(const wxDateTime &d) 84 { 85 nextrun = d; 86 } GetLastrun()87 wxDateTime GetLastrun() const 88 { 89 return lastrun; 90 } iSetLastrun(const wxDateTime & d)91 void iSetLastrun(const wxDateTime &d) 92 { 93 lastrun = d; 94 } GetLastresult()95 wxString GetLastresult() const 96 { 97 return lastresult; 98 } iSetLastresult(const wxString & s)99 void iSetLastresult(const wxString &s) 100 { 101 lastresult = s; 102 } GetCurrentAgent()103 wxString GetCurrentAgent() const 104 { 105 return currentAgent; 106 } iSetCurrentAgent(const wxString & s)107 void iSetCurrentAgent(const wxString &s) 108 { 109 currentAgent = s; 110 } GetHostAgent()111 wxString GetHostAgent() const 112 { 113 return hostAgent; 114 } iSetHostAgent(const wxString & s)115 void iSetHostAgent(const wxString &s) 116 { 117 hostAgent = s; 118 } GetRecId()119 long GetRecId() const 120 { 121 return recId; 122 } iSetRecId(const long l)123 void iSetRecId(const long l) 124 { 125 recId = l; 126 } 127 bool RunNow(); 128 129 wxMenu *GetNewMenu(); CanCreate()130 bool CanCreate() 131 { 132 return true; 133 } CanView()134 bool CanView() 135 { 136 return false; 137 } CanEdit()138 bool CanEdit() 139 { 140 return true; 141 } CanDrop()142 bool CanDrop() 143 { 144 return true; 145 } WantDummyChild()146 bool WantDummyChild() 147 { 148 return true; 149 } 150 GetHelpPage(bool forCreate)151 wxString GetHelpPage(bool forCreate) const 152 { 153 return wxT("pgagent-jobs"); 154 } 155 156 private: 157 bool enabled; 158 wxDateTime created, changed, nextrun, lastrun; 159 wxString lastresult, jobclass, currentAgent, hostAgent; 160 long recId; 161 }; 162 163 164 class pgaJobObject : public pgServerObject 165 { 166 public: 167 pgaJobObject(pgaJob *job, pgaFactory &factory, const wxString &newName); GetJob()168 virtual pgaJob *GetJob() 169 { 170 return job; 171 } 172 CanCreate()173 bool CanCreate() 174 { 175 return job->CanCreate(); 176 } CanView()177 bool CanView() 178 { 179 return false; 180 } CanEdit()181 bool CanEdit() 182 { 183 return job->CanEdit(); 184 } CanDrop()185 bool CanDrop() 186 { 187 return job->CanDrop(); 188 } 189 190 protected: 191 pgaJob *job; 192 }; 193 194 195 class pgaJobCollection : public pgServerObjCollection 196 { 197 public: 198 pgaJobCollection(pgaFactory *factory, pgServer *sv); 199 wxString GetTranslatedMessage(int kindOfMessage) const; 200 }; 201 202 203 class pgaJobObjCollection : public pgServerObjCollection 204 { 205 public: 206 pgaJobObjCollection(pgaFactory *factory, pgaJob *job); 207 bool CanCreate(); 208 }; 209 210 class pgaJobObjFactory : public pgServerObjFactory 211 { 212 public: 213 pgaJobObjFactory(const wxChar *tn, const wxChar *ns, const wxChar *nls, wxImage *img, wxImage *imgSm = 0) pgServerObjFactory(tn,ns,nls,img,imgSm)214 : pgServerObjFactory(tn, ns, nls, img, imgSm) {} 215 virtual pgCollection *CreateCollection(pgObject *obj); 216 }; 217 218 class runNowFactory : public contextActionFactory 219 { 220 public: 221 runNowFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar); 222 wxWindow *StartDialog(frmMain *form, pgObject *obj); 223 bool CheckEnable(pgObject *obj); 224 }; 225 226 #endif 227