Ejemplo n.º 1
0
        public ActionResult Overview()
        {
            ViewBag.Title = "Metrics Overview";
            OverviewViewModel model = new OverviewViewModel();

            model.Sessions       = MetricsRepo.Sessions;
            model.Visitors       = MetricsRepo.VisitorCount;
            model.LastDeployment = MetricsRepo.LastDeployment;

            foreach (Session session in model.Sessions)
            {
                foreach (Page pageLoad in session.PageLoads)
                {
                    if (!model.PageLoads.Any(page => page.Page.Equals(pageLoad)))
                    {
                        model.PageLoads.Add(new PageMetrics {
                            Page = pageLoad, Loads = 1
                        });
                    }
                    else
                    {
                        PageMetrics page = model.PageLoads.Where(metric => metric.Page.Equals(pageLoad)).FirstOrDefault();
                        if (page != null)
                        {
                            page.Loads = ++page.Loads;
                        }
                    }
                }
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public override void Load(XElement root)
        {
            base.Load(root);

            XNamespace ns     = root.GetDefaultNamespace();
            XElement   header = root.Element(ns + "Header")?.Element(ns + "GroupLayout");

            if (header != null)
            {
                _headerLayout = new GroupLayout(_generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition);
                _headerLayout.Load(header);
                _headerLayout.SetAsHeaderOf(this);
            }
            XElement footer = root.Element(ns + "Footer")?.Element(ns + "GroupLayout");

            if (footer != null)
            {
                _footerLayout = new GroupLayout(_generator, _trackingInfo.LineNumber, _trackingInfo.LinePosition);
                _footerLayout.Load(footer);
                _footerLayout.SetAsFooterOf(this);
            }

            PageMetrics metrics = _generator.ReportDesign.LoadPageMetrics(root.Element(ns + "PageMetrics"));

            if (metrics == null)
            {
                throw new System.InvalidOperationException($"ChapterLayout page metrics is null at {_trackingInfo}.");
            }
            _mediaBox = new Rectangle
            {
                Left   = metrics.MediaBoxLeft,
                Bottom = metrics.MediaBoxBottom,
                Right  = metrics.MediaBoxRight,
                Top    = metrics.MediaBoxTop
            };
            _bodyBox = new Rectangle
            {
                Left   = metrics.BodyBoxLeft,
                Bottom = metrics.BodyBoxBottom,
                Right  = metrics.BodyBoxRight,
                Top    = metrics.BodyBoxTop
            };
            _headerBox = new Rectangle
            {
                Left   = metrics.HeaderBoxLeft,
                Bottom = metrics.HeaderBoxBottom,
                Right  = metrics.HeaderBoxRight,
                Top    = metrics.HeaderBoxTop
            };
            _footerBox = new Rectangle
            {
                Left   = metrics.FooterBoxLeft,
                Bottom = metrics.FooterBoxBottom,
                Right  = metrics.FooterBoxRight,
                Top    = metrics.FooterBoxTop
            };

            _bounds = _bodyBox;

            //	Note that the header and footer tables are structured as part of the
            //	page layout, not as content. That is, the page layout has explicit
            //	pointers to the header and footer, and the header and footer layouts
            //	nominate no container. This allows a header or footer
            //	layout to be shared by any number of page layouts.
//			if(src.HeaderLayout != null)
//				_headerLayout = new TableLayout(src.HeaderLayout,generator);
//			if(src.FooterLayout != null)
//				_footerLayout = new TableLayout(src.FooterLayout,generator);

            //	A page layout's page break rules is always null because a page layout always
            //	starts on a new page

            //	Load any background images
            _background = new List <FixedPicture>();
            XElement background = root.Element(ns + "Background");

            if (background != null)
            {
                foreach (XElement pictureElement in background.Elements(ns + "Picture"))
                {
                    //	The picture can be specified either with an explicit filename or with
                    //	a reference to a resource
                    string filename   = _generator.ReportDesign.LoadString(pictureElement.Attribute("filename"));
                    string resourceId = _generator.ReportDesign.LoadString(pictureElement.Attribute("ref"));

                    int left   = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Left")) ?? 0;
                    int bottom = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Bottom")) ?? 0;
                    int right  = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Right")) ?? 0;
                    int top    = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Top")) ?? 0;

                    PictureAlignment alignment = _generator.ReportDesign.LoadEnum <PictureAlignment>(pictureElement.Element(ns + "Alignment"));
                    PictureScaleMode scalemode = _generator.ReportDesign.LoadEnum <PictureScaleMode>(pictureElement.Element(ns + "ScaleMode"));
                    int quality = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Quality")) ?? 0;

                    FixedPicture picture = new FixedPicture(resourceId, filename, left, bottom, right, top, alignment, scalemode, quality);
                    _background.Add(picture);
                }
            }

            //	Load any overlay images
            _overlays = new List <FixedPicture>();
            XElement overlay = root.Element(ns + "Overlay");

            if (overlay != null)
            {
                foreach (XElement pictureElement in overlay.Elements(ns + "Picture"))
                {
                    //	The picture can be specified either with an explicit filename or with
                    //	a reference to a resource
                    string filename   = _generator.ReportDesign.LoadString(pictureElement.Attribute("filename"));
                    string resourceId = _generator.ReportDesign.LoadString(pictureElement.Attribute("ref"));

                    int left   = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Left")) ?? 0;
                    int bottom = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Bottom")) ?? 0;
                    int right  = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Right")) ?? 0;
                    int top    = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Top")) ?? 0;

                    PictureAlignment alignment = _generator.ReportDesign.LoadEnum <PictureAlignment>(pictureElement.Element(ns + "Alignment"));
                    PictureScaleMode scalemode = _generator.ReportDesign.LoadEnum <PictureScaleMode>(pictureElement.Element(ns + "ScaleMode"));
                    int quality = _generator.ReportDesign.LoadInt(pictureElement.Element(ns + "Quality")) ?? 0;

                    FixedPicture picture = new FixedPicture(resourceId, filename, left, bottom, right, top, alignment, scalemode, quality);
                    _overlays.Add(picture);
                }
            }

            _drawRules   = _generator.ReportDesign.LoadBoolean(root.Attribute("drawRules")) ?? false;
            _renderEmpty = _generator.ReportDesign.LoadBoolean(root.Attribute("renderEmpty")) ?? false;
        }