public ApiResult <List <UpdateInfoEntity> > CheckUpdate(string appKey, string verion, string isTest) { ApiResult <List <UpdateInfoEntity> > result = new ApiResult <List <UpdateInfoEntity> >(); result.Data = new List <UpdateInfoEntity>(); //判断当前版本是否为回退版 string appID = string.Empty; MED_APP_INFO info = this.updateService.GetAppInfoByAppKey(appKey); if (info == null) { result.Msg = "应用程序主键不存在"; } else { appID = info.APP_ID; List <MED_VER_INFO> versionList = this.updateService.GetListByAppIDAndVerio(appID, verion, isTest); if (versionList != null) { foreach (MED_VER_INFO item in versionList) { UpdateInfoEntity entity = new UpdateInfoEntity(); entity.VerionNo = item.VER_NO; entity.Description = item.DESCRIPTION; entity.IsRollBack = item.ROLL_BACK ?? 0; entity.RollBackDesc = item.ROLL_BACK_DESC; entity.IsForcibly = item.IS_FORCIBLY ?? 0; entity.FilePath = item.FILE_PATH; result.Data.Add(entity); } } } return(result); }
public ActionResult Modify(MED_APP_INFO appInfo) { DapperContext dapper = new DapperContext("docareConnString"); bool result = false; if (appInfo != null) { if (string.IsNullOrEmpty(appInfo.APP_ID)) { MED_APP_INFO info = dapper.Set <MED_APP_INFO>().Single(x => x.APP_KEY.Equals(appInfo.APP_KEY)); //判断重复KEY if (null != info) { return(Json("应用程序Key已存在!", "text/html")); } appInfo.APP_ID = Guid.NewGuid().ToString(); appInfo.CREATE_TIME = DateTime.Now; appInfo.ModelStatus = ModelStatus.Add; } else { //编辑KEY不修改TODO:这里不可编辑暂未做后台认证 appInfo.ModelStatus = ModelStatus.Modeified; appInfo.MODIFY_TIME = DateTime.Now; } result = dapper.Set <MED_APP_INFO>().Save(appInfo); dapper.SaveChanges(); } return(Json(result, "text/html")); }
public virtual bool SaveAppInfo(MED_APP_INFO data) { bool ret = false; ret = dapper.Set <MED_APP_INFO>().Save(data); dapper.SaveChanges(); return(ret); }
/// <summary> /// 上传版本更新记录 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ApiResult <bool> UploadUpdateRec([FromBody] MachineInfoEntity entity) { //MachineInfoEntity entity = JsonConvert.DeserializeObject<MachineInfoEntity>(par); ApiResult <bool> result = new ApiResult <bool>(); try { //根据应用程序Key和版本号判断是否存在数据 MED_APP_INFO appInfo = this.updateService.GetAppInfoByAppKey(entity.AppKey); MED_VER_INFO verInfo = this.updateService.GetVer_InfoByAppIDAndVerion(appInfo.APP_ID, entity.VerionNo.ToString()); if (verInfo != null) { //根据IP、版ID获取更新记录 存在更新,不存插入数据 MED_VER_UPDATE_REC verUpdateRecEntity = this.updateService.GetVerUpdateRecByIPAndVerionID(entity.IP, verInfo.VER_ID); if (verUpdateRecEntity == null) { //插入 verUpdateRecEntity = new MED_VER_UPDATE_REC(); verUpdateRecEntity.UP_ID = Guid.NewGuid().ToString(); verUpdateRecEntity.APP_NAME = appInfo.APP_NAME; verUpdateRecEntity.VER_ID = verInfo.VER_ID; verUpdateRecEntity.IP = entity.IP; verUpdateRecEntity.SYSTEM_NAME = entity.SystemName; verUpdateRecEntity.CREATE_TIME = DateTime.Now; verUpdateRecEntity.ModelStatus = ModelStatus.Add; } if (entity.IsDownload == 1) { verUpdateRecEntity.IS_DOWNLOAD = entity.IsDownload; verUpdateRecEntity.DOWNLOAD_TIME = entity.DownloadTime; } if (entity.IsUpdated == 1) { verUpdateRecEntity.IS_UPDATED = entity.IsUpdated; verUpdateRecEntity.UPDATED_TIME = entity.UpdatedTime; } if (entity.IsRollBack == 1) { verUpdateRecEntity.ROLL_BACK = entity.IsRollBack; verUpdateRecEntity.ROLL_BACK_TIME = entity.RollBackTime; } result.Data = this.updateService.SaveVerUpdateRec(verUpdateRecEntity); } else { result.Msg = "此版本号不存在!"; result.Data = false; } } catch (Exception ex) { result.Msg = ex.ToString(); result.Data = false; } return(result); }
public ActionResult MoidfyView(string id) { DapperContext dapper = new DapperContext("docareConnString"); MED_APP_INFO info = dapper.Set <MED_APP_INFO>().Single(x => x.APP_ID.Equals(id)); if (null == info) { info = new MED_APP_INFO(); } return(View(info)); }
public ActionResult Delete(string id) { DapperContext dapper = new DapperContext("docareConnString"); bool result = false; List <MED_VER_INFO> verList = dapper.Set <MED_VER_INFO>().Select(x => x.APP_ID.Equals(id)); if (verList.Count > 0) { return(Json("应用程序下存在已发布版本记录!", "text/html")); } MED_APP_INFO info = dapper.Set <MED_APP_INFO>().Single(x => x.APP_ID.Equals(id)); info.ModelStatus = ModelStatus.Deleted; result = dapper.Set <MED_APP_INFO>().Delete(info); dapper.SaveChanges(); return(Json(result)); }
public virtual MED_APP_INFO GetAppInfoByAppKey(string appKey) { MED_APP_INFO info = dapper.Set <MED_APP_INFO>().Single(x => x.APP_KEY.Equals(appKey)); return(info); }
public ActionResult Create(MED_VER_INFO verInfo, HttpPostedFileBase postFileBase) { DapperContext dapper = new DapperContext("docareConnString"); string erroMsg = string.Empty; try { //检测应用程序最大版本号,是否为测试版,如果为测试版又未回退,就不能发布新版 if (!string.IsNullOrEmpty(verInfo.APP_ID)) { MED_VER_INFO maxNoVerInfo = dapper.Set <MED_VER_INFO>().Select(x => x.APP_ID.Equals(verInfo.APP_ID)).OrderByDescending(x => x.VER_NO).FirstOrDefault(); if (maxNoVerInfo == null || maxNoVerInfo.IS_TEST != 1 || (maxNoVerInfo.IS_TEST == 1 && maxNoVerInfo.ROLL_BACK == 1)) { if (Request.Files.Count > 0) { MED_APP_INFO appInfo = dapper.Set <MED_APP_INFO>().Single(x => x.APP_ID.Equals(verInfo.APP_ID)); postFileBase = Request.Files[0]; //文件上传,一次上传1M的数据,防止出现大文件无法上传 uploadStream = postFileBase.InputStream; int bufferLen = 1024; byte[] buffer = new byte[bufferLen]; int contentLen = 0; string fileName = Path.GetFileName(postFileBase.FileName); //判断扩展名 string[] extens = new string[] { ".zip" }; if (Array.Exists(extens, p => p.ToUpper() == System.IO.Path.GetExtension(fileName).ToUpper())) { string baseUrl = Server.MapPath("/"); string uploadPath = "UpdateFile" + @"\" + appInfo.APP_KEY + @"\"; //创建文件夹 string[] folderFile = uploadPath.Split(new String[] { @"\" }, StringSplitOptions.RemoveEmptyEntries); String l = folderFile.LastOrDefault(); string cPath = baseUrl; foreach (var item in folderFile) { if (!item.Contains(":")) { cPath += @"\" + item; if (!Directory.Exists(cPath)) { Directory.CreateDirectory(cPath); } } } //保存文件 string newFilename = verInfo.VER_NO + Path.GetExtension(fileName); string newFilePath = baseUrl + @"\" + uploadPath + newFilename; fs = new FileStream(newFilePath, FileMode.Create, FileAccess.ReadWrite); while ((contentLen = uploadStream.Read(buffer, 0, bufferLen)) != 0) { fs.Write(buffer, 0, bufferLen); fs.Flush(); } fs.Close(); verInfo.FILE_PATH = uploadPath + newFilename; //保存数据 verInfo.VER_ID = Guid.NewGuid().ToString(); verInfo.CREATE_TIME = DateTime.Now; verInfo.ModelStatus = ModelStatus.Add; bool rest = dapper.Set <MED_VER_INFO>().Save(verInfo); dapper.SaveChanges(); MedicalSystem.Services.Logger.Info("上传完成"); if (!rest) { //删除文件 System.IO.File.Delete(newFilePath); erroMsg = "数据保存失败"; } else { MedicalSystem.Services.Logger.Info("发消息给客户端"); // 发布消息给客户端 MED_USERS user = new MED_USERS { LOGIN_NAME = "admin", USER_NAME = "admin", USER_JOB_ID = "admin", USER_JOB = "医生", USER_ROLE = "主任,管理员", isMDSD = true }; if (System.Web.HttpContext.Current.Application["admin"] == null) { try { MedicalSystem.Services.Logger.Info("消息平台连接"); TransMessageManager tmm = new TransMessageManager(user); tmm.OpenConnection(); System.Web.HttpContext.Current.Application["admin"] = tmm; MedicalSystem.Services.Logger.Info("消息平台连接成功"); // 设置消息体 TransMessageModel tm = new TransMessageModel() { TargetClientEnumAppType = EnumAppType.AnesWorkStation, CurEnumMessageType = EnumMessageType.Broadcase, CurEnumFunctionType = EnumFunctionType.HasNewVersion, SourceClientEnumAppType = EnumAppType.Platform, MessageContent = appInfo.APP_KEY }; MedicalSystem.Services.Logger.Info("发送消息"); tmm.SendMsg(tm); MedicalSystem.Services.Logger.Info("发送消息完"); } catch (Exception ex) { MedicalSystem.Services.Logger.Info("消息平台错误:" + ex.Message); } } } } else { erroMsg = "扩展名必须为zip"; } } else { erroMsg = "未选择要上传文件!"; } } else { erroMsg = "版本号" + maxNoVerInfo.VER_NO + "是测试版并没有回退版本!"; } } else { erroMsg = "没有选择应用程序!"; } if (!string.IsNullOrEmpty(erroMsg)) { return(Json(erroMsg, "text/html")); } else { return(Json(true, "text/html")); } } catch (Exception ex) { erroMsg = ex.Message; return(Json(erroMsg, "text/html")); } finally { if (System.Web.HttpContext.Current.Application["admin"] != null) { TransMessageManager tmm = System.Web.HttpContext.Current.Application["admin"] as TransMessageManager; tmm.CloseConnection(); System.Web.HttpContext.Current.Application.Remove("admin"); } } }