SVN Commit by dpage: r4184 - in trunk/pgadmin3/src: agent ctl include/ctl - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by dpage: r4184 - in trunk/pgadmin3/src: agent ctl include/ctl
Date
Msg-id 200505161400.j4GE0iFU005663@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: dpage
Date: 2005-05-16 15:00:43 +0100 (Mon, 16 May 2005)
New Revision: 4184

Modified:
   trunk/pgadmin3/src/agent/dlgJob.cpp
   trunk/pgadmin3/src/agent/dlgSchedule.cpp
   trunk/pgadmin3/src/agent/dlgStep.cpp
   trunk/pgadmin3/src/ctl/ctlListView.cpp
   trunk/pgadmin3/src/include/ctl/ctlListView.h
Log:
Ah-ha. Finally - finished the first cut of the pgAgent management code! Yay :-)

Modified: trunk/pgadmin3/src/agent/dlgJob.cpp
===================================================================
--- trunk/pgadmin3/src/agent/dlgJob.cpp    2005-05-16 12:24:48 UTC (rev 4183)
+++ trunk/pgadmin3/src/agent/dlgJob.cpp    2005-05-16 14:00:43 UTC (rev 4184)
@@ -373,7 +373,7 @@
               wxT("SELECT <JobId>, jcl.jclid, ") + qtString(GetName()) +
               wxT(", ") + qtString(txtComment->GetValue()) + wxT(", ") + BoolToStr(chkEnabled->GetValue()) +
               wxT(", ") + qtString(txtHostAgent->GetValue()) + wxT("\n")
-              wxT("  FROM pgagent.pga_jobclass jcl WHERE jclname=") + qtString(cbJobclass->GetValue());
+              wxT("  FROM pgagent.pga_jobclass jcl WHERE jclname=") + qtString(cbJobclass->GetValue()) + wxT(";\n");
     }
     return sql;
 }
@@ -422,7 +422,7 @@

         if (!vars.IsEmpty())
             sql = wxT("UPDATE pgagent.pga_job SET ") + vars + wxT("\n")
-                  wxT(" WHERE jobid=") + NumToStr(recId);
+                  wxT(" WHERE jobid=") + NumToStr(recId) + wxT(";\n");

     }
     else
@@ -448,7 +448,7 @@
         {
             str=*(wxString *)lstSteps->GetItemData(pos);
             if (!str.IsEmpty())
-                sql += str + wxT(";\n");
+                sql += str;
         }
     }

@@ -472,7 +472,7 @@
         {
             str=*(wxString *)lstSchedules->GetItemData(pos);
             if (!str.IsEmpty())
-                sql += str + wxT(";\n");
+                sql += str;
         }
     }


Modified: trunk/pgadmin3/src/agent/dlgSchedule.cpp
===================================================================
--- trunk/pgadmin3/src/agent/dlgSchedule.cpp    2005-05-16 12:24:48 UTC (rev 4183)
+++ trunk/pgadmin3/src/agent/dlgSchedule.cpp    2005-05-16 14:00:43 UTC (rev 4184)
@@ -166,7 +166,7 @@
             }

             lstExceptions->SetItem(pos, 2, BoolToStr(false));
-            lstExceptions->SetItem(pos, 3, NumToStr(pos));
+            lstExceptions->SetItem(pos, 3, id);

         }

@@ -295,9 +295,11 @@
     else
         exTime = _("<any>");

+    long item = lstExceptions->GetFocusedItem();
+
     for (int pos=0; pos < lstExceptions->GetItemCount(); pos++)
     {
-        if (lstExceptions->GetFocusedItem() != pos)
+        if (item != pos)
         {
             if (lstExceptions->GetText(pos, 0) == exDate &&
                 lstExceptions->GetText(pos, 1) == exTime)
@@ -322,10 +324,9 @@
         }
     }

-    lstExceptions->SetText(lstExceptions->GetFocusedItem(), 0, exDate);
-    lstExceptions->SetText(lstExceptions->GetFocusedItem(), 1, exTime);
-    lstExceptions->SetText(lstExceptions->GetFocusedItem(), 2, BoolToStr(true));
-    lstExceptions->RefreshItem(lstExceptions->GetFocusedItem());
+    lstExceptions->SetItem(item, 0, exDate);
+    lstExceptions->SetItem(item, 1, exTime);
+    lstExceptions->SetItem(item, 2, BoolToStr(true));
     CheckChange();
 }

@@ -379,7 +380,7 @@
         else
             sql += wxT(", NULL");

-        sql += wxT(")");
+        sql += wxT(");\n");
     }

     return sql;
@@ -489,13 +490,83 @@

         if (!vars.IsEmpty())
             sql = wxT("UPDATE pgagent.pga_schedule SET ") + vars + wxT("\n")
-                  wxT(" WHERE jscid=") + NumToStr(recId);
+                  wxT(" WHERE jscid=") + NumToStr(recId) + wxT(";\n");
     }
     else
     {
         // create mode
         // Handled by GetInsertSQL
     }
+
+    unsigned int x=0;
+    int y=0;
+    wxDateTime tmpDateTime;
+    wxString newDate, newTime;
+
+    // Remove old exceptions
+    for (x=0; x < deleteExceptions.Count(); x++)
+    {
+        sql += wxT("DELETE FROM pgagent.pga_exception\n  WHERE jexid = ") + deleteExceptions[x] + wxT(";\n");
+    }
+
+    // Update dirty exceptions
+    for (y=0; y < lstExceptions->GetItemCount(); y++)
+    {
+        if (lstExceptions->GetText(y, 2) == BoolToStr(true) &&
+            lstExceptions->GetText(y, 3) != wxEmptyString)
+        {
+            if (lstExceptions->GetText(y, 0) == _("<any>"))
+                newDate = wxT("null");
+            else
+            {
+                tmpDateTime.ParseFormat(lstExceptions->GetText(y, 0), wxT("%x"));
+                newDate = wxT("'") + tmpDateTime.FormatISODate() + wxT("'");
+            }
+
+            if (lstExceptions->GetText(y, 1) == _("<any>"))
+                newTime = wxT("null");
+            else
+            {
+                tmpDateTime.ParseTime(lstExceptions->GetText(y, 1));
+                newTime = wxT("'") + tmpDateTime.FormatISOTime() + wxT("'");
+            }
+
+            sql += wxT("UPDATE pgagent.pga_exception SET jexdate = ") + newDate +
+                   wxT(", jextime = ") + newTime + wxT("\n  WHERE jexid = ") +
+                   lstExceptions->GetText(y, 3) + wxT(";\n");
+        }
+    }
+
+    // Insert new exceptions
+    for (y=0; y < lstExceptions->GetItemCount(); y++)
+    {
+        if (lstExceptions->GetText(y, 2) == wxEmptyString &&
+            lstExceptions->GetText(y, 3) == wxEmptyString)
+        {
+            if (lstExceptions->GetText(y, 0) == _("<any>"))
+                newDate = wxT("null");
+            else
+            {
+                tmpDateTime.ParseFormat(lstExceptions->GetText(y, 0), wxT("%x"));
+                newDate = wxT("'") + tmpDateTime.FormatISODate() + wxT("'");
+            }
+
+            if (lstExceptions->GetText(y, 1) == _("<any>"))
+                newTime = wxT("null");
+            else
+            {
+                tmpDateTime.ParseTime(lstExceptions->GetText(y, 1));
+                newTime = wxT("'") + tmpDateTime.FormatISOTime() + wxT("'");
+            }
+
+            sql += wxT("INSERT INTO pgagent.pga_exception (jexschid, jexdate, jextime)\n  VALUES (")
+                + NumToStr(recId) + wxT(", ") + newDate + wxT(", ") + newTime + wxT(");\n");
+
+        }
+    }
+
+
+
     return sql;
 }

@@ -503,7 +574,7 @@
 {
     wxString res = wxT("{");

-    for (int x=0; x<lb->GetCount(); x++)
+    for (int x=0; x < lb->GetCount(); x++)
     {
         if (lb->IsChecked(x))
             res += wxT("t,");
@@ -522,7 +593,7 @@
 {
     wxString res;

-    for (int x=0; x<lb->GetCount(); x++)
+    for (int x=0; x < lb->GetCount(); x++)
     {
         if (lb->IsChecked(x))
             res += wxT("t");

Modified: trunk/pgadmin3/src/agent/dlgStep.cpp
===================================================================
--- trunk/pgadmin3/src/agent/dlgStep.cpp    2005-05-16 12:24:48 UTC (rev 4183)
+++ trunk/pgadmin3/src/agent/dlgStep.cpp    2005-05-16 14:00:43 UTC (rev 4184)
@@ -182,7 +182,7 @@
         sql = wxT("INSERT INTO pgagent.pga_jobstep (jstid, jstjobid, jstname, jstdesc, jstenabled, jstkind,
jstonerror,jstcode, jstdbname)\n") 
               wxT("SELECT <StpId>, ") + jstjobid + wxT(", ") + qtString(name) + wxT(", ") +
qtString(txtComment->GetValue())+ wxT(", ") 
                 + BoolToStr(chkEnabled->GetValue()) + wxT(", ") + qtString(kind) + wxT(", ")
-                + qtString(onerror) + wxT(", ") + qtString(sqlBox->GetText()) + wxT(", ") + db;
+                + qtString(onerror) + wxT(", ") + qtString(sqlBox->GetText()) + wxT(", ") + db + wxT(";\n");
     }
     return sql;
 }
@@ -253,7 +253,8 @@
         if (!vars.IsEmpty())
             sql = wxT("UPDATE pgagent.pga_jobstep\n")
                   wxT("   SET ") + vars + wxT("\n")
-                  wxT(" WHERE jstid=") + NumToStr(step->GetRecId());
+                  wxT(" WHERE jstid=") + NumToStr(step->GetRecId()) +
+                  wxT(";\n");
     }
     else
     {

Modified: trunk/pgadmin3/src/ctl/ctlListView.cpp
===================================================================
--- trunk/pgadmin3/src/ctl/ctlListView.cpp    2005-05-16 12:24:48 UTC (rev 4183)
+++ trunk/pgadmin3/src/ctl/ctlListView.cpp    2005-05-16 14:00:43 UTC (rev 4184)
@@ -40,17 +40,7 @@
     return item.GetText();
 };

-void ctlListView::SetText(long row, long col, const wxString &text)
-{
-    wxListItem item;
-    item.SetId(row);
-    item.SetColumn(col);
-    item.SetMask(wxLIST_MASK_TEXT);
-    GetItem(item);
-    item.SetText(text);
-};

-
 void ctlListView::AddColumn(const wxChar *text, int size, int format)
 {
     InsertColumn(GetColumnCount(), text, format, ConvertDialogToPixels(wxPoint(size,0)).x);

Modified: trunk/pgadmin3/src/include/ctl/ctlListView.h
===================================================================
--- trunk/pgadmin3/src/include/ctl/ctlListView.h    2005-05-16 12:24:48 UTC (rev 4183)
+++ trunk/pgadmin3/src/include/ctl/ctlListView.h    2005-05-16 14:00:43 UTC (rev 4184)
@@ -26,7 +26,6 @@
     ctlListView(wxWindow *p, int id, wxPoint pos, wxSize siz, long attr=0);
     long GetSelection();
     wxString GetText(long row, long col=0);
-    void SetText(long row, long col, const wxString &text);

     void CreateColumns(wxImageList *images, const wxString &left, const wxString &right, int leftSize=60);



pgadmin-hackers by date:

Previous
From: Raphaël Enrici
Date:
Subject: Re: [PATCH] Appbundle-Support for 1.2
Next
From: svn@pgadmin.org
Date:
Subject: SVN Commit by dpage: r4186 - trunk/pgadmin3/xtra/pgagent