Esempio n. 1
0
 private void WriteBooks(AttributeOutput output, Utility utility)
 {
     output
     .Add("PRODUCTSKU", "linkSku");
     SetContributors(utility, output);
     output
     .AddLiteral("MAINCONTRIBUTOR", ExtractContributor(utility.GetMainContributor()))
     .Add("PUBLISHER", "publisherName");
     SetSpecs(utility, output);
     output
     .AddLiteral("CATALOG", Context.AttributesDictionary["linkCatalog"])
     .Add("IMAGEHEADER", "imageHeader");
 }
Esempio n. 2
0
        private void SetSpecs(Utility utility, AttributeOutput output)
        {
            var pages  = (int?)utility.GetAttributeValue("pages").DbNullToNull();
            var height = (decimal?)utility.GetAttributeValue("Height").DbNullToNull();
            var width  = (decimal?)utility.GetAttributeValue("Width").DbNullToNull();
            var depth  = (decimal?)utility.GetAttributeValue("Depth").DbNullToNull();

            string pagesString = pages != null?pages.ToString() + " Pages" : null;

            string widthString = width != null?width.Value.ToString("0.##") : null;

            string heightString = height != null?height.Value.ToString("0.##") : null;

            string depthString = depth != null?depth.Value.ToString("0.##") : null;

            string dimensions = null;

            if (widthString != null && heightString != null)
            {
                if (depthString != null)
                {
                    dimensions = string.Join(" x ", new[] { heightString, widthString, depthString });
                }
                else
                {
                    dimensions = string.Join(" x ", new[] { heightString, widthString });
                }

                dimensions += " in.";
            }

            string spec = string.Empty;

            if (pagesString != null && dimensions != null)
            {
                spec = pagesString + ", " + dimensions;
            }

            else if (pagesString != null)
            {
                spec = pagesString;
            }

            else if (dimensions != null)
            {
                spec = dimensions;
            }

            output.AddLiteral("SPECS", spec);
        }
Esempio n. 3
0
        private void SetContributors(Utility utility, AttributeOutput output)
        {
            var contributors = utility.GetContributorsArray();

            foreach (string contributor in contributors)
            {
                var typeNameDelimiterIndex = contributor.IndexOf(" ", StringComparison.Ordinal);

                if (typeNameDelimiterIndex < 0)
                {
                    var pid = utility.GetAttributeValue("gId");
                    Context.Log.ErrorFormat(
                        "CustomAttributeFileFeedWriter.SetContributors(). Contributor type/value delimiter not found. Not writing to output. contributor: \"{0}\", PID: {1}",
                        contributor, pid);

                    continue;
                }

                var contributorType = contributor.Substring(0, typeNameDelimiterIndex);
                var contributorName = contributor.Substring(typeNameDelimiterIndex + 1);

                output.AddLiteral(contributorType, contributorName);
            }
        }