Beispiel #1
0
        /// <summary>
        /// Zwraca fajerwerk polecany klientowi.
        /// </summary>
        /// <returns>fajerwerk polecany klientowi</returns>
        public Firework GetRecommended()
        {
            // jeœli promowany jest konkretny fajerwerk, nale¿y do zwróciæ
            try
            {
                String        s            = FileFinder.GetFileName("config", "strategy.xml");
                StreamReader  r            = new StreamReader(s);
                XmlSerializer xs           = new XmlSerializer(typeof(String));
                String        promotedName = (String)xs.Deserialize(r);
                r.Close();

                Firework f = Firework.Lookup(promotedName);
                if (f != null)
                {
                    return(f);
                }
            }
            catch {}

            // jeœli klient jest zarejestrowany, trzeba go porównaæ z innymi
            if (IsRegistered())
            {
                return((Firework)Rel8.Advise(this));
            }
            // sprawdzenie wydatków z ubieg³ego roku
            if (SpendingSince(DateTime.Now.AddYears(-1)) > 1000)
            {
                return((Firework)LikeMyStuff.Suggest(this));
            }
            // trudno - bêdzie losowy
            return(Firework.GetRandom());
        }
Beispiel #2
0
        /// <summary>
        /// Return a firework to recommend to this customer.
        /// </summary>
        /// <returns>a firework to recommend to this customer</returns>
        public Firework GetRecommended()
        {
            // if we're promoting a particular firework, return it
            try
            {
                String        s            = FileFinder.GetFileName("config", "strategy.xml");
                StreamReader  r            = new StreamReader(s);
                XmlSerializer xs           = new XmlSerializer(typeof(String));
                String        promotedName = (String)xs.Deserialize(r);
                r.Close();

                Firework f = Firework.Lookup(promotedName);
                if (f != null)
                {
                    return(f);
                }
            }
            catch {}

            // if registered, compare to other customers
            if (IsRegistered())
            {
                return((Firework)Rel8.Advise(this));
            }
            // check spending over the last year
            if (SpendingSince(DateTime.Now.AddYears(-1)) > 1000)
            {
                return((Firework)LikeMyStuff.Suggest(this));
            }
            // oh well!
            return(Firework.GetRandom());
        }
Beispiel #3
0
 // look for a promoted firework
 private PromotionAdvisor()
 {
     try
     {
         String        s    = FileFinder.GetFileName("config", "strategy.xml");
         StreamReader  r    = new StreamReader(s);
         XmlSerializer xs   = new XmlSerializer(typeof(String));
         String        name = (String)xs.Deserialize(r);
         r.Close();
         _promoted = Firework.Lookup(name);
     }
     catch {}
 }