Exemplo n.º 1
0
 public ReportParameter(string name, ReportParameterType type, object value = null)
     : this()
 {
     Name          = name;
     ParameterType = type;
     AddValue(value);
 }
Exemplo n.º 2
0
 public NParameterValue(string label, string name, string value, ReportParameterType parameterType, bool useDefault)
 {
     _label = label;
     _name = name;
     _value = value;
     _parameterType = parameterType;
     _useDefault = useDefault;
 }
Exemplo n.º 3
0
 public ReportParameter(
     string name, string caption,
     ReportParameterType type,
     string sql)
 {
     this.name    = name;
     this.caption = caption;
     this.type    = type;
     this.sql     = sql;
 }
Exemplo n.º 4
0
 public ReportParameter(
     string name, string caption,
     ReportParameterType type,
     string sql, string groupName,
     string comparedExpression, string sections)
     : this(name, caption, type, sql)
 {
     this.groupName            = groupName;
     this.comparisonExpression = comparedExpression;
     this.tables = new List <string>(sections.Split(';'));
 }
Exemplo n.º 5
0
 public static void AddParameters(ReportParametersType pParams, string[] pParameterNames)
 {
     foreach (string pName in pParameterNames)
     {
         ReportParameterType param = new ReportParameterType(pName);
         param.DataType   = DataTypeEnum.String;
         param.Nullable   = true;
         param.AllowBlank = true;
         param.Prompt     = param.Name;
         pParams.Add(param);
     }
 }
        public NReportParameter(ReportParameter reportParameter)
        {
            Prompt = reportParameter.Prompt;
            Name = reportParameter.Name;
            MultiValue = reportParameter.MultiValue;
            MultiValueSpecified = reportParameter.MultiValueSpecified;
            AllowBlank = reportParameter.AllowBlank;

            switch (reportParameter.Type)
            {
                case ParameterTypeEnum.Boolean:
                    _parameterType = ReportParameterType.Boolean;
                    break;
                case ParameterTypeEnum.DateTime:
                    _parameterType = ReportParameterType.DateTime;
                    break;
                case ParameterTypeEnum.Float:
                    _parameterType = ReportParameterType.Float;
                    break;
                case ParameterTypeEnum.Integer:
                    _parameterType = ReportParameterType.Integer;
                    break;
                case ParameterTypeEnum.String:
                    _parameterType = ReportParameterType.String;
                    break;
            }

            if (reportParameter.ValidValues != null)
            {
                foreach (ValidValue vv in reportParameter.ValidValues)
                {
                    _validValues.Add(new NValidValue(vv));
                }
            }

            if (reportParameter.Dependencies != null)
            {
                foreach (string dep in reportParameter.Dependencies)
                {
                    _dependencies.Add(dep);
                }
            }

            if (reportParameter.DefaultValues != null)
            {
                foreach (string def in reportParameter.DefaultValues)
                {
                    _defaultValues.Add(def);
                }
            }
        }
Exemplo n.º 7
0
 public void Add(string name, ReportParameterType type, object value)
 {
     _parameters.Add(new ReportParameter(name, type, value));
 }
Exemplo n.º 8
0
        private List <ReportParameter> ParseParameters(string paramsText, ref bool isDesignedReport)
        {
            var       result    = new List <ReportParameter>();
            XDocument paramsDoc = null;

            try
            {
                paramsDoc = XDocument.Parse(paramsText);
            }
            catch (Exception)
            {
                // workaround: Data at the root level is invalid. Line 1, position 1
                string byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
                if (paramsText.StartsWith(byteOrderMarkUtf8))
                {
                    paramsText = paramsText.Remove(0, byteOrderMarkUtf8.Length);
                }
                paramsDoc = XDocument.Parse(paramsText);
            }

            XElement firstElement = paramsDoc.Root.Elements("panel").FirstOrDefault();

            isDesignedReport = firstElement != null?firstElement.Attribute("sections") != null : false;

            foreach (XElement el in paramsDoc.Root.Elements("panel"))
            {
                XAttribute sqlAttr  = el.Attribute("sql");
                string     typeText = el.Attribute("type").Value;
                if (string.IsNullOrEmpty(typeText))
                {
                    if (isDesignedReport)
                    {
                        result.Add(new ReportParameter(null, el.Attribute("title").Value, ReportParameterType.Unknown, null));
                    }
                    continue;
                }

                var    groupNameAttribute = el.Attribute("groupName");
                string groupName          = isDesignedReport && groupNameAttribute != null ? groupNameAttribute.Value : null;
                string comparedExpr       = isDesignedReport ? el.Attribute("define").Value : null;
                string sections           = isDesignedReport ? el.Attribute("sections").Value : null;

                ReportParameterType pType = ReportParameter.ParseParameterType(typeText);
                if (pType == ReportParameterType.Unknown)
                {
                    throw new InvalidOperationException(string.Format("Неизвестный тип параметра: {0}", typeText));
                }

                // В мастере отчетов заменяем текстовый тип на текст с вариантами
                if (isDesignedReport && pType == ReportParameterType.Text)
                {
                    pType = ReportParameterType.VarText;
                }

                var parameter = isDesignedReport ?
                                new ReportParameter(
                    el.Attribute("name").Value,
                    el.Attribute("title").Value,
                    pType, sqlAttr != null ? el.Attribute("sql").Value : null, groupName, comparedExpr, sections) :
                                new ReportParameter(
                    el.Attribute("name").Value,
                    el.Attribute("title").Value,
                    pType, sqlAttr != null ? el.Attribute("sql").Value : null);

                result.Add(parameter);
            }

            return(result);
        }