• UserAgentStringLibrary


    It is at WebWorkContext.CurrentCustomer's part.
    
                    //check whether request is made by a search engine
                    //in this case return built-in customer record for search engines 
                    //or comment the following two lines of code in order to disable this functionality
                    if (customer == null || customer.Deleted || !customer.Active)
                    {
                        if (_userAgentHelper.IsSearchEngine())
                            customer = _customerService.GetCustomerBySystemName(SystemCustomerNames.SearchEngine);
                    }
    
    and to _userAgentHelper.IsSearchEngine()
    
            /// <summary>
            /// Get a value indicating whether the request is made by search engine (web crawler)
            /// </summary>
            /// <returns>Result</returns>
            public virtual bool IsSearchEngine()
            {
                if (_httpContext == null)
                    return false;
    
                //we put required logic in try-catch block
                //more info: http://www.nopcommerce.com/boards/t/17711/unhandled-exception-request-is-not-available-in-this-context.aspx
    
    (I checked this page, but the url is not valid now)
    
                bool result = false;
                try
                {
                    var uasParser = GetUasParser();
                    var userAgent = _httpContext.Request.UserAgent;
                    result = uasParser.IsBot(userAgent);
                    //result = context.Request.Browser.Crawler;
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc);
                }
                return result;
            }
    
    and to var uasParser = GetUasParser();
    
            protected virtual UasParser GetUasParser()
            {
                if (Singleton<UasParser>.Instance == null)
                {
                    //no database created
                    if (String.IsNullOrEmpty(_config.UserAgentStringsPath))
                        //UNDONE: maybe, throw an exception?
                        return null;
    
                    var filePath = _webHelper.MapPath(_config.UserAgentStringsPath);
                    var uasParser = new UasParser(filePath);
                    Singleton<UasParser>.Instance = uasParser;
                }
                return Singleton<UasParser>.Instance;
            }

    This library is used to parse information about user agents located at App_Datauas_20140809-02.ini file. Both of them (DLL and INI files) were downloaded at http://user-agent-string.info (was available for free). Now I see that this project is moved to https://udger.com/ on November 2014 with sone new pricing options. I've jusy contacted them trying to understand whether we can continue usage of the new project (still looking forward for reply)

    这个库是用来解析用户代理信息 位于 App_Data uas_20140809-02。ini文件。(DLL和INI文件)在http://user-agent-string.info下载(免费)。

    我看到这个项目转到https://udger.com/在2014年11月重新的定价方案。我jusy联系他们试图了解我们是否可以继续使用新项目(仍然期待回复)

    http://blog.csdn.net/defonds/article/details/8128165

  • 相关阅读:
    Wakeari(有诡)念摄模式的渲染原理和帧率暴跌原因分析,及更优化的渲染方案设想
    离心力与木桶实验
    搬家成功!
    x264编码参数大测试:05 subme与crf(g)
    四探C#类与结构体究竟谁快——跨程序集(assembly)调用
    x264编码参数大测试:03 subme与crf(c)
    昨日购买了华为U8800+。晒联通2.2版系统与官方2.3版系统的评测跑分。
    用JavaScript生成Android SDK的下载地址(3)——放弃xsl,纯JavaScript转换xml为html
    向量除法——标量乘法的逆运算
    [Color]灰度系数与网点增大
  • 原文地址:https://www.cnblogs.com/xchit/p/4679912.html
Copyright © 2020-2023  润新知