public void CreateOrUpdateDupExTest()
        {
            TransitReferrerHost host = new TransitReferrerHost();
            host.LastSource = string.Format("http://{0}", Guid.NewGuid().ToString());
            host.LastUrl = string.Format("http://{0}", Guid.NewGuid().ToString());
            host.Name = Guid.NewGuid().ToString();
            host.RequestCount = 1;
            host.Id = Blog.CreateOrUpdateReferrerHost(Ticket, host);

            string rollupname = Guid.NewGuid().ToString();

            TransitReferrerHostRollup rollup = new TransitReferrerHostRollup();
            rollup.Name = string.Format("%.{0}", rollupname);
            rollup.Rollup = host.Name;
            rollup.Id = Blog.CreateOrUpdateReferrerHostRollup(Ticket, rollup);

            TransitReferrerHost host2 = new TransitReferrerHost();
            host2.LastSource = host2.LastUrl = string.Format("http://{0}", Guid.NewGuid().ToString());
            host2.Name = string.Format("www.{0}", rollupname);
            host2.RequestCount = 1;
            host2.Id = Blog.CreateOrUpdateReferrerHost(Ticket, host2);

            Assert.AreEqual(host.Id, host2.Id, "Rollup did not translate a LIKE host.");

            Blog.DeleteReferrerHost(Ticket, host.Id);
            Blog.DeleteReferrerHostRollup(Ticket, rollup.Id);
        }
        public void ExistingReferrerHostRollupTest()
        {
            int count = 10;
            // create hosts
            TransitReferrerHost host = new TransitReferrerHost();
            host.LastSource = host.LastUrl = "http://localhost";
            host.RequestCount = 1;

            string root = Guid.NewGuid().ToString();
            for (int i = 0; i < count; i++)
            {
                host.Name = string.Format("www.{0}.{1}", root, i);
                Blog.CreateOrUpdateReferrerHost(Ticket, host);
                Console.WriteLine("Created {0}", host.Name);
            }

            // create a rollup, should merge hosts
            TransitReferrerHostRollup rollup = new TransitReferrerHostRollup();
            rollup.Name = string.Format("www.{0}.%", root);
            rollup.Rollup = string.Format("www.{0}.target", root);
            rollup.Id = Blog.CreateOrUpdateReferrerHostRollup(Ticket, rollup);

            // additional host will auto-rollup
            for (int i = 0; i < count; i++)
            {
                host.Name = string.Format("www.{0}.{1}", root, i);
                Blog.CreateOrUpdateReferrerHost(Ticket, host);
                Console.WriteLine("Created {0}", host.Name);
            }

            // get the rollup host
            TransitReferrerHost[] hosts = Blog.GetReferrerHosts(Ticket, null);

            bool found = false;
            foreach (TransitReferrerHost rh in hosts)
            {
                if (rh.Name == rollup.Rollup)
                {
                    Console.WriteLine("Found {0} with {1} hits", rh.Name, rh.RequestCount);
                    Assert.AreEqual(rh.RequestCount, count * 2);
                    found = true;
                    Blog.DeleteReferrerHost(Ticket, rh.Id);
                }
            }

            Assert.IsTrue(found);
            Blog.DeleteReferrerHostRollup(Ticket, rollup.Id);
        }
Exemple #3
0
 /// <remarks/>
 public void CreateOrUpdateReferrerHostRollupAsync(string ticket, TransitReferrerHostRollup t_referrerhostrollup, object userState) {
     if ((this.CreateOrUpdateReferrerHostRollupOperationCompleted == null)) {
         this.CreateOrUpdateReferrerHostRollupOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateOrUpdateReferrerHostRollupOperationCompleted);
     }
     this.InvokeAsync("CreateOrUpdateReferrerHostRollup", new object[] {
                 ticket,
                 t_referrerhostrollup}, this.CreateOrUpdateReferrerHostRollupOperationCompleted, userState);
 }
Exemple #4
0
 /// <remarks/>
 public void CreateOrUpdateReferrerHostRollupAsync(string ticket, TransitReferrerHostRollup t_referrerhostrollup) {
     this.CreateOrUpdateReferrerHostRollupAsync(ticket, t_referrerhostrollup, null);
 }
Exemple #5
0
 public int CreateOrUpdateReferrerHostRollup(string ticket, TransitReferrerHostRollup t_referrerhostrollup) {
     object[] results = this.Invoke("CreateOrUpdateReferrerHostRollup", new object[] {
                 ticket,
                 t_referrerhostrollup});
     return ((int)(results[0]));
 }
 public BlogReferrerHostRollupTest()
 {
     mReferrerHostRollup = new TransitReferrerHostRollup();
     mReferrerHostRollup.Name = Guid.NewGuid().ToString();
     mReferrerHostRollup.Rollup = Guid.NewGuid().ToString();
 }