public ActionResult Create(spot spot, HttpPostedFileBase[] tourism_photo) { //表單內容 string act_id = db.Database.SqlQuery <string>("Select dbo.GetspotId()").FirstOrDefault(); spot.spot_id = act_id; spot.update_date = DateTime.Now; spot.page_status = false; //圖片 string fileName = ""; for (int i = 0; i < tourism_photo.Length; i++) { HttpPostedFileBase f = tourism_photo[i]; if (f != null) { if (f.ContentLength > 0) { string t = tourism_photo[i].FileName; fileName = spot.spot_id + "_" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + (i + 1).ToString() + Path.GetExtension(t); f.SaveAs(Server.MapPath("~/images/spot/" + fileName)); tourism_photo tp = new tourism_photo(); tp.tourism_photo1 = fileName; tp.tourism_id = spot.spot_id; db.tourism_photo.Add(tp); } } } db.spot.Add(spot); db.SaveChanges(); return(RedirectToAction("Index", new { page = Session["pg"] })); }
public ActionResult Create(spot spot, HttpPostedFileBase tourism_photo) { string act_id = db.Database.SqlQuery <string>("Select dbo.GetspotId()").FirstOrDefault(); spot.spot_id = act_id; string fileName = ""; if (tourism_photo != null) { if (tourism_photo.ContentLength > 0) { fileName = System.IO.Path.GetFileName(tourism_photo.FileName); tourism_photo.SaveAs(Server.MapPath("~/images/spot/" + fileName)); } } tourism_photo tp = new tourism_photo(); tp.tourism_photo1 = fileName; tp.tourism_id = spot.spot_id; db.spots.Add(spot); db.tourism_photo.Add(tp); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: ImportTEST public void LoadJson() { using (StreamReader r = new StreamReader(@"D:\TravelCAT\TravelCat\spot_C_f.json")) { var json = r.ReadToEnd(); List <Rootobject> rt = JsonConvert.DeserializeObject <List <Rootobject> >(json); for (int i = 0; i < rt.Count; i++) { spot items = new spot(); items.spot_id = db.Database.SqlQuery <string>("Select dbo.GetspotId()").FirstOrDefault(); items.spot_intro = rt[i].Toldescribe; items.spot_tel = rt[i].Tel; items.spot_title = rt[i].Name; items.latitude = rt[i].Py.ToString(); items.longitude = rt[i].Px.ToString(); items.addition_note = rt[i].Remarks; items.address_detail = rt[i].Add; items.city = rt[i].Region; items.district = rt[i].Town; items.open_time = rt[i].Opentime; items.ticket_info = rt[i].Ticketinfo; items.update_date = rt[i].Changetime; items.travelling_info = rt[i].Travellinginfo; if (String.IsNullOrEmpty(rt[i].Picture1) != true) { tourism_photo tp = new tourism_photo(); tp.tourism_id = items.spot_id; tp.tourism_photo1 = rt[i].Picture1; db.tourism_photo.Add(tp); } if (String.IsNullOrEmpty(rt[i].Picture2) != true) { tourism_photo tp = new tourism_photo(); tp.tourism_id = items.spot_id; tp.tourism_photo1 = rt[i].Picture2; db.tourism_photo.Add(tp); } if (String.IsNullOrEmpty(rt[i].Picture3) != true) { tourism_photo tp = new tourism_photo(); tp.tourism_id = items.spot_id; tp.tourism_photo1 = rt[i].Picture3; db.tourism_photo.Add(tp); } db.spot.Add(items); db.SaveChanges(); } Console.WriteLine("success"); } }
VectorAdd(spot->s.origin, playerMins, mins);
// create line matrix to display private void SetGrid() { if (grid != null) { grid.active = false; Destroy(grid); } grid = GameObject.CreatePrimitive(PrimitiveType.Cube); grid.name = "grid"; // set the right scale (z = very thin) rotation and position so it will cover the puzzl grid.transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, 0.0001F); grid.transform.rotation = transform.rotation; // add grid to puzzle grid.transform.parent = gameObject.transform; // set 'transparent' material to grid grid.renderer.material = main.grid; // move this 'thin' cube so that it floats just above the puzzle grid.transform.position = transform.position + transform.forward * ((transform.localScale.z / 2) + 0.005F); // scale the texture in relation to specified size grid.renderer.material.mainTextureScale = new Vector2(size.x, size.y); // set the right offset in relation to the specified size and the specified topLeftPiece grid.active = false; checkSize = size; checkSpacing = spacing; checkSpot = emptySpot; }