示例#1
0
        public JsonResult VcrTest(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.TxtFile, false);

            if (userfile != null)
            {
                string part2     = DateTime.Now.ToFileTime() + "_" + file.FileName;
                string p         = Path.Combine(Server.MapPath(userfile), part2);
                string returnPth = userfile + "/" + part2;

                try
                {
                    file.SaveAs(p);
                    pth[0] = returnPth;
                    //save the model

                    IVcrTest vcrTest = new VcrTestBLL();
                    int      i       = vcrTest.BulkInsert(p, vid, MyUserId);
                    if (i == 0)
                    {
                        error = "文件无法解析,请下载'Doc模板'";
                        return(Json(new { error }, JsonRequestBehavior.AllowGet));
                    }
                }
                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));
        }
示例#2
0
        /// <summary>
        /// ajax bulk del video record.
        /// </summary>
        /// <param name="vids"></param>
        /// <returns></returns>
        public ActionResult DelMany(string[] vids)
        {
            int vcr   = 0;
            int files = 0;
            int tsts  = 0;

            if (vids.Count() > 0)
            {
                IEnumerable <VcrFile> mdl;
                IEnumerable <VcrTest> tst;
                for (int s = 0; s < vids.Count(); s++)
                {
                    mdl = _trainVcrBll.vcrFiles(vids[s]);

                    if (mdl != null && mdl.Count() > 0)
                    {
                        mdl.ToList().ForEach(a => a.DelFile());
                        files = new VcrFileBLL().BulkDel(mdl.Select(a => a.Id).ToList());
                    }

                    files = mdl == null?0:mdl.Count();
                    tst   = _trainVcrBll.vcrTests(vids[s]);



                    if (tst != null && tst.Count() > 0)
                    {
                        tsts = new VcrTestBLL().BulkDel(tst.Select(a => a.Id).ToList());
                    }

                    bool b = new TrainVcrBLL().DelVcrVideo(vids[s]);
                    vcr += _trainVcrBll.Del(vids[s]) == AppConfigs.OperResult.success ?1:0;
                }
            }

            return(Json(new { v = vcr, f = files, t = tsts }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
 public VcrTestController()
 {
     dbData = new VcrTestBLL();
 }
示例#4
0
 public VcrTestSvc()
 {
     _testBLL = new VcrTestBLL();
 }
示例#5
0
文件: VcrTestSv.cs 项目: HubWong/Edu2
 public VcrTestSv()
 {
     vcrTestBLL = new VcrTestBLL();
 }