Пример #1
0
        public System.Drawing.Image GetImage(Rdl.Runtime.Context context)
        {
            System.Drawing.Image img = null;
            string name;

            switch (_source)
            {
            case ImageSourceEnum.Database:
                img = System.Drawing.Image.FromStream(new MemoryStream((byte[])_value.Exec(context)));
                break;

            case ImageSourceEnum.Embedded:
                name = _value.ExecAsString(context);
                try
                {
                    EmbeddedImage e = Report.GetEmbeddedImage(name);
                    img = System.Drawing.Image.FromStream(new MemoryStream(e.ImageData));
                }
                catch (Exception err)
                {
                    throw new Exception("Error locating embedded image " + name, err);
                }
                break;

            case ImageSourceEnum.External:
                name = _value.ExecAsString(context);
                try
                {
                    Stream s = null;
                    if (name.Contains("://"))
                    {
                        s = System.Net.HttpWebRequest.Create(name).GetResponse().GetResponseStream();
                    }
                    else
                    {
                        s = new FileStream(name, FileMode.Open, FileAccess.Read);
                    }
                    img = System.Drawing.Image.FromStream(s);
                    s.Close();
                    s.Dispose();
                }
                catch (Exception err)
                {
                    throw new Exception("Error loading image file " + name, err);
                }
                break;
            }

            return(img);
        }
Пример #2
0
        protected override void ParseAttribute(XmlNode attr)
        {
            switch (attr.Name.ToLower())
            {
            case "autorefresh":
                _autoRefresh = int.Parse(attr.InnerText);
                break;

            case "datasources":
                foreach (XmlNode child in attr.ChildNodes)
                {
                    DataSource ds = new DataSource(child, this);
                    _dataSources.Add(ds.Name, ds);
                }
                break;

            case "datasets":
                _dataSets = new DataSets(attr, this);
                break;

            case "body":
                _body = new Body(attr, this);
                break;

            case "reportparameters":
                foreach (XmlElement parm in attr.ChildNodes)
                {
                    ReportParameter param = new ReportParameter(parm, this);
                    _reportParameters.Add(param.Name, param);
                }
                break;

            case "custom":
                break;

            case "width":
                _width = new Size(attr.InnerText);
                break;

            case "pageheader":
                _pageHeader = new PageHeaderFooter(attr, this, PageHeaderFooter.HeaderFooterEnum.Header);
                break;

            case "pagefooter":
                _pageFooter = new PageHeaderFooter(attr, this, PageHeaderFooter.HeaderFooterEnum.Footer);
                break;

            case "pageheight":
                _pageHeight = new Size(attr.InnerText);
                break;

            case "pagewidth":
                _pageWidth = new Size(attr.InnerText);
                break;

            case "interactiveheight":
                _interactiveHeight = new Size(attr.InnerText);
                break;

            case "interactivewidth":
                _interactiveWidth = new Size(attr.InnerText);
                break;

            case "leftmargin":
                _leftMargin = new Size(attr.InnerText);
                break;

            case "rightmargin":
                _rightMargin = new Size(attr.InnerText);
                break;

            case "topmargin":
                _topMargin = new Size(attr.InnerText);
                break;

            case "bottommargin":
                _bottomMargin = new Size(attr.InnerText);
                break;

            case "embeddedimages":
                foreach (XmlNode child in attr.ChildNodes)
                {
                    EmbeddedImage e = new EmbeddedImage(child, this);
                    _embeddedImages.Add(e.Name, e);
                }
                break;

            case "language":
                _language = new Expression(attr, this);
                break;

            case "codemodules":
                foreach (XmlNode child in attr.ChildNodes)
                {
                    _codeModules.Add(child.Attributes[0].InnerText);
                }
                break;

            case "code":
                _code = attr.InnerText;
                break;

            case "classes":
                break;

            case "datatransform":
                break;

            case "dataschema":
                _dataSchema = attr.InnerText;
                break;

            case "dataelementname":
                _dataElementName = attr.InnerText;
                break;

            case "dataelementstyle":
                _dataElementStyle = (DataElementStyleEnum)Enum.Parse(typeof(DataElementStyleEnum), attr.InnerText, true);
                break;

            default:
                break;
            }
        }