コード例 #1
0
ファイル: ExtensionMethods.cs プロジェクト: crazyants/aarbac
        public static string ToTextAndFixSpaces(this SqlQueryStringParser.SqlStringParser stringParser)
        {
            string parsedString = stringParser.ToText();

            //fixing spaces
            parsedString = parsedString.Replace("[ ", "[").Replace(" ]", "]").Replace(" . ", ".")
                           .Replace("( ", "(").Replace(" )", ")");

            return(parsedString);
        }
コード例 #2
0
ファイル: SqlQueryParser.cs プロジェクト: radtek/aarbac
        private void ApplyCondition(RbacTable table)
        {
            if (table.Conditions.Count == 0)
            {
                return;
            }

            if (ConditionAppliedOn.Where(c => c == table.Name).SingleOrDefault() != null)
            {
                return;
            }

            string selfName = this.GetTableNameOrAlias(table.Name);

            //if (!table.ReferencedOnly)
            //    selfName = this.GetTableNameOrAlias(table.Name);
            //else
            //    selfName = table.TempAlias;


            foreach (RbacCondition condition in table.Conditions)
            {
                //if this condition's column name already exists in the original query, we need to remove that condition from original query
                IfSameColumnConditionExistsRemoveCondition(selfName, condition);

                string thisItemWhereClause = condition.WhereClause.Replace("__self__", selfName);

                SqlQueryStringParser.SqlStringParser strParser = new SqlQueryStringParser.SqlStringParser();
                strParser.Parse(ParsedQuery);

                string originalWhereClause = strParser.WhereClause;
                if (string.IsNullOrEmpty(originalWhereClause))
                {
                    strParser.WhereClause = thisItemWhereClause;
                }
                else
                {
                    strParser.WhereClause = string.Format("({0}) AND ({1})", originalWhereClause, thisItemWhereClause);
                }

                ParsedQuery = strParser.ToTextAndFixSpaces();
            }

            //if (!string.IsNullOrEmpty(table.OrderBy))
            //{
            //    string orginalOrderByClause = strParser.OrderByClause;

            //    if (string.IsNullOrEmpty(orginalOrderByClause))
            //        strParser.OrderByClause = table.OrderBy;
            //    else
            //        strParser.OrderByClause = string.Format("{0}, {1}", orginalOrderByClause, OrderbyClause.Text);
            //}

            ConditionAppliedOn.Add(table.Name);
        }