Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9006)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9007)
@@ -85,4 +85,12 @@
      - use telescope number as argument
      - simplified and improved
+
+   * datacenter/macros/filldotrun.C:
+     - some changes to output
+     - skip comment line at the beginning
+     - skip the line with the telescope number
+     - removed ISNULL from telescope/run/file check
+     - added fPriority to RunProcessStatus
+     - added telescope und file number to RunData and RunProcessStatus
 
 
Index: trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C	(revision 9006)
+++ trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C	(revision 9007)
@@ -44,20 +44,17 @@
 //
 /////////////////////////////////////////////////////////////////////////////
-
 #include <iostream>
 #include <iomanip>
 #include <fstream>
 
-#include <TSQLRow.h>
-#include <TSQLResult.h>
+#include <TPRegexp.h>
 
-#include "MSQLServer.h"
+#include "MSQLMagic.h"
 
 using namespace std;
 
-
-int resetallruns(TString filename, TString column)
+int resetallruns(TString filename, TString column, Bool_t dummy=kTRUE)
 {
-    MSQLServer serv("sql.rc");
+    MSQLMagic serv("sql.rc");
     if (!serv.IsConnected())
     {
@@ -65,4 +62,5 @@
         return 0;
     }
+
     cout << "resetallruns" << endl;
     cout << "------------" << endl;
@@ -70,22 +68,19 @@
     cout << "Connected to " << serv.GetName() << endl;
     cout << endl;
+    cout << "File:   " << filename << endl;
+    cout << "Column: " << column << endl;
+    cout << endl;
 
-    //reset column to NULL
-    TString query(Form("UPDATE RunProcessStatus SET %s=NULL",
-                       column.Data()));
-    //if the column is fCaCoFileAvail, reset also the column fCaCoFileFound
+    serv.SetIsDummy(dummy);
+
+    //reset column to NULL, if the column is fCaCoFileAvail,
+    //reset also the column fCaCoFileFound
+    TString vars(column);
+    vars += "=NULL";
     if (column.Contains("CaCo"))
-        query+=", fCaCoFileFound=NULL";
+        vars += ", fCaCoFileFound=NULL";
 
-    cout << "q: " << query << endl;
-
-    TSQLResult *res = serv.Query(query);
-    if (!res)
-    {
-        cout << "updating (setting " << column.Data() << "= NULL) didn't work " << endl;
-        return 0;
-    }
-    delete res;
-
+    if (serv.Update("RunProcessStatus", vars)==kFALSE)
+        return 2;
 
     //read in file
@@ -93,36 +88,49 @@
     if (!fin)
     {
-        cout << "file: " << filename << " missing!" << endl;
-        return 0;
+        cout << "ERROR - File " << filename << " missing!" << endl;
+        return 2;
     }
+
+    TPRegexp regtel("^_M[0-9]_");
+    TPRegexp regrun("_[0-9]{5,8}");
+    TPRegexp regfile("[.][0-9]{3,5}_$");
     while (1)
     {
         //get runnumber
-        TString runnumber;
-        runnumber.ReadLine(fin);
+        TString str;
+        str.ReadLine(fin);
         if (!fin)
             break;
 
+        const TString tel  = str(regtel);
+        const TString run  = str(regrun);
+        const TString file = str(regfile);
+
+        const UInt_t ntel  = tel.IsNull()  ? 1 : atoi(tel.Data()+2);
+        const UInt_t nfile = file.IsNull() ? 0 : atoi(file.Data()+1);
+        const UInt_t nrun  = atoi(run.Data()+1);
+
+        if (nrun>999999 && (tel.IsNull() || file.IsNull()))
+        {
+            cout << "ERROR - Run number " << nrun << ">999999 and telescope and/or run-number missing!" << endl;
+            cout << str << endl;
+            continue;
+        }
+
+        const UInt_t id = nrun*1000+nfile;
+
         //build query and set status for this run to Now()
-        TString query(Form("UPDATE RunProcessStatus SET %s=Now()", column.Data()));
+        TString vars2(column);
+        vars2 += "=Now()";
+        if (column.Contains("CaCo"))
+            vars2 += Form(", fCaCoFileFound=%d", id);
 
-        if (column.Contains("CaCo"))
-            query+=Form(", fCaCoFileFound=%d", atoi(runnumber));
+        TString where = Form("fTelescopeNumber=%d AND fRunNumber=%d AND fFileNumber=%d ",
+                             ntel, nrun, nfile);
 
-        query+=Form(" WHERE fRunNumber=%d ", atoi(runnumber));
-
-        cout << "q2: " << query << endl;
-
-        res = serv.Query(query);
-        if (!res)
-        {
-            cout << "updating (setting " << column.Data() << " = Now()) for run# " << atoi(runnumber) << ") didn't work " << endl;
-            return 0;
-        }
-        delete res;
+        if (serv.Update("RunProcessStatus", vars2, where)==kFALSE)
+            return 2;
     }
 
     return 1;
 }
-
-
