public ReturnResponse DeleteUpgradeBag(DTOUpgradeFileDelete dto) { string fileDirPath = Environment.CurrentDirectory + "/LocalFile/UpgradeBag/"; Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext); Prc_VersionInfo versionInfo = repository.Get(a => a.ID == dto.VersionId); try { NosService.DeleteFile("UpgradeBag/" + versionInfo.UpgradeBagName); } catch (Exception ex) { logger.Error("删除升级文件失败", ex); } versionInfo.IsPublish = false; versionInfo.LastPublishTime = null; versionInfo.UpgradeBagName = string.Empty; repository.Update(versionInfo); //取消该版本的所有预约 Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext); List <Prc_UpgradeInfo> infos = repositoryInfo.Search(a => !a.IsDelete && a.UpgradeStatus == Model.Enum.EnumUpgradeStatus.Reserved && a.TargetVersionID == versionInfo.ID); infos.ForEach(a => { BllUpgrade.CancelReserve(a.ID); }); OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "删除了版本【" + versionInfo.VersionNo + "】的更新包"); DbContext.SaveChanges(); return(new ReturnResponse()); }
public ReturnResponse DeleteUpgradeBag(DTOUpgradeFileDelete dto) { string fileDirPath = Environment.CurrentDirectory + "/LocalFile/UpgradeBag/"; Repository <Prc_VersionInfo> repository = new Repository <Prc_VersionInfo>(DbContext); Prc_VersionInfo versionInfo = repository.Get(a => a.ID == dto.VersionId); string fileFullName = fileDirPath + versionInfo.UpgradeBagName; string bytesKey = "UpgradeBag_" + dto.VersionId.ToString().ToUpper(); string nameKey = "UpgradeBagName_" + dto.VersionId.ToString().ToUpper(); _cache.Remove(bytesKey); _cache.Remove(nameKey); if (System.IO.File.Exists(fileFullName)) { System.IO.File.Delete(fileFullName); } versionInfo.IsPublish = false; versionInfo.LastPublishTime = null; versionInfo.UpgradeBagName = string.Empty; repository.Update(versionInfo); //取消该版本的所有预约 Repository <Prc_UpgradeInfo> repositoryInfo = new Repository <Prc_UpgradeInfo>(DbContext); List <Prc_UpgradeInfo> infos = repositoryInfo.Search(a => !a.IsDelete && a.UpgradeStatus == Model.Enum.EnumUpgradeStatus.Reserved && a.TargetVersionID == versionInfo.ID); infos.ForEach(a => { BllUpgrade.CancelReserve(a.ID); }); OperateLoger.Write(LoginUserInfo.CurrUser.UserName, DateTime.Now, "删除了版本【" + versionInfo.VersionNo + "】的更新包"); DbContext.SaveChanges(); return(new ReturnResponse()); }