Пример #1
0
        public override bool Edit(LogIpInfoVO m)
        {
            CodeCommand command = new CodeCommand();

            command.CommandText = EDIT;

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Ip", Value = ParameterHelper.ConvertValue(m.Ip)
            });
            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 = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });
            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);
        }
Пример #2
0
        public override int InsertIdentityId(LogIpInfoVO m)
        {
            CodeCommand command = new CodeCommand();

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

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Ip", Value = ParameterHelper.ConvertValue(m.Ip)
            });
            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 = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });


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

            return(int.Parse(result.ToString()));
        }
Пример #3
0
        public static void UpdateIp()
        {
            HashSet <string> m_Ips = new HashSet <string>();

            var list = DN.WeiAd.Business.LogIpInfoBLL.Instance.GetModels(new LogIpInfoPara());

            foreach (var item in list)
            {
                if (!m_Ips.Contains(item.Ip))
                {
                    m_Ips.Add(item.Ip);
                }
            }

            string cmd = "select distinct(clientip) ip from [LogBrowse] ";

            DataTable table = DN.WeiAd.Business.ChartBLL.Instance.GetTable(cmd);

            for (int i = 0; i < table.Rows.Count; i++)
            {
                try
                {
                    string ip    = table.Rows[i][0].ToString();
                    var    tlist = ip.Split(',');
                    if (tlist.Length == 1)
                    {
                        ip = tlist[0];
                    }
                    if (ip == "127.0.0.1")
                    {
                        continue;
                    }

                    if (!m_Ips.Contains(ip))
                    {
                        string url  = string.Format("http://ip.taobao.com/service/getIpInfo.php?ip={0}", ip);
                        string json = DN.Framework.Utility.WebClientHelper.GetSend(url);

                        IpInfo info = DN.Framework.Utility.Serializer.DeserializeObject <IpInfo>(json);
                        Console.WriteLine(json);
                        LogIpInfoVO log = new LogIpInfoVO();
                        log.Ip         = ip;
                        log.CreateDate = DateTime.Now;
                        if (info.code == 0)
                        {
                            log.area    = info.data.area;
                            log.city    = info.data.city;
                            log.country = info.data.country;
                            log.county  = info.data.county;
                            log.Ip      = info.data.ip;
                            log.isp     = info.data.isp;
                            log.region  = info.data.region;
                        }
                        LogIpInfoBLL.Instance.Add(log);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                //Thread.Sleep(600);
            }

            Console.ReadKey();
        }
Пример #4
0
 public override string GetOtherConditionByModel(LogIpInfoVO m)
 {
     return("");
 }
Пример #5
0
 public override string GetOrderByModel(LogIpInfoVO m)
 {
     return("");
 }