// // GET: /en/Map/ public string test() { mdlMapModel record = new mdlMapModel(); record.mapheight = "2000"; record.mapwidth = "2000"; List <mdlMapCategories> categories_list = new List <mdlMapCategories>(); mdlMapCategories categories = new mdlMapCategories(); categories.id = "location"; categories.title = "Locations"; categories.color = "#4cd3b8"; categories.show = "true"; categories_list.Add(categories); List <mdlMapLocations> locations_list = new List <mdlMapLocations>(); mdlMapLocations locations = new mdlMapLocations(); locations.id = "diningtable"; locations.title = "Dining Table"; locations.category = "location"; locations.x = "0.4746"; locations.pin = "circular pin-md pin-label"; locations.fill = "#4d5e6d"; locations.y = "0.2883"; locations.zoom = "3"; locations_list.Add(locations); mdlMapLevels level = new mdlMapLevels(); level.id = "lower"; level.title = "Lower floor"; level.map = "/Content/map/1_1eed5a4478d73e34.jpg"; level.locations = locations_list; // record.levels = level; record.categories = categories_list; return(JsonConvert.SerializeObject(record)); }
public ActionResult definelocation() { string maptitle = ""; string mapimage = ""; Populate DropDown = new Populate(); string map = ""; if (!string.IsNullOrEmpty(Request.QueryString["map"])) { map = Request.QueryString["map"].ToString(); } Db_Connection dbconn = new Db_Connection(); Utility util = new Utility(); try { dbconn.openConnection(); string strSQL = ""; strSQL = @"SELECT ID,MAP,LOCATIONS FROM VMAP ORDER BY MAP ASC"; SqlCommand cmd = new SqlCommand(strSQL, dbconn.DbConn); SqlDataReader dr = cmd.ExecuteReader(); List <mdlMap> record = new List <mdlMap>(); if (dr.HasRows) { while (dr.Read()) { mdlMap list = new mdlMap(); list.ID = dr["ID"].ToString(); list.MAP = dr["MAP"].ToString(); list.LOCATIONS = dr["LOCATIONS"].ToString(); record.Add(list); if (map == "") { map = list.ID; } } } dr.Dispose(); cmd.Dispose(); strSQL = @"SELECT MAP,IMAGE FROM MAP WHERE ID=@ID"; cmd = new SqlCommand(strSQL, dbconn.DbConn); cmd.Parameters.Add("ID", SqlDbType.VarChar).Value = map; dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); maptitle = dr["MAP"].ToString(); mapimage = dr["IMAGE"].ToString(); } dr.Dispose(); cmd.Dispose(); mdlMapModel maprecord = new mdlMapModel(); maprecord.mapheight = "2000"; maprecord.mapwidth = "2000"; strSQL = @"SELECT MAPTITLE,LOCATIONID,ID,MAP,LOCATION,X,Y FROM VMAP_LOCATION WHERE MAP=@MAP ORDER BY LOCATION ASC"; cmd = new SqlCommand(strSQL, dbconn.DbConn); cmd.Parameters.Add("MAP", SqlDbType.VarChar).Value = map; dr = cmd.ExecuteReader(); List <mdlMapCategories> categories_list = new List <mdlMapCategories>(); mdlMapCategories categories = new mdlMapCategories(); List <mdlMapLocations> locations_list = new List <mdlMapLocations>(); while (dr.Read()) { mdlMapLocations locations = new mdlMapLocations(); locations.id = dr["LOCATIONID"].ToString(); locations.title = dr["LOCATION"].ToString(); locations.category = "location"; locations.x = dr["X"].ToString(); locations.y = dr["Y"].ToString(); locations_list.Add(locations); } categories.id = "location"; categories.title = maptitle; categories.color = "#4cd3b8"; categories.show = "true"; categories_list.Add(categories); List <mdlMapLevels> level_list = new List <mdlMapLevels>(); mdlMapLevels level = new mdlMapLevels(); level.id = "lower"; level.title = "Lower floor"; level.map = "/" + mapimage; level.locations = locations_list; level_list.Add(level); maprecord.levels = level_list; maprecord.categories = categories_list; ViewData["maprecord"] = JsonConvert.SerializeObject(maprecord); List <SelectListItem> location_combo = new List <SelectListItem>(); dr.Dispose(); cmd.Dispose(); strSQL = "SELECT LOCATIONID,LOCATION FROM VMAP_LOCATION WHERE MAP=@MAP ORDER BY LOCATION ASC"; cmd = new SqlCommand(strSQL, dbconn.DbConn); cmd.Parameters.Add("MAP", SqlDbType.VarChar).Value = map; dr = cmd.ExecuteReader(); location_combo.Add(new SelectListItem { Text = "", Value = "" }); while (dr.Read()) { location_combo.Add(new SelectListItem { Text = dr[1].ToString(), Value = dr[0].ToString() }); } ViewData["location"] = location_combo; ViewData["mapid"] = map; dr.Dispose(); cmd.Dispose(); dbconn.closeConnection(); return(View(record)); } finally { dbconn.closeConnection(); } }
public ActionResult location_modal(string id) { try { Db_Connection dbconn = new Db_Connection(); dbconn.openConnection(); string strSQL = ""; strSQL = @"SELECT X,Y,LOCATION,IMAGE,MAPTITLE,DESCRIPTION FROM VMAP_LOCATION WHERE LOCATIONID=@ID"; SqlCommand cmd = new SqlCommand(strSQL, dbconn.DbConn); cmd.Parameters.Add("ID", SqlDbType.VarChar).Value = id; SqlDataReader dr = cmd.ExecuteReader(); mdlTrack location = new mdlTrack(); if (dr.HasRows) { dr.Read(); location.X = dr["X"].ToString(); location.Y = dr["Y"].ToString(); location.LOCATION = dr["LOCATION"].ToString(); location.MAPIMAGE = dr["IMAGE"].ToString(); location.MAPTITLE = dr["MAPTITLE"].ToString(); location.DESCRIPTION = dr["DESCRIPTION"].ToString(); } dr.Dispose(); cmd.Dispose(); mdlMapModel maprecord = new mdlMapModel(); maprecord.mapheight = "2000"; maprecord.mapwidth = "2000"; List <mdlMapCategories> categories_list = new List <mdlMapCategories>(); mdlMapCategories categories = new mdlMapCategories(); List <mdlMapLocations> locations_list = new List <mdlMapLocations>(); mdlMapLocations locations = new mdlMapLocations(); locations.id = id; locations.title = location.LOCATION; locations.pin = "pin-pulse"; locations.category = "location"; locations.description = location.DESCRIPTION; locations.x = location.X; locations.y = location.Y; locations.zoom = "1"; locations_list.Add(locations); categories.id = "location"; categories.title = location.MAPTITLE; categories.color = "#4cd3b8"; categories.show = "true"; categories_list.Add(categories); List <mdlMapLevels> level_list = new List <mdlMapLevels>(); mdlMapLevels level = new mdlMapLevels(); level.id = "lower"; level.title = "Lower floor"; level.map = "/" + location.MAPIMAGE; level.locations = locations_list; level_list.Add(level); maprecord.levels = level_list; maprecord.categories = categories_list; ViewData["maprecord"] = JsonConvert.SerializeObject(maprecord); ViewData["maptitle"] = location.MAPTITLE; dbconn.closeConnection(); return(PartialView()); } finally { } }