public static CPFormEngine Instance(int curUserId) { CPFormEngine iObj = CPAppContext.GetService <CPFormEngine>(); iObj.CurUserId = curUserId; return(iObj); }
public SaveFormDataReturn SaveFormData([FromBody] SaveFormDataInput input) { base.SetHeader(); SaveFormDataReturn re = new SaveFormDataReturn(); if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { CPForm form = CPFormTemplate.Instance(input.CurUserId).GetForm(input.FormCode, true, true, false, false, false, false); string errormsg; string pkValues = input.PKValue; CPFormUseScene useScene = CPFormTemplate.Instance(input.CurUserId).GetFormUseScene(input.SceneCode, false); re.Result = CPFormEngine.Instance(input.CurUserId).SaveData(form, form.ChildTableCol, form.FieldCol, ref pkValues, input.FormDataJSON, useScene, out errormsg); if (re.Result == false) { re.ErrorMsg = errormsg; } else { re.PKValues = pkValues; } return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public GetFormInfoReturn GetFormInfo(string FormCode, string SceneCode, string ViewCode, string InitGroupCode, string RightGroupCode, string PKValues , int CurUserId, string CurUserIden, string DeviceType = "1", bool IsView = false ) { GetFormInfoReturn re = new GetFormInfoReturn(); try { base.SetHeader(); FormCode = CPAppContext.FormatSqlPara(FormCode); SceneCode = CPAppContext.FormatSqlPara(SceneCode); ViewCode = CPAppContext.FormatSqlPara(ViewCode); InitGroupCode = CPAppContext.FormatSqlPara(InitGroupCode); RightGroupCode = CPAppContext.FormatSqlPara(RightGroupCode); PKValues = CPAppContext.FormatSqlPara(PKValues); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); DeviceType = CPAppContext.FormatSqlPara(DeviceType); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } CPForm form = CPFormTemplate.Instance(CurUserId).GetForm(FormCode, true, true, false, false, false, true); form.ViewCol = new List <CPFormView>(); form.ViewCol.Add(CPFormTemplate.Instance(CurUserId).GetFormView(ViewCode, true)); //re.Form = EmitMapper.ObjectMapperManager.DefaultInstance.GetMapper<CPForm, CPFormClient>() // .Map(form); Mapper.Initialize(cfg => { cfg.CreateMap <CPForm, CPFormClient>(); }); re.Form = AutoMapper.Mapper.Map <CPFormClient>(form); CPFormGroup rightGroup = CPFormTemplate.Instance(CurUserId).GetFormRightGroup(RightGroupCode, true); // re.FieldRightCol = (rightGroup == null ? null : rightGroup.FieldRightCol); CPFormGroup initGroup = CPFormTemplate.Instance(CurUserId).GetFormInitGroup(InitGroupCode, true); re.Form.FieldInitCol = (initGroup == null ? null : initGroup.FieldInitCol); re.ViewHTML = CPFormTemplate.Instance(CurUserId).FormatFormViewHtml(form, form.FieldCol, form.ViewCol[0], (rightGroup == null ? null : rightGroup.FieldRightCol), CPEnum.ConvertDeviceTypeEnum(int.Parse(DeviceType)), true, IsView); //获取应用场景 re.Form.UseSceneCol = new List <CPFormUseScene>(); re.Form.UseSceneCol.Add(CPFormTemplate.Instance(CurUserId).GetFormUseScene(SceneCode, true)); re.Form.UseSceneCol.ForEach(t => { t.FormSavedInfo = CPExpressionHelper.Instance.RunCompile(t.FormSavedInfo); //处理按钮是否显示 List <CPFormUseSceneFunc> funcCol = new List <CPFormUseSceneFunc>(); t.FuncCol.ForEach(func => { if (func.FuncIsShowInView == CPFormEnum.FuncIsShowInViewEnum.ShowAll) { funcCol.Add(func); } else if (func.FuncIsShowInView == CPFormEnum.FuncIsShowInViewEnum.OnlyWriteShow) { if (IsView == false) { funcCol.Add(func); } } else if (func.FuncIsShowInView == CPFormEnum.FuncIsShowInViewEnum.OnlyReadShow) { if (IsView == true) { funcCol.Add(func); } } }); #region 添加修改配置按钮 if (re.Form.SysId.HasValue && re.Form.SysId.Value.Equals(CPAppContext.InnerSysId) == false) { string UserAdminSysIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserAdminSysIds()}"); if (UserAdminSysIds.Split(',').ToList().Contains(re.Form.SysId.ToString())) { CPFormUseSceneFunc func1 = new CPFormUseSceneFunc(); func1.FuncTitle = "修改配置"; func1.ShowOrder = 999999; func1.FuncIcon = "icon-shezhi1"; func1.IsControlByRight = false; func1.FuncIsShowInView = CPFormEnum.FuncIsShowInViewEnum.ShowAll; func1.FuncExeJS = "CPFormUpdateConfig(" + re.Form.Id + ")"; func1.SceneID = t.Id; funcCol.Add(func1); } } #endregion t.FuncCol = funcCol; t.FuncCol = t.FuncCol.OrderBy(c => c.ShowOrder).ToList(); }); //读取真实数据 re.FormDataJSON = CPFormEngine.Instance(CurUserId).GetFormDataJSON(form, form.ChildTableCol, form.FieldCol, re.Form.FieldInitCol, PKValues, re.Form.UseSceneCol[0]); re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }