/// <summary> /// 提交事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string imgs = Request.Form["img1"].ToString(); //string imgs2 = Request.Form["img2"].ToString(); Common.Cookie cookie = new Common.Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); string sql = string.Empty; Dictionary <string, string> di = new Dictionary <string, string>(); for (int i = 0; i < imgs.Split(',').Length; i++) { sql = "SELECT * FROM TopTaobaoShopImg WHERE nick='" + taobaoNick + "' AND name='" + imgs.Split(',')[i].ToString() + "'"; di.Add(imgs.Split(',')[i].ToString(), ""); FileStream stream = new FileStream("D:\\groupbuy.7fshop.com/wwwroot/top/groupbuy/images/" + imgs.Split(',')[i].ToString(), FileMode.Open); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, int.Parse(stream.Length.ToString())); stream.Close(); string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); PictureUploadRequest req = new PictureUploadRequest(); req.PictureCategoryId = 0L; req.ImageInputTitle = imgs.Split(',')[i].ToString(); req.Title = imgs.Split(',')[i].ToString(); req.Img = new Taobao.Top.Api.Util.FileItem(imgs.Split(',')[i].ToString(), bytes); client.PictureUpload(req, session); PictureGetRequest pc = new PictureGetRequest(); pc.Title = imgs.Split(',')[i].ToString(); pc.PictureCategoryId = 0L; Taobao.Top.Api.Domain.PageList <Taobao.Top.Api.Domain.Picture> li = client.PictureGet(pc, session); for (int j = 0; j < li.Content.Count; j++) { sql = "INSERT INTO TopTaobaoShopImg ([nick],[imgSrc] ,[name]) VALUES ('" + taobaoNick + "','" + li.Content[j].PicturePath + "','" + imgs.Split(',')[i].ToString() + "')"; } } }
private void GetData(string nick) { string session = top_session; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", top_appkey, app_secret); //获取店铺基本信息 UserGetRequest request = new UserGetRequest(); request.Fields = "user_id,nick,seller_credit"; request.Nick = nick; string oldNick = nick; User user = client.UserGet(request, session); if (CheckUserExits(nick)) { //更新登录次数和最近登陆时间 string sql = "UPDATE TCS_ShopSession SET session='" + top_session + "',version='" + versionNo + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); } else { //记录该会员的店铺信息 InsertUserInfo(nick); } IDictionary <string, string> param = new Dictionary <string, string>(); string result = Post("http://gw.api.taobao.com/router/rest", top_appkey, app_secret, "taobao.increment.customer.permit", top_session, param); //更新用户订购信息 CheckUser("0", nick); //加密NICK Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Encrypt(nick); Common.Cookie cookie = new Common.Cookie(); cookie.setCookie("top_sessionsale", top_session, 999999); cookie.setCookie("nick", nick, 999999); Response.Redirect("indexsale.html"); }
protected void Page_Load(object sender, EventArgs e) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); id = utils.NewRequest("id", utils.RequestType.QueryString); id = id.Replace(".png", ""); string title = string.Empty; string width = string.Empty; string height = string.Empty; string num = string.Empty; //获取广告标题 string sql = string.Empty; //图片缓存判断 if (1 == 1) { sql = "SELECT name,size,nick FROM TopIdea WHERE id = " + id; DataTable dt = utils.ExecuteDataTable(sql); if (dt.Rows.Count != 0) { //创建图片临时文件架 folderPath = Server.MapPath("../folder/" + MD5(dt.Rows[0]["nick"].ToString())); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } //判断生成好的图片是否过期 string resultPath = folderPath + "/result_" + id + ".jpg"; if (File.Exists(resultPath)) { RecordAndShow(folderPath); return; } } else { return; } } }
/// <summary> /// 更新淘宝商品的描述内容 /// </summary> /// <param name="p"></param> /// <param name="newContent"></param> private void UpdateProductInfo(long p, string newContent) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); ItemUpdateRequest request = new ItemUpdateRequest(); request.NumIid = p; request.Desc = newContent; client.ItemUpdate(request, session); Response.Write("http://item.taobao.com/item.htm?id=" + p); Response.Write("<br><br>"); Response.Write(newContent); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.tbsandbox.com/router/rest", "test", "test"); //UserGetRequest request = new UserGetRequest(); //request.Fields = "buyer_credit"; //request.Nick = "golddonkey"; //Taobao.Top.Api.Domain.User user = client.UserGet(request); //Response.Write(user.BuyerCredit.Score); //ProductsGetRequest request = new ProductsGetRequest(); //request.Fields = "product_id,name,pic_url,shop_price"; //request.Nick = "golddonkey"; //PageList<Product> product = client.ProductsGet(request); //Response.Write(product.Content.Count); //test.DataSource = product.Content; //test.DataBind(); ShopGetRequest request = new ShopGetRequest(); request.Fields = "title"; request.Nick = "golddonkey"; Shop shop = client.ShopGet(request); Response.Write(shop.Title); }
/// <summary> /// 清除宝贝描述里面的活动页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button4_Click(object sender, EventArgs e) { string appkey = "12690738"; string secret = "66d488555b01f7b85f93d33bc2a1c001"; session = utils.NewRequest("session", utils.RequestType.QueryString); StringBuilder builder = new StringBuilder(); //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDel(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); builder.Append(resultpro + "\r\n"); //Response.Write(resultpro + "<br>\r\n"); } catch { } } if (product.Content.Count < 200) { break; } } File.WriteAllText(Server.MapPath("htmlLog/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + nick + ".txt"), builder.ToString()); Response.Write("<script>alert('清除成功!');</script>"); Response.End(); }
/// <summary> /// 记录该会员的店铺信息 /// </summary> private void InsertUserInfo(string nick) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", top_appkey, app_secret); //记录店铺基本信息 string ip = Request.UserHostAddress; ShopGetRequest request = new ShopGetRequest(); request.Fields = "sid,cid,title,nick,desc,bulletin,pic_path,created,modified"; request.Nick = nick; Shop shop; try { shop = client.ShopGet(request); } catch { Response.Write("没有店铺的淘宝会员不可使用该应用,如果您想继续使用,请先去淘宝网开个属于您自己的店铺!<br> <a href='http://www.taobao.com/'>返回</a>"); Response.End(); return; } //获取版本号 string version = "9"; //IDictionary<string, string> param = new Dictionary<string, string>(); //param.Add("article_code", "service-0-22904"); //param.Add("nick", nick); //string result = PostJson("http://gw.api.taobao.com/router/rest", top_appkey, app_secret, "taobao.vas.subscribe.get", top_session, param); //if (result.IndexOf("\"article_user_subscribes\":{}") == -1) //{ // Regex reg = new Regex(@"""item_code"":""([^""]*)""", RegexOptions.IgnoreCase); // //更新店铺的版本号 // MatchCollection match = reg.Matches(result); // for (int j = 0; j < match.Count; j++) // { // version = match[j].Groups[1].ToString().Replace("service-0-22904-", ""); // if (version == "9") // { // version = "3"; // } // if (int.Parse(version) <= 3) // { // break; // } // } //} //记录到本地数据库 string sql = "INSERT INTO TCS_ShopSession (" + "sid, " + "nick, " + "typ, " + "version, " + "session" + " ) VALUES ( " + " '" + shop.Sid + "', " + " '" + shop.Nick + "', " + " 'taobao', " + " '" + version + "', " + " '" + top_session + "' " + ") "; utils.ExecuteNonQuery(sql); }
/// <summary> /// 添加活动 /// </summary> public void addactivity() { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取原宝贝 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc,num_iid,title,price,pic_url "; requestItem.NumIid = long.Parse(iid); Item product = client.ItemGet(requestItem, session); sql = "select * from tete_activity where id=" + actionId; DataTable dt = utils.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { discountType = Request.QueryString["discountType"].ToString(); //DISCOUNT 或PRICE discountValue = Request.QueryString["discountValue"].ToString(); //促销力度 discountValue = Request.QueryString["discountValue"].ToString(); //促销力度 if (discountType == "") { discountType = "DISCOUNT"; if (discountValue == "") { discountValue = "10"; } } else { if (discountValue == "") { discountValue = "0"; } } decreaseNum = Request.QueryString["decreaseNum"].ToString(); //是否优惠限制 string rcounts = Request.QueryString["rcounts"].ToString(); //团购人数 //创建活动及相关人群 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; //创建活动相关人群 string guid = Guid.NewGuid().ToString().Substring(0, 4); IDictionary <string, string> param = new Dictionary <string, string>(); string tagid = "1"; //new Regex(@"<tag_id>([^<]*)</tag_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //创建活动 param = new Dictionary <string, string>(); param.Add("num_iids", iid); param.Add("discount_type", discountType); param.Add("discount_value", discountValue); param.Add("start_date", DateTime.Parse(dt.Rows[0]["startDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss")); param.Add("end_date", DateTime.Parse(dt.Rows[0]["endDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss")); param.Add("promotion_title", dt.Rows[0]["Name"].ToString()); param.Add("decrease_num", decreaseNum); param.Add("tag_id", tagid); string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotion.add", session, param); WriteLog(result, "1", taobaoNick, iid); if (result.IndexOf("error_response") != -1) { // sql = "delete from [tete_activitylist] WHERE ActivityID = " + actionId + " and ProductID=" + iid; // utils.ExecuteNonQuery(sql); string err = new Regex(@"<sub_msg>([^<]*)</sub_msg>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); if (err == "") { Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>您的session已经失效,需要重新授权</font><br><a href='http://container.api.taobao.com/container?appkey=12287381&scope=promotion' target='_parent'>重新授权</a>"); Response.End(); } Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>" + err + "</font><br><a href='activityadd.aspx'>重新添加</a>"); Response.End(); return; } string promotionid = new Regex(@"<promotion_id>([^<]*)</promotion_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); sql = "INSERT [tete_activitylist] ([ActivityID] ,[Productname] ,[Productprice] ,[ProductImg] ,[ProductUrl] ,[ProductID] ,[promotionID] ,[Name] ,[Description] ,[Remark] ,[startDate] ,[endDate] ,[itemType] ,[discountType] ,[discountValue] ,[tagId] ,[Status] ,[Rcount] ,[Nick] ,[decreaseNum] ,[isOK]) VALUES(" + actionId + ",'" + product.Title + "','" + product.Price + "','" + product.PicUrl + "','http://item.taobao.com/item.htm?id=" + product.NumIid.ToString() + "','" + iid + "','" + promotionid + "','" + dt.Rows[0]["Name"].ToString() + "','" + dt.Rows[0]["Description"].ToString() + "','" + dt.Rows[0]["Remark"].ToString() + "','" + dt.Rows[0]["startDate"].ToString() + "','" + dt.Rows[0]["endDate"].ToString() + "','" + dt.Rows[0]["itemType"].ToString() + "','" + discountType + "','" + discountValue + "','" + dt.Rows[0]["tagId"].ToString() + "',0," + rcounts + ",'" + taobaoNick + "'," + decreaseNum + ",0)"; utils.ExecuteNonQuery(sql); Response.Write("true"); Response.End(); } else { Response.Write("null"); Response.End(); } }
/// <summary> /// 记录该会员的店铺信息 /// </summary> private void InsertUserInfo(string nick) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5"); //记录店铺基本信息 ShopGetRequest request = new ShopGetRequest(); request.Fields = "sid,cid,title,nick,desc,bulletin,pic_path,created,modified"; request.Nick = nick; Shop shop; try { shop = client.ShopGet(request); } catch { Response.Write("没有店铺的淘宝会员不可使用该应用,如果您想继续使用,请先去淘宝网开个属于您自己的店铺!<br> <a href='http://www.taobao.com/'>返回</a>"); Response.End(); return; } //记录到本地数据库 string sql = "INSERT INTO TopTaobaoShop (" + "sid, " + "cid, " + "title, " + "nick, " + "[desc], " + "bulletin, " + "pic_path, " + "created, " + "modified, " + "shop_score, " + "versionNo, " + "remain_count " + " ) VALUES ( " + " '" + shop.Sid + "', " + " '" + shop.Cid + "', " + " '" + shop.Title + "', " + " '" + shop.Nick + "', " + " '" + shop.Desc + "', " + " '" + shop.Bulletin + "', " + " '" + shop.PicPath + "', " + " '" + shop.Created + "', " + " '" + shop.Modified + "', " + " '" + shop.ShopScore + "', " + " '" + versionNo + "', " + " '" + shop.RemainCount + "' " + ") "; utils.ExecuteNonQuery(sql); //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = nick; PageList <SellerCat> cat = client.SellercatsListGet(request1); for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + nick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //记录店铺所有商品信息-暂不记录 }
protected void Page_Load(object sender, EventArgs e) { try { id = utils.NewRequest("id", Common.utils.RequestType.QueryString); if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } style = utils.NewRequest("style", Common.utils.RequestType.Form); size = utils.NewRequest("size", Common.utils.RequestType.Form); type = utils.NewRequest("type", Common.utils.RequestType.Form); orderby = utils.NewRequest("orderby", Common.utils.RequestType.Form); query = utils.NewRequest("query", Common.utils.RequestType.Form); shopcat = utils.NewRequest("shopcat", Common.utils.RequestType.Form); name = utils.NewRequest("name", Common.utils.RequestType.Form); items = utils.NewRequest("items", Common.utils.RequestType.Form); string act = utils.NewRequest("act", Common.utils.RequestType.Form); if (act == "save") { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //记录到本地数据库 string sql = "INSERT INTO TopIdea (" + "name, " + "showtype, " + "nick, " + "size, " + "style, " + "orderby, " + "shopcategoryid, " + "query " + " ) VALUES ( " + " '" + name + "', " + " '" + type + "', " + " '" + taobaoNick + "', " + " '" + size + "', " + " '" + style + "', " + " '" + orderby + "', " + " '" + shopcat + "', " + " '" + query + "' " + ") "; //如果为编辑模式 if (id != "" && id != "0") { //更新广告 sql = "UPDATE TopIdea SET " + "name = '" + name + "', " + "showtype = '" + type + "', " + "size = '" + size + "', " + "style = '" + style + "', " + "orderby = '" + orderby + "', " + "shopcategoryid = '" + shopcat + "', " + "query = '" + query + "' " + " WHERE id = " + id; utils.ExecuteNonQuery(sql); //如果是自动更新模式,需要更新店铺商品数据 sql = "SELECT shopcategoryid,query,nick,showtype FROM TopIdea WHERE nick = '" + taobaoNick + "' AND id = " + id; DataTable dt1 = utils.ExecuteDataTable(sql); if (dt1.Rows[0]["showtype"].ToString() == "0") { //更新下架商品数据 shopcat = dt1.Rows[0][0].ToString(); query = dt1.Rows[0][1].ToString(); taobaoNick = dt1.Rows[0][2].ToString(); //获取新商品列表 TopXmlRestClient clientaa = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 12; request.OrderBy = "list_time:desc"; request.OrderBy = "volume:desc"; if (shopcat != "0") { request.SellerCids = shopcat; } request.Q = query; //清理关联商品 sql = "DELETE FROM TopIdeaProduct WHERE ideaid = " + id; utils.ExecuteNonQuery(sql); //未登录用户不能获取小二下架或删除的商品-错误过滤,原因未知 try { PageList <Item> product = clientaa.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + product.Content[i].NumIid + "', " + " '" + product.Content[i].Title + "', " + " '" + product.Content[i].Price + "', " + " '" + product.Content[i].PicUrl + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } catch { } } //清理关联商品 sql = "DELETE FROM TopIdeaProduct WHERE ideaid = " + id; utils.ExecuteNonQuery(sql); //清理广告缓存 CacheManager testcaching1 = CacheFactory.GetCacheManager(); if (testcaching1.Contains("cache_1_" + id)) { testcaching1.Remove("cache_1_" + id); } //更新广告图片 string folderPath = Server.MapPath("\\show\\folder\\" + MD5(taobaoNick) + "\\result_" + id + ".jpg"); if (File.Exists(folderPath)) { File.Delete(folderPath); } } utils.ExecuteNonQuery(sql); if (id != "" && id != "0") { //编辑模式,ID不变 } else { //插入模式,获取最新ID sql = "SELECT TOP 1 id FROM TopIdea WHERE nick = '" + taobaoNick + "' ORDER BY id DESC"; id = utils.ExecuteString(sql); } //获取符合结果集的相关商品并记录到本地数据库 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); //如果为自动选择模式 if (type == "0") { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 12; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } //未登录用户不能获取小二下架或删除的商品-错误过滤,原因未知 try { PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + product.Content[i].NumIid + "', " + " '" + product.Content[i].Title + "', " + " '" + product.Content[i].Price + "', " + " '" + product.Content[i].PicUrl + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } catch { } } else { string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); for (int i = 0; i < arr.Length; i++) { string strSPID = "29230000ea039296234e9d74d8d3d5b7"; string strSKEY = "2dsi35b3fdx050a41jufbnzirrlqd9kl"; string strUIN = taobaoNick; string strTOKEN = session; ApiClient clientQQ = new ApiClient(strSPID, strSKEY, Convert.ToInt32(strUIN), strTOKEN); //通过以下的接口函数添加这些参数 clientQQ.addParamInStringField("itemCode", arr[i]); clientQQ.invokeApi("http://api.paipai.com/item/getItem.xhtml?charset=utf-8"); string result = clientQQ.ToString(); Regex reg = new Regex(@"""itemName"":""([^""]*)"",[\s\S]*""itemPrice"":""([^""]*)"",[\s\S]*""picLink"":""([^""]*)"",", RegexOptions.IgnoreCase); MatchCollection match = reg.Matches(result); for (int j = 0; j < match.Count; j++) { sql = "INSERT INTO TopIdeaProduct (" + "itemid, " + "itemname, " + "itemprice, " + "itempicurl, " + "ideaid " + " ) VALUES ( " + " '" + arr[i] + "', " + " '" + match[j].Groups[1].ToString() + "', " + " '" + match[j].Groups[2].ToString() + "', " + " '" + match[j].Groups[3].ToString() + "', " + " '" + id + "' " + ") "; utils.ExecuteNonQuery(sql); } } } } //获取NICK的淘宝ID Cookie cookieNew = new Cookie(); string taobaoNickNew = cookieNew.getCookie("nick"); Rijndael_ encodeaa = new Rijndael_("tetesoft"); taobaoNickNew = encodeaa.Decrypt(taobaoNickNew); md5nick = MD5(taobaoNickNew); //string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNickNew + "'"; string sqlNew = "SELECT sellerUin FROM TopPaipaiShop WHERE sellerUin = '" + taobaoNickNew + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop.paipai.com/" + dtNew.Rows[0][0].ToString(); } else { nickid = "http://www.paipai.com/"; } nickidEncode = "http://www.7fshop.com/click/?s=" + EncodeStr(new string[] { id, "0", nickid }); string sql112 = "SELECT * FROM TopIdea WHERE id = " + id; DataTable newdt1 = utils.ExecuteDataTable(sql112); if (newdt1.Rows.Count != 0) { tabletitle = newdt1.Rows[0]["name"].ToString(); size = newdt1.Rows[0]["size"].ToString(); } string num = string.Empty; string row = string.Empty; switch (size) { case "514*160": num = "5"; row = "5"; break; case "514*288": num = "10"; row = "5"; break; case "664*160": num = "6"; row = "6"; break; case "312*288": num = "6"; row = "3"; break; case "336*280": num = "4"; row = "2"; break; case "714*160": num = "7"; row = "7"; break; case "114*418": num = "3"; row = "1"; break; case "218*286": num = "4"; row = "2"; break; case "743*308": num = "4"; row = "4"; break; default: num = "4"; row = "4"; break; } //绑定商品列表 string sql11 = "SELECT TOP " + num + " *,'' AS html FROM TopIdeaProduct WHERE ideaid = " + id; DataTable newdt = utils.ExecuteDataTable(sql11); //加换行符 for (int i = 0; i < newdt.Rows.Count; i++) { if ((i + 1) % int.Parse(row) == 0) { newdt.Rows[i]["html"] = "</tr><tr>"; } } if (size != "743*308") { panel1.Visible = true; panel2.Visible = false; rptProduct.DataSource = newdt; rptProduct.DataBind(); } else { panel1.Visible = false; panel2.Visible = true; rptProduct2.DataSource = newdt; rptProduct2.DataBind(); } string[] arrNew = size.Split('*'); width = arrNew[0]; height = arrNew[1]; } catch { } }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { Response.Write("<input type='checkbox' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title + "</label><br>"); } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); } }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessionblog"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string isradio = utils.NewRequest("isradio", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5"); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { if (isradio == "1") { Response.Write("<input type='radio' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title + "</label><br>"); } else { Response.Write("<input type='checkbox' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title + "</label><br>"); } } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); } else if (act == "getResultStr") { string items = utils.NewRequest("ids", utils.RequestType.QueryString); string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //标志 int flag = 1; if (arr.Length == 1) { flag = 0; } for (int i = flag; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } string str = string.Empty; //根据不同样式显示不同的字符串 string style = utils.NewRequest("style", utils.RequestType.QueryString); string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); string nickid = string.Empty; if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } if (isradio == "1") { //团购需要的商品数据 for (int i = 0; i < itemList.Count; i++) { str = "<A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_160x160.jpg\" border=0 /></A><br>" + itemList[i].Title + "<br>" + itemList[i].Price + "<input type=\"hidden\" id=\"productid\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\">"; } } else { if (style == "1") { str += "<table background=\"http://www.7fshop.com/top/show1/4.gif\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\" style=\"border-right: #999999 1px solid; border-top: #999999 1px solid;border-left: #999999 1px solid; border-bottom: #999999 1px solid\" width=\"580\"><tr><td> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\"><tr><td width=\"10\"></td><td background=\"http://www.7fshop.com/top/show1/1.gif\" width=\"24\"></td><td background=\"http://www.7fshop.com/top/show1/2.gif\"><font color=\"white\" style=\"font-size: 13px\"><strong>掌柜推荐商品</strong></font></td><td><img src=\"http://www.7fshop.com/top/show1/3.gif\" /></td></tr></table></td><td align=\"right\"></td></tr></table></td></tr></table> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-right: #999999 1px solid;border-top: #999999 1px solid; overflow: hidden; border-left: #999999 1px solid;border-bottom: #999999 1px solid\" width=\"578\"><tr><td valign=\"top\"><TABLE cellSpacing=0 cellPadding=0 width=578 border=0><TBODY><TR><TD align=\"middle\"><TABLE cellSpacing=8 cellPadding=0 align=center border=0><TBODY><TR>"; for (int i = 0; i < itemList.Count; i++) { str += "<TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD align=\"middle\"><DIV style=\"BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; MARGIN-TOP: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 160px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 160px\"><DIV style=\"OVERFLOW: hidden; WIDTH: 160px; HEIGHT: 160px\"><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_160x160.jpg\" border=0 /></A></DIV></DIV></TD></TR><TR><TD align=\"middle\"><DIV style=\"PADDING-RIGHT: 4px; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px\"><A style=\"FONT-SIZE: 12px; COLOR: #3f3f3f; TEXT-DECORATION: none\" href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\">" + itemList[i].Title + "</A><BR /><FONT style=\"COLOR: #fe596a\"><B>¥ " + itemList[i].Price + "元</B></FONT> </DIV><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"http://www.7fshop.com/top/show1/buy1.gif\" border=0 /></A> <DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>"; if ((i + 1) % 3 == 0) { str += "</tr><tr>"; } } str += "</TR></TBODY></TABLE></td></tr><tr><td align=\"right\" height=\"24\" style=\"border-bottom: #999999 1px solid\" valign=\"center\"><a href=\"" + nickid + "\" style=\"text-decoration: none\" target=\"_blank\"><font style=\"font-size: 13px; color: #ff6600\"><strong>更多详情请见 " + nickid + "</strong> </font></a></td></tr></table></td></tr></table>"; } else { for (int i = 0; i < itemList.Count; i++) { str += "<a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><img src=\"" + itemList[i].PicUrl + "\" border=\"0\" /></a><br />"; str += "<a href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\">" + itemList[i].Title + "</a> 售价:" + itemList[i].Price + "元<br><br>"; } } } Response.Write(str); } }
protected void Page_Load(object sender, EventArgs e) { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; //获取参数 string q = utils.NewRequest("query", utils.RequestType.QueryString); string page = utils.NewRequest("p", utils.RequestType.QueryString); if (page == "") { page = "1"; } string catid = utils.NewRequest("catid", utils.RequestType.QueryString); string isradio = utils.NewRequest("isradio", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); int pageSizeNow = 15; if (act == "get") { //获取用户店铺商品列表 ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = pageSizeNow; request.PageNo = int.Parse(page); request.Q = q; if (catid != "0") { request.SellerCids = catid; } PageList <Item> product = client.ItemsOnsaleGet(request, session); //输出页面HTML for (int i = 0; i < product.Content.Count; i++) { if (isradio == "1") { Response.Write("<input type='radio' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title.Replace("%", "") + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title.Replace("%", "") + "</label><br>"); } else { Response.Write("<input type='checkbox' name='items' id='item_" + product.Content[i].NumIid + "' title='" + product.Content[i].Title.Replace("%", "") + "' value='" + product.Content[i].NumIid + "' onclick=\"InitArea(this)\"><label onMouseOver=\"javascript:ddrivetip('<img src=" + product.Content[i].PicUrl + "_80x80.jpg>','#ffffff',100)\" onMouseOut=\"hideddrivetip()\" for='item_" + product.Content[i].NumIid + "'>" + product.Content[i].Title.Replace("%", "") + "</label><br>"); } } Response.Write("<br>"); long totalPage = (product.TotalResults % pageSizeNow == 0) ? (product.TotalResults / pageSizeNow) : (product.TotalResults / pageSizeNow + 1); //输出分页HTML for (int i = 1; i <= totalPage; i++) { if (page == i.ToString()) { Response.Write(i.ToString() + " "); } else { Response.Write("<a href=\"javascript:spreadStat(" + i.ToString() + ")\">[" + i.ToString() + "]</a> "); } } } else if (act == "getCat") { //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = taobaoNick; PageList <SellerCat> cat = client.SellercatsListGet(request1); //清除老分类 string sql = "DELETE FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; utils.ExecuteNonQuery(sql); //插入新分类 for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + taobaoNick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //输出页面HTML Response.Write("<select id=\"shopcat\" name=\"shopcat\"><option value=\"0\"></option>"); for (int i = 0; i < cat.Content.Count; i++) { Response.Write("<option value='" + cat.Content[i].Cid + "'>" + cat.Content[i].Name + "</option>"); } Response.Write("</select>"); } else if (act == "getResultStr") { string items = utils.NewRequest("ids", utils.RequestType.QueryString); string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //标志 int flag = 1; if (arr.Length == 1) { flag = 0; } for (int i = flag; i < arr.Length; i++) { ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(arr[i]); Item product = client.ItemGet(request); itemList.Add(product); } string str = string.Empty; //根据不同样式显示不同的字符串 string style = utils.NewRequest("style", utils.RequestType.QueryString); //string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; //DataTable dtNew = utils.ExecuteDataTable(sqlNew); //string nickid = string.Empty; //if (dtNew.Rows.Count != 0) //{ // nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; //} //else //{ // nickid = "http://www.taobao.com/"; //} if (isradio == "1") { //团购需要的商品数据 for (int i = 0; i < itemList.Count; i++) { str = "<div id=item_" + itemList[i].NumIid.ToString() + " style=\"float:left;width:46px;border:solid 1px #ccc;padding:2px;margin:2px;\"><A href=\"http://item.taobao.com/item.htm?id=" + itemList[i].NumIid.ToString() + "\" target=\"_blank\"><IMG src=\"" + itemList[i].PicUrl + "_40x40.jpg\" border=0 title=\"" + itemList[i].Title + "\" /></A><br>" + itemList[i].Price + "<input type=\"hidden\" id=\"productid\" name=\"productid\" value=\"" + itemList[i].NumIid.ToString() + "\"><input type=\"hidden\" id=\"price\" name=\"price\" value=\"" + itemList[i].Price.ToString() + "\"><br><a href=\"javascript:delitem(" + itemList[i].NumIid.ToString() + ")\">删除</a></div>"; } } Response.Write(str); } }
protected void Button2_Click(object sender, EventArgs e) { nick = this.TextBox1.Text; session = this.TextBox2.Text; string appkey = "12132145"; string secret = "1fdd2aadd5e2ac2909db2967cbb71e7f"; //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDelHaoping(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); } catch { } } if (product.Content.Count < 200) { break; } } Response.Write("<script>alert('清除成功!');</script>"); Response.End(); }
/// <summary> /// 完成创建 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnsubmit_Click(object sender, EventArgs e) { Common.Cookie cookie = new Common.Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Decrypt(taobaoNick); //判断人群数不得超过4个 if (ActCountJudge()) { ShowErr("您最多只能创建4个活动"); return; } //后端判断数据但是否合法 if (DataJudge()) { ShowErr("录入数据不合法"); return; } //插入数据库 string groupbuyname = utils.NewRequest("groupbuyname", utils.RequestType.Form).Replace("'", "''"); string starttime = utils.NewRequest("starttime", utils.RequestType.Form) + " " + utils.NewRequest("startSelect", utils.RequestType.Form).Replace("'", "''") + ":00"; string endtime = utils.NewRequest("endtime", utils.RequestType.Form) + " " + utils.NewRequest("endSelect", utils.RequestType.Form).Replace("'", "''") + ":00"; string groupbuyprice = utils.NewRequest("groupbuyprice", utils.RequestType.Form); string productid = utils.NewRequest("productid", utils.RequestType.Form); string maxcount = utils.NewRequest("maxcount", utils.RequestType.Form); string zhekou = utils.NewRequest("zhekou", utils.RequestType.Form); string mintime = utils.NewRequest("mintime", utils.RequestType.Form); //通过借口获取淘宝相关数据 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.NumIid = long.Parse(productid); Item product = client.ItemGet(request, session); string newprice = Math.Round(decimal.Parse(product.Price) - decimal.Parse(zhekou), 2).ToString(); //创建活动及相关人群 string appkey = "12132145"; string secret = "1fdd2aadd5e2ac2909db2967cbb71e7f"; ////创建活动相关人群 //string guid = Guid.NewGuid().ToString().Substring(0, 4); IDictionary <string, string> param = new Dictionary <string, string>(); //param.Add("tag_name", nick + "_活动人群_" + guid); //param.Add("description", nick + "_活动人群描述_" + guid); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.tag.add", session, param); //string tagid = new Regex(@"<tag_id>([^<]*)</tag_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //Response.Write(result + "<br><br>"); //目前针对全部商城会员 string tagid = "1"; //创建活动 param = new Dictionary <string, string>(); param.Add("num_iids", productid); param.Add("discount_type", "PRICE"); param.Add("discount_value", newprice); param.Add("start_date", starttime); param.Add("end_date", endtime); param.Add("promotion_title", groupbuyname); param.Add("tag_id", tagid); string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotion.add", session, param); if (result.IndexOf("Insufficient session permissions") != -1) { Response.Write("<b>优惠券创建失败,错误原因:</b><br><font color='red'>您的session已经失效,需要重新授权</font><br><a href='http://container.api.taobao.com/container?appkey=12132145&scope=promotion' target='_parent'>重新授权</a>"); Response.End(); return; } if (result.IndexOf("error_response") != -1) { string err = new Regex(@"<sub_msg>([^<]*)</sub_msg>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); Response.Write("<b>活动创建失败,错误原因:</b><br><font color='red'>" + err + "</font><br><a href='groupbuyadd.aspx'>重新添加</a>"); Response.End(); return; } string promotionid = new Regex(@"<promotion_id>([^<]*)</promotion_id>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString(); //Response.Write(result + "<br><br>"); string productname = product.Title; string productprice = product.Price; string productimg = product.PicUrl; string producturl = "http://item.taobao.com/item.htm?id=" + productid; string sql = "INSERT INTO TopGroupBuy (" + "name," + "starttime," + "endtime," + "productname," + "productprice," + "productimg," + "producturl," + "productid," + "nick," + "maxcount," + "buycount," + "tagid," + "promotionid," + "mintime," + "zhekou," + "groupbuyprice" + " ) VALUES ( " + " '" + groupbuyname + "'," + " '" + starttime + "'," + " '" + endtime + "'," + " '" + productname + "'," + " '" + productprice + "'," + " '" + productimg + "'," + " '" + producturl + "'," + " '" + productid + "'," + " '" + nick + "'," + " '" + maxcount + "'," + " '0'," + " '" + tagid + "'," + " '" + promotionid + "'," + " '" + mintime + "'," + " '" + newprice + "'," + " '" + zhekou + "'" + ") "; //Response.Write(sql); //Response.End(); //return; utils.ExecuteNonQuery(sql); //将测试用户加入该活动关联人群组 //IDictionary<string, string> param = new Dictionary<string, string>(); //param.Add("tag_id", tagid); //param.Add("nick", "美杜莎之心"); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.taguser.add", session, param); //Response.Write(result); //查询活动详细 //IDictionary<string, string> param = new Dictionary<string, string>(); //param.Add("fields", "num_iids,discount_type,discount_value,start_date,end_date,promotion_title,tag_id"); //param.Add("num_iid", "7591980225"); //string result = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.marketing.promotions.get", session, param); //Response.Write(result); //更新商品描述关联的广告图片 CreateGroupbuyImg(); Response.Redirect("grouplist.aspx"); }
protected void Page_Load(object sender, EventArgs e) { //try //{ id = utils.NewRequest("id", Common.utils.RequestType.QueryString); if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } style = utils.NewRequest("style", Common.utils.RequestType.Form); size = utils.NewRequest("size", Common.utils.RequestType.Form); type = utils.NewRequest("type", Common.utils.RequestType.Form); orderby = utils.NewRequest("orderby", Common.utils.RequestType.Form); query = utils.NewRequest("query", Common.utils.RequestType.Form); shopcat = utils.NewRequest("shopcat", Common.utils.RequestType.Form); name = utils.NewRequest("name", Common.utils.RequestType.Form); items = utils.NewRequest("items", Common.utils.RequestType.Form); ads = utils.NewRequest("ads", Common.utils.RequestType.Form); string act = utils.NewRequest("act", Common.utils.RequestType.Form); if (act == "save") { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); //提交更新到淘宝商品上去 if (type == "0") { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 1; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { string newContent = BindData(product.Content[i].NumIid.ToString(), ads); UpdateProductInfo(product.Content[i].NumIid, newContent); break; } } else { string[] itemId = items.Split(','); for (int i = 0; i < itemId.Length; i++) { string newContent = BindData(itemId[i], ads); UpdateProductInfo(long.Parse(itemId[i]), newContent); break; } } } //} //catch { } }
/// <summary> /// 增加活动图片到店铺分类 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; string name = utils.NewRequest("left", utils.RequestType.Form); string istop = utils.NewRequest("leftimgistop", utils.RequestType.Form); int order = 0; //保存到数据库 string sql = "UPDATE TopAutoReview SET leftimgname = '" + name + "', leftimgistop = '" + istop + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); //通过接口同步到淘宝 TopXmlRestClient clientaa = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); //左侧分类的图片位置默认在最下面,获取当前序列号最大的 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Nick = nick; request1.Fields = "name,sort_order,parent_cid"; PageList <SellerCat> cat = clientaa.SellercatsListGet(request1, session); if (cat.Content.Count == 0) { order = 1; } else { int max = 0; for (int i = 0; i < cat.Content.Count; i++) { if (cat.Content[i].ParentCid == 0 && cat.Content[i].SortOrder > max) { max = cat.Content[i].SortOrder; } } order = max + 1; } //判断该店铺是否增加过该分类 string isok = "0"; string catid = string.Empty; for (int i = 0; i < cat.Content.Count; i++) { if (cat.Content[i].Name == "好评有礼_特特营销") { isok = "1"; catid = cat.Content[i].Cid.ToString(); break; } } if (isok == "0") { //添加到左侧分类 SellercatsListAddRequest request = new SellercatsListAddRequest(); request.Name = "好评有礼_特特营销"; request.PictUrl = GetTaobaoImg(name, "left"); request.SortOrder = order; clientaa.SellercatsListAdd(request, session); } else { //更新分类图片 SellercatsListUpdateRequest request = new SellercatsListUpdateRequest(); request.Cid = int.Parse(catid); request.PictUrl = GetTaobaoImg(name, "left"); clientaa.SellercatsListUpdate(request, session); } Response.Write("<script>alert('同步成功!');window.location.href='html.aspx';</script>"); Response.End(); return; }
protected void Page_Load(object sender, EventArgs e) { //TopXmlRestClient client = new TopXmlRestClient("http://gw.api.tbsandbox.com/router/rest", "test", "test"); id = utils.NewRequest("id", utils.RequestType.QueryString); string itemid = utils.NewRequest("itemid", utils.RequestType.QueryString); string ideaid = utils.NewRequest("idea", utils.RequestType.QueryString); string act = utils.NewRequest("act", utils.RequestType.QueryString); url = utils.NewRequest("url", utils.RequestType.QueryString); width = utils.NewRequest("width", utils.RequestType.QueryString); height = utils.NewRequest("height", utils.RequestType.QueryString); num = utils.NewRequest("num", utils.RequestType.QueryString); string size = string.Empty; if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } if (num != "" && !utils.IsInt32(id)) { Response.Write("非法参数0"); Response.End(); return; } if (itemid != "" && !IsLong(itemid)) { Response.Write("非法参数2"); Response.End(); return; } if (ideaid != "" && !utils.IsInt32(ideaid)) { Response.Write("非法参数3"); Response.End(); return; } string sql = string.Empty; //只有正式模式下才统计相关信息 if (id != "0") { if (act == "hit") { return; //记录广告点击 sql = "UPDATE TopIdea SET hitcount = hitcount + 1 WHERE id = " + ideaid; utils.ExecuteNonQuery(sql); //记录点击日志 sql = "INSERT INTO TopIdeaHitLog (ideaid, itemid, url) VALUES ('" + ideaid + "', '" + itemid + "', '" + url + "')"; utils.ExecuteNonQuery(sql); Response.End(); return; } else // if (act == "view") { //记录广告浏览次数 sql = "UPDATE TopIdea SET viewcount = viewcount + 1 WHERE id = " + id; utils.ExecuteNonQuery(sql); //记录浏览日志 sql = "INSERT INTO TopIdeaLog (ideaid, url) VALUES ('" + id + "', '" + url + "')"; utils.ExecuteNonQuery(sql); //Response.End(); //return; } } //开启缓存 CacheManager testcaching1 = CacheFactory.GetCacheManager(); if (testcaching1.Contains("cache_1_" + id) && id != "3972") { Response.Write(testcaching1.GetData("cache_1_" + id)); Response.End(); return; } TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); //如果为0则为调试模式,自动按照参数进行调用 if (id == "0") { Cookie cookie1 = new Cookie(); string taobaoNick1 = cookie1.getCookie("nick"); Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick1 = encode.Decrypt(taobaoNick1); string sqlNew = "SELECT sellerUin FROM TopPaipaiShop WHERE sellerUin = '" + taobaoNick1 + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop.paipai.com/" + dtNew.Rows[0][0].ToString(); } else { nickid = "http://www.paipai.com/"; } width = (int.Parse(width) - 10).ToString(); Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_session"); string style = utils.NewRequest("style", utils.RequestType.QueryString); size = utils.NewRequest("size", utils.RequestType.QueryString); string type = utils.NewRequest("type", utils.RequestType.QueryString); string orderby = utils.NewRequest("orderby", utils.RequestType.QueryString); string query = utils.NewRequest("query", utils.RequestType.QueryString); string shopcat = utils.NewRequest("shopcat", utils.RequestType.QueryString); string items = utils.NewRequest("items", utils.RequestType.QueryString); title = utils.NewRequest("title", utils.RequestType.QueryString); //如果为自动选择模式 if (type == "0") { } //如果选择了具体商品 else { if (items == "") { return; } string[] arr = items.Split(','); List <Item> itemList = new List <Item>(); //过滤可能发生的错误 try { for (int i = 0; i < arr.Length; i++) { if (i >= int.Parse(num)) { break; } string strSPID = "29230000ea039296234e9d74d8d3d5b7"; string strSKEY = "2dsi35b3fdx050a41jufbnzirrlqd9kl"; string strUIN = taobaoNick1; string strTOKEN = session; ApiClient clientQQ = new ApiClient(strSPID, strSKEY, Convert.ToInt32(strUIN), strTOKEN); //通过以下的接口函数添加这些参数 clientQQ.addParamInStringField("itemCode", arr[i]); clientQQ.invokeApi("http://api.paipai.com/item/getItem.xhtml?charset=utf-8"); string result = clientQQ.ToString(); Regex reg = new Regex(@"""itemName"":""([^""]*)"",[\s\S]*""itemPrice"":""([^""]*)"",[\s\S]*""picLink"":""([^""]*)"",", RegexOptions.IgnoreCase); MatchCollection match = reg.Matches(result); for (int j = 0; j < match.Count; j++) { Item product = new Item(); product.Created = arr[i]; product.PicUrl = match[j].Groups[3].ToString(); product.Price = (decimal.Parse(match[j].Groups[2].ToString()) / 100).ToString(); product.Title = match[j].Groups[1].ToString(); itemList.Add(product); } } } catch { } if (size == "743*308") { panel1.Visible = false; panel2.Visible = true; Repeater2.DataSource = itemList; Repeater2.DataBind(); } else { Repeater1.DataSource = itemList; Repeater1.DataBind(); } } return; } //获取广告标题 sql = "SELECT name,size FROM TopIdea WHERE id = " + id; DataTable dt = utils.ExecuteDataTable(sql); if (dt.Rows.Count != 0) { title = dt.Rows[0]["name"].ToString(); size = dt.Rows[0]["size"].ToString(); string[] arr = size.Split('*'); width = arr[0]; height = arr[1]; switch (size) { case "514*160": num = "5"; break; case "514*288": num = "10"; break; case "664*160": num = "6"; break; case "312*288": num = "6"; break; case "336*280": num = "4"; break; case "714*160": num = "7"; break; case "114*418": num = "3"; break; case "218*286": num = "4"; break; case "743*308": num = "4"; break; default: num = "4"; break; } } //获取数据库中保存的商品 sql = "SELECT TOP " + num + " * FROM TopIdeaProduct WHERE ideaid = " + id + "";// ORDER BY NEWID()"; dt = utils.ExecuteDataTable(sql); test.DataSource = dt; test.DataBind(); //获取店铺地址 sql = "SELECT name,size,nick FROM TopIdea WHERE id = " + id; DataTable dt22 = utils.ExecuteDataTable(sql); if (dt22.Rows.Count != 0) { string taobaoNick = dt22.Rows[0]["nick"].ToString(); string sqlNew = "SELECT sellerUin FROM TopPaipaiShop WHERE sellerUin = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop.paipai.com/" + dtNew.Rows[0][0].ToString(); } else { nickid = "http://www.paipai.com/"; } } //生成HTML缓存 string cache = string.Empty; if (size == "743*308") { cache += "<table background=\"/top/show1/4.gif\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\" style=\"border-right: #999999 1px solid; border-top: #999999 1px solid;border-left: #999999 1px solid; border-bottom: #999999 1px solid\" width=\"740\"><tr><td> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"30\"><tr><td width=\"10\"></td><td background=\"/top/show1/1.gif\" width=\"24\"></td><td background=\"/top/show1/2.gif\"><font color=\"white\" style=\"font-size: 13px\"><strong>" + title + "</strong></font></td><td><img src=\"/top/show1/3.gif\" /></td></tr></table></td><td align=\"right\"></td></tr></table></td></tr></table> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-right: #999999 1px solid;border-top: #999999 1px solid; overflow: hidden; border-left: #999999 1px solid;border-bottom: #999999 1px solid\" width=\"740\"><tr><td valign=\"top\"><TABLE cellSpacing=0 cellPadding=0 width=730 border=0><TBODY><TR><TD align=\"middle\"><TABLE cellSpacing=8 cellPadding=0 align=center border=0><TBODY><TR>"; for (int i = 0; i < dt.Rows.Count; i++) { cache += "<TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD vAlign=top align=\"middle\" width=175 bgColor=white><TABLE cellSpacing=0 cellPadding=0 align=center border=0><TBODY><TR><TD align=\"middle\"><DIV style=\"BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; MARGIN-TOP: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 160px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 160px\"><DIV style=\"OVERFLOW: hidden; WIDTH: 160px; HEIGHT: 160px\"><A href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://auction1.paipai.com/" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\"><IMG alt=\"" + dt.Rows[i]["itemname"].ToString() + "\" src=\"" + dt.Rows[i]["itempicurl"].ToString() + ".3.jpg\" width=160 height=160 border=0 /></A></DIV></DIV></TD></TR><TR><TD align=\"middle\"><DIV style=\"PADDING-RIGHT: 4px; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px\"><A style=\"FONT-SIZE: 12px; COLOR: #3f3f3f; TEXT-DECORATION: none\" href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://auction1.paipai.com/" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\" title=\"" + dt.Rows[i]["itemname"].ToString() + "\">" + dt.Rows[i]["itemname"].ToString() + "</A><BR /><FONT style=\"COLOR: #fe596a\"><B>¥ " + (decimal.Parse(dt.Rows[i]["itemprice"].ToString()) / 100).ToString() + "元</B></FONT> </DIV><A href=\"/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://auction1.paipai.com/" + dt.Rows[i]["itemid"].ToString() }) + "\" onclick=\"javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');\" target=\"_blank\"><IMG src=\"/top/show1/buy1.gif\" border=0 /></A> <DIV></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>"; } cache += "</TR></TBODY></TABLE></td></tr><tr><td align=\"right\" height=\"24\" style=\"border-bottom: #999999 1px solid\" valign=\"center\"><a href=\"/click/?s=" + EncodeStr(new string[] { id, "0", nickid }) + "\" style=\"text-decoration: none\" target=\"_blank\"><font style=\"font-size: 13px; color: #ff6600\"><strong>更多详情请见 " + nickid + "</strong> </font></a></td></tr></table>"; cache += "<script type=\"text/javascript\" language=\"javascript\" src=\"css/common.js\"></script>"; cache += "<script type=\"text/javascript\">"; cache += "var xmlHttp;"; cache += "var url = '" + url + "';"; cache += "if(\"0\" != \"" + id + "\" && url != \"\"){"; cache += "createxmlHttpRequest();"; cache += "var queryString = \"http://www.7fshop.com/qqshow/plist.aspx?act=view&id=" + id + "&url=\"+escape(url)+\"&t=\"+new Date().getTime();"; cache += "xmlHttp.open(\"GET\",queryString);"; cache += "xmlHttp.send(null); }"; cache += "</script>"; } else { cache = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; cache += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; cache += "<head>"; cache += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; cache += "<title>特特推广</title>"; cache += "<link type=\"text/css\" href=\"css/css.css\" rel=\"stylesheet\"/>"; cache += "</head>"; cache += "<body>"; cache += "<div id=\"container\" style=\"width:" + width + "px; height:" + height + "px; overflow:hidden\">"; cache += "<div class=\"navigation\">" + title + "</div>"; cache += "<div class=\"outer\">"; cache += "<div class=\"inner\">"; for (int i = 0; i < dt.Rows.Count; i++) { cache += "<dl>"; cache += "<dt><a href='/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://auction1.paipai.com/" + dt.Rows[i]["itemid"].ToString() }) + "' title='" + dt.Rows[i]["itemname"].ToString() + "' onclick='javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');' target='_blank'><img src='" + dt.Rows[i]["itempicurl"].ToString() + ".2.jpg' border='0' /></a></dt>"; cache += "<dd><a href='/click/?s=" + EncodeStr(new string[] { id, dt.Rows[i]["itemid"].ToString(), "http://auction1.paipai.com/" + dt.Rows[i]["itemid"].ToString() }) + "' onclick='javascript:spreadStat('" + id + "','" + dt.Rows[i]["itemid"].ToString() + "');' target='_blank'>" + left(dt.Rows[i]["itemname"].ToString(), 16) + "</a></dd>"; cache += "</dl>"; } cache += "<br class=\"clearfloat\"/>"; cache += "</div>"; cache += "</div>"; cache += "</div>"; cache += "<script type=\"text/javascript\" language=\"javascript\" src=\"css/common.js\"></script>"; cache += "<script type=\"text/javascript\">"; cache += "var xmlHttp;"; cache += "var url = '" + url + "';"; cache += "if(\"0\" != \"" + id + "\" && url != \"\"){"; cache += "createxmlHttpRequest();"; cache += "var queryString = \"http://www.7fshop.com/qqshow/plist.aspx?act=view&id=" + id + "&url=\"+escape(url)+\"&t=\"+new Date().getTime();"; cache += "xmlHttp.open(\"GET\",queryString);"; cache += "xmlHttp.send(null); }"; cache += "</script>"; } CacheManager testcaching = CacheFactory.GetCacheManager(); if (!testcaching.Contains("cache_1_" + id)) { testcaching.Add("cache_1_" + id, cache); } //如果是743*308,则直接显示 Response.Write(cache); Response.End(); }
private void DoMyJob(string topMissionID) { //获取正在进行中的宝贝同步任务 string appkey = "12287381"; string secret = "d3486dac8198ef01000e7bd4504601a4"; string session = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); string sql = "SELECT t.*, s.sessiongroupbuy FROM TopMission t INNER JOIN TopTaobaoShop s ON s.nick = t.nick WHERE t.isok = 0 AND t.typ = 'write' AND t.id=" + topMissionID + " ORDER BY t.id ASC"; DataTable dt = utils.ExecuteDataTable(sql); DataTable dtWrite = null; string styleHtml = string.Empty; if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { session = dt.Rows[i]["sessiongroupbuy"].ToString(); sql = "SELECT * FROM TopWriteContent WHERE missionid = '" + dt.Rows[i]["id"].ToString() + "' AND isok = 0"; //WriteLog("sql1:" + sql, ""); dtWrite = utils.ExecuteDataTable(sql); if (dtWrite != null) { for (int j = 0; j < dtWrite.Rows.Count; j++) { styleHtml = CreateGroupbuyHtml(dtWrite.Rows[j]["groupbuyid"].ToString()); try { //获取原宝贝描述 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = long.Parse(dtWrite.Rows[j]["itemid"].ToString()); Item product = client.ItemGet(requestItem, session); string newContent = string.Empty; string groupid = dtWrite.Rows[j]["groupbuyid"].ToString(); string tetegroupbuyGuid = groupid; string sqltemp = "SELECT * FROM TopGroupBuy WHERE id = '" + groupid + "'"; DataTable dttemp = utils.ExecuteDataTable(sqltemp); if (dttemp == null) { Response.Write("<script>alert('更新宝贝描述失败,该团购不存在!');window.location.href='missionlist.aspx';</script>"); Response.End(); } //判断团购是多模板 if (dttemp.Rows[0]["groupbuyGuid"].ToString() != "") { tetegroupbuyGuid = dttemp.Rows[0]["groupbuyGuid"].ToString(); } //WriteLog("html:" + styleHtml.Length.ToString(), ""); if (!Regex.IsMatch(product.Desc, @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>([\s\S]*)<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>")) { newContent = @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>" + styleHtml + @"<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>" + product.Desc; } else { newContent = Regex.Replace(product.Desc, @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>([\s\S]*)<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>", @"<div><a name=""tetesoft-area-start-" + tetegroupbuyGuid + @"""></a></div>" + styleHtml + @"<div><a name=""tetesoft-area-end-" + tetegroupbuyGuid + @"""></a></div>"); } //WriteLog("html2:" + newContent.Length.ToString(), ""); //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", dtWrite.Rows[j]["itemid"].ToString()); param.Add("desc", newContent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update ", session, param); //插入宝贝错误日志 if (resultpro.IndexOf("ITEM_PROPERTIES_ERROR") != -1) { //WriteLog("更新宝贝描述:宝贝ID:" + dtWrite.Rows[j]["itemid"].ToString() + "返回的错误信息" + resultpro, "", dt.Rows[i]["nick"].ToString()); ////插入宝贝错误日志 //sql = "insert TopMissionErrDetail (TopMissionID,itemid,nick,ErrDetail) values('" + dt.Rows[i]["id"].ToString() + "','" + dtWrite.Rows[j]["itemid"].ToString() + "','" + dt.Rows[i]["nick"].ToString() + "','" + resultpro + "')"; //utils.ExecuteNonQuery(sql); //更新宝贝错误数 sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } else { WriteLog("itemid:" + dtWrite.Rows[j]["itemid"].ToString() + resultpro, "", dt.Rows[i]["nick"].ToString()); //更新状态 sql = "UPDATE TopWriteContent SET isok = 1 WHERE id = " + dtWrite.Rows[j]["id"].ToString(); utils.ExecuteNonQuery(sql); //更新状态 sql = "UPDATE TopMission SET success = success + 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } } catch (Exception e) { WriteLog(e.Message, "1", dt.Rows[i]["nick"].ToString()); WriteLog(e.StackTrace, "1", dt.Rows[i]["nick"].ToString()); sql = "UPDATE TopMission SET fail = fail + 1,isok = -1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); continue; } } dtWrite.Dispose(); } sql = "UPDATE TopMission SET isok = 1 WHERE id = " + dt.Rows[i]["id"].ToString(); utils.ExecuteNonQuery(sql); } dt.Dispose(); } }
private void GetData(string nick) { string session = top_session; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5"); //获取店铺基本信息 UserGetRequest request = new UserGetRequest(); request.Fields = "user_id,nick,seller_credit"; request.Nick = nick; string oldNick = nick; User user = client.UserGet(request, session); if (versionNo == "1") { versionNo = "2"; } if (CheckUserExits(nick)) { string plus = string.Empty; if (versionNo == "2") { plus = "freecard"; } if (versionNo == "3") { plus = "crm|freecard"; } //更新登录次数和最近登陆时间 string sql = "UPDATE TCS_ShopSession SET session='" + top_session + "',version='" + versionNo + "',plus='" + plus + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); //更新特殊用户 sql = "UPDATE TCS_ShopSession SET version = 2 WHERE nick = '玩具第一城'"; utils.ExecuteNonQuery(sql); //更新特殊用户 sql = "UPDATE TCS_ShopSession SET version = 3 WHERE nick = '魔女茶花'"; utils.ExecuteNonQuery(sql); } else { //记录该会员的店铺信息 InsertUserInfo(nick); } InsertConfigInfo(nick, session, versionNo); IDictionary <string, string> param = new Dictionary <string, string>(); string result = Post("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5", "taobao.increment.customer.permit", top_session, param); //更新用户订购信息 CheckUser("0", nick); //加密NICK Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Encrypt(nick); Common.Cookie cookie = new Common.Cookie(); cookie.setCookie("top_sessionblog", top_session, 999999); cookie.setCookie("top_sessiongroupbuy", top_session, 999999); cookie.setCookie("nick", nick, 999999); //Response.Redirect("http://www.7fshop.com/top/market/setcookie.aspx?t=1&nick=" + HttpUtility.UrlEncode(nick)); if (isFirst == "1") { Response.Write("<span style='font-size:18px; font-weight:bold'>好评有礼真情回馈,恭喜您获得我们送出的首次订购赠送的<font color=red>【" + sendMsg + "】</font>条短信,感谢您的使用,您的支持是我们的最大动力!</span><hr><input type=button value='开始使用服务' onclick='window.location.href=\"indexnew.html\"'>"); Response.End(); } else { Response.Redirect("indexnew.html"); } }
protected void Page_Load(object sender, EventArgs e) { //try //{ id = utils.NewRequest("id", Common.utils.RequestType.QueryString); if (id != "" && !utils.IsInt32(id)) { Response.Write("非法参数1"); Response.End(); return; } style = utils.NewRequest("style", Common.utils.RequestType.Form); size = utils.NewRequest("size", Common.utils.RequestType.Form); type = utils.NewRequest("type", Common.utils.RequestType.Form); orderby = utils.NewRequest("orderby", Common.utils.RequestType.Form); query = utils.NewRequest("query", Common.utils.RequestType.Form); shopcat = utils.NewRequest("shopcat", Common.utils.RequestType.Form); name = utils.NewRequest("name", Common.utils.RequestType.Form); items = utils.NewRequest("items", Common.utils.RequestType.Form); ads = utils.NewRequest("ads", Common.utils.RequestType.Form); string missionid = string.Empty; string html = CreateGroupbuyHtml(id); if (html.Length == 0) { return; } int itemcount = 0; string act = utils.NewRequest("act", Common.utils.RequestType.Form); //创建任务时,判断是否有同类型任务在进行 if (act == "save" && NoRepeat(id, type)) { //记录该任务 missionid = RecordMission(); TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); //提交更新到淘宝商品上去 if (type != "1") { for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 200; request.PageNo = j; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { RecordMissionDetail(id, missionid, product.Content[i].NumIid.ToString(), html); itemcount++; } if (product.Content.Count < 200) { break; } } } else { string[] itemId = items.Split(','); for (int i = 0; i < itemId.Length; i++) { RecordMissionDetail(id, missionid, itemId[i], html); itemcount++; } } } //} //catch { } //更新总数量 string sql = "UPDATE TopMission SET total = '" + itemcount + "' WHERE id = " + missionid; utils.ExecuteNonQuery(sql); //更新任务 DoMyJob(missionid); //Response.Redirect("missionlist.aspx"); }
private void GetData(string nick) { string session = top_session; //string session = "23200d282b335fc82ee9466c363c14f7e1b03"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "21093339", "c1c22ba85fb91bd20279213ef7b9ee80"); //通过获取当前会话客户的在销商品来获取用户NICK //ItemsOnsaleGetRequest request1 = new ItemsOnsaleGetRequest(); //request1.PageSize = 1; //request1.Fields = "nick"; //PageList<Item> item = client.ItemsOnsaleGet(request1, session); //if (item.Content.Count == 0) //{ // Response.Write("请您先在店铺里添加商品 <a href='http://i.taobao.com/my_taobao.htm'>我的淘宝</a>"); // Response.End(); // return; //} //else //{ // nick = item.Content[0].Nick; //} //获取店铺基本信息 UserGetRequest request = new UserGetRequest(); request.Fields = "user_id,nick,seller_credit"; request.Nick = nick; //User user = client.UserGet(request, session); //加入推荐好友判断 //Tuijian(nick); if (CheckUserExits(nick)) { //更新该会员的店铺信息 string ip = Request.UserHostAddress; //记录2次登录日志 string sql = "INSERT INTO TopLoginLog (" + "nick " + " ) VALUES ( " + " '" + nick + "'" + ") "; utils.ExecuteNonQuery(sql); //更新登录次数和最近登陆时间 sql = "UPDATE toptaobaoshop SET logintimes = logintimes + 1,lastlogin = GETDATE(),session='" + top_session + "',sessionmarket='" + top_session + "',ip='" + ip + "',refreshToken='" + refreshToken + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); ReflashSession(); } else { //记录该会员的店铺信息 InsertUserInfo(nick); } //string oldNick = nick; ////加密NICK //Rijndael_ encode = new Rijndael_("tetesoft"); //nick = encode.Encrypt(nick); //Common.Cookie cookie = new Common.Cookie(); //cookie.setCookie("top_session", top_session, 999999); //cookie.setCookie("nick", nick, 999999); //这里做获取用户商品的操作 AddCookie(top_session); //CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLBUYNINFO); Response.Redirect("Default.aspx"); //Response.Redirect("http://bang.7fshop.com/default.aspx?istongji=1&session=" + top_session + "&nick=" + HttpUtility.UrlEncode(oldNick)); }
/// <summary> /// 数据绑定 /// </summary> private void BindData() { Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); //COOKIE过期判断 if (taobaoNick == "") { //SESSION超期 跳转到登录页 Response.Write("<script>parent.location.href='http://container.open.taobao.com/container?appkey=12287381'</script>");//12287381 Response.End(); } Rijndael_ encode = new Rijndael_("tetesoft"); taobaoNick = encode.Decrypt(taobaoNick); string sql = "SELECT * FROM TopTaobaoShopCat WHERE nick = '" + taobaoNick + "'"; DataTable dt = utils.ExecuteDataTable(sql); rptShopCat.DataSource = dt; rptShopCat.DataBind(); Repeater1.DataSource = dt; Repeater1.DataBind(); //获取用户店铺商品列表 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 10; PageList <Item> product = new PageList <Item>(); try { product = client.ItemsOnsaleGet(request, session); } catch (Exception e) { if (e.Message == "27:Invalid session:Session not exist") { //SESSION超期 跳转到登录页 Response.Write("<script>parent.location.href='http://container.open.taobao.com/container?appkey=12287381'</script>"); Response.End(); } return; } rptItems.DataSource = product.Content; rptItems.DataBind(); //团购活动数据绑定 string sqlNew = "SELECT * FROM tete_activity WHERE Status=1 and Nick = '" + taobaoNick + "' ORDER BY id DESC"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); rptAds.DataSource = dtNew; rptAds.DataBind(); //团购活动模板数据绑定 sqlNew = "SELECT * FROM Tete_shoptemplet WHERE Nick = '" + taobaoNick + "' and (isdelete=0 or isdelete is null) ORDER BY id DESC"; dtNew = utils.ExecuteDataTable(sqlNew); rptAdstemp.DataSource = dtNew; rptAdstemp.DataBind(); }
private void GetData(string nick) { string session = top_session; //string session = "23200d282b335fc82ee9466c363c14f7e1b03"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12579331", "02314dab9db5c4255129ad772dd65424"); //通过获取当前会话客户的在销商品来获取用户NICK //ItemsOnsaleGetRequest request1 = new ItemsOnsaleGetRequest(); //request1.PageSize = 1; //request1.Fields = "nick"; //PageList<Item> item = client.ItemsOnsaleGet(request1, session); //if (item.Content.Count == 0) //{ // Response.Write("请您先在店铺里添加商品 <a href='http://i.taobao.com/my_taobao.htm'>我的淘宝</a>"); // Response.End(); // return; //} //else //{ // nick = item.Content[0].Nick; //} //获取店铺基本信息 /*UserGetRequest request = new UserGetRequest(); * request.Fields = "user_id,nick,seller_credit"; * request.Nick = nick; * User user = client.UserGet(request, session);*/ //加入推荐好友判断 Tuijian(nick); if (CheckUserExits(nick)) { //更新该会员的店铺信息 string ip = Request.UserHostAddress; //记录2次登录日志 string sql = "INSERT INTO TopLoginLog (" + "nick " + " ) VALUES ( " + " '" + nick + "'" + ") "; utils.ExecuteNonQuery(sql); //更新登录次数和最近登陆时间 sql = "UPDATE toptaobaoshop SET logintimes = logintimes + 1,lastlogin = GETDATE(),session='" + top_session + "',sessionmarket='" + top_session + "',ip='" + ip + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); } else { try { //记录该会员的店铺信息 InsertUserInfo(nick); } catch { } } try { //更新用户订购信息 CheckUser("1", nick); } catch { } //加密NICK Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Encrypt(nick); Common.Cookie cookie = new Common.Cookie(); cookie.setCookie("top_sessionbao", top_session, 999999); cookie.setCookie("nick", nick, 999999); Response.Redirect("indexbao.html"); }
/// <summary> /// 买家好评自动发微博 /// </summary> private void CheckNew2() { string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); string session = string.Empty; DBSql db = new DBSql(); string sql = "SELECT b.*, s.sessionblog FROM TopMicroBlogAuto b INNER JOIN TopTaobaoShop s ON s.nick = b.nick"; textBox1.AppendText("\r\n" + sql); DataTable dt = db.GetTable(sql); textBox1.AppendText("\r\n" + dt.Rows.Count.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { session = dt.Rows[i]["sessionblog"].ToString(); textBox1.AppendText("\r\n" + session); TraderatesGetRequest request = new TraderatesGetRequest(); request.Fields = "tid"; request.PageSize = 20; request.PageNo = 1; request.RateType = "get"; request.Role = "seller"; try { PageList <TradeRate> traderate = client.TraderatesGet(request, session); if (traderate.Content.Count != 0) { //获取商品详细信息 for (int j = 0; j < traderate.Content.Count; j++) { TradeFullinfoGetRequest request1 = new TradeFullinfoGetRequest(); request1.Fields = "orders.title,orders.pic_path,orders.price,orders.num_iid"; request1.Tid = traderate.Content[j].Tid; Trade product = client.TradeFullinfoGet(request1, session); string str = CreateContentNew(dt.Rows[i]["content3"].ToString(), product.Orders[0]); textBox1.AppendText("\r\n" + str); SendMicroBlog(dt.Rows[i]["nick"].ToString(), str, product.Orders[0].PicPath, "3"); Thread.Sleep(10000); } } } catch { //SESSION失效 textBox1.AppendText("\r\nsession失效"); continue; } } this.Dispose(); this.Close(); Application.Exit(); Application.ExitThread(); GC.Collect(); }
private void GetData(string nick) { string session = top_session; //string session = "23200d282b335fc82ee9466c363c14f7e1b03"; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12159997", "614e40bfdb96e9063031d1a9e56fbed5"); //通过获取当前会话客户的在销商品来获取用户NICK //ItemsOnsaleGetRequest request1 = new ItemsOnsaleGetRequest(); //request1.PageSize = 1; //request1.Fields = "nick"; //PageList<Item> item = client.ItemsOnsaleGet(request1, session); //if (item.Content.Count == 0) //{ // Response.Write("请您先在店铺里添加商品 <a href='http://i.taobao.com/my_taobao.htm'>我的淘宝</a>"); // Response.End(); // return; //} //else //{ // nick = item.Content[0].Nick; //} //获取店铺基本信息 UserGetRequest request = new UserGetRequest(); request.Fields = "user_id,nick,seller_credit"; request.Nick = nick; User user = client.UserGet(request, session); if (CheckUserExits(nick)) { //更新该会员的店铺信息 //记录2次登录日志 string sql = "INSERT INTO TopLoginLog (" + "nick " + " ) VALUES ( " + " '" + nick + "'" + ") "; utils.ExecuteNonQuery(sql); //更新登录次数和最近登陆时间 sql = "UPDATE toptaobaoshop SET logintimes = logintimes + 1,lastlogin = GETDATE(),session='" + top_session + "',versionNo='" + versionNo + "' WHERE nick = '" + nick + "'"; utils.ExecuteNonQuery(sql); } else { //记录该会员的店铺信息 InsertUserInfo(nick); } //更新用户订购信息 CheckUser("0", nick); //加密NICK Rijndael_ encode = new Rijndael_("tetesoft"); nick = encode.Encrypt(nick); Common.Cookie cookie = new Common.Cookie(); cookie.setCookie("top_sessionblog", top_session, 999999); cookie.setCookie("nick", nick, 999999); Response.Redirect("indexnew.html"); }
/// <summary> /// 记录该会员的店铺信息 /// </summary> private void InsertUserInfo(string nick) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4"); //记录店铺基本信息 ShopGetRequest request = new ShopGetRequest(); request.Fields = "sid,cid,title,nick,desc,bulletin,pic_path,created,modified"; request.Nick = nick; Shop shop = client.ShopGet(request); //记录到本地数据库 string sql = "INSERT INTO TopTaobaoShop (" + "sid, " + "cid, " + "title, " + "nick, " + "[desc], " + "bulletin, " + "pic_path, " + "created, " + "modified, " + "shop_score, " + "remain_count " + " ) VALUES ( " + " '" + shop.Sid + "', " + " '" + shop.Cid + "', " + " '" + shop.Title + "', " + " '" + shop.Nick + "', " + " '" + shop.Desc + "', " + " '" + shop.Bulletin + "', " + " '" + shop.PicPath + "', " + " '" + shop.Created + "', " + " '" + shop.Modified + "', " + " '" + shop.ShopScore + "', " + " '" + shop.RemainCount + "' " + ") "; utils.ExecuteNonQuery(sql); //记录店铺分类信息 SellercatsListGetRequest request1 = new SellercatsListGetRequest(); request1.Fields = "cid,parent_cid,name,is_parent"; request1.Nick = nick; PageList <SellerCat> cat = client.SellercatsListGet(request1); for (int i = 0; i < cat.Content.Count; i++) { sql = "INSERT INTO TopTaobaoShopCat (" + "cid, " + "parent_cid, " + "name, " + "pic_url, " + "sort_order, " + "created, " + "nick, " + "modified " + " ) VALUES ( " + " '" + cat.Content[i].Cid + "', " + " '" + cat.Content[i].ParentCid + "', " + " '" + cat.Content[i].Name + "', " + " '" + cat.Content[i].PicUrl + "', " + " '" + cat.Content[i].SortOrder + "', " + " '" + cat.Content[i].Created + "', " + " '" + nick + "', " + " '" + cat.Content[i].Modified + "' " + ") "; utils.ExecuteNonQuery(sql); } //记录店铺所有商品信息-暂不记录 }
/// <summary> /// 清除宝贝描述里面的活动页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button4_Click(object sender, EventArgs e) { string appkey = "12159997"; string secret = "614e40bfdb96e9063031d1a9e56fbed5"; //上传到宝贝描述 TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret); for (int j = 1; j <= 500; j++) { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid"; request.PageSize = 200; request.PageNo = j; PageList <Item> product = client.ItemsOnsaleGet(request, session); for (int i = 0; i < product.Content.Count; i++) { try { //获取商品详细 ItemGetRequest requestItem = new ItemGetRequest(); requestItem.Fields = "desc"; requestItem.NumIid = product.Content[i].NumIid; Item item = client.ItemGet(requestItem, session); //判断是否增加过该图片 string newcontent = CreateDescDel(item.Desc); //if (product.Content[i].NumIid.ToString() == "10002247109") //{ // Response.Write(item.Desc); // Response.Write("**************************************************"); // Response.Write(newcontent); // return; //} if (newcontent == "") { continue; } //更新宝贝描述 IDictionary <string, string> param = new Dictionary <string, string>(); param.Add("num_iid", product.Content[i].NumIid.ToString()); param.Add("desc", newcontent); string resultpro = Post("http://gw.api.taobao.com/router/rest", appkey, secret, "taobao.item.update", session, param); } catch { } } if (product.Content.Count < 200) { break; } } Response.Write("<script>alert('清除成功!');window.location.href='html.aspx';</script>"); Response.End(); }
private void BindData(string items, string adsid) { string html = string.Empty; string total = string.Empty; TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12287381", "d3486dac8198ef01000e7bd4504601a4");//d3486dac8198ef01000e7bd4504601a4 if (type != "1") { ItemsOnsaleGetRequest request = new ItemsOnsaleGetRequest(); request.Fields = "num_iid,title,price,pic_url"; request.PageSize = 1; if (orderby == "new") { request.OrderBy = "list_time:desc"; } else if (orderby == "sale") { request.OrderBy = "volume:desc"; } if (shopcat != "0") { request.SellerCids = shopcat; } if (query != "0") { request.Q = query; } Cookie cookie = new Cookie(); string taobaoNick = cookie.getCookie("nick"); string session = cookie.getCookie("top_sessiongroupbuy"); PageList <Item> product = client.ItemsOnsaleGet(request, session); ItemGetRequest request1 = new ItemGetRequest(); request1.Fields = "num_iid,title,price,pic_url,desc"; request1.NumIid = product.Content[0].NumIid; Item product1 = client.ItemGet(request1); html = product1.Desc; } else { string itemId = items.Split(',')[0]; ItemGetRequest request = new ItemGetRequest(); request.Fields = "num_iid,title,price,pic_url,desc"; request.NumIid = long.Parse(itemId); Item product = client.ItemGet(request); //获取商品详细描述 html = product.Desc; } //获取广告代码 string adsHtml = "团购的HTML代码";// getAdsContent(ads); if (!Regex.IsMatch(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">")) { html += @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"; } else { html = Regex.Replace(html, @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">([\s\S]*)<img alt=""tetesoft-area-end"" width=""0"" height=""0"">", @"<img alt=""tetesoft-area-start"" width=""0"" height=""0"">" + adsHtml + @"<img alt=""tetesoft-area-end"" width=""0"" height=""0"">"); } lbView.InnerHtml = html; //Response.Write("搜索结果共计" + total + "个商品...<br>"); }
protected void Page_Load(object sender, EventArgs e) { TopXmlRestClient client = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12132145", "1fdd2aadd5e2ac2909db2967cbb71e7f"); id = utils.NewRequest("id", utils.RequestType.QueryString); string title = string.Empty; string width = string.Empty; string height = string.Empty; string num = string.Empty; string taobaoNick = string.Empty; //获取广告标题 string sql = string.Empty; //图片缓存判断 if (1 == 1) { sql = "SELECT name,size,nick FROM TopIdea WHERE id = " + id; DataTable dt = utils.ExecuteDataTable(sql); if (dt.Rows.Count != 0) { taobaoNick = dt.Rows[0]["nick"].ToString(); //创建图片临时文件架 folderPath = Server.MapPath("folder/" + MD5(dt.Rows[0]["nick"].ToString())); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } //判断生成好的图片是否过期 string resultPath = folderPath + "/result_" + id + ".jpg"; if (File.Exists(resultPath) && id != "3972") { //判断过期时间为1小时 System.TimeSpan ts = DateTime.Now - File.GetLastWriteTime(resultPath); if (ts.Seconds < 3600) { RecordAndShow(folderPath); return; } } title = dt.Rows[0]["name"].ToString(); size = dt.Rows[0]["size"].ToString(); string[] arr = size.Split('*'); width = arr[0]; height = arr[1]; switch (size) { case "514*160": num = "5"; break; case "514*288": num = "10"; break; case "664*160": num = "6"; break; case "312*288": num = "6"; break; case "336*280": num = "4"; break; case "714*160": num = "7"; break; case "114*418": num = "3"; break; case "218*286": num = "4"; break; case "743*308": num = "4"; break; default: num = "4"; break; } } else { return; } //获取数据库中保存的商品 sql = "SELECT TOP " + num + " * FROM TopIdeaProduct WHERE ideaid = " + id + ""; dt = utils.ExecuteDataTable(sql); //生成图片 string proPath = string.Empty; System.Drawing.Image pro1; System.Drawing.Image pro2; //背景图片 string bgPath = Server.MapPath("images/bg1.jpg"); System.Drawing.Image CurrentBitmap = System.Drawing.Image.FromFile(bgPath); switch (size) { //风格1 case "514*160": bgPath = Server.MapPath("images/bg1.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格2 case "514*288": bgPath = Server.MapPath("images/bg2.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格3 case "312*288": bgPath = Server.MapPath("images/bg3.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格4 case "714*160": bgPath = Server.MapPath("images/bg4.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格5 case "114*418": bgPath = Server.MapPath("images/bg5.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格6 case "664*160": bgPath = Server.MapPath("images/bg6.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格7 case "218*286": bgPath = Server.MapPath("images/bg7.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; //风格8 case "743*308": bgPath = Server.MapPath("images/bg8.jpg"); CurrentBitmap = System.Drawing.Image.FromFile(bgPath); break; } string nickid = string.Empty; string sqlNew = "SELECT sid FROM TopTaobaoShop WHERE nick = '" + taobaoNick + "'"; DataTable dtNew = utils.ExecuteDataTable(sqlNew); if (dtNew.Rows.Count != 0) { nickid = "http://shop" + dtNew.Rows[0]["sid"].ToString() + ".taobao.com/"; } else { nickid = "http://www.taobao.com/"; } using (Graphics graphics = Graphics.FromImage(CurrentBitmap)) { graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.SmoothingMode = SmoothingMode.HighQuality; //文字 Font font = new Font("宋体", 12); if (size == "514*160" || size == "514*288" || size == "714*160" || size == "664*160") { graphics.DrawString(title + " " + nickid + "", font, new SolidBrush(Color.Black), 16, 6); } else if (size == "743*308") { font = new Font("宋体", 13, FontStyle.Bold); graphics.DrawString(title, font, new SolidBrush(Color.White), 38, 10); } else { graphics.DrawString(title, font, new SolidBrush(Color.Black), 16, 6); } switch (size) { //风格1 case "514*160": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + i * 100, 29, 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 112); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 126); pro1.Dispose(); } break; //风格2 case "514*288": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + (i % 5) * 100, 29 + (i / 5 * 130), 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 5) * 100, 112 + (i / 5 * 130)); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 5) * 100, 126 + (i / 5 * 130)); pro1.Dispose(); } break; //风格3 case "312*288": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + (i % 3) * 100, 29 + (i / 3 * 130), 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 3) * 100, 112 + (i / 3 * 130)); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 3) * 100, 126 + (i / 3 * 130)); pro1.Dispose(); } break; //风格4 case "714*160": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + i * 100, 29, 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 112); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 126); pro1.Dispose(); } break; //风格5 case "114*418": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17, 29 + i * 130, 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14, 112 + i * 130); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14, 126 + i * 130); pro1.Dispose(); } break; //风格6 case "664*160": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + i * 100, 29, 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 112); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + i * 100, 126); pro1.Dispose(); } break; //风格7 case "218*286": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_80x80.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 17 + (i % 2) * 100, 29 + (i / 2 * 130), 80, 80); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 2) * 100, 112 + (i / 2 * 130)); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 8, 16), font, new SolidBrush(ColorTranslator.FromHtml("#0394EF")), 14 + (i % 2) * 100, 126 + (i / 2 * 130)); pro1.Dispose(); } break; //风格7 case "743*308": for (int i = 0; i < dt.Rows.Count; i++) { saveimage(dt.Rows[i]["itempicurl"].ToString() + "_160x160.jpg", folderPath); proPath = folderPath + "/proTmp.jpg"; Pen pen = new Pen(new SolidBrush(ColorTranslator.FromHtml("#cccccc")), 1); pen.DashStyle = DashStyle.Solid; Point p0 = new Point(15 + i * 180, 45); Point p1 = new Point(15 + i * 180 + 161, 45 + 161); graphics.DrawRectangle(pen, new Rectangle(p0.X, p0.Y, Math.Abs(p0.X - p1.X), Math.Abs(p0.Y - p1.Y))); //商品 pro1 = System.Drawing.Image.FromFile(proPath); graphics.DrawImage(pro1, 16 + i * 180, 46, 160, 160); //购买按钮 pro2 = System.Drawing.Image.FromFile(Server.MapPath("/top/show1/buy1.png")); graphics.DrawImage(pro2, 44 + i * 180, 246, 108, 28); //文字 font = new Font("宋体", 12); graphics.DrawString(left(dt.Rows[i]["itemname"].ToString(), 0, 12), font, new SolidBrush(ColorTranslator.FromHtml("#3f3f3f")), 22 + i * 180, 212); //价格 font = new Font("Arial", 12, FontStyle.Bold); graphics.DrawString("¥" + dt.Rows[i]["itemprice"].ToString() + "元", font, new SolidBrush(ColorTranslator.FromHtml("#fe596a")), 66 + i * 180, 228); pro1.Dispose(); pro2.Dispose(); } //增加店铺链接 font = new Font("Arial", 13, FontStyle.Bold); graphics.DrawString("更多详情请见 " + nickid, font, new SolidBrush(ColorTranslator.FromHtml("#ff6600")), 435, 284); break; } } ImageCodecInfo ici; System.Drawing.Imaging.Encoder enc; EncoderParameter ep; EncoderParameters epa; // Initialize the necessary objects ici = GetEncoderInfo("image/png"); enc = System.Drawing.Imaging.Encoder.Quality;//设置保存质量 epa = new EncoderParameters(1); // Set the compression level ep = new EncoderParameter(enc, 100L);//质量等级为25% epa.Param[0] = ep; CurrentBitmap.Save(folderPath + "/result_" + id + ".jpg", ici, epa); epa.Dispose(); ep.Dispose(); } RecordAndShow(folderPath); }