public ReferrerHost GetReferrerHost(ISession session)
        {
            ReferrerHost rh = null;

            if (Id == 0)
            {
                rh = session.CreateCriteria(typeof(ReferrerHost))
                     .Add(Expression.Eq("Name", Name))
                     .UniqueResult <ReferrerHost>();

                if (rh == null)
                {
                    // find whether this is a dup host
                    ReferrerHostRollup duphost =
                        session.CreateSQLQuery(
                            "SELECT {R.*} FROM ReferrerHostRollup {R}" +
                            " WHERE '" + Renderer.SqlEncode(Name) + "' LIKE Name")
                        .AddEntity("R", typeof(ReferrerHostRollup))
                        .SetMaxResults(1)
                        .UniqueResult <ReferrerHostRollup>();

                    if (duphost != null)
                    {
                        rh = session.CreateCriteria(typeof(ReferrerHost))
                             .Add(Expression.Eq("Name", duphost.Rollup))
                             .UniqueResult <ReferrerHost>();
                    }
                }

                if (rh != null)
                {
                    // found an existing host
                    rh.RequestCount += RequestCount;
                }
                else
                {
                    rh = new ReferrerHost();
                    rh.RequestCount = RequestCount;
                    rh.Name         = Name;
                }
            }
            else
            {
                rh = session.Load <ReferrerHost>(Id);
                rh.RequestCount = RequestCount;
            }

            rh.LastUrl    = LastUrl;
            rh.LastSource = LastSource;
            rh.Updated    = DateTime.UtcNow;
            if (rh.Id == 0)
            {
                rh.Created = rh.Updated;
            }

            return(rh);
        }
        public ReferrerHostRollup GetReferrerHostRollup(ISession session)
        {
            ReferrerHostRollup referrerhostrollup = (Id != 0)
                ? (ReferrerHostRollup)session.Load(typeof(ReferrerHostRollup), Id)
                : new ReferrerHostRollup();

            referrerhostrollup.Name   = Name;
            referrerhostrollup.Rollup = Rollup;
            return(referrerhostrollup);
        }
Exemple #3
0
 public ManagedReferrerHostRollup(ReferrerHostRollup ReferrerHostRollup)
 {
     mReferrerHostRollup = ReferrerHostRollup;
 }
 public ReferrerHostRollupTest()
 {
     mReferrerHostRollup        = new ReferrerHostRollup();
     mReferrerHostRollup.Name   = Guid.NewGuid().ToString();
     mReferrerHostRollup.Rollup = Guid.NewGuid().ToString();
 }