Ejemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Loads sub reports.
        /// </summary>
        /// <param name="nodeReport">Report node.</param>
        /// <returns>Readed subreports collection.</returns>
        private ICollection <SubReportInfo> _LoadSubReports(XmlNode nodeReport)
        {
            List <SubReportInfo> subReports = new List <SubReportInfo> ();

            foreach (XmlNode node in nodeReport.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue; // skip comments and other non element nodes
                }
                if (!node.Name.Equals(NODE_NAME_SUBREPORTS, StringComparison.OrdinalIgnoreCase))
                {
                    continue; // NOTE: skip not supported
                }
                foreach (XmlNode subReportNode in node.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue; // skip comments and other non element nodes
                    }
                    if (subReportNode.Name.Equals(NODE_NAME_SUBREPORT, StringComparison.OrdinalIgnoreCase))
                    {
                        string template = subReportNode.Attributes[ATTRIBUTE_NAME_FILEPATH].Value;

                        if (File.Exists(ReportsGenerator.GetTemplateAbsolutelyPath(template)))
                        {
                            string name      = subReportNode.Attributes[ATTRIBUTE_NAME_NAME].Value;
                            bool   isDefault = false;
                            if (null != subReportNode.Attributes[ATTRIBUTE_NAME_DEFAULT])
                            {
                                isDefault = bool.Parse(subReportNode.Attributes[ATTRIBUTE_NAME_DEFAULT].Value);
                            }
                            string groupId = null;
                            if (null != subReportNode.Attributes[ATTRIBUTE_NAME_GROUPID])
                            {
                                groupId = subReportNode.Attributes[ATTRIBUTE_NAME_GROUPID].Value;
                            }
                            bool isVisible = true; // default is visible state
                            if (null != subReportNode.Attributes[ATTRIBUTE_NAME_VISIBLE])
                            {
                                isVisible = bool.Parse(subReportNode.Attributes[ATTRIBUTE_NAME_VISIBLE].Value);
                            }

                            string        description = _LoadDescription(subReportNode);
                            SubReportInfo subInfo     = new SubReportInfo(name, template, description,
                                                                          isDefault, groupId, isVisible);
                            subReports.Add(subInfo);
                        }
                    }
                    else
                    {
                        Debug.Assert(false); // NOTE: not supported
                    }
                }
            }

            return(subReports.AsReadOnly());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads report structure.
        /// </summary>
        /// <param name="templatePath">Report template path.</param>
        /// <returns>Created and inited report core.</returns>
        private ActiveReport3 _LoadReportStructure(string templatePath)
        {
            Debug.Assert(!string.IsNullOrEmpty(templatePath));

            // load report structure
            var rpt = new ActiveReport3();

            rpt.Document.CacheToDisk         = true;
            rpt.Document.CacheToDiskLocation = GetTempFullFileName();

            string filePath =
                ReportsGenerator.GetTemplateAbsolutelyPath(templatePath);

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                rpt.LoadLayout(fs);

            return(rpt);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads report template.
        /// </summary>
        /// <param name="nodeReport">Report template node.</param>
        /// <param name="isPredefined">Is predefined flag.</param>
        /// <returns>Report template info.</returns>
        private ReportInfo _LoadTemplate(XmlNode nodeReport, bool isPredefined)
        {
            ReportInfo info = null;

            try
            {
                string template = nodeReport.Attributes[ATTRIBUTE_NAME_FILEPATH].Value;
                if (File.Exists(ReportsGenerator.GetTemplateAbsolutelyPath(template)))
                {
                    string      name        = nodeReport.Attributes[ATTRIBUTE_NAME_NAME].Value;
                    ContextType context     = (ContextType)Enum.Parse(typeof(ContextType), nodeReport.Attributes[ATTRIBUTE_NAME_CONTEXT].Value, true);
                    string      description = _LoadDescription(nodeReport);
                    info = new ReportInfo(name, context, template, description, isPredefined,
                                          _LoadSubReports(nodeReport));
                }
            }
            catch
            {
                info = null;
            }

            return(info);
        }