Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            string origin = context.Request.Headers["Origin"];

            context.Response.AppendHeader("Access-Control-Allow-Origin", string.IsNullOrEmpty(origin) ? "*" : origin);
            string requestHeaders = context.Request.Headers["Access-Control-Request-Headers"];

            context.Response.AppendHeader("Access-Control-Allow-Headers", string.IsNullOrEmpty(requestHeaders) ? "*" : requestHeaders);
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");
            context.Response.ContentType    = "text/Json";
            context.Response.HeaderEncoding = Encoding.UTF8;
            StringBuilder logParams = new StringBuilder();

            foreach (var item in context.Request.Params.AllKeys)
            {
                logParams.AppendFormat("{0}:{1},", item, context.Request[item]);
            }
            int pid = 0;

            if (context.Request.Params["pid"] != null)
            {
                int.TryParse(context.Request.Params["pid"], out pid);
            }
            int total = 0;
            var list  = new BandInfoDb().GetAllBrandBuyParentId(pid.ToString());

            if (list != null)
            {
                total = list.Count;
            }
            ApiLogInfo log = new ApiLogInfo
            {
                LogType   = "BrandApi",
                UserAgent = context.Request.UserAgent,
                Referer   = context.Request.UrlReferrer == null ? "" : context.Request.UrlReferrer.ToString(),
                UserIp    = getip(),
                Remark    = "param:" + logParams + " result count" + total
            };

            new ApiLogInfoDb().AddApiLogo(log);
            if (total == 0)
            {
                context.Response.Write("{ret:0, data:[],msg: 'empty'}");
                return;
            }

            var blist = list.OrderBy(c => c.FirstChart).Select(bandInfo => new Tempbrand {
                FirstChart = bandInfo.FirstChart, BrandName = bandInfo.BrandName, BrandNum = bandInfo.BrandNum, LogoImg = bandInfo.LogoImg
            }).ToList();

            string result = JsonConvert.SerializeObject(blist);

            var tempitem = "{ret:1, data:" + result + ",msg: 'sucessed'}";

            context.Response.Write(tempitem);
        }
Пример #2
0
        //public string ppz = "";
        public SearchWhere(string id, bool islogin = true)
        {
            string key, value;

            Init();
            if (string.IsNullOrEmpty(id))
            {
                id = "";
            }
            //分解条件
            StringBuilder   sb = new StringBuilder();
            Regex           r  = new Regex("\\d+\\.?\\d*");
            MatchCollection mc = r.Matches(id + "Z");

            for (int i = 0; i < mc.Count; i++)
            {
                if (mc[i].Index - 1 >= 0)
                {
                    key   = id[mc[i].Index - 1].ToString();
                    value = mc[i].ToString();
                    if (value != "0" && string.IsNullOrEmpty(value) == false)
                    {
                        where.Add(key, value);
                    }
                }
            }
            if (!islogin)
            {
                where.Remove("q");
            }

            string name = Getname("a");
            string num  = "";

            if (string.IsNullOrEmpty(name) && where.TryGetValue("a", out num))
            {
                //var ls1 = new CarDetialInfoDb().Exec(sb.ToString(), 1, 25, order, orderby, out TotalRecord, out TotalPage);
                var band = new BandInfoDb().getBrandByKey(num);
                var dic  = Carwhere["a"];
                dic.Add(band.BrandName, band.BrandNum);
            }

            //车系
            if (where.TryGetValue("a", out value) == true)
            {
                Dictionary <string, string> dic = Carwhere["b"];
                var ls = new BandInfoDb().GetAllBrandBuyParentId(value);
                dic.Clear();
                dic.Add("不限", "0");
                foreach (var v in ls)
                {
                    dic.Add(v.BrandName, v.BrandNum);
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            year = DateTime.Now.Year;

            var str = Request["ac"];

            carsort        = Request["carsort"] ?? "";
            p_no           = Request["p_no"] ?? "";
            p_brand        = Request["p_brand"] ?? "";
            p_subbrand     = Request["p_subbrand"] ?? "";
            startprice     = Request["startprice"] ?? "";
            endprice       = Request["endprice"] ?? "";
            startage       = Request["startage"] ?? "";
            endage         = Request["endage"] ?? "";
            p_transmission = Request["p_transmission"] ?? "";
            keywords       = Request["keywords"] ?? "";

            var binfo = new BandInfoDb();

            mlist = binfo.GetBandInfoByParentNum("0");
            if (p_brand != "")
            {
                clist = binfo.GetBandInfoByParentNum(p_brand);
            }
            var carinfo = new CarTypeInfoDb();

            tlist = carinfo.GetCarinfoList("0");
            blist = carinfo.GetCarinfoList("1");

            sb.Append("ac=");
            if (!string.IsNullOrEmpty(str))
            {
                sb.Append(str);
            }

            //str = Request["keywords"];

            ////str= HttpUtility.UrlDecode(str,Encoding.Default);
            //string tmp1 = System.Web.HttpUtility.UrlDecode(str, Encoding.GetEncoding("gb2312"));
            //sb.Append("&keywords=");
            //if (!string.IsNullOrEmpty(str))
            //    sb.Append(str);
            //winfo = sb.ToString();
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
        }
Пример #4
0
        private void brandType(HttpContext context)
        {
            var id = context.Request.QueryString["brandid"].ToString();

            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            var           list   = new BandInfoDb().GetBandInfoByParentNum(id);
            StringBuilder brands = new StringBuilder();

            brands.Append("<option value=''>请选择型号</option>");
            foreach (var item in list)
            {
                brands.AppendFormat("<option value='{0}'>{1}</option>", item.BrandNum, item.DisplayName);
            }
            context.Response.Write(brands.ToString());
        }
Пример #5
0
        private void addCar(prolog item)
        {
            string detial = item.proName.TrimStart('[').TrimEnd(']').Replace("\"", "");


            var prolist = detial.Split(',');

            var spri     = prolist[2].Substring(prolist[2].IndexOf(":") + 1).Replace("年", "-").Replace("月", "");
            var Cartype  = prolist[3].Substring(prolist[3].IndexOf(":") + 1);
            var typeitem = new CarTypeInfoDb().GetCarinfo(new CarTypeInfo {
                DisplayName = Cartype
            });
            var p_sort = typeitem.CarTypeKey; //Request.Form["p_sort"];
            var title  = prolist[23];

            title = title.Substring(title.IndexOf(":") + 1);

            var bramdName = Regex.Match(title, brandReg, RegexOptions.IgnoreCase).Value;

            var brand = brandList.FirstOrDefault(c => c.BrandName == bramdName);



            var catxinghao = new BandInfoDb().GetBandInfoByParentNum(brand.BrandNum);

            string xhReg = "";

            foreach (var xh in catxinghao)
            {
                xhReg += xh.BrandName + "|";
            }
            xhReg = xhReg.TrimEnd('|');


            var tempxinghao   = Regex.Match(title, xhReg, RegexOptions.IgnoreCase).Value;
            var tempbrandtype = catxinghao.FirstOrDefault(c => c.DisplayName == tempxinghao);
            var temppic       = "";

            foreach (var propic in prolist)
            {
                if (propic.Contains(".jpg"))
                {
                    temppic += propic.Trim(' ') + ";";
                }
            }

            var p_price             = Regex.Match(prolist[0], ":(?<x>.*?)万元", RegexOptions.IgnoreCase).Groups["x"].Value;
            var p_color             = prolist[5].Substring(prolist[5].IndexOf(":") + 1);
            var p_kilometre         = prolist[8].Substring(prolist[8].IndexOf(":") + 1).Replace("万", "");
            var p_gas               = prolist[6].Substring(prolist[6].IndexOf(":") + 1);
            var p_country           = prolist[4].Substring(prolist[4].IndexOf(":") + 1);
            var p_transmission      = prolist[7].Substring(prolist[7].IndexOf(":") + 1);
            var p_fuel              = prolist[10].Substring(prolist[10].IndexOf(":") + 1);
            var p_emissionstandards = prolist[9].Substring(prolist[9].IndexOf(":") + 1);
            var p_details           = Regex.Match(detial, "车况说明:(?<x>.*?)$", RegexOptions.IgnoreCase).Groups["x"].Value;

            var seller       = prolist[12].Substring(prolist[12].IndexOf(":") + 1);
            var sellerphone  = prolist[14].Substring(prolist[14].IndexOf(":") + 1);
            var selleradress = prolist[13].Substring(prolist[13].IndexOf(":") + 1);
            var proNum       = prolist[1].Substring(prolist[1].IndexOf(":") + 1);


            CarDetialInfo pro = new CarDetialInfo();

            pro.ProTitle     = title;
            pro.CarType      = p_sort;
            pro.BrandInfo    = bramdName;
            pro.BrandType    = tempxinghao;
            pro.ProNum       = proNum;
            pro.OtherParam   = "";
            pro.ShangPaiTime = spri; //p_year + "-" + p_month;
            if (brand.BrandNum != null)
            {
                pro.BrandInfoKey = brand.BrandNum;
            }
            if (tempbrandtype != null)
            {
                pro.BrandTypeKey = tempbrandtype.BrandNum;
            }
            pro.ShangPaiMonth   = int.Parse(spri.Split('-')[1]);
            pro.ShangPaiYear    = int.Parse(spri.Split('-')[0]);
            pro.Images          = temppic;
            pro.mianimg         = "1";
            pro.baojia          = decimal.Parse(p_price);
            pro.CarColor        = p_color;
            pro.LiCheng         = decimal.Parse(p_kilometre);
            pro.PaiLiang        = p_gas;
            pro.country         = p_country;
            pro.BianShuQi       = p_transmission;
            pro.RanYou          = p_fuel;
            pro.Remark          = p_details;
            pro.PaiFangBiaoZhun = p_emissionstandards;
            pro.SellerName      = seller;
            pro.SellerPhone     = sellerphone;
            pro.SellerName      = proNum.Split(' ')[0];
            pro.CarSellAddress  = selleradress;
            new CarDetialInfoDb().AddCarinfo(pro);
        }
Пример #6
0
        private List <CarDetialInfo> GetDbData(HttpRequest Request, out int TotalRecord, out int TotalPage)
        {
            List <CarDetialInfo> ls = new List <CarDetialInfo>();

            StringBuilder sb  = new StringBuilder();
            var           str = Request["ac"];

            if (!string.IsNullOrEmpty(str))
            {
            }
            str = Request["mod"];
            if (!string.IsNullOrEmpty(str))
            {
            }
            str = Request["carsort"];
            if (!string.IsNullOrEmpty(str) && str != "0")
            {
                sb.Append(" CarType='" + str + "' and");
            }
            str = Request["p_no"];
            if (!string.IsNullOrEmpty(str))
            {
                // SellerName
                sb.Append(" SellerNumber='" + str + "' and");
            }


            str = Request["p_brand"];
            var str1 = Request["p_subbrand"];

            if (!string.IsNullOrEmpty(str) || !string.IsNullOrEmpty(str1))
            {
                if (!string.IsNullOrEmpty(str1))
                {
                    str = str1;
                }
                BandInfo binfo = new BandInfoDb().getBrandByKey(str);
                sb.Append(" ( BrandType ='" + binfo.BrandName + "' or   Brandinfo = '" + binfo.BrandName + "')  and");
            }
            str  = Request["startprice"];
            str1 = Request["endprice"];
            if (!string.IsNullOrEmpty(str) || !string.IsNullOrEmpty(str1))
            {
                if (!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(str1))
                {
                    sb.Append(" ( baojia>=" + str + " and  baojia<=" + str1 + " ) and");
                }
                else if (!string.IsNullOrEmpty(str))
                {
                    sb.Append(" baojia>=" + str + " and");
                }
                else if (!string.IsNullOrEmpty(str1))
                {
                    sb.Append(" baojia<=" + str1 + " and");
                }
            }

            str  = Request["startage"];
            str1 = Request["endage"];
            if (!string.IsNullOrEmpty(str) || !string.IsNullOrEmpty(str1))
            {
                if (!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(str1))
                {
                    sb.Append(" ( ShangPaiYear>=" + str + " and  ShangPaiYear<=" + str1 + ") and");
                }
                else if (!string.IsNullOrEmpty(str))
                {
                    sb.Append(" ShangPaiYear>=" + str + " and");
                }
                else if (!string.IsNullOrEmpty(str1))
                {
                    sb.Append(" ShangPaiYear<=" + str1 + " and");
                }
            }


            str = Request["p_transmission"];
            if (!string.IsNullOrEmpty(str) && str != "0")
            {
                sb.Append(" BianShuQi ='" + str + "' and");
            }
            str = Request["keywords"];
            if (!string.IsNullOrEmpty(str))
            {
                sb.Append("( BrandType ='" + str + "' or   Brandinfo = '" + str + "' ) and");
            }
            str = Request["s_type"];

            if (!string.IsNullOrEmpty(str) && str != "1")
            {
            }
            var page = Request["page"];

            if (string.IsNullOrEmpty(page))
            {
                page = "1";
            }
            str = Request["order"];
            var order   = "";
            var orderby = 0;

            switch (str)
            {
            case "1":
                order   = "shangpaitime";
                orderby = 1;
                break;

            case "2":
                order   = "shangpaitime";
                orderby = 0;
                break;

            case "3":
                order   = "baojia";
                orderby = 1;
                break;

            case "4":
                order   = "baojia";
                orderby = 0;
                break;

            case "5":
                order   = "ShangPaiTime";
                orderby = 1;
                break;

            case "6":
                order   = "ShangPaiTime";
                orderby = 0;
                break;

            case "7":
                order   = "BrandInfo";
                orderby = 1;
                break;

            case "8":
                order   = "BrandInfo";
                orderby = 0;
                break;

            default:
                order   = "id";
                orderby = 1;
                break;
            }
            str = Request["show"];
            if (!string.IsNullOrEmpty(str))
            {
            }
            if (sb.Length > 3)
            {
                sb.Remove(sb.Length - 3, 3);
            }
            if (sb.Length == 0)
            {
                sb.Append("1=1");
            }
            int pg;

            int.TryParse(page, out pg);
            var ls1 = new CarDetialInfoDb().Exec(" where " + sb.ToString(), pg, 25, order, orderby, out TotalRecord, out TotalPage);

            if (ls1 != null)
            {
                foreach (var l in ls1)
                {
                    ls.Add(l);
                }
            }
            else
            {
            }
            return(ls);
        }
Пример #7
0
        private void dataBind(int proid)
        {
            var proinfo = new CarDetialInfoDb().GetCarinfo(proid);

            Page.Title = "我的车源管理";
            var           list   = new BandInfoDb().GetBandInfoByParentNum("0");
            StringBuilder brands = new StringBuilder();

            brands.Append("<option value=''>请选择品牌</option>");
            string brandBind = "";
            int    yearBind  = 0;
            int    monthBind = 0;

            p_country = "<input type='radio' name='p_country' value='国产' checked='checked'>国产 <input type='radio' name='p_country' value='进口' >进口";
            if (proinfo != null)
            {
                brandBind   = proinfo.BrandInfo;
                yearBind    = proinfo.ShangPaiYear;
                monthBind   = proinfo.ShangPaiMonth;
                p_mainpic   = proinfo.mianimg;
                p_color     = proinfo.CarColor;
                p_name      = proinfo.OtherParam;
                p_price     = proinfo.baojia.ToString("0.00");
                p_kilometre = proinfo.LiCheng;
                p_gas       = proinfo.PaiLiang;
                p_details   = proinfo.Remark.Replace("\n", "");
                if (proinfo.country == "进口")
                {
                    p_country = "<input type='radio' name='p_country' value='国产' >国产 <input type='radio' name='p_country' checked='checked' value='进口' >进口";
                }
                var imgs = proinfo.Images.Split(';');
                foreach (var img in imgs)
                {
                    var imgid = Regex.Match(img, "/carimg/small/(?<x>\\d+).jpg", RegexOptions.IgnoreCase).Value;
                    if (string.IsNullOrEmpty(imgid))
                    {
                        imgid = "0";
                    }
                    Imgli += string.Format("<li id='{0}'><img name='p_pics' src='{1}'><p><a href=\"javascript:delimg('{0}')\"> 删除</a></p></li>", imgid, img);
                }

                var secBrand = new BandInfoDb().GetBandInfoByParentNum(proinfo.BrandInfoKey);
                foreach (var item in secBrand)
                {
                    if (proinfo.BrandTypeKey == item.BrandNum)
                    {
                        subbrand += string.Format("<option  selected='selected' value='{0}'>{1}</option>", item.BrandNum, item.DisplayName);
                    }
                    else
                    {
                        subbrand += string.Format("<option value='{0}'>{1}</option>", item.BrandNum, item.DisplayName);
                    }
                }
            }

            string[] pfbz = { "国一", "国二", "国三", "国三+OBD", "国四", "国五" };
            foreach (var item in pfbz)
            {
                if (proinfo != null && proinfo.PaiFangBiaoZhun == item)
                {
                    p_emissionstandards += string.Format("<option selected='selected' value='{0}'>{0}</option>", item);
                }
                else
                {
                    p_emissionstandards += string.Format("<option value='{0}'>{0}</option>", item);
                }
            }
            string[] p_fuellist = { "汽油", "柴油", "混动", "电动" };
            foreach (var item in p_fuellist)
            {
                if (proinfo != null && proinfo.RanYou == item)
                {
                    p_fuel += string.Format("<option selected='selected' value='{0}'>{0}</option>", item);
                }
                else
                {
                    p_fuel += string.Format("<option value='{0}'>{0}</option>", item);
                }
            }



            var typelist = new CarTypeInfoDb().GetAllCarType();

            foreach (var item in typelist)
            {
                if (item.ParentCarTypeKey == "0")
                {
                    if (proinfo != null && proinfo.BrandTypeKey == item.CarTypeKey)
                    {
                        p_sort += string.Format("<option  selected='selected' value='{0}'>{1}</option>", item.CarTypeKey, item.DisplayName);
                    }
                    else
                    {
                        p_sort += string.Format("<option value='{0}'>{1}</option>", item.CarTypeKey, item.DisplayName);
                    }
                }
                if (item.ParentCarTypeKey == "1")
                {
                    if (proinfo != null && proinfo.BianShuQi == item.DisplayName)
                    {
                        p_transmission += string.Format("<input type='radio' name='p_transmission' checked='checked' value='{0}'>{0}", item.DisplayName);
                    }
                    else
                    {
                        p_transmission += string.Format("<input type='radio' name='p_transmission' value='{0}'>{0}", item.DisplayName);
                    }
                }
                //
            }



            foreach (var item in list)
            {
                if (item.BrandName == brandBind)
                {
                    brands.AppendFormat("<option  selected='selected' value='{0}'>{1}</option>", item.BrandNum, item.DisplayName);
                }
                else
                {
                    brands.AppendFormat("<option value='{0}'>{1}</option>", item.BrandNum, item.DisplayName);
                }
            }
            Brandinfo = brands.ToString();

            StringBuilder Buyyear  = new StringBuilder();
            int           currYear = DateTime.Now.Year;

            Buyyear.Append("<option value=''>请选择年份</option>");
            for (int i = 0; i < 20; i++)
            {
                if (yearBind == (currYear - i))
                {
                    Buyyear.AppendFormat("<option selected='selected' value='{0}'>{0}</option>", currYear - i);
                }
                else
                {
                    Buyyear.AppendFormat("<option value='{0}'>{0}</option>", currYear - i);
                }
            }


            BuyCarYear = Buyyear.ToString();

            StringBuilder BuyMonth = new StringBuilder();

            BuyMonth.Append("<option value=''>请选择月份</option>");
            for (int i = 1; i < 13; i++)
            {
                if (monthBind == i)
                {
                    BuyMonth.AppendFormat("<option selected='selected' value='{0}'>{0}</option>", i.ToString("00"));
                }
                else
                {
                    BuyMonth.AppendFormat("<option value='{0}'>{0}</option>", i.ToString("00"));
                }
            }
            BuyCarMonth = BuyMonth.ToString();

            var carType = new CarTypeInfoDb().GetAllCarType();
        }
Пример #8
0
        private void addCar(int id = 0)
        {
            ///static/carImg/load
            var p_sort      = Request.Form["p_sort"];
            var p_brand     = Request.Form["p_brand"];
            var p_brandName = "";
            var probrand    = new BandInfoDb().getBrandByKey(p_brand);

            if (probrand != null)
            {
                p_brandName = probrand.BrandName;
            }

            var p_name    = HttpUtility.UrlDecode(Request.Form["p_name"]);
            var uptype    = Request.Form["uptype"];
            var pic       = Request.Form["imgs"];
            var piclist   = pic.Split(',');
            var priallimg = "";

            foreach (var tempimg in piclist)
            {
                priallimg = priallimg + string.Format("/carimg/small/{0}.jpg;", pic);
            }

            var mainpic             = Request.Form["p_mainpic"];
            var p_color             = Request.Form["p_color"];
            var p_price             = Request.Form["p_price"];
            var isfixprice          = Request.Form["isfixprice"];
            var p_year              = Request.Form["p_year"];
            var p_month             = Request.Form["p_month"];
            var p_kilometre         = Request.Form["p_kilometre"];
            var p_gas               = Request.Form["p_gas"];
            var p_country           = Request.Form["p_country"];
            var p_transmission      = Request.Form["p_transmission"];
            var p_emissionstandards = Request.Form["p_emissionstandards"];
            var p_fuel              = Request.Form["p_fuel"];
            var p_details           = Request.Form["p_details"];
            var p_img               = Request.Form[""];
            var ac = Request.Form["ac"];

            var    pstate       = Request.Form["pstate"];
            var    page         = Request.Form["page"];
            var    subbrand2    = Request.Form["p_subbrand"];
            string subbrandName = "";
            var    prosubbrand  = new BandInfoDb().getBrandByKey(subbrand2);

            if (prosubbrand != null)
            {
                subbrandName = prosubbrand.BrandName;
            }


            CarDetialInfo pro = new CarDetialInfo();

            pro.Id              = id;
            pro.CarType         = p_sort;
            pro.BrandInfo       = p_brandName;
            pro.BrandInfoKey    = p_brand;
            pro.BrandType       = subbrandName;
            pro.BrandTypeKey    = subbrand2;
            pro.OtherParam      = p_name;
            pro.ShangPaiTime    = p_year + "-" + p_month;
            pro.ShangPaiYear    = int.Parse(p_year);
            pro.ShangPaiMonth   = int.Parse(p_month);
            pro.Images          = priallimg;
            pro.mianimg         = mainpic;
            pro.baojia          = decimal.Parse(p_price);
            pro.CarColor        = p_color;
            pro.LiCheng         = p_kilometre;
            pro.PaiLiang        = p_gas;
            pro.country         = p_country;
            pro.BianShuQi       = p_transmission;
            pro.RanYou          = p_fuel;
            pro.Remark          = p_details;
            pro.ProTitle        = pro.BrandInfo + " " + pro.BrandType + " " + pro.OtherParam;
            pro.PaiFangBiaoZhun = p_emissionstandards;
            if (Session["userid"] == null)
            {
                Response.Redirect("Login.aspx");
                return;
            }
            string shopid = Session["userid"].ToString();

            var shopinfo = new ShopInfoDb().getShopinfo(int.Parse(shopid));

            if (shopid != null)
            {
                pro.SellerName     = shopinfo.CompanyName;
                pro.SellerNumber   = shopinfo.ShopNum;
                pro.SellerPhone    = shopinfo.PhoneNumber;
                pro.CarSellAddress = shopinfo.CompanyAddress;
            }


            new CarDetialInfoDb().AddCarinfo(pro);
            Response.Redirect("UserCarList.aspx");
        }