Пример #1
0
        private Evaluator CreateExpressionEvaluator()
        {
            var meta = new ExpressionMeta("VisualBasic");

            // Expressions
            string expression;

            foreach (var candidate in GetPossibleExpressions())
            {
                if (LocalReportsEngineCommon.IsExpression(candidate, out expression))
                {
                    meta.AddExpression(expression);
                }
            }

            // TODO: Extensions
            var extension = new Extension();

            extension.Name     = "Parameters";
            extension.Instance = new ReadOnlyParameterCollection(ReportParameters);
            meta.AddExtension(extension);

            // TODO: Async compile in Evaluator

            return(meta.Compile());
        }
Пример #2
0
        public object ResolveDataSet(RdlDataSet dataSetElement, bool adhoc)
        {
            var queryElement = dataSetElement.Query;

            if (queryElement == null)
            {
                return(null);
            }

            var transactional = !adhoc && IsTransactional;
            var command       = (transactional ? TransactionConnection : AdHocConnection).CreateCommand();

            command.CommandType    = GetCommandType(queryElement.CommandType);
            command.CommandText    = queryElement.CommandText;
            command.CommandTimeout = GetCommandTimeout(queryElement.Timeout);
            command.Transaction    = transactional ? Transaction : null;

            foreach (var parameterElement in queryElement.QueryParameters)
            {
                var parameter = command.CreateParameter();
                parameter.ParameterName = parameterElement.Name;
                var value = LocalReportsEngineCommon.PhraseToValue(ReportMeta, RdlDataTypeEnum.String,
                                                                   parameterElement.Value);
                parameter.Value = value;

                command.Parameters.Add(parameter);
            }

            using (var reader = command.ExecuteReader())
            {
                var dataTable = new DataTable();
                dataTable.Load(reader);
                return(dataTable);
            }
        }
Пример #3
0
        private void ReportParameters_Resolve(object sender, ResolvableEventArgs <string, ReportParameter> args)
        {
            // Prompt the consumer first

            var reportParameterElement =
                ReportElement.ReportParameters.First(rp => rp.Name.SafeEqualsIgnoreCase(args.ResolvingKey));

            args.ResolvedItem = LocalReportsEngineCommon.ElementToObject(reportParameterElement, this);
            args.IsResolved   = true;
        }
Пример #4
0
        private void DataSources_Resolve(object sender, ResolvableEventArgs <string, IResolvedDataSource> args)
        {
            // Prompt the user first

            var dataSourceElement =
                ReportElement.DataSources.First(ds => ds.Name.SafeEqualsIgnoreCase(args.ResolvingKey));

            args.ResolvedItem = LocalReportsEngineCommon.ElementToObject(dataSourceElement, this);
            args.IsResolved   = true;

            // We need to kick off this event, if the ds was resolved while the report was being refreshed
            if (IsReportRefreshing)
            {
                args.ResolvedItem.OnReportRefreshing();
            }
        }
Пример #5
0
        public void Initialize(RdlDataSource dataSourceElement, ReportMeta reportMeta)
        {
            DataSourceElement = dataSourceElement;
            ReportMeta        = reportMeta;
            IsTransactional   = LocalReportsEngineCommon.StringToBool(dataSourceElement.Transaction);

            string factoryName;

            lock (DbFactoryNames)
                if (!DbFactoryNames.TryGetValue(dataSourceElement.ConnectionProperties.DataProvider, out factoryName))
                {
                    throw new ArgumentOutOfRangeException("dataSourceElement",
                                                          "ConnectionProperties.DataProvider is unknown");
                }

            var providerFactory  = DbProviderFactories.GetFactory(factoryName);
            var connectionString = CreateConnectionString(dataSourceElement, providerFactory);

            AdHocConnection       = CreateConnection(providerFactory, connectionString);
            TransactionConnection = IsTransactional ? CreateConnection(providerFactory, connectionString) : null;
        }
        private IEnumerable <Microsoft.Reporting.WinForms.ReportParameter> GetParameters()
        {
            foreach (var parameterElement in CurrentReportMeta.ReportElement.ReportParameters)
            {
                var parameter         = new Microsoft.Reporting.WinForms.ReportParameter(parameterElement.Name);
                var resolvedParameter = CurrentReportMeta.ReportParameters[parameter.Name];

                if (resolvedParameter.MultiValue)
                {
                    foreach (var value in (object[])resolvedParameter.Value)
                    {
                        parameter.Values.Add(LocalReportsEngineCommon.ValueToString(value, resolvedParameter.DataType));
                    }
                }
                else
                {
                    parameter.Values.Add(LocalReportsEngineCommon.ValueToString(resolvedParameter.Value, resolvedParameter.DataType));
                }

                yield return(parameter);
            }
        }
Пример #7
0
        public static ReportMeta Load(Stream stream)
        {
            var reportElement = LocalReportsEngineCommon.DeserializeReport(stream);

            return(new ReportMeta(reportElement));
        }