int dlgStep::Go(bool modal) { int returncode; hasConnStrSupport = connection->TableHasColumn(wxT("pgagent"), wxT("pga_jobstep"), wxT("jstconnstr")); cbDatabase->Append(wxT(" ")); cbDatabase->SetSelection(0); pgSet *db = connection->ExecuteSet(wxT("SELECT datname FROM pg_database")); if (db) { while (!db->Eof()) { cbDatabase->Append(db->GetVal(0)); db->MoveNext(); } delete db; } if (step) { // edit mode recId = step->GetRecId(); txtID->SetValue(NumToStr(recId)); if (step->HasConnectionString()) { rbRemoteConn->SetValue(true); txtConnStr->Enable(true); txtConnStr->ChangeValue(step->GetConnStr()); btnSelDatabase->Enable(true); cbDatabase->Enable(false); } else { rbLocalConn->SetValue(true); if (step->GetDbname().IsEmpty()) cbDatabase->SetSelection(0); else cbDatabase->SetValue(step->GetDbname()); } rbxKind->SetSelection(wxString(wxT("sb")).Find(step->GetKindChar())); rbxOnError->SetSelection(wxString(wxT("fsi")).Find(step->GetOnErrorChar())); sqlBox->SetText(step->GetCode()); chkEnabled->SetValue(step->GetEnabled()); } else { // create mode rbLocalConn->SetValue(true); cbDatabase->Enable(true); btnSelDatabase->Enable(false); txtConnStr->Enable(false); if (!hasConnStrSupport) rbLocalConn->Enable(false); } returncode = dlgProperty::Go(modal); SetSqlReadOnly(true); return returncode; }
int dlgSchedule::Go(bool modal) { int returncode; if (schedule) { // edit mode recId = schedule->GetRecId(); txtID->SetValue(NumToStr(recId)); chkEnabled->SetValue(schedule->GetEnabled()); calStart->SetValue(schedule->GetStart().GetDateOnly()); timStart->SetTime(schedule->GetStart()); if (schedule->GetEnd().IsValid()) { calEnd->SetValue(schedule->GetEnd().GetDateOnly()); timEnd->SetTime(schedule->GetEnd()); } else { calEnd->SetValue(wxInvalidDateTime); timEnd->SetTime(wxInvalidDateTime); timEnd->Disable(); } unsigned int x; for (x = 0; x < schedule->GetMonths().Length(); x++ ) if (schedule->GetMonths()[x] == 't') chkMonths->Check(x, true); for (x = 0; x < schedule->GetMonthdays().Length(); x++ ) if (schedule->GetMonthdays()[x] == 't') chkMonthdays->Check(x, true); for (x = 0; x < schedule->GetWeekdays().Length(); x++ ) if (schedule->GetWeekdays()[x] == 't') chkWeekdays->Check(x, true); for (x = 0; x < schedule->GetHours().Length(); x++ ) if (schedule->GetHours()[x] == 't') chkHours->Check(x, true); for (x = 0; x < schedule->GetMinutes().Length(); x++ ) if (schedule->GetMinutes()[x] == 't') chkMinutes->Check(x, true); wxString id, dateToken, timeToken; wxDateTime val; long pos = 0; wxStringTokenizer tkz(schedule->GetExceptions(), wxT("|")); while (tkz.HasMoreTokens() ) { dateToken.Empty(); timeToken.Empty(); // First is the ID id = tkz.GetNextToken(); // Look for a date if (tkz.HasMoreTokens()) dateToken = tkz.GetNextToken(); // Look for a time if (tkz.HasMoreTokens()) timeToken = tkz.GetNextToken(); if (!dateToken.IsEmpty() && !timeToken.IsEmpty()) { val.ParseDate(dateToken); val.ParseTime(timeToken); pos = lstExceptions->AppendItem(0, val.FormatDate(), val.FormatTime()); } else if (!dateToken.IsEmpty() && timeToken.IsEmpty()) { val.ParseDate(dateToken); pos = lstExceptions->AppendItem(0, val.FormatDate(), _("<any>")); } else if (dateToken.IsEmpty() && !timeToken.IsEmpty()) { val.ParseTime(timeToken); pos = lstExceptions->AppendItem(0, _("<any>"), val.FormatTime()); } lstExceptions->SetItem(pos, 2, BoolToStr(false)); lstExceptions->SetItem(pos, 3, id); } wxNotifyEvent ev; } else { // create mode } // setup de-/select buttons InitSelectAll(); returncode = dlgProperty::Go(modal); SetSqlReadOnly(true); return returncode; }
int dlgJob::Go(bool modal) { int returncode; pgSet *jcl = connection->ExecuteSet(wxT("SELECT jclname FROM pgagent.pga_jobclass")); if (jcl) { while (!jcl->Eof()) { cbJobclass->Append(jcl->GetVal(0)); jcl->MoveNext(); } delete jcl; } if (job) { // edit mode recId = job->GetRecId(); txtID->SetValue(NumToStr(recId)); cbJobclass->SetValue(job->GetJobclass()); chkEnabled->SetValue(job->GetEnabled()); txtHostAgent->SetValue(job->GetHostAgent()); txtCreated->SetValue(DateToStr(job->GetCreated())); txtChanged->SetValue(DateToStr(job->GetChanged())); txtNextrun->SetValue(DateToStr(job->GetNextrun())); txtLastrun->SetValue(DateToStr(job->GetLastrun())); txtLastresult->SetValue(job->GetLastresult()); wxCookieType cookie; pgObject *data = 0; wxTreeItemId item, stepsItem, schedulesItem; item = mainForm->GetBrowser()->GetFirstChild(job->GetId(), cookie); while (item) { data = mainForm->GetBrowser()->GetObject(item); if (data->GetMetaType() == PGM_STEP) stepsItem = item; else if (data->GetMetaType() == PGM_SCHEDULE) schedulesItem = item; item = mainForm->GetBrowser()->GetNextChild(job->GetId(), cookie); } if (stepsItem) { pgCollection *coll = (pgCollection *)data; // make sure all columns are appended coll->ShowTreeDetail(mainForm->GetBrowser()); // this is the columns collection item = mainForm->GetBrowser()->GetFirstChild(stepsItem, cookie); // add columns while (item) { data = mainForm->GetBrowser()->GetObject(item); if (data->IsCreatedBy(stepFactory)) { pgaStep *step = (pgaStep *)data; int pos = lstSteps->AppendItem(stepFactory.GetIconId(), step->GetName(), step->GetComment()); lstSteps->SetItem(pos, 3, NumToStr((long)step)); previousSteps.Add(NumToStr((long)step)); } item = mainForm->GetBrowser()->GetNextChild(stepsItem, cookie); } } if (schedulesItem) { pgCollection *coll = (pgCollection *)data; // make sure all columns are appended coll->ShowTreeDetail(mainForm->GetBrowser()); // this is the columns collection item = mainForm->GetBrowser()->GetFirstChild(schedulesItem, cookie); // add columns while (item) { data = mainForm->GetBrowser()->GetObject(item); if (data->IsCreatedBy(scheduleFactory)) { pgaSchedule *schedule = (pgaSchedule *)data; int pos = lstSchedules->AppendItem(scheduleFactory.GetIconId(), schedule->GetName(), schedule->GetComment()); lstSchedules->SetItem(pos, 3, NumToStr((long)schedule)); previousSchedules.Add(NumToStr((long)schedule)); } item = mainForm->GetBrowser()->GetNextChild(schedulesItem, cookie); } } } else { // create mode cbJobclass->SetSelection(0); btnChangeStep->Hide(); btnChangeSchedule->Hide(); } returncode = dlgProperty::Go(modal); SetSqlReadOnly(true); // This fixes a UI glitch on MacOS X // Because of the new layout code, the Columns pane doesn't size itself properly SetSize(GetSize().GetWidth() + 1, GetSize().GetHeight()); SetSize(GetSize().GetWidth() - 1, GetSize().GetHeight()); return returncode; }