예제 #1
0
 public static Adspace Create(XElement xml, XNamespace ns)
 {
     if (xml.Element(ns + "name").Value == "CO - Widescreen Premium 01-02")
     {
         var stop = "";
     }
     Adspace adspace = new Adspace
     {
         ID = xml.Element(ns + "adSpaceId").Value,
         Name = xml.Element(ns + "name").Value,
         AdCount = Int32.Parse(xml.Element(ns + "adCount").Value)
     };
     return adspace;
 }
예제 #2
0
        public static Adspace Complement(XElement xml, List<Adspace> adspaces, List<string> formats, XNamespace ns)
        {
            // foreach statschunk, create dailystats.
            // impressions = dailystats.sum()
            // Sätter statistik dag för dag
            var dailystats = xml.Descendants(ns + "statsChunk").Select(sc => DailyStatsFactory.CreateFromXML(sc, ns)).ToList();

            //var refs = xml.Attribute("ref").Value;
            //var pos = xml.Element(ns + "positiveImpressionRequests").Value;
            var selectedAdspace = adspaces.Where(a => a.ID == xml.Attribute("ref").Value).FirstOrDefault();
            if(selectedAdspace.Name == "VT - Panorama - 01")//"UNT - Widescreen 01-02")
            {
                var stop = "";
            }
            Adspace adspace = new Adspace
            {
                ID = selectedAdspace.ID,
                Name = selectedAdspace.Name,
                AdCount = selectedAdspace.AdCount,
                Dailystats = dailystats,
                AdspaceImpressions = dailystats.Sum(ds => ds.Impressions),
                AdImpressions = dailystats.Sum(ds => ds.Impressions) * selectedAdspace.AdCount, // antal gånger adpaces laddats * antal annonser i adspacet
                DailyAdImpressionsAverage = (dailystats.Sum(ds => ds.Impressions) != 0 ? (dailystats.Sum(ds => ds.Impressions) / dailystats.Count()) * selectedAdspace.AdCount : 0),
                RoundedDailyAdImpressionsAverage = (dailystats.Sum(ds => ds.Impressions) != 0 ? ((dailystats.Sum(ds => ds.Impressions) / dailystats.Count()) * selectedAdspace.AdCount).RoundDownToThousand() : 0)
            };

            // ...sök igenom formatet för matchningar mot "Internetenhet" (för att sedan kunna gruppera dem efter formetet från listan "formats", och inte Format (t.ex. "Panorama 1 240")
            foreach (var format in formats)
            {
                if (adspace.Name.ToLower().Contains(format))
                {
                    adspace.FormatType = format;
                    break;
                }
            }

            return adspace;
        }