English 中文(简体)
Crystal Reports - 搜索依赖
原标题:Crystal Reports - Search Dependencies

是否有一种工具可以让您搜索一些不同的晶体报告, 以查看具体表格/ View/ SP 的用途?

假设情况是:我们有200多份报告, 因此在改变“ 视图或存储程序” 时, 要找到哪些报告会受到影响, 不打开每份报告, 检查“ 数据库专家” 或“ 数据源位置 ”, 并不容易。

我试过Ransack探员查过他们 却不挑桌子 也不看名字

最佳回答

在C#. Net 4.

如果晶体报告使用 SQL 命令而不是拖曳在表格中,它会变得有点棘手。 我建议只搜索表格名称,而不是完全合格的数据库.dbo. TableName - 因为粘贴的 SQL 命令可能忽略了这一点 。

使用量 :

var reports = CrystalExtensions.FindUsages("C:/Reports", "table_name");

代码 :

namespace Crystal.Helpers
{
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using CrystalDecisions.CrystalReports.Engine;
    using Microsoft.CSharp.RuntimeBinder;

    public static class CrystalExtensions
    {
        public static List<string> FindUsages(string directory, string tableName)
        {
            var result = new List<string>();

            foreach (var file in Directory.EnumerateFiles(directory, "*.rpt", SearchOption.AllDirectories))
            {
                using (var report = new ReportClass { FileName = file })
                {
                    if (report.Database == null) continue;

                    var tables = report.Database.Tables.ToList();
                    var hasTable = tables.Any(x => x.Name == tableName || x.GetCommandText().Contains(tableName));

                    if (hasTable)
                        result.Add(file);
                }
            }

            return result;
        }

        public static List<Table> ToList(this Tables tables)
        {
            var list = new List<Table>();
            var enumerator = tables.GetEnumerator();

            while (enumerator.MoveNext())
                list.Add((Table)enumerator.Current);

            return list;
        }

        public static string GetCommandText(this Table table)
        {
            var propertyInfo = table.GetType().GetProperty("RasTable", BindingFlags.NonPublic | BindingFlags.Instance);

            try
            {
                return ((dynamic)propertyInfo.GetValue(table, propertyInfo.GetIndexParameters())).CommandText;
            }
            catch (RuntimeBinderException)
            {
                return ""; // for simplicity of code above, really should return null
            }
        }
    }
}

希望有帮助!

问题回答

See the question here: Any way to search inside a Crystal Report

另一个选择是滚动自己的软件来完成它,但这可能比你想的要耗费更多时间。或者找到一个已经这样做的人:如果你找到有效的东西,让我们知道,因为我们都在同一条船上。祝你好运!





相关问题
How to structure files / dependencies in Visual C++ project

This is more of a design question than a C++ question. I m working on a Texas Hold Em poker game in C++. So far, I have a HandChecker module written that is responsible for determining a player s ...

draw dependency graph for a java class

Heyho, I m searching for a tool like JDepend to draw a graph for a java classfile. JDepend seams to be fine, but it s not resolving the deps from the deps (maybe I m just missing some special options?)...

How to use the -MG flag in cc 4.4.1?

I ve recently upgraded my Ubuntu installation from Jaunty to Karmic. This apparently includes an update of the GNU C compiler, because code that compiled previously no longer does. Running cc 4.4.1 (...

How to manually disable/blacklist Maven repository

In my base project I use dependency of JasperReports which has non-existent repository declaration in its pom. When I run every Maven commad there is dependency looking for commons-collection in this ...

Batch Job Dependencies Using Open Source/Free Software

I run a large data warehouse plant where we have a lot of nightly jobs running concerruently however many have dependencies on a extract or data load process before they start. Currently we use an ...

热门标签