Exemplo n.º 1
0
 public JsonResult uploadFile()
 {
     try
     {
         HttpPostedFileBase file = Request.Files["file"];
         DataTable          dtExcel;
         if (file != null)
         {
             var    fileName = Path.GetFileName(file.FileName);
             string filePath = Path.Combine(HttpContext.Server.MapPath("~//upload//" + fileName));
             string logPath  = Path.Combine(HttpContext.Server.MapPath("~//log//"));
             file.SaveAs(filePath);//将文件保存到路径
             ArrayList msg = _service.compareExcel(fileName, filePath);
             if (msg[0].ToString() != "")
             {
                 return(Json(msg, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 dtExcel = (DataTable)msg[1];
             }
             backMessage = _service.UploadFile(fileName, filePath, logPath, dtExcel);
         }
         return(Json(backMessage, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message.ToString(), JsonRequestBehavior.AllowGet));
     }
 }