Index: pgaSchedule.cpp =================================================================== RCS file: /projects/pgadmin3/src/agent/pgaSchedule.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -Lsrc/agent/pgaSchedule.cpp -Lsrc/agent/pgaSchedule.cpp -u -w -r1.16 -r1.17 --- src/agent/pgaSchedule.cpp +++ src/agent/pgaSchedule.cpp @@ -25,9 +25,6 @@ #include "pgaSchedule.h" -WX_DEFINE_OBJARRAY(wxArrayTimeSpan); - - pgaSchedule::pgaSchedule(pgCollection *_collection, const wxString& newName) : pgaJobObject(_collection->GetJob(), PGA_SCHEDULE, newName) { @@ -40,29 +37,9 @@ } -void pgaSchedule::iSetIntervalList(const wxString &s) -{ - if (s[0] == '{') - intervalListString = s.Mid(1, s.Length()-2); - else - intervalListString = s; - - wxStringTokenizer tk(intervalListString, wxT(",")); - - while (tk.HasMoreTokens()) - { - wxString str=tk.GetNextToken(); - - int h, m, s; - wxSscanf(str, wxT("%d:%d:%d"), &h, &m, &s); - intervalList.Add(wxTimeSpan(h, m, s)); - } -} - - bool pgaSchedule::DropObject(wxFrame *frame, wxTreeCtrl *browser) { - return GetDatabase()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_jobschedule WHERE jscid=") + NumToStr(GetJobId())); + return GetDatabase()->ExecuteVoid(wxT("DELETE FROM pgagent.pga_schedule WHERE jscid=") + NumToStr(GetJobId())); } @@ -80,19 +57,14 @@ properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("ID"), GetJobId()); properties->AppendItem(_("Enabled"), GetEnabled()); - properties->AppendItem(_("Type"), GetKind()); - if (kindChar == 'n' || kindChar == 's') - properties->AppendItem(_("Scheduled"), GetSchedule()); - if (kindChar != 's') - { - wxTimeSpan ts=intervalList.Item(0); - if (ts.GetDays() > 0) - properties->AppendItem(_("Interval"), ts.Format(wxT("%D:%H:%M:%S"))); - else - properties->AppendItem(_("Interval"), ts.Format(wxT("%H:%M:%S"))); - } + properties->AppendItem(_("Start date"), GetStart()); properties->AppendItem(_("End date"), GetEnd()); + properties->AppendItem(_("Minutes"), GetMinutesString()); + properties->AppendItem(_("Hours"), GetHoursString()); + properties->AppendItem(_("Weekdays"), GetWeekdaysString()); + properties->AppendItem(_("Monthdays"), GetMonthdaysString()); + properties->AppendItem(_("Months"), GetMonthsString()); properties->AppendItem(_("Comment"), GetComment()); } @@ -118,6 +90,7 @@ pgObject *pgaSchedule::ReadObjects(pgCollection *collection, wxTreeCtrl *browser, const wxString &restriction) { pgaSchedule *schedule=0; + wxString tmp; pgSet *schedules= collection->GetDatabase()->ExecuteSet( wxT("SELECT * FROM pgagent.pga_schedule\n") @@ -135,22 +108,36 @@ schedule->iSetDatabase(collection->GetDatabase()); schedule->iSetStart(schedules->GetDateTime(wxT("jscstart"))); schedule->iSetEnd(schedules->GetDateTime(wxT("jscend"))); - schedule->iSetSchedule(schedules->GetDateTime(wxT("jscsched"))); - schedule->iSetIntervalList(schedules->GetVal(wxT("jsclist"))); - wxChar kindc = *schedules->GetVal(wxT("jsckind")).c_str(); - wxString kinds; - switch (kindc) - { - case 'n': kinds = _("repeat"); break; - case 's': kinds = _("single"); break; - case 'd': kinds = _("daily") ; break; - case 'w': kinds = _("weekly"); break; - case 'm': kinds = _("monthly"); break; - case 'y': kinds = _("yearly"); break; - } - schedule->iSetKind(kinds); - schedule->iSetKindChar(kindc); + tmp = schedules->GetVal(wxT("jscminutes")); + tmp.Replace(wxT("{"), wxT("")); + tmp.Replace(wxT("}"), wxT("")); + tmp.Replace(wxT(","), wxT("")); + schedule->iSetMinutes(tmp); + + tmp = schedules->GetVal(wxT("jschours")); + tmp.Replace(wxT("{"), wxT("")); + tmp.Replace(wxT("}"), wxT("")); + tmp.Replace(wxT(","), wxT("")); + schedule->iSetHours(tmp); + + tmp = schedules->GetVal(wxT("jscweekdays")); + tmp.Replace(wxT("{"), wxT("")); + tmp.Replace(wxT("}"), wxT("")); + tmp.Replace(wxT(","), wxT("")); + schedule->iSetWeekdays(tmp); + + tmp = schedules->GetVal(wxT("jscmonthdays")); + tmp.Replace(wxT("{"), wxT("")); + tmp.Replace(wxT("}"), wxT("")); + tmp.Replace(wxT(","), wxT("")); + schedule->iSetMonthdays(tmp); + + tmp = schedules->GetVal(wxT("jscmonths")); + tmp.Replace(wxT("{"), wxT("")); + tmp.Replace(wxT("}"), wxT("")); + tmp.Replace(wxT(","), wxT("")); + schedule->iSetMonths(tmp); schedule->iSetComment(schedules->GetVal(wxT("jscdesc"))); @@ -168,3 +155,252 @@ } return schedule; } + +wxString pgaSchedule::GetMinutesString() +{ + size_t x = 0; + bool isWildcard = true; + wxString res; + + for (x=0; x <= minutes.Length();x++) + { + if (minutes[x] == 't') + { + res.Printf(wxT("%s%d, "), res, x); + isWildcard = false; + } + } + + if (isWildcard) + { + res = _("Every minute"); + } + else + { + if (res.Length() > 2) + { + res.RemoveLast(); + res.RemoveLast(); + } + } + + return res; +} + +wxString pgaSchedule::GetHoursString() +{ + size_t x = 0; + bool isWildcard = true; + wxString res; + + for (x=0; x <= hours.Length();x++) + { + if (hours[x] == 't') + { + res.Printf(wxT("%s%d, "), res, x); + isWildcard = false; + } + } + + if (isWildcard) + { + res = _("Every hour"); + } + else + { + if (res.Length() > 2) + { + res.RemoveLast(); + res.RemoveLast(); + } + } + + return res; +} + +wxString pgaSchedule::GetWeekdaysString() +{ + size_t x = 0; + bool isWildcard = true; + wxString res; + + for (x=0; x <= weekdays.Length();x++) + { + if (weekdays[x] == 't') + { + switch (x) + { + case 0: + res += _("Monday"); + res += wxT(", "); + break; + case 1: + res += _("Tuesday"); + res += wxT(", "); + break; + case 2: + res += _("Wednesday"); + res += wxT(", "); + break; + case 3: + res += _("Thursday"); + res += wxT(", "); + break; + case 4: + res += _("Friday"); + res += wxT(", "); + break; + case 5: + res += _("Saturday"); + res += wxT(", "); + break; + case 6: + res += _("Sunday"); + res += wxT(", "); + break; + default: + res += _("The mythical 8th day!"); + res += wxT(", "); + break; + } + isWildcard = false; + } + } + + if (isWildcard) + { + res = _("Any day of the week"); + } + else + { + if (res.Length() > 2) + { + res.RemoveLast(); + res.RemoveLast(); + } + } + + return res; +} + +wxString pgaSchedule::GetMonthdaysString() +{ + size_t x = 0; + bool isWildcard = true; + wxString res; + + for (x=0; x <= monthdays.Length();x++) + { + if (monthdays[x] == 't') + { + if (x < 32) + res.Printf(wxT("%s%d, "), res, x); + else + { + res += _("Last day"); + res += wxT(", "); + } + isWildcard = false; + } + } + + if (isWildcard) + { + res = _("Every day"); + } + else + { + if (res.Length() > 2) + { + res.RemoveLast(); + res.RemoveLast(); + } + } + + return res; +} + +wxString pgaSchedule::GetMonthsString() +{ + size_t x = 0; + bool isWildcard = true; + wxString res; + + for (x=0; x <= months.Length();x++) + { + if (months[x] == 't') + { + switch (x) + { + case 0: + res += _("January"); + res += wxT(", "); + break; + case 1: + res += _("February"); + res += wxT(", "); + break; + case 2: + res += _("March"); + res += wxT(", "); + break; + case 3: + res += _("April"); + res += wxT(", "); + break; + case 4: + res += _("May"); + res += wxT(", "); + break; + case 5: + res += _("June"); + res += wxT(", "); + break; + case 6: + res += _("July"); + res += wxT(", "); + break; + case 7: + res += _("August"); + res += wxT(", "); + break; + case 8: + res += _("September"); + res += wxT(", "); + break; + case 9: + res += _("October"); + res += wxT(", "); + break; + case 10: + res += _("November"); + res += wxT(", "); + break; + case 11: + res += _("December"); + res += wxT(", "); + break; + default: + res += _("The mythical 13th month!"); + res += wxT(", "); + break; + } + isWildcard = false; + } + } + + if (isWildcard) + { + res = _("Every month"); + } + else + { + if (res.Length() > 2) + { + res.RemoveLast(); + res.RemoveLast(); + } + } + + return res; +} \ No newline at end of file Index: dlgSchedule.cpp =================================================================== RCS file: /projects/pgadmin3/src/agent/dlgSchedule.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -Lsrc/agent/dlgSchedule.cpp -Lsrc/agent/dlgSchedule.cpp -u -w -r1.16 -r1.17 --- src/agent/dlgSchedule.cpp +++ src/agent/dlgSchedule.cpp @@ -89,7 +89,6 @@ { // edit mode chkEnabled->SetValue(schedule->GetEnabled()); - cbKind->SetSelection(wxString(wxT("nsdwmy")).Find(schedule->GetKindChar())); calStart->SetDate(schedule->GetStart()); timStart->SetTime(schedule->GetStart()); if (schedule->GetEnd().IsValid()) @@ -99,9 +98,6 @@ } else timEnd->Disable(); - calSchedule->SetDate(schedule->GetSchedule()); - timSchedule->SetTime(schedule->GetSchedule()); - timInterval->SetValue(schedule->GetIntervalList().Item(0)); wxNotifyEvent ev; OnChangeKind(ev); @@ -185,7 +181,6 @@ { enable = name != schedule->GetName() || chkEnabled->GetValue() != schedule->GetEnabled() - || cbKind->GetSelection() != wxString(wxT("nsdwmy")).Find(schedule->GetKindChar()) || txtComment->GetValue() != schedule->GetComment(); } else Index: pgaSchedule.h =================================================================== RCS file: /projects/pgadmin3/src/agent/include/pgaSchedule.h,v retrieving revision 1.11 retrieving revision 1.12 diff -Lsrc/agent/include/pgaSchedule.h -Lsrc/agent/include/pgaSchedule.h -u -w -r1.11 -r1.12 --- src/agent/include/pgaSchedule.h +++ src/agent/include/pgaSchedule.h @@ -5,7 +5,7 @@ // Copyright (C) 2002 - 2005, The pgAdmin Development Team // This software is released under the Artistic Licence // -// pgaStep.h - PostgreSQL Agent Job Schedule +// pgaSchedule.h - PostgreSQL Agent Job Schedule // ////////////////////////////////////////////////////////////////////////// @@ -24,9 +24,6 @@ // Class declarations -WX_DECLARE_OBJARRAY(wxTimeSpan, wxArrayTimeSpan); - - class pgaSchedule : public pgaJobObject { public: @@ -41,29 +38,38 @@ bool GetEnabled() const { return enabled; } void iSetEnabled(const bool b) { enabled=b; } - wxChar GetKindChar() const { return kindChar; } - void iSetKindChar(const wxChar c) { kindChar=c; } - wxString GetKind() const { return kind; } - void iSetKind(const wxString &s) { kind=s; } wxDateTime GetStart() const { return start; } void iSetStart(const wxDateTime &d) { start=d; } wxDateTime GetEnd() const { return end; } void iSetEnd(const wxDateTime &d) { end=d; } - wxDateTime GetSchedule() const { return schedule; } - void iSetSchedule(const wxDateTime &d) { schedule=d; } - wxString GetIntervalListString() const { return intervalListString; } - void iSetIntervalList(const wxString &s); - wxArrayTimeSpan GetIntervalList() const { return intervalList; } long GetJobId() const { return jobId; } void iSetJobId(const long l) { jobId=l; } + wxString GetMinutes() const { return minutes; } + wxString GetMinutesString(); + void iSetMinutes(const wxString &s) { minutes = s; } + + wxString GetHours() const { return hours; } + wxString GetHoursString(); + void iSetHours(const wxString &s) { hours = s; } + + wxString GetWeekdays() const { return weekdays; } + wxString GetWeekdaysString(); + void iSetWeekdays(const wxString &s) { weekdays = s; } + + wxString GetMonthdays() const { return monthdays; } + wxString GetMonthdaysString(); + void iSetMonthdays(const wxString &s) { monthdays = s; } + + wxString GetMonths() const { return months; } + wxString GetMonthsString(); + void iSetMonths(const wxString &s) { months = s; } + private: bool enabled; - wxString kind, intervalListString; - wxArrayTimeSpan intervalList; - wxDateTime start, end, schedule; - wxChar kindChar; + wxDateTime start, end; long jobId; + wxString minutes, hours, weekdays, monthdays, months; }; #endif