Example #1
0
        public void Build()
        {
            if (!isSetup)
            {
                throw new InvalidOperationException();
            }

            var connectionString  = queryXml.GetConnectionString();
            var parameters        = BuildParameters(queryXml.GetParameters());
            var templateVariables = queryXml.GetTemplateVariables();
            var timeout           = queryXml.Timeout;

            if (!string.IsNullOrEmpty(queryXml.InlineQuery))
            {
                args = new EmbeddedQueryResolverArgs(queryXml.InlineQuery
                                                     , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            else if (!string.IsNullOrEmpty(queryXml.File))
            {
                var file = GetFullPath(settingsXml?.BasePath, queryXml.File);

                args = new ExternalFileQueryResolverArgs(file
                                                         , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            else if (queryXml.Assembly != null)
            {
                var file = GetFullPath(settingsXml?.BasePath, queryXml.Assembly.Path);

                args = new AssemblyQueryResolverArgs(
                    file, queryXml.Assembly.Klass, queryXml.Assembly.Method,
                    queryXml.Assembly.Static, queryXml.Assembly.GetMethodParameters()
                    , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            else if (queryXml.Report != null)
            {
                var path = string.IsNullOrEmpty(queryXml.Report.Source) ? settingsXml.BasePath + queryXml.Report.Path : queryXml.Report.Path;

                args = new ReportDataSetQueryResolverArgs(
                    queryXml.Report.Source, path, queryXml.Report.Name, queryXml.Report.Dataset
                    , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            else if (queryXml.SharedDataset != null)
            {
                var path = string.IsNullOrEmpty(queryXml.SharedDataset.Source) ? settingsXml.BasePath + queryXml.SharedDataset.Path : queryXml.SharedDataset.Path;

                args = new SharedDataSetQueryResolverArgs(
                    queryXml.SharedDataset.Source, queryXml.SharedDataset.Path, queryXml.SharedDataset.Name
                    , connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            if (args == null)
            {
                throw new ArgumentException();
            }
        }
Example #2
0
 private IQuery BuildQuery(QueryXml queryXml)
 {
     return(new NBi.Core.Query.Query(queryXml.GetQuery(), queryXml.GetConnectionString(), new TimeSpan(0, 0, 0)));
 }