/// <summary> /// list lesson vcrs and func. /// </summary> /// <param name="lessonid">lsn id</param> /// <param name="lsn">lsn name</param> /// <param name="pic">pic url</param> /// <returns></returns> public ActionResult Index(string lessonid, string lsn, string pic) { if (string.IsNullOrWhiteSpace(lessonid)) { throw new Exception($"param {nameof (lsn)} is null"); } var mdl = new TrainVcrSv(BaseSchoolId).Query(lessonid, 1); //interface not impliment the func int i; var mdlBypag = new VcrSvc().GetVcrs(lsn, 1, out i); string pager = Common.Utility.HtmlPager(10, 1, i, 5); var vcrModel = new VcrListViewModel() { LessonId = lessonid, LessonName = lsn, VcrListPag = new VcrListPag() { Pager = pager, Vcrs = mdlBypag, }, Vcrs = mdlBypag }; return(PartialView(vcrModel)); }
///upload trainvcr /// <summary> /// ajax upload image or files, work with plug of fileupload /// </summary> /// <returns></returns> public async Task <JsonResult> GetVcr(string vid) { string error = string.Empty; HttpPostedFileBase file = Request.Files[0]; if (file == null) { return(Json(new { error = "上传失败" }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(vid)) { return(Json(new { error = "没有视频ID参数" }, JsonRequestBehavior.AllowGet)); } string[] pth = new string[1]; string userfile = GetFilePath(FileType.VideoFile, false); if (userfile != null) { string part2 = DateTime.Now.ToFileTime().ToString() + Path.GetExtension(file.FileName); string p = Path.Combine(Server.MapPath(userfile), part2); string returnPth = userfile + "/" + part2; try { file.SaveAs(p); pth[0] = returnPth; TrainVcrSv trainVcrSv = new TrainVcrSv(BaseSchoolId); var mdl = trainVcrSv.Single(vid); if (mdl != null) { mdl.VideoPath = returnPth; mdl.Duration = await trainVcrSv.VideoDuration(Common.Utility.GetMapPath(returnPth)); trainVcrSv.Update(mdl); } } catch (Exception ex) { error = ex.ToString(); return(Json(new { error }, JsonRequestBehavior.AllowGet)); } return(Json(new { initialPreview = pth }, JsonRequestBehavior.AllowGet)); } return(Json(new { error = "遇到错误...", initialPreview = "<p>失败,请重试...</p>", }, JsonRequestBehavior.AllowGet)); }