Exemplo n.º 1
0
        private string GetCaption(string callee)
        {
            try
            {
                if (this.captions.ContainsKey(callee))
                {
                    return(this.captions[callee]);
                }

                var file = Directory.GetFiles(this.target, callee, SearchOption.AllDirectories).FirstOrDefault();

                if (string.IsNullOrWhiteSpace(file))
                {
                    return(string.Empty);
                }

                var caption = FoxUtil.GetProperty(file, "form", "Caption");

                this.captions[callee] = caption;

                return(caption);
            }
            catch (Exception ex)
            {
                // who cares
            }

            return(string.Empty);
        }
        public override void Analyze(string content, SqlSummaryResult result)
        {
            var stripped = FoxUtil.Strip(content).ToLower();

            result.PlainQueryCount       += Regex.Matches(stripped, @"""select\s*\S*").Count;
            result.StoredProceduresCount += Regex.Matches(stripped, @"\su?sp_").Count;
        }
        public override void Analyze(string content, StoredProcedureResult result)
        {
            var stripped = FoxUtil.Strip(content);

            foreach (Match match in Regex.Matches(stripped, @"\s*u?sp_\S*", RegexOptions.Multiline | RegexOptions.IgnoreCase))
            {
                result.Calls.Add(
                    new StoredProcedureCall
                {
                    Name = match.ToString().Trim('\r', '\n', '"', ' '),
                });
            }
        }
Exemplo n.º 4
0
        public override void Analyze(string content, FormResult result)
        {
            var stripped = FoxUtil.Strip(content);

            foreach (Match match in Regex.Matches(stripped, @"do\s+form\s+(\S+)(.*)$", RegexOptions.Multiline | RegexOptions.IgnoreCase))
            {
                result.Calls.Add(
                    new FormCall
                {
                    Callee   = match.Groups[1].ToString().Trim(),
                    Params   = match.Groups[2].ToString().Trim(),
                    FullText = match.Groups[0].ToString().Trim()
                });
            }
        }
Exemplo n.º 5
0
        public override void Process(string file)
        {
            var result = new FormResult {
                Name = Path.GetFileName(file), Path = file, Calls = new List <FormCall>()
            };

            var extension = Path.GetExtension(file);

            if (extension == ".prg" || extension == ".h")
            {
                this.Analyze(File.ReadAllText(file), result);
            }
            else
            {
                var processor = new Processor <FormResult>();
                processor.Process(file, this, result);
            }

            if (file.EndsWith(".scx"))
            {
                result.Caption             = FoxUtil.GetProperty(file, "form", "Caption");
                this.captions[result.Name] = result.Caption;
            }

            var basename = Path.GetFileNameWithoutExtension(result.Name);

            foreach (var call in result.Calls)
            {
                this.outFile.WriteLine(
                    basename,
                    result.Caption,
                    call.Callee,
                    this.GetCaption(call.Callee + ".scx"),
                    call.Params,
                    call.FullText,
                    result.IsError,
                    result.ErrorMessage);
            }
        }