public ActionResult Table(string id = "")
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         string last_update = (from g in this._db.recsys_group
                               orderby g.last_update descending
                               select g.last_update).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = Common.doSql(_grid.sql("", "SELECT g.* FROM {p}_group AS g LEFT JOIN {p}_users AS u ON g.supervisor_id = u.id"));
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_group>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             Member _member = new Member("users");
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 sql = Common.doSql("SELECT u.* FROM {p}_relate AS r LEFT JOIN {p}_users AS u ON r.id2 = u.id WHERE r.id1 = '" + rs["id"] + "' AND r.table1 = 'group' AND r.table2 = 'users' ORDER BY u.name ASC");
                 ArrayList engineer = Common.query(this._db.ExecuteStoreQuery<recsys_users>(sql));
                 ArrayList arr1 = new ArrayList();
                 ArrayList arr2 = new ArrayList();
                 Hashtable supervisor = _member.get(rs["supervisor_id"].ToString(), "id");
                 if (engineer.Count > 0)
                 {
                     foreach (Hashtable item in engineer)
                     {
                         arr1.Add(item["name"]);
                         arr2.Add(item["id"]);
                     }
                 }
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["name"],
                     supervisor["name"],
                     rs["supervisor_id"],
                     string.Join(", ", arr1.ToArray()),
                     string.Join(",", arr2.ToArray()),
                     "<span class=\"status-" + (Convert.ToInt32(rs["status"]) == 1 ? "on" : "off") + "\" title=\"" + this._status[rs["status"].ToString()] + "\"></span>",
                     this._status[rs["status"].ToString()],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }