示例#1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, SafetyActivityEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public object Save()
        {
            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);
                SafetyActivityEntity entity   = JsonConvert.DeserializeObject <SafetyActivityEntity>(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 + "01", "SafetyActivityFile", files);
                UploadifyFile(entity.ID, "SafetyActivityPic", files);
                SafetyActivitybll.SaveForm(keyValue, entity);
            }
            catch (Exception)
            {
                return(new { code = -1, count = 0, info = "保存失败" });
            }

            return(new { code = 0, count = 0, info = "保存成功" });
        }
 public ActionResult SaveForm(string keyValue, SafetyActivityEntity entity)
 {
     SafetyActivitybll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
        public object GetEntity([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
                SafetyActivityEntity entity = SafetyActivitybll.GetEntity(id);
                var     data    = outsouringengineerbll.GetEntity(entity.EngineerId);
                var     proData = outProjectbll.GetOutProjectInfo(data.OUTPROJECTID);
                dynamic obj     = new ExpandoObject();
                obj.Id                 = entity.ID;
                obj.CREATEUSERID       = entity.CREATEUSERID;
                obj.CREATEUSERDEPTCODE = entity.CREATEUSERDEPTCODE;
                obj.CREATEUSERORGCODE  = entity.CREATEUSERORGCODE;
                obj.CREATEDATE         = entity.CREATEDATE.Value.ToString("yyyy-MM-dd HH:mm");
                obj.CREATEUSERNAME     = entity.CREATEUSERNAME;
                obj.MODIFYDATE         = entity.MODIFYDATE;
                obj.MODIFYUSERID       = entity.MODIFYUSERID;
                obj.MODIFYUSERNAME     = entity.MODIFYUSERNAME;
                obj.EngineerId         = entity.EngineerId;
                obj.StartTime          = entity.StartTime.Value.ToString("yyyy-MM-dd HH:mm");
                obj.EndTime            = entity.EndTime.Value.ToString("yyyy-MM-dd HH:mm");
                obj.PeopleNum          = entity.PeopleNum;
                obj.PracticalPeopleNum = entity.PracticalPeopleNum;
                obj.Condition          = entity.Condition;
                obj.StudyRecord        = entity.StudyRecord;
                obj.StudyDetails       = entity.StudyDetails;
                obj.EngineerletDept    = data.ENGINEERLETDEPT;
                obj.OutsourcingName    = proData.OUTSOURCINGNAME;
                obj.OutprojectId       = data.OUTPROJECTID;
                obj.UnitSuper          = data.UnitSuper;
                obj.EngineerName       = data.ENGINEERNAME;


                IList <Photo> pList = new List <Photo>(); //附件
                DataTable     file  = fileInfoBLL.GetFiles(entity.ID + "01");
                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.SafetyActivityFile = pList;

                IList <Photo> pList1 = new List <Photo>(); //附件
                DataTable     file1  = fileInfoBLL.GetFiles(entity.ID);
                foreach (DataRow dr in file1.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);
                    pList1.Add(p);
                }
                obj.SafetyActivityPic = pList1;

                return(new { Code = 0, Count = 1, Info = "获取数据成功", data = obj });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }