/// <summary> /// 下载Apk文件 /// </summary> /// <param name="Path"></param> /// <param name="Id"></param> /// <returns></returns> public ActionResult DownApkFile(string Path, int Id) { IMobileVersionBLL mobileVersionBll = BLLFactory <IMobileVersionBLL> .GetBLL("MobileVersionBLL"); T_MobileVersion mobileVersion = mobileVersionBll.GetEntity(u => u.Id == Id); //获取文件的相对路径 var path = Server.MapPath(Path); //如果客户端信息版本不存在 if (mobileVersion != null) { //获取文件名 var item = mobileVersion.ApkFilePath.Substring(12); //如果不包含改路径 if (!System.IO.File.Exists(path)) { return(RedirectToAction("MobileVersion", "Error404")); } return(File(path, "application/octet-stream", item)); } return(RedirectToAction("MobileVersion", "VersionList")); }
public JsonResult DeleteVersion(int id) { JsonModel jm = new JsonModel(); IMobileVersionBLL mobileVersionBll = BLLFactory <IMobileVersionBLL> .GetBLL("MobileVersionBLL"); // 根据指定id值获取实体对象 var versionInfo = mobileVersionBll.GetEntity(index => index.Id == id); if (versionInfo != null) { //修改平台用户对应的角色集合 if (mobileVersionBll.DeleteVersion(id)) { //删除apk文件 string apkPath = versionInfo.ApkFilePath; string fullDirectory = Server.MapPath(apkPath); if (!string.IsNullOrEmpty(apkPath)) { FileInfo f = new FileInfo(fullDirectory); if (f.Exists) { f.Delete(); } } jm.Content = "删除指定版本" + versionInfo.VersionName + "成功"; } } else { jm.Msg = "该版本不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }