示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string adid = context.Request.Params["id"] ?? "0";

            articleinfo tinfo = new articleinfo();

            try
            {
                var    info    = AdPageInfoBLL.Instance.GetModelById(int.Parse(adid));
                string content = string.Empty;
                string title   = string.Empty;
                if (info != null)
                {
                    string clientip = DN.Framework.Utility.ClientHelper.ClientIP();
                    var    ipinfo   = DN.WeiAd.Business.Services.IpTaoBaoHelper.GetIpResult(clientip);
                    string isp      = "";
                    if (ipinfo.code == 0 && ipinfo.data != null)
                    {
                        isp = ipinfo.data.isp;
                    }
                    if (isp.IndexOf("腾讯") != -1)
                    {
                        var ainfo = ArticleInfoBLL.Instance.GetRandModel();
                        if (ainfo != null)
                        {
                            tinfo.title   = ainfo.Title;
                            tinfo.content = DN.Framework.Utility.HtmlHelper.DecodeHtml(ainfo.Content);
                        }
                    }
                    else
                    {
                        content = GetContent(info, context);
                        title   = info.Title;
                    }
                }
                tinfo.title   = title;
                tinfo.content = content;
            }
            catch (Exception ex)
            {
                DN.Framework.Utility.LogHelper.Write(ex.Message, "error");
            }

            string json = DN.Framework.Utility.Serializer.SerializeObject(tinfo);

            context.Response.Write(json);
            context.Response.End();
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            articleinfo tinfo = new articleinfo();
            LogBrowseVO log   = new LogBrowseVO();

            tinfo.title   = "我的标题";
            tinfo.content = "我喜欢你";

            try
            {
                context.Response.ContentType = "text/json";
                string pname  = context.Request.Params["_pname"] ?? "";
                string curl   = context.Request.Params["_curl"] ?? "";
                string hisurl = context.Request.Params["_hisurl"] ?? "";
                string adid   = context.Request.Params["id"] ?? "0";

                string filepath = Path.GetFileName(pname);
                string PageName = filepath;
                int    last     = PageName.IndexOf("?");
                if (last != -1)
                {
                    PageName = PageName.Substring(0, last);
                }

                log.BrowseType    = DN.Framework.Utility.ClientHelper.GetUserAgent();
                log.ClientIp      = DN.Framework.Utility.ClientHelper.ClientIP();
                log.CreateDate    = DateTime.Now;
                log.AdUrl         = pname;
                log.IsMoney       = 0;
                log.Money         = 0;
                log.Time          = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
                log.ClientId      = GetClentId(context.Request, context.Response);
                log.IsMobile      = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0;
                log.ReferrerUrl   = hisurl;
                log.OsName        = DN.Framework.Utility.ClientHelper.GetOsName();
                log.BrowseName    = DN.Framework.Utility.ClientHelper.GetBrowseName();
                log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion();
                log.Url           = curl;
                var ipinfo = DN.WeiAd.Business.Services.IpTaoBaoHelper.GetIpResult(log.ClientIp);
                if (ipinfo.code == 0 && ipinfo.data != null)
                {
                    log.Country = ipinfo.data.country;
                    log.Area    = ipinfo.data.area;
                    log.City    = ipinfo.data.city;
                    log.Region  = ipinfo.data.region;
                    log.County  = ipinfo.data.county;
                    log.Isp     = ipinfo.data.isp;
                }

                bool ispass = true;

                if (DN.WeiAd.Business.Config.AppConfig.IsIpArea == 1)
                {
                    if (DN.WeiAd.Business.Config.AppConfig.IpAreas.Count != 0)
                    {
                        foreach (var item in DN.WeiAd.Business.Config.AppConfig.IpAreas)
                        {
                            if (log.Region.IndexOf(item) != -1)
                            {
                                ispass = false;
                                break;
                            }
                        }
                    }
                }

                //检查ISP
                if (log.Isp.IndexOf("腾讯") != -1)
                {
                    ispass = false;
                }

                //是否通过
                if (ispass)
                {
                    var adinfo = AdPageInfoBLL.Instance.GetModelById(int.Parse(adid));
                    if (adinfo == null)
                    {
                        adinfo = AdPageInfoBLL.Instance.GetModelById(int.Parse(adid));
                    }
                    if (adinfo != null)
                    {
                        log.AdUserId = adinfo.UserId;
                        log.AdId     = adinfo.Id;
                    }

                    string content = string.Empty;
                    string title   = string.Empty;
                    if (adinfo != null)
                    {
                        content = GetContent(adinfo, context);
                        title   = adinfo.Title;
                    }
                    tinfo.title   = title;
                    tinfo.content = content;
                }
                else
                {
                    var info = ArticleInfoBLL.Instance.GetRandModel();
                    if (info != null)
                    {
                        tinfo.title   = info.Title;
                        tinfo.content = DN.Framework.Utility.HtmlHelper.DecodeHtml(info.Content);
                    }
                }

                if (DN.WeiAd.Business.Config.AppConfig.IsLogBrowse == 1)
                {
                    ErrorBLL.Add <LogBrowseVO>(log);
                }
            }
            catch (Exception ex)
            {
                ErrorBLL.Add <LogBrowseVO>(ex, log);
                DN.Framework.Utility.LogHelper.Write(ex.Message, "error");
            }

            LogBrowseBLL.Instance.Add(log);

            string json = DN.Framework.Utility.Serializer.SerializeObject(tinfo);

            context.Response.ClearContent();
            context.Response.Write(json);
            context.Response.End();
        }