private IReport FindReportByServerPath(string path, bool proxy)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("Report path cannot be null or empty");
            }

            Serialization.ReportCenterMetadata metadata = Serialization.Metadata.Instance.Cache;

            IReport report = null;

            foreach (Serialization.Report xmlReport in metadata.Reports)
            {
                if (xmlReport.ReportProcessingLocation.ServerReport != null)
                {
                    if (xmlReport.ReportProcessingLocation.ServerReport.Path.Equals(path))
                    {
                        report = LoadReport(xmlReport, proxy);
                        break;
                    }
                }
            }

            if (report == null)
            {
                throw new ReportNotFoundException("No such report: " + path);
            }

            return(report);
        }
        public override IReportTreeNode BuildReportTree(ReportType reportType, int businessUnitId)
        {
            Serialization.ReportCenterMetadata metadata = Serialization.Metadata.Instance.Cache;

            Serialization.PanelType panelType;

            if (reportType == ReportType.Dealer)
            {
                panelType = Serialization.PanelType.Dealer;
            }
            else
            {
                panelType = Serialization.PanelType.DealerGroup;
            }

            IReportTreeNode root = null;

            foreach (Serialization.Panel panel in metadata.Panels)
            {
                if (!panel.PanelType.Equals(panelType))
                {
                    continue;
                }

                root = Copy(panel.Node, businessUnitId);

                break;
            }

            return(root);
        }
        private IReport FindReport(string id, bool proxy)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("Report ID cannot be null or empty");
            }

            Serialization.ReportCenterMetadata metadata = Serialization.Metadata.Instance.Cache;

            IReport report = null;

            foreach (Serialization.Report xmlReport in metadata.Reports)
            {
                if (xmlReport.Id.Equals(id))
                {
                    report = LoadReport(xmlReport, proxy);
                    break;
                }
            }

            if (report == null)
            {
                throw new ReportNotFoundException("No such report: " + id);
            }

            return(report);
        }
        private bool IsAuthorized(string idref, int businessUnitId)
        {
            Serialization.ReportCenterMetadata metadata = Serialization.Metadata.Instance.Cache;

            bool foundReport = false;

            bool authorized = false;

            foreach (Serialization.Report xmlReport in metadata.Reports)
            {
                if (!xmlReport.Id.Equals(idref))
                {
                    continue;
                }

                foundReport = true;

                if (xmlReport.Authorization == null)
                {
                    authorized = true;
                }
                else
                {
                    Acl <string> acl = new Acl <string>();

                    int i = 0, j = xmlReport.Authorization.Items.Length;

                    for (; i < j; i++)
                    {
                        string value = xmlReport.Authorization.Items[i];

                        switch (xmlReport.Authorization.ItemsElementName[i])
                        {
                        case Serialization.ItemsChoiceType.Allow:
                            acl.Install(AceType.Allow, new StringAce(value));
                            break;

                        case Serialization.ItemsChoiceType.Deny:
                            acl.Install(AceType.Deny, new StringAce(value));
                            break;
                        }
                    }

                    authorized = acl.Allow(businessUnitId.ToString());
                }
            }

            if (!foundReport)
            {
                throw new ReportNotFoundException(idref);
            }

            return(authorized);
        }
        public override IReportTreeNode BuildReportTree(string id, int businessUnitId)
        {
            Serialization.ReportCenterMetadata metadata = Serialization.Metadata.Instance.Cache;

            IReportTreeNode root = null;

            foreach (Serialization.Panel panel in metadata.Panels)
            {
                Serialization.Node node = FindNode(panel.Node, id);

                if (node != null)
                {
                    root = Copy(node, businessUnitId);
                    break;
                }
            }

            return(root);
        }