Пример #1
0
        public GetMsgReturn GetMsg(int MsgType, int MsgCount, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            GetMsgReturn re = new GetMsgReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.MsgCol = CPMsgs.Instance().GetMsg(CurUserId, CPEnum.ConvertMsgTypeEnum(MsgType), MsgCount);
                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public LoginReturn Login(string LoginName, string UserPwd, int DeviceType)
        {
            base.SetHeader();
            LoginReturn re = new LoginReturn();

            re.Result = true;
            try
            {
                string         errorMsg = "";
                COUserIdentity iden     = COOrgans.Instance().Login(LoginName, UserPwd, CPEnum.ConvertDeviceTypeEnum(DeviceType), ref errorMsg);
                if (string.IsNullOrEmpty(errorMsg) == false)
                {
                    re.Result   = false;
                    re.ErrorMsg = errorMsg;
                    return(re);
                }
                re.UserId  = iden.UserId;
                re.UserKey = iden.UserKey;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }