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
        //string serializeActiveJobs()
        //{
        //    string s = "";
        //    for (int i = 0; i < activeJobs.Count; ++i)
        //    {
        //        Job job = activeJobs[i];
        //        if (job.start < DateTime.Now && job.end > DateTime.Now && job.active)
        //        {
        //            string js = job.serialize();
        //            if (s != "") s += ",";
        //            s += js;
        //        }
        //    }
        //    s = "{" + s + "}";
        //    return s;

        //}

        public string getAllJobs()
        {
            List <object> oblist = RTDB.selectObList("SELECT * FROM JobRecord", new JobRecord(), "TrainTasker");

            string s = "";

            for (int i = 0; i < oblist.Count; ++i)
            {
                JobRecord job = (JobRecord)oblist[i];
                if (i > 0)
                {
                    s += ",";
                }
                s += job.serialize();
            }
            return("{" + s + "}");
        }
Example #4
0
        public string getUserJobs(string userID)
        {
            List <object> oblist = RTDB.selectObList("SELECT * FROM JobRecord WHERE userID= '" + userID + "'", new JobRecord(), "TrainTasker");

            string s = "";

            for (int i = 0; i < oblist.Count; ++i)
            {
                JobRecord job = (JobRecord)oblist[i];
                if (i > 0)
                {
                    s += ",";
                }
                s += job.serialize();
            }
            return("[" + s + "]");
        }
Example #5
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 + "]");
        }