Example #1
0
        public static string requestNextAvailableTrain(string jobID, string userID)
        {
            TaskRecord    tr     = new TaskRecord();
            List <object> oblist = RTDB.selectObList("SELECT * FROM TaskRecord WHERE JobID='" + jobID + "'" + " AND TrainCount < MaxTrains", tr, "TrainTasker");
            TrainRecord   trn    = new TrainRecord();

            for (int i = 0; i < oblist.Count; ++i)
            {
                tr  = (TaskRecord)oblist[i];
                trn = (TrainRecord)trn.selectOb("WHERE UserID='" + userID + "'" + " AND TaskRecordID = " + tr.ID);
                if (trn == null)
                {
                    trn = new TrainRecord();
                    trn.ResourcePath = tr.ResourcePath;
                    trn.TaskRecordID = tr.ID;
                    trn.RequesterID  = tr.RequesterID;
                    trn.JobID        = tr.JobID;
                    string s = trn.serialize();
                    s = s.Replace("1/1/1800 12:00:00 AM", "");
                    s = s.Replace("\\", "/");  // \ breaks client json
                    return(s);
                }
            }
            return("Error: No Train available");
        }
Example #2
0
        public static string getTrainResultsPerTask(string taskID)
        {
            List <object> oblist = RTDB.selectObList("SELECT * FROM TrainRecord WHERE TaskID=" + taskID, new TrainRecord(), "TrainTasker");
            string        s      = "";

            for (int i = 0; i < oblist.Count; ++i)
            {
                if (i > 0)
                {
                    s += ",";
                }
                TrainRecord tr = (TrainRecord)oblist[i];
                s += tr.serialize();
            }
            return(s);
        }
Example #3
0
        public static string getTaskIDsPerJob(string jobID)
        {
            List <int>    list   = new List <int>();
            List <object> oblist = RTDB.selectObList("SELECT * FROM TrainRecord WHERE JobID=" + jobID, new TrainRecord(), "TrainTasker");
            string        s      = "";

            for (int i = 0; i < oblist.Count; ++i)
            {
                TrainRecord tr = (TrainRecord)oblist[i];
                if (!list.Contains(tr.TaskRecordID))
                {
                    if (s != "")
                    {
                        s += ",";
                    }
                    s += tr.serialize();
                    list.Add(tr.TaskRecordID);
                }
            }

            return("[" + s + "]");
        }