Пример #1
0
        /// <summary>
        /// Creates the interaction.
        /// </summary>
        /// <param name="interactionComponentId">The interaction component identifier.</param>
        /// <param name="userAgent">The user agent.</param>
        /// <param name="url">The URL.</param>
        /// <param name="ipAddress">The ip address.</param>
        /// <param name="browserSessionId">The browser session identifier.</param>
        /// <returns></returns>
        public Interaction CreateInteraction(int interactionComponentId, string userAgent, string url, string ipAddress, Guid?browserSessionId)
        {
            userAgent = userAgent ?? string.Empty;
            var deviceOs          = uaParser.ParseOS(userAgent).ToString();
            var deviceApplication = uaParser.ParseUserAgent(userAgent).ToString();
            var deviceClientType  = InteractionDeviceType.GetClientType(userAgent);

            var interaction = CreateInteraction(interactionComponentId, null, null, string.Empty, null, null, RockDateTime.Now, deviceApplication, deviceOs, deviceClientType, userAgent, ipAddress, browserSessionId);

            interaction.SetUTMFieldsFromURL(url);

            return(interaction);
        }
        /// <summary>
        /// Creates the interaction.
        /// </summary>
        /// <param name="interactionComponentId">The interaction component identifier.</param>
        /// <param name="userAgent">The user agent.</param>
        /// <param name="url">The URL.</param>
        /// <param name="ipAddress">The ip address.</param>
        /// <param name="browserSessionId">The browser session identifier.</param>
        /// <returns></returns>
        public Interaction CreateInteraction(int interactionComponentId, string userAgent, string url, string ipAddress, Guid?browserSessionId)
        {
            userAgent = userAgent ?? string.Empty;
            var deviceOs          = uaParser.ParseOS(userAgent).ToString();
            var deviceApplication = uaParser.ParseUserAgent(userAgent).ToString();
            var deviceClientType  = InteractionDeviceType.GetClientType(userAgent);

            var interaction = CreateInteraction(interactionComponentId, null, null, string.Empty, null, null, RockDateTime.Now,
                                                deviceApplication, deviceOs, deviceClientType, userAgent, ipAddress, browserSessionId);

            if (url.IsNotNullOrWhiteSpace() && url.IndexOf("utm_", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                var urlParams = System.Web.HttpUtility.ParseQueryString(url);
                interaction.Source   = urlParams.Get("utm_source").Truncate(25);
                interaction.Medium   = urlParams.Get("utm_medium").Truncate(25);
                interaction.Campaign = urlParams.Get("utm_campaign").Truncate(50);
                interaction.Content  = urlParams.Get("utm_content").Truncate(50);
                interaction.Term     = urlParams.Get("utm_term").Truncate(50);
            }

            return(interaction);
        }
Пример #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            System.Console.WriteLine("Hello");
            System.Diagnostics.Debug.WriteLine("world");


            // http://www.useragentstring.com/pages/useragentstring.php
            // http://www.user-agents.org/
            string ua = System.Web.HttpContext.Current.Request.UserAgent;

            ua = @"Googlebot/2.1 (+http://www.google.com/bot.html)";
            ua = @"Googlebot-Image/1.0";
            ua = @"Baiduspider+(+http://www.baidu.com/search/spider.htm)";


            UAParser.Parser     parser = UAParser.Parser.GetDefault();
            UAParser.Device     dev    = parser.ParseDevice(ua);
            UAParser.OS         os     = parser.ParseOS(ua);
            UAParser.UserAgent  pua    = parser.ParseUserAgent(ua);
            UAParser.ClientInfo cli    = parser.Parse(ua);

            string strua = pua.ToString();

            System.Console.WriteLine(strua);


            System.Console.WriteLine(dev);
            System.Console.WriteLine(os);
            System.Console.WriteLine(pua);
            System.Console.WriteLine(cli);



            // System.Web.HttpContext.Current.Request.Browser.IsMobileDevice


            // SomeDbOperations.Test();
        }