Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        public override bool Edit(LogBrowseVO m)
        {
            CodeCommand command = new CodeCommand();

            command.CommandText = EDIT;

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Url", Value = ParameterHelper.ConvertValue(m.Url)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ClientIp", Value = ParameterHelper.ConvertValue(m.ClientIp)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseType", Value = ParameterHelper.ConvertValue(m.BrowseType)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdId", Value = ParameterHelper.ConvertValue(m.AdId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdUserId", Value = ParameterHelper.ConvertValue(m.AdUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@FlowUserId", Value = ParameterHelper.ConvertValue(m.FlowUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdUrl", Value = ParameterHelper.ConvertValue(m.AdUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Money", Value = ParameterHelper.ConvertValue(m.Money)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsMoney", Value = ParameterHelper.ConvertValue(m.IsMoney)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Time", Value = ParameterHelper.ConvertValue(m.Time)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ClientId", Value = ParameterHelper.ConvertValue(m.ClientId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsMobile", Value = ParameterHelper.ConvertValue(m.IsMobile)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ReferrerUrl", Value = ParameterHelper.ConvertValue(m.ReferrerUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseName", Value = ParameterHelper.ConvertValue(m.BrowseName)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseVersion", Value = ParameterHelper.ConvertValue(m.BrowseVersion)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OsName", Value = ParameterHelper.ConvertValue(m.OsName)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Country", Value = ParameterHelper.ConvertValue(m.Country)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Area", Value = ParameterHelper.ConvertValue(m.Area)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Region", Value = ParameterHelper.ConvertValue(m.Region)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@City", Value = ParameterHelper.ConvertValue(m.City)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@County", Value = ParameterHelper.ConvertValue(m.County)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Isp", Value = ParameterHelper.ConvertValue(m.Isp)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IpSource", Value = ParameterHelper.ConvertValue(m.IpSource)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Id", Value = ParameterHelper.ConvertValue(m.Id)
            });


            int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command);

            if (result >= 1)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public override int InsertIdentityId(LogBrowseVO m)
        {
            CodeCommand command = new CodeCommand();

            command.CommandText = INSERT + "; select @@Identity";

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Url", Value = ParameterHelper.ConvertValue(m.Url)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ClientIp", Value = ParameterHelper.ConvertValue(m.ClientIp)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseType", Value = ParameterHelper.ConvertValue(m.BrowseType)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdId", Value = ParameterHelper.ConvertValue(m.AdId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdUserId", Value = ParameterHelper.ConvertValue(m.AdUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@FlowUserId", Value = ParameterHelper.ConvertValue(m.FlowUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AdUrl", Value = ParameterHelper.ConvertValue(m.AdUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Money", Value = ParameterHelper.ConvertValue(m.Money)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsMoney", Value = ParameterHelper.ConvertValue(m.IsMoney)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Time", Value = ParameterHelper.ConvertValue(m.Time)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ClientId", Value = ParameterHelper.ConvertValue(m.ClientId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsMobile", Value = ParameterHelper.ConvertValue(m.IsMobile)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ReferrerUrl", Value = ParameterHelper.ConvertValue(m.ReferrerUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseName", Value = ParameterHelper.ConvertValue(m.BrowseName)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@BrowseVersion", Value = ParameterHelper.ConvertValue(m.BrowseVersion)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OsName", Value = ParameterHelper.ConvertValue(m.OsName)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Country", Value = ParameterHelper.ConvertValue(m.Country)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Area", Value = ParameterHelper.ConvertValue(m.Area)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Region", Value = ParameterHelper.ConvertValue(m.Region)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@City", Value = ParameterHelper.ConvertValue(m.City)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@County", Value = ParameterHelper.ConvertValue(m.County)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Isp", Value = ParameterHelper.ConvertValue(m.Isp)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IpSource", Value = ParameterHelper.ConvertValue(m.IpSource)
            });


            var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command);

            return(int.Parse(result.ToString()));
        }
Exemplo n.º 4
0
 public override string GetOtherConditionByModel(LogBrowseVO m)
 {
     return("");
 }
Exemplo n.º 5
0
 public override string GetOrderByModel(LogBrowseVO m)
 {
     return("");
 }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            LogBrowseVO log = new LogBrowseVO();

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

                string filepath = Path.GetFileName(pname);
                //string fileExt = Path.GetExtension(filepath);

                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;
                }

                var userpage = AdUserPageBLL.Instance.GetModelByPageName(PageName);
                if (userpage != null)
                {
                    var info = AdPageInfoBLL.Instance.GetModelById(userpage.AdPageId);
                    if (info != null)
                    {
                        //访问日志
                        log.AdUserId = info.UserId;
                        log.AdId     = info.Id;

                        if (userpage != null)
                        {
                            log.FlowUserId = userpage.FlowUserId;
                        }
                    }
                }
                else
                {
                    var info = AdPageInfoBLL.Instance.GetModelByViewPage(PageName);
                    if (info != null)
                    {
                        log.AdId     = info.Id;
                        log.AdUserId = info.UserId;
                    }
                }
                if (DN.WeiAd.Business.Config.AppConfig.IsLogBrowse == 0)
                {
                    LogBrowseBLL.Instance.Add(log);
                }
                else
                {
                    ErrorBLL.Add <LogBrowseVO>(log);
                }
            }
            catch (Exception ex)
            {
                ErrorBLL.Add <LogBrowseVO>(ex, log);
                DN.Framework.Utility.LogHelper.Write(ex.Message, "errorlogbrow");
            }
        }