Beispiel #1
0
        public string ParamsProcess(string input, fmQueryExtract form)
        {
            //Dim pramItemID As New SqlParameter("@ItemID", SqlDbType.VarChar, 30)
            Parser <string> dimSqlParameterParser
                = from dim in Parse.String("Dim").Text().Token()
                  from _a in Parse.LetterOrDigit.Many().Token()
                  from _b in Parse.String("As New SqlParameter(\"").Text().Token()
                  from at in Parse.Char('@')
                  from param in Parse.LetterOrDigit.AtLeastOnce().Text().Token()
                  from _c in Parse.Char('"')
                  from _d in Parse.AnyChar.Many()
                  select at + param;

            foreach (var line in input.Split(Environment.NewLine.ToArray()))
            {
                if (line != "")
                {
                    Regex dimRegex          = new System.Text.RegularExpressions.Regex("^Dim");
                    Regex sqlParameterRegex = new System.Text.RegularExpressions.Regex("SqlParameter");

                    if (dimRegex.IsMatch(line) && sqlParameterRegex.IsMatch(line))
                    {
                        var result = dimSqlParameterParser.Parse(line);
                        form.RegistSqlParam(result);
                    }
                }
            }

            return(input);
        }
Beispiel #2
0
        public string IfProcess(string inputAfterComment, fmQueryExtract form)
        {
            List <IfConditionAndVbLine> x = new List <IfConditionAndVbLine>();

            foreach (var line in inputAfterComment.Split(Environment.NewLine.ToArray()))
            {
                if (line != "")
                {
                    Regex ifRegex    = new System.Text.RegularExpressions.Regex("^If");
                    Regex endIfRegex = new System.Text.RegularExpressions.Regex("^END If");

                    if (ifRegex.IsMatch(line))
                    {
                        var ifStatementParser
                            = from _a in Parse.String("If").Token()
                              from condition in Parse.LetterOrDigit.AtLeastOnce().Token()
                              from _b in Parse.String("Then").Token()
                              select new string(condition.ToArray());

                        var ifParameter = ifStatementParser.Parse(line);
                        RegistIfParameter(ifParameter, form);
                    }
                    else if (endIfRegex.IsMatch(line))
                    {
                        RemoveIfParameter();
                    }
                    else
                    {
                        x.Add(new IfConditionAndVbLine(new List <string>(_currentIfConditions.ToArray()), line));
                    }
                }
            }

            form.RegistIfParameter(_allIfConditions);

            var retval = "";

            foreach (var ifAndVbline in x)
            {
                var isAdd = true;
                foreach (var ifCondition in ifAndVbline.IfConditions)
                {
                    if (!_validIfConditions.Contains(ifCondition))
                    {
                        isAdd = false;
                    }
                }
                if (isAdd)
                {
                    retval += ifAndVbline.QueryString + Environment.NewLine;
                }
            }

            return(retval);
        }
Beispiel #3
0
        public string ExecParse(string input, fmQueryExtract form)
        {
            ClearQueryStringVarialbes();
            var inputAfterTrim            = GetVbLines(input);              //空白の処理
            var inputAfterComment         = CommentProcess(inputAfterTrim); //コメントの除去
            var vbLinesAfterIf            = IfProcess(inputAfterComment, form);
            var vbLinesAfterParams        = ParamsProcess(vbLinesAfterIf, form);
            var vbLinesAfterAppendLine    = AppendLineProcess(vbLinesAfterParams);
            var vbLinesAfterReplaceParams = ReplaceParamsProcess(vbLinesAfterAppendLine);

            var vbLinesFinal = vbLinesAfterReplaceParams;

            return(vbLinesFinal);
        }
Beispiel #4
0
 private void RegistIfParameter(string condition, fmQueryExtract form)
 {
     _allIfConditions.Add(condition);
     _currentIfConditions.Push(condition);
 }
Beispiel #5
0
 public string IfProcess(string inputAfterComment, fmQueryExtract form)
 {
     return(_ifParameter.IfProcess(inputAfterComment, form));
 }