Esempio n. 1
0
        /// <summary>
        /// Render the header of document
        /// </summary>
        /// <param name="header"></param>
        /// <param name="document"></param>
        /// <param name="mainDocumentPart"></param>
        /// <param name="context"></param>
        /// <param name="formatProvider"></param>
        public static void Render(this Models.Header header, Models.Document document, MainDocumentPart mainDocumentPart, ContextModel context, IFormatProvider formatProvider)
        {
            var headerPart = mainDocumentPart.AddNewPart <HeaderPart>();

            headerPart.Header = new Header();

            foreach (var element in header.ChildElements)
            {
                element.InheritFromParent(header);
                element.Render(document, headerPart.Header, context, headerPart, formatProvider);
            }

            string headerPartId = mainDocumentPart.GetIdOfPart(headerPart);

            if (!mainDocumentPart.Document.Body.Descendants <SectionProperties>().Any())
            {
                mainDocumentPart.Document.Body.AppendChild(new SectionProperties());
            }
            foreach (var section in mainDocumentPart.Document.Body.Descendants <SectionProperties>())
            {
                section.PrependChild(new HeaderReference()
                {
                    Id = headerPartId, Type = (DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues)(int) header.Type
                });
            }

            if (header.Type == HeaderFooterValues.First)
            {
                mainDocumentPart.Document.Body.Descendants <SectionProperties>().First().PrependChild(new TitlePage());
            }
        }
Esempio n. 2
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            SizeUp.Core.API.APISession.Create();
            var data = new Models.Header();

            CurrentInfo = new Core.DataLayer.Models.CurrentInfo();
            CurrentInfo.CurrentIndustry       = WebContext.Current.CurrentIndustry;
            CurrentInfo.CurrentPlace          = WebContext.Current.CurrentPlace;
            CurrentInfo.CurrentBusinessStatus = WebContext.Current.CurrentBusinessStatus;

            ViewBag.CurrentInfo     = CurrentInfo;
            ViewBag.CurrentInfoJSON = Serializer.ToJSON(CurrentInfo);
            ViewBag.Header          = data;


            SizeUp.Core.Analytics.PageViewToken t = new Core.Analytics.PageViewToken();
            t.IndustryId = WebContext.Current.CurrentIndustry != null ? WebContext.Current.CurrentIndustry.Id : (long?)null;
            var currentPlace = WebContext.Current.CurrentPlace;

            if (currentPlace.Id != null)
            {
                t.GeographicLocationId = currentPlace.Id;
            }
            else if (currentPlace.County != null && currentPlace.County.Id != null)
            {
                t.GeographicLocationId = currentPlace.County.Id;
            }
            else if (currentPlace.Metro != null && currentPlace.Metro.Id != null)
            {
                t.GeographicLocationId = currentPlace.Metro.Id;
            }
            else if (currentPlace.State != null && currentPlace.State.Id != null)
            {
                t.GeographicLocationId = currentPlace.State.Id;
            }
            ViewBag.TrackingToken = Server.UrlEncode(t.GetToken());
        }