protected virtual XElement CreateVariable(PrintContext printContext, bool skipNumber, bool emptyNumber)
        {
            Item     renderingItem = this.RenderingItem;
            XElement xelement      = RenderItemHelper.CreateXElement("Variable", renderingItem, printContext.Settings.IsClient, (Item)null, true);

            if (renderingItem.Fields["Find"] != null && renderingItem.Fields["Replace"] != null)
            {
                if (printContext.Settings.IsClient && renderingItem.Fields["PageXML"] != null)
                {
                    XElementExtensions.AddInnerXml(xelement, renderingItem.Fields["PageXML"].Value, false);
                }

                var findElement = new XElement("Find", (object)renderingItem["Find"]);
                xelement.Add(findElement);

                if (printContext.Settings.Parameters.ContainsKey("Variables") &&
                    (SafeDictionary <string, object>)printContext.Settings.Parameters["Variables"] != null)
                {
                    var variables      = (SafeDictionary <string, object>)printContext.Settings.Parameters["Variables"];
                    var variable       = variables.FirstOrDefault(v => v.Key == (string)renderingItem["Find"]);
                    var replaceElement = new XElement("Replace", (object)variable.Value);
                    xelement.Add(replaceElement);
                }
                else
                {
                    var replaceElement = new XElement("Replace", (object)renderingItem["Replace"]);
                    xelement.Add(replaceElement);
                }
            }

            return(xelement);
        }
Exemplo n.º 2
0
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            XElement baseXml = new XElement("base");

            base.RenderContent(printContext, baseXml);

            XElement textFrame = baseXml.Element("TextFrame");
            Item     dataItem  = GetDataItem(printContext);

            XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem);

            this.SetAttributes(xElement);

            output.Add(xElement);

            XAttribute xAttribute = output.Attribute("ParagraphStyle");
            string     text       = (xAttribute != null && !string.IsNullOrEmpty(xAttribute.Value)) ? xAttribute.Value : "NormalParagraphStyle";

            Field     fieldname = dataItem.Fields[this.ContentFieldName];
            DateField dateField = fieldname;

            string dateoutput = dateField.DateTime.ToString(Format);

            IEnumerable <XElement> result = this.FormatText(text, dateoutput);

            xElement.Add(result);

            this.RenderChildren(printContext, xElement);
        }
Exemplo n.º 3
0
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            if (ScriptHelper.ExecuteScriptReference(printContext, this.RenderingItem, this.GetDataItem(printContext), output))
            {
                return;
            }
            bool flag = !SitecoreHelper.HasScriptItemAssigned(this.RenderingItem) && !SitecoreHelper.HasMergeItemAssigned(this.RenderingItem);

            if (flag && string.IsNullOrEmpty(this.ContentFieldName))
            {
                Item obj = this.RenderingItem.Children.FirstOrDefault <Item>((Func <Item, bool>)(c => c.TemplateName.Equals("p_text", StringComparison.InvariantCultureIgnoreCase)));
                if (obj != null && obj.Fields[printContext.Settings.StaticTextFieldName] != null)
                {
                    this.DataSource       = obj.ID.ToString();
                    this.ContentFieldName = printContext.Settings.StaticTextFieldName;
                    this.RenderDeep       = false;
                }
            }
            Item     dataItem = this.GetDataItem(printContext);
            XElement xelement = RenderItemHelper.CreateXElement("TextFrame", this.RenderingItem, printContext.Settings.IsClient, dataItem);

            this.SetAttributes(xelement);
            IEnumerable <XElement> xelements = (IEnumerable <XElement>)null;

            if (flag)
            {
                xelements = this.GetContent(printContext, xelement);
            }
            output.Add((object)xelement);
            xelement.Add((object)xelements);
            this.RenderChildren(printContext, xelement);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Begins the render.
        /// </summary>
        /// <param name="printContext">The print context.</param>
        /// <summary>
        /// Renders the content.
        /// </summary>
        /// <param name="printContext">The print context.</param>
        /// <param name="output">The output.</param>
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            XElement imageNode     = RenderItemHelper.CreateXElement("Image", this.RenderingItem, printContext.Settings.IsClient, null);
            string   imageFilePath = string.Empty;

            Item contentItem = this.GetDataItem(printContext);

            string ExternalID = contentItem[this.FieldName];

            if (contentItem != null && !string.IsNullOrEmpty(this.baseUrl))
            {
                try
                {
                    string url = this.GenerateQrCodeUrl(this.baseUrl, this.path, ExternalID);
                    imageFilePath = ImageRendering.CreateQrOnServer(printContext.Settings, this.RenderingItem, url);
                    string qrcodeFilePath = this.GetQrImageFilePath(contentItem, printContext.Settings);

                    File.Copy(imageFilePath, qrcodeFilePath, true);
                    imageFilePath = qrcodeFilePath;
                }
                catch (Exception exc)
                {
                    Log.Error(exc.Message, this);
                    imageFilePath = string.Empty;
                }
            }

            imageFilePath = printContext.Settings.FormatResourceLink(imageFilePath);

            imageNode.SetAttributeValue("LowResSrc", imageFilePath);
            imageNode.SetAttributeValue("HighResSrc", imageFilePath);

            output.Add(imageNode);
            this.RenderChildren(printContext, imageNode);
        }
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            Item     dataItem = this.GetDataItem(printContext);
            XElement xElement = RenderItemHelper.CreateXElement("ImageFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem);

            xElement.SetAttributeValue("SitecoreFieldname", base.RenderingItem["item field"]);
            xElement.SetAttributeValue("SitecoreMediaID", base.RenderingItem["medialibrary reference"]);
            xElement.SetAttributeValue("ItemReferenceID", base.RenderingItem["item reference"]);
            xElement.SetAttributeValue("RenderingID", base.RenderingItem["xml renderer"]);
            xElement.SetAttributeValue("ItemReferenceDisplayName", (dataItem != null) ? dataItem.DisplayName : string.Empty);
            output.Add(xElement);
            this.RenderChildren(printContext, xElement);
        }
Exemplo n.º 6
0
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            XElement baseXml = new XElement("base");

            base.RenderContent(printContext, baseXml);

            XElement textFrame = baseXml.Element("TextFrame");
            Item     dataItem  = GetDataItem(printContext);

            XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem);

            this.SetAttributes(xElement);

            output.Add(xElement);

            XAttribute xAttribute = output.Attribute("ParagraphStyle");
            string     text       = (RenderingItem["ParagraphStyle"].ToString() != null) ? RenderingItem["ParagraphStyle"].ToString() : "H1 Orange";

            string fieldtype = dataItem.Fields[this.ContentFieldName].Type;

            string input      = dataItem.Fields[this.ContentFieldName].ToString();
            string outputtext = "";

            if (fieldtype == "Commerce Decimal Control")
            {
                outputtext = System.Convert.ToDecimal(input).ToString("c");
            }
            else if (fieldtype == "Commerce Read-Only Control")
            {
                outputtext = input;
            }
            else
            {
                // No transformation
                outputtext = input;
            }
            //var price = response.Prices.ContainsKey(ListPriceKey) ? response.Prices[ListPriceKey].Amount : decimal.Zero;

            //var price = this.pricingService.GetProductPrice("11");

            IEnumerable <XElement> result = this.FormatText(text, outputtext);

            xElement.Add(result);

            this.RenderChildren(printContext, xElement);
        }
Exemplo n.º 7
0
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            XElement baseXml = new XElement("base");

            base.RenderContent(printContext, baseXml);

            XElement textFrame = baseXml.Element("TextFrame");
            Item     dataItem  = GetDataItem(printContext);

            XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem);

            this.SetAttributes(xElement);

            output.Add(xElement);

            XAttribute xAttribute = output.Attribute("ParagraphStyle");

            string ParagraphStyle = base.RenderingItem["ParagraphStyle"];

            int     ContentLength         = dataItem.Fields[this.ContentFieldName].ToString().Length;
            decimal textFrameWidthDecimal = Convert.ToDecimal(base.RenderingItem["Width"].ToString());
            int     textFrameWidthInt     = Convert.ToInt32(textFrameWidthDecimal);

            XElement format = RenderItemHelper.CreateXElement("Format", base.RenderingItem, printContext.Settings.IsClient);

            int fontsize = textFrameWidthInt / ContentLength;

            fontsize = fontsize * 5;
            string fontsizeattrib = fontsize.ToString();

            format.SetAttributeValue("FontSize", fontsizeattrib);

            format.SetValue(dataItem.Fields[this.ContentFieldName].ToString());

            XElement result = RenderItemHelper.CreateXElement("ParagraphStyle", base.RenderingItem, printContext.Settings.IsClient);

            result.SetAttributeValue("Style", ParagraphStyle);

            result.Add(format);

            xElement.Add(result);

            this.RenderChildren(printContext, xElement);
        }
Exemplo n.º 8
0
        protected virtual XElement CreateImageElement(HtmlNode htmlNode, Item mediaContentItem, ParseContext parseContext, string width, string height)
        {
            XElement        xelement   = RenderItemHelper.CreateXElement("Image", ((TemplateItem)parseContext.Database.GetItem(WebConfigHandler.PrintStudioEngineSettings.EngineTemplates + "P_Image")).StandardValues, parseContext.PrintOptions.IsClient, (Item)null);
            ParseDefinition definition = parseContext.ParseDefinitions[htmlNode];

            if (definition != null)
            {
                this.SetAttributes(xelement, htmlNode, definition);
            }
            xelement.SetAttributeValue((XName)"Height", (object)height);
            xelement.SetAttributeValue((XName)"Width", (object)width);
            xelement.SetAttributeValue((XName)"SitecoreMediaID", (object)mediaContentItem.ID.Guid.ToString());
            string imageOnServer = ImageRendering.CreateImageOnServer(parseContext.PrintOptions, (MediaItem)mediaContentItem);
            string str           = parseContext.PrintOptions.FormatResourceLink(imageOnServer);

            xelement.SetAttributeValue((XName)"LowResSrc", (object)str);
            xelement.SetAttributeValue((XName)"HighResSrc", (object)str);
            return(xelement);
        }
        protected virtual XElement CreateImageElement(HtmlNode htmlNode, Item mediaContentItem, ParseContext parseContext, string width, string height)
        {
            Item            item            = parseContext.Database.GetItem(WebConfigHandler.PrintStudioEngineSettings.EngineTemplates + "P_Image");
            Item            standardValues  = item.Template.StandardValues;
            XElement        xElement        = RenderItemHelper.CreateXElement("Image", standardValues, parseContext.PrintOptions.IsClient, null);
            ParseDefinition parseDefinition = parseContext.ParseDefinitions[htmlNode];

            if (parseDefinition != null)
            {
                this.SetAttributes(xElement, htmlNode, parseDefinition);
            }
            xElement.SetAttributeValue("Height", height);
            xElement.SetAttributeValue("Width", width);
            xElement.SetAttributeValue("SitecoreMediaID", mediaContentItem.ID.Guid.ToString());
            string text = ImageRendering.CreateImageOnServer(parseContext.PrintOptions, mediaContentItem);

            text = parseContext.PrintOptions.FormatResourceLink(text);
            xElement.SetAttributeValue("LowResSrc", text);
            xElement.SetAttributeValue("HighResSrc", text);
            return(xElement);
        }
Exemplo n.º 10
0
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            string ListPriceKey = "List";

            XElement baseXml = new XElement("base");

            base.RenderContent(printContext, baseXml);

            XElement textFrame = baseXml.Element("TextFrame");
            Item     dataItem  = GetDataItem(printContext);

            XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem);

            this.SetAttributes(xElement);

            output.Add(xElement);

            XAttribute xAttribute = output.Attribute("ParagraphStyle");
            string     text       = (xAttribute != null && !string.IsNullOrEmpty(xAttribute.Value)) ? xAttribute.Value : "H1 Orange";

            Field     fieldname = dataItem.Fields[this.ContentFieldName];
            DateField dateField = fieldname;

            var request  = new GetProductPricesRequest(dataItem["ExternalID"]);
            var response = new PricingServiceProvider();
            var price    = response.GetProductPrices(request).Prices[ListPriceKey].Amount;
            //var price = response.Prices.ContainsKey(ListPriceKey) ? response.Prices[ListPriceKey].Amount : decimal.Zero;

            //var price = this.pricingService.GetProductPrice("11");

            IEnumerable <XElement> result = this.FormatText(text, price.ToString("c"));

            xElement.Add(result);

            this.RenderChildren(printContext, xElement);
        }
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            XElement xElement = RenderItemHelper.CreateXElement("Image", base.RenderingItem, printContext.Settings.IsClient, null);
            string   text     = string.Empty;
            string   value    = base.RenderingItem["MediaLibrary Reference"];
            bool     flag     = string.IsNullOrEmpty(value);
            ID       iD;

            if (!flag && ID.TryParse(value, out iD) && iD != ID.Null)
            {
                MediaItem mediaItem = printContext.Database.GetItem(iD);
                text = ImageRendering.CreateImageOnServer(printContext.Settings, mediaItem);
            }
            else
            {
                string text2 = base.RenderingItem.Parent["Item Field"];
                flag &= string.IsNullOrEmpty(text2);
                Item dataItem = this.GetDataItem(printContext);
                if (dataItem != null && !string.IsNullOrEmpty(text2))
                {
                    Field field = dataItem.Fields[text2];
                    if (field != null)
                    {
                        if (field.Type == "QR Code Image")
                        {
                            text = ImageRendering.CreateQrOnServer(printContext.Settings, base.RenderingItem, field.Value);
                        }
                        else if (field.Type == "Image")
                        {
                            MediaItem mediaItem2 = printContext.Database.GetItem(field.Value);
                            text = ImageRendering.CreateImageOnServer(printContext.Settings, mediaItem2);
                        }
                        else if (field.Type == "Treelist")
                        {
                            string[] images;
                            images = field.Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

                            int intPosition;

                            if (position != null)
                            {
                                intPosition = Convert.ToInt32(position);
                            }
                            else
                            {
                                intPosition = 0;
                            }

                            MediaItem mediaItem3 = printContext.Database.GetItem(images[intPosition]);
                            text = ImageRendering.CreateImageOnServer(printContext.Settings, mediaItem3);
                        }
                        else
                        {
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(text) && flag)
            {
                xElement.SetAttributeValue("LowResSrc", base.RenderingItem["LowResSrc"]);
                xElement.SetAttributeValue("HighResSrc", base.RenderingItem["HighResSrc"]);
            }
            else
            {
                text = printContext.Settings.FormatResourceLink(text);
                xElement.SetAttributeValue("LowResSrc", text);
                xElement.SetAttributeValue("HighResSrc", text);
            }
            output.Add(xElement);
            this.RenderChildren(printContext, xElement);
        }