/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, PatrolRecordEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public object GetPatrolRecordEntity([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); //获取用户Id string userId = dy.userid; OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); if (null == curUser) { return(new { code = -1, count = 0, info = "请求失败,请登录!" }); } string id = dy.data.Id;//ID PatrolRecordEntity entity = patrolrecordbll.GetEntity(id); dynamic obj = new ExpandoObject(); obj.Id = entity.Id; obj.NextPatrolDate = entity.NextPatrolDate; obj.State = entity.State; obj.Describe = entity.Describe; obj.Measure = entity.Measure; obj.PatrolDate = entity.PatrolDate; obj.PatrolPerson = entity.PatrolPerson; obj.PatrolPersonId = entity.PatrolPersonId; obj.MainId = entity.MainId; obj.PatrolPeriod = entity.PatrolPeriod; IList <Photo> pList = new List <Photo>(); //附件 DataTable file = fileInfoBLL.GetFiles(entity.Id); foreach (DataRow dr in file.Rows) { Photo p = new Photo(); p.id = dr["fileid"].ToString(); p.filename = dr["filename"].ToString(); p.fileurl = dataitemdetailbll.GetItemValue("imgUrl") + dr["filepath"].ToString().Substring(1); pList.Add(p); } obj.file = pList; return(new { Code = 0, Count = 1, Info = "获取数据成功", data = obj }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = ex.Message }); } }
public object SavePatrolRecord() { try { string res = ctx.Request["json"]; dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; //当前用户ID OperatorProvider.AppUserId = userId; //设置当前用户 Operator curUser = OperatorProvider.Provider.Current(); string keyValue = dy.data.Id; string str = JsonConvert.SerializeObject(dy.data); PatrolRecordEntity entity = JsonConvert.DeserializeObject <PatrolRecordEntity>(str); if (!string.IsNullOrEmpty(keyValue)) { //获取删除附件ID string deleteFileId = dy.data.deleteFileId; if (!string.IsNullOrEmpty(deleteFileId)) { DeleteFile(deleteFileId); } } else { entity.Id = Guid.NewGuid().ToString(); keyValue = entity.Id; } HttpFileCollection files = ctx.Request.Files; //上传的文件 //上传设备图片 UploadifyFile(entity.Id, "PatrolRecord", files); patrolrecordbll.SaveForm(keyValue, entity); } catch (Exception) { return(new { code = -1, count = 0, info = "保存失败" }); } return(new { code = 0, count = 0, info = "保存成功" }); }
public ActionResult SaveForm(string keyValue, PatrolRecordEntity entity) { patrolrecordbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }