public ActionResult UpdateMD5() { var sresult = string.Empty; var list = MusicBLL.GetList(a => true).ToList(); foreach (var item in list) { var FileFullName = Server.MapPath(item.SRC); if (System.IO.File.Exists(FileFullName)) { item.MD5 = Md5Helper.GetMD5HashFromFile(FileFullName); bool result = MusicBLL.Edit(item); sresult += FileFullName + "|MD5=" + item.MD5 + "|Result=" + result; } } return(Content(sresult)); }
public ActionResult Edit(MusicInfo info) { MusicInfo infoExist = MusicBLL.GetList(p => p.ID == info.ID).FirstOrDefault(); if (string.IsNullOrEmpty(info.Name)) { return(Json(new APIJson("请填写名称"))); } if (info.CategoryID <= 0) { return(Json(new APIJson("请选择分类"))); } HttpPostedFileBase FileMain = Request.Files["FileMain"]; if (null != FileMain) { info.SRC = "/Content/File/Music/" + Guid.NewGuid().ToString() + FileMain.FileName.Substring(FileMain.FileName.LastIndexOf(".")); FileMain.SaveAs(Server.MapPath(info.SRC)); infoExist.SRC = info.SRC; infoExist.MD5 = Md5Helper.GetMD5HashFromFile(Server.MapPath(info.SRC)); } if (info.PlayTime <= 0) { info.PlayTime = 1; } infoExist.CategoryID = info.CategoryID; infoExist.Name = info.Name; infoExist.SortID = info.SortID; infoExist.Enable = info.Enable; infoExist.PlayTime = info.PlayTime; if (MusicBLL.Edit(infoExist)) { return(Json(new APIJson(0, "提交成功"))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }