public void ProcessRequest(HttpContext context) { int id = 0; Info info; var ids = context.Request["id"]; var tel = context.Request["tel"]; var lxr = context.Request["lxr"]; int.TryParse(ids, out id); string txt = "no"; if (id > 0 && !string.IsNullOrEmpty(tel) && !string.IsNullOrEmpty(lxr)) { var c = new CarDetialInfoDb().GetCarinfo(id); info = new Info(); info.title = lxr + "预约看车"; info.context = $"{c.ProTitle},联系人:{lxr},电话:{tel}"; info.contact = lxr; info.contact = tel; info.type = 5; info.username = c.SellerNumber; txt = "ok"; new InfoDb().Addinfo(info); } context.Response.ContentType = "text/plain"; context.Response.Write(txt); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string id = context.Request["id"]; int id1 = 0; StringBuilder sb = new StringBuilder(); if (id == null) {//找最新的id var ls1 = new CarDetialInfoDb().GetDBSql("select top 1 * from CarDetialInfo order by id desc"); if (ls1.Count > 0) { sb.Append("\"id\":" + ls1[0].Id); } } else { int.TryParse(id, out id1); var ls1 = new CarDetialInfoDb().GetDBSql("select top 1 * from CarDetialInfo where id>" + id1.ToString()); if (ls1 != null && ls1.Count > 0) { int i; int.TryParse(ls1[0].mianimg, out i); var strs = ls1[0].Images.Split(';'); sb.Append($"\"ProTitle\":\"" + ls1[0].ProTitle + "\",\"Baishuqi\":\"" + ls1[0].BianShuQi + "\",\"baojia\":\"" + ls1[0].baojia + "\",\"id\":\"" + ls1[0].Id + "\",\"img\":\"" + (strs.Length > i?strs[i]:"") + "\",\"pronum\":\"" + ls1[0].ProNum + "\",\"sellernumber\":\"" + ls1[0].SellerNumber + "\",\"shangpaitime\":\"" + ls1[0].ShangPaiTime + "\""); } } context.Response.Write("{" + sb + "}"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["userid"] == null) { Response.Redirect("Login.aspx"); return; } string shopid = Session["userid"].ToString(); var shopinfo = new ShopInfoDb().getShopinfo(int.Parse(shopid)); if (shopinfo.ShopNum == "123456") { shopinfo.ShopNum = "90002"; } // var list = new CarDetialInfoDb().GetCarLIst(shopinfo.ShopNum); if (catTypeList == null) { catTypeList = new CarTypeInfoDb().GetAllCarType(); } repCarlist.DataSource = list; repCarlist.DataBind(); }
private void loadCarImg() { var list = new CarDetialInfoDb().getAllCar(); WebClient myWebClient = new WebClient(); string path = Server.MapPath("/"); foreach (var item in list) { if (string.IsNullOrEmpty(item.Images)) { continue; } var imgs = item.Images.Split(';'); foreach (var img in imgs) { string file1 = "http://www.912sc.com/" + img.TrimStart('/').Replace("small", "load"); string newfile = path + img.TrimStart('/').Replace("/", "\\").Replace("small", "load"); //string newfile2 = path + img.TrimStart('/').Replace("/", "\\"); if (File.Exists(newfile)) { continue; } string path1 = newfile.Substring(0, newfile.LastIndexOf("\\")); try { if (!Directory.Exists(path1)) { Directory.CreateDirectory(path1); } myWebClient.DownloadFile(file1, newfile); } catch (Exception ex) { LogServer.WriteLog(ex.Message + "item" + item.Id + "\t" + file1); } string file2 = "http://www.912sc.com/" + img.TrimStart('/'); string newfile2 = path + img.TrimStart('/').Replace("/", "\\"); string path2 = newfile2.Substring(0, newfile2.LastIndexOf("\\")); try { if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } myWebClient.DownloadFile(file2, newfile2); } catch (Exception ex) { LogServer.WriteLog(ex.Message + "item" + item.Id + "\t" + file2); } } //string file1 = "http://www.912sc.com/" + item.IdCart.TrimStart('/'); //string file2 = "http://www.912sc.com/" + item.BusinessLicense.TrimStart('/'); } }
protected void Page_Load(object sender, EventArgs e) { int TotalRecord, TotalPage; List <CarDetialInfo> cdlist; carlist = new CarTypeInfoDb().GetCarinfoList("0"); var cdi = new CarDetialInfoDb(); foreach (var v in carlist) { cdlist = cdi.Exec("", 1, 10, "Id", 1, out TotalRecord, out TotalPage).ToList(); if (cdlist.Count > 0) { cardic.Add(v, cdlist); } } }
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); }
private void DataBing() { int currentPage = 0; string key = ""; if (Request.QueryString["pageid"] != null) { int.TryParse(Request.QueryString["pageid"].ToString(), out currentPage); } string query = ""; if (Request.QueryString["key"] != null) { key = HttpUtility.HtmlDecode(Request.QueryString["key"]); keyword = key; query = "&key=" + HttpUtility.UrlEncode(key); } string cartype = ""; if (Request.QueryString["cartype"] != null) { cartype = Request.QueryString["cartype"]; query = "&cartype=" + cartype; } if (currentPage <= 0) { currentPage = 1; } int totalCount = 0, totalpage; string shopid = Session["userid"].ToString(); var shopinfo = new ShopInfoDb().getShopinfo(int.Parse(shopid)); // IEnumerable<CarDetialInfo> querys = new CarDetialInfoDb().GetCarLIst(shopinfo.ShopNum); string where = " 1=1 and"; if (!string.IsNullOrEmpty(key)) { where = $" ProTitle like '%{key}%' and"; } if (!string.IsNullOrEmpty(cartype)) { where = $"CarType = '{cartype}' and"; } var list = new CarDetialInfoDb().Exec($"where {where} SellerNumber='{shopinfo.ShopNum}'", currentPage, 10, "id", 1, out totalCount, out totalpage);// t(shopinfo.ShopNum); int pagesize = 10; int index = (currentPage - 1) * pagesize; list = list.Skip(index).Take(pagesize).ToList(); string url = "UserCarList.aspx"; if (catTypeList == null) { catTypeList = new CarTypeInfoDb().GetAllCarType(); } // int totalpage = totalCount / pagesize; //if (totalCount % pagesize > 0) // totalpage = totalpage + 1; string syyurl = url; string xyyurl = url; string wyurl = url + "?pageid=" + ((currentPage + 1) > totalpage ? totalpage:(currentPage + 1)) + query; if (currentPage > 1) { syyurl = url + "?pageid=" + ((currentPage - 1) < 1?1:(currentPage - 1)) + query; if (currentPage < totalpage) { xyyurl = url + "?pageid=" + totalpage + query; } } else { if (currentPage < totalpage) { xyyurl = url + "?pageid=" + totalpage + query; } } pagenum = string.Format("共{0}条 {1}/{5}页 <a href=\"UserCarList.aspx?/" + url + "\">首页</a> <a href='{2}'>上一页</a> <a href='{3}'>下一页</a> <a href='{4}'>尾页</a> ", totalCount, currentPage, syyurl, xyyurl, wyurl, totalpage); repCarlist.DataSource = list; repCarlist.DataBind(); }
private List <CarDetialInfo> GetDbData(out int TotalRecord, out int TotalPage) { List <CarDetialInfo> ls = null; StringBuilder sb = new StringBuilder(); var str = Request["ac"]; if (!string.IsNullOrEmpty(str)) { } str = Request["keywords"]; if (!string.IsNullOrEmpty(str)) { } str = Request["carsort"]; if (!string.IsNullOrEmpty(str) && str != "0") { sb.Append(" randInfoKey='" + str + "' and"); } str = Request["p_no"]; if (!string.IsNullOrEmpty(str)) { // SellerName sb.Append(" SellerName='" + str + "' and"); } str = Request["p_brand"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" BrandInfo='" + str + "' and"); } str = Request["p_subbrand"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" BrandType='" + str + "' and"); } str = Request["startprice"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" baojia>=" + str + " and"); } str = Request["endprice"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" baojia<=" + str + " and"); } str = Request["startage"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" ShangPaiYear>=" + str + " and"); } str = Request["endage"]; if (!string.IsNullOrEmpty(str)) { sb.Append(" ShangPaiYear<=" + str + " 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(" BianShuQi ='" + str + "' and"); } str = Request["s_type"]; if (!string.IsNullOrEmpty(str) && str != "1") { } str = Request["order"]; var order = ""; var orderby = 0; switch (str) { case "1": order = "CreateTime"; orderby = 1; break; case "2": order = "CreateTime"; 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; } str = Request["show"]; if (!string.IsNullOrEmpty(str)) { } if (sb.Length > 3) { sb.Remove(sb.Length - 3, 3); } var ls1 = new CarDetialInfoDb().Exec(sb.ToString(), 1, 25, order, orderby, out TotalRecord, out TotalPage); foreach (var l in ls1) { ls.Add(l); } return(ls); }
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(); }
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; string CarType = context.Request.Params["CarType"]; StringBuilder logParams = new StringBuilder(); foreach (var item in context.Request.Params.AllKeys) { logParams.AppendFormat("{0}:{1},", item, context.Request[item]); } if (string.IsNullOrEmpty(CarType)) { CarType = ""; } string brandNum = context.Request.Params["brandNum"]; int tempid = 0; if (string.IsNullOrEmpty(brandNum) || !int.TryParse(brandNum.ToLower().Replace("n", ""), out tempid)) { brandNum = ""; } string BrandType = context.Request.Params["BrandType"]; if (string.IsNullOrEmpty(BrandType) || !int.TryParse(BrandType.ToLower().Replace("n", ""), out tempid)) { BrandType = ""; } string CarColor = context.Request.Params["CarColor"]; if (string.IsNullOrEmpty(CarColor)) { CarColor = ""; } string BianShuQi = context.Request.Params["BianShuQi"]; if (string.IsNullOrEmpty(BianShuQi)) { BianShuQi = ""; } string baojia = context.Request.Params["MinBaojia"]; decimal minBaojia = 0; if (!string.IsNullOrEmpty(baojia)) { decimal.TryParse(baojia, out minBaojia); if (minBaojia <= 0) { minBaojia = 0; } } baojia = context.Request.Params["MaxBaojia"]; decimal maxBaojia = 0; if (!string.IsNullOrEmpty(baojia)) { decimal.TryParse(baojia, out maxBaojia); if (maxBaojia <= minBaojia) { maxBaojia = minBaojia; } } int pageid = 1; string temppageid = context.Request.Params["pageid"]; if (!string.IsNullOrEmpty(temppageid)) { int.TryParse(temppageid, out pageid); if (pageid <= 1) { pageid = 1; } } int pageCount = 20; temppageid = context.Request.Params["pageCount"]; if (!string.IsNullOrEmpty(temppageid)) { int.TryParse(temppageid, out pageCount); if (pageCount <= 5) { pageCount = 5; } } string sort = context.Request.Params["sort"]; if (string.IsNullOrEmpty(sort)) { sort = ""; } string sortKey = ""; switch (sort.ToLower()) { case "time": sortKey = "ShangPaiYear"; break; case "brand": sortKey = "BrandInfoKey"; break; case "price": sortKey = "baojia"; break; default: sortKey = "id"; break; } string sortType = context.Request.Params["sortType"]; sortType = string.IsNullOrEmpty(sortType) ? "desc" : sortType.Trim().ToLower(); if (sortType != "desc") { sortType = "asc"; } var list = new CarDetialInfoDb().GetCarList(CarType, brandNum, BrandType, CarColor, BianShuQi, minBaojia, maxBaojia, pageid, pageCount, sortKey, sortType); int total = 0; if (list != null) { total = list.Count; } ApiLogInfo log = new ApiLogInfo { LogType = "SearchApi", UserAgent = context.Request.UserAgent, Referer = context.Request.UrlReferrer == null ? "" : context.Request.UrlReferrer.ToString(), UserIp = Gsetip(), Remark = "param:" + logParams + " result count" + total }; new ApiLogInfoDb().AddApiLogo(log); string filepath = context.Server.MapPath("/"); //picchange(list, filepath); foreach (var car in list) { string[] pic = car.Images.Split(';'); foreach (var img in pic) { picchange(filepath + img.Replace("/", "\\").TrimStart('\\')); } } if (list != null && list.Count > 0) { string result = JsonConvert.SerializeObject(list); var tempitem = "{ret:1, data:" + result + ",msg: 'sucessed'}"; context.Response.Write(tempitem); } else { var tempitem = "{ret:0, data[],msg: 'empty'}"; context.Response.Write(tempitem); } }