Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        protected void Build(QueryXml queryXml)
        {
            queryXml.Settings = Settings;
            var connectionString  = new ConnectionStringHelper().Execute(queryXml, Scope);
            var parameters        = BuildParameters(queryXml.GetParameters());
            var templateVariables = queryXml.GetTemplateVariables();
            var timeout           = Convert.ToInt32(Math.Ceiling(queryXml.Timeout / 1000m)); //Timeout is expressed in milliseconds

            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(Settings?.BasePath, queryXml.File);

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

            else if (queryXml.Assembly != null)
            {
                args = Build(queryXml.Assembly, connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }


            else if (queryXml.Report != null)
            {
                args = Build(queryXml.Report, connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }


            else if (queryXml.SharedDataset != null)
            {
                args = Build(queryXml.SharedDataset, connectionString, parameters, templateVariables, new TimeSpan(0, 0, timeout));
            }

            if (args == null)
            {
                throw new ArgumentException();
            }
        }