Exemple #1
0
        public static dynamic GetDimissionValueByUserData(AbstractCriteria ac, PropertyInfo propertyInfo, RoleType roleType, UserInfoDTO userInfo)
        {
            dynamic ret = null;

            var     attr  = (CriteriaPropertyAttribute)propertyInfo.GetCustomAttributes(typeof(CriteriaPropertyAttribute), false).FirstOrDefault();
            dynamic value = propertyInfo.GetValue(ac);

            if ((attr.Role == UserRole.Common &&
                 (roleType == RoleType.KDSAdmin || roleType == RoleType.KDSUser)) ||
                (attr.Role == UserRole.User && roleType == RoleType.KDSUser) ||
                (attr.Role == UserRole.Admin && roleType == RoleType.KDSAdmin)
                )
            {
                if (attr.UserFlag == UserData.CompanyID)
                {
                    int CompanyID = 0;
                    if (userInfo.CompanyID != null)
                    {
                        CompanyID = userInfo.CompanyID.Value;
                    }
                    dynamic defalutValue = new int[] { CompanyID };
                    if (attr.Conditions == CriteriaConditions.QueryKDSPermissionsCondition)
                    {
                        ret = GetDimissionValue(attr.Opration, value, defalutValue, attr.NoDataID);
                    }
                    else if (attr.Conditions == CriteriaConditions.KDSPermissionsCondition)
                    {
                        ret = defalutValue;
                    }
                }
                else if (attr.UserFlag == UserData.EmpID && attr.EntityID != 0)
                {
                    int EmpID = 0;
                    if (userInfo.EmpID != null)
                    {
                        EmpID = userInfo.EmpID.Value;
                    }
                    dynamic defaultValue = PermissionsConditionBL.GetWhereByEntityID(userInfo.UserID, attr, EmpID);

                    if (attr.Conditions == CriteriaConditions.QueryKDSPermissionsCondition)
                    {
                        ret = GetDimissionValue(attr.Opration, value, defaultValue, attr.NoDataID);
                    }
                    else if (attr.Conditions == CriteriaConditions.KDSPermissionsCondition)
                    {
                        ret = defaultValue;
                    }
                }
            }


            return(ret);
        }
Exemple #2
0
        public override dynamic GetDimssionValue(AbstractCriteria ac, PropertyInfo propertyInfo)
        {
            dynamic ret   = null;
            var     attr  = (CriteriaPropertyAttribute)propertyInfo.GetCustomAttributes(typeof(CriteriaPropertyAttribute), false).FirstOrDefault();
            dynamic value = propertyInfo.GetValue(ac);

            if (attr.UserFlag == UserData.Normal && attr.EntityID != 0)
            {
                dynamic defaultValue = PermissionsConditionBL.GetWhereByEntityID(userInfo.UserID, attr);

                switch (attr.Conditions)
                {
                case CriteriaConditions.PermissionsCondition:
                    ret = defaultValue;
                    break;

                case CriteriaConditions.KBPPermissionsCondition:
                    if ((attr.Role == UserRole.Common &&
                         (roleType == RoleType.KBPAdmin || roleType == RoleType.KBPUser)) ||
                        (attr.Role == UserRole.User && roleType == RoleType.KBPUser) ||
                        (attr.Role == UserRole.Admin && roleType == RoleType.KBPAdmin)
                        )
                    {
                        ret = defaultValue;
                    }
                    break;


                case CriteriaConditions.KDSPermissionsCondition:
                    if ((attr.Role == UserRole.Common &&
                         (roleType == RoleType.KDSAdmin || roleType == RoleType.KDSUser)) ||
                        (attr.Role == UserRole.User && roleType == RoleType.KDSUser) ||
                        (attr.Role == UserRole.Admin && roleType == RoleType.KDSAdmin)
                        )
                    {
                        ret = defaultValue;
                    }
                    break;


                case CriteriaConditions.QueryPermissionsCondition:
                    ret = CriteriaHelper.GetDimissionValue(attr.Opration, value, defaultValue, attr.NoDataID);
                    break;


                case CriteriaConditions.QueryKBPPermissionsCondition:
                    if ((attr.Role == UserRole.Common &&
                         (roleType == RoleType.KBPAdmin || roleType == RoleType.KBPUser)) ||
                        (attr.Role == UserRole.User && roleType == RoleType.KBPUser) ||
                        (attr.Role == UserRole.Admin && roleType == RoleType.KBPAdmin)
                        )
                    {
                        ret = CriteriaHelper.GetDimissionValue(attr.Opration, value, defaultValue, attr.NoDataID);
                    }

                    else if ((attr.Role == UserRole.Common &&
                              (roleType == RoleType.KDSAdmin || roleType == RoleType.KDSUser)) ||
                             (attr.Role == UserRole.User && roleType == RoleType.KDSUser) ||
                             (attr.Role == UserRole.Admin && roleType == RoleType.KDSAdmin)
                             )
                    {
                        ret = value;
                    }
                    break;



                case CriteriaConditions.QueryKDSPermissionsCondition:
                    if ((attr.Role == UserRole.Common &&
                         (roleType == RoleType.KDSAdmin || roleType == RoleType.KDSUser)) ||
                        (attr.Role == UserRole.User && roleType == RoleType.KDSUser) ||
                        (attr.Role == UserRole.Admin && roleType == RoleType.KDSAdmin)
                        )
                    {
                        ret = CriteriaHelper.GetDimissionValue(attr.Opration, value, defaultValue, attr.NoDataID);
                    }

                    else if ((attr.Role == UserRole.Common &&
                              (roleType == RoleType.KBPAdmin || roleType == RoleType.KBPUser)) ||
                             (attr.Role == UserRole.User && roleType == RoleType.KBPUser) ||
                             (attr.Role == UserRole.Admin && roleType == RoleType.KBPAdmin)
                             )
                    {
                        ret = value;
                    }
                    break;

                default: break;
                }
            }
            if (ret == null)
            {
                ret = base.GetDimssionValue(ac, propertyInfo);
            }
            return(ret);
        }