Example #1
0
        public bool ImportTreeInnerFunc(int treeId)
        {
            List <CPTreeFunc> col  = new List <CPTreeFunc>();
            CPTreeFunc        fun0 = new CPTreeFunc();

            fun0.TreeId              = treeId;
            fun0.FuncTitle           = "全展开";
            fun0.FuncIcon            = "icon-unfold";
            fun0.ShowOrder           = 20;
            fun0.JSMethod            = "CPTreeExpandAllNode()";
            fun0.ShowPosition        = CPTreeEnum.ShowPositionEnum.TopAndRight;
            fun0.SourceId            = -1;
            fun0.IsUseExpressionShow = false;
            fun0.IsShowByExpression  = true;
            col.Add(fun0);
            CPTreeFunc fun1 = new CPTreeFunc();

            fun1.TreeId              = treeId;
            fun1.FuncTitle           = "全收缩";
            fun1.FuncIcon            = "icon-narrow";
            fun1.ShowOrder           = 30;
            fun1.JSMethod            = "CPTreeCollapseAllNode()";
            fun1.ShowPosition        = CPTreeEnum.ShowPositionEnum.TopAndRight;
            fun1.SourceId            = -1;
            fun1.IsUseExpressionShow = false;
            fun1.IsShowByExpression  = true;
            col.Add(fun1);
            CPTreeFunc fun = new CPTreeFunc();

            fun.TreeId              = treeId;
            fun.FuncTitle           = "删除";
            fun.FuncIcon            = "icon-guanbi1";
            fun.ShowOrder           = 40;
            fun.JSMethod            = "CPTreeDeleteNode()";
            fun.ShowPosition        = CPTreeEnum.ShowPositionEnum.TopAndRight;
            fun.SourceId            = -1;
            fun.IsUseExpressionShow = false;
            fun.IsShowByExpression  = true;
            col.Add(fun);
            this._CPTreeFuncRep.Add(col);
            return(true);
        }
Example #2
0
        public GetTreeInfoReturn GetTreeInfo(string TreeCode, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            TreeCode    = CPAppContext.FormatSqlPara(TreeCode);
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);

            GetTreeInfoReturn re = new GetTreeInfoReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                re.Tree = CPTreeEngine.Instance().GetTree(TreeCode, true, true);

                #region 处理
                List <CPTreeFunc> cCol = new List <CPTreeFunc>();
                re.Tree.FuncCol.ForEach(t =>
                {
                    bool isShow = true;
                    if (t.IsUseExpressionShow.Value)
                    {
                        string leftValue  = CPExpressionHelper.Instance.RunCompile(t.LeftExpression);
                        string rightValue = CPExpressionHelper.Instance.RunCompile(t.RightExpression);

                        if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.EqualTo)
                        {
                            if (leftValue.Equals(rightValue, StringComparison.CurrentCultureIgnoreCase))
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.NotEqualTo)
                        {
                            if (leftValue.Equals(rightValue, StringComparison.CurrentCultureIgnoreCase) == false)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.GreaterThanOrEqualTo)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft >= dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.GreaterThan)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft > dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.LessThanOrEqualTo)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft <= dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.LessThan)
                        {
                            double dLeft  = 0;
                            double dRight = 0;
                            try
                            {
                                dLeft = Convert.ToDouble(leftValue);
                            }
                            catch (Exception ex) { }
                            try
                            {
                                dRight = Convert.ToDouble(rightValue);
                            }
                            catch (Exception ex) { }
                            if (dLeft < dRight)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.Contains)
                        {
                            if (leftValue.IndexOf(rightValue, StringComparison.CurrentCultureIgnoreCase) != -1)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                        else if (t.ShowMethod == CPTreeEnum.ShowMethodEnum.DoesNotContain)
                        {
                            if (leftValue.IndexOf(rightValue, StringComparison.CurrentCultureIgnoreCase) == -1)
                            {
                                isShow = t.IsShowByExpression.Value;
                            }
                            else
                            {
                                if (t.IsShowByExpression.Value)
                                {
                                    isShow = false;
                                }
                                else
                                {
                                    isShow = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        isShow = true;
                    }
                    if (isShow)
                    {
                        t.JSMethod = CPExpressionHelper.Instance.RunCompile(t.JSMethod);
                        cCol.Add(t);
                    }
                });
                #region 添加修改配置按钮
                if (re.Tree.SysId.HasValue && re.Tree.SysId.Value.Equals(CPAppContext.InnerSysId) == false)
                {
                    string UserAdminSysIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserAdminSysIds()}");
                    if (UserAdminSysIds.Split(',').ToList().Contains(re.Tree.SysId.ToString()))
                    {
                        CPTreeFunc func1 = new CPTreeFunc();
                        func1.FuncTitle           = "修改配置";
                        func1.ShowOrder           = 999999;
                        func1.FuncIcon            = "icon-shezhi1";
                        func1.IsUseExpressionShow = false;
                        func1.JSMethod            = "CPTreeUpdateConfig(" + re.Tree.Id + ")";
                        func1.ShowPosition        = CPTreeEnum.ShowPositionEnum.TopAndRight;
                        func1.SourceId            = -1;
                        func1.TreeId = re.Tree.Id;
                        cCol.Add(func1);
                    }
                }
                #endregion
                re.Tree.FuncCol = cCol;
                #endregion


                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }