public ActionResult Async_Save(IEnumerable <HttpPostedFileBase> annex, string HospID) { string connDRUGSys = ConfigurationManager.ConnectionStrings["connSysDB"].ConnectionString; foreach (var file in annex) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); string sDir = Server.MapPath("~/FileCloud") + @"/UploadFile/HITemp"; //string sDir = @"\FileCloud\UploadFile\" + Session["UserRowid"].ToString().Trim(); if (Directory.Exists(sDir) == false) { DirectoryInfo di = Directory.CreateDirectory(sDir); } Session["targetNewFileName"] = HospID + "_" + Guid.NewGuid().ToString() + "_" + fileName; var destinationPath = Path.Combine(sDir + "/", Session["targetNewFileName"].ToString()); file.SaveAs(destinationPath); // 把上傳的紀錄寫至 UploadServer var us = new UploadServer() { USRowid = Guid.NewGuid().ToString(), USHospRowid = "HIU", USHospID = HospID, USLoadFilename = Session["targetNewFileName"].ToString(), USLoadDateTime = DateTime.Now, USServerStatus = "S", USRecordCount = 0, USType = "H" }; db_zmcmsv2_sys.UploadServer.Add(us); db_zmcmsv2_sys.SaveChanges(); } } //Return an empty string to signify success. return(Content("")); }
public ActionResult PushDT2Server(string sHospID, DateTime pdt) { bool isValid = false; // 把上傳的紀錄寫至 UploadServer try { var us = new UploadServer() { USRowid = Guid.NewGuid().ToString(), USHospRowid = "LISPMBK", USHospID = sHospID, USLoadFilename = "由使用者設定自動匯入,預計執行時間:" + pdt.ToString(), USLoadDateTime = DateTime.Now, USBookingDatetime = pdt, USServerStatus = "S", USRecordCount = 0, USType = "A" }; db_zmcmsv2_sys.UploadServer.Add(us); db_zmcmsv2_sys.SaveChanges(); isValid = true; } catch { isValid = false; } var obj = new { valid = isValid }; return(Json(obj)); }