protected void editClass_Click(object sender, EventArgs e) { string cid = DropDownListClass.Text.Trim(); string classNameTemp = className.Text.Trim(); if (!String.IsNullOrEmpty(classNameTemp as string)) { strValue[0] = classNameTemp; strValue[1] = classUrl.Text; strValue[2] = tk.Text; strValue[3] = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss"); xc.insertMyLog(xc.adminID, "admin", "修改分类:" + classNameTemp); string returnStr = db.InsertUpdateDB("NewsTree", "@TreeName,@TreeUrl,@taobaoKe,@PostDate", strValue, "Tid=" + cid + " and TreeType='" + typeClss + "'"); string strSql = "select Tid from newsTree where Tid=" + cid; strSql += " union select Tid from newsTree where idLayerStr like '%|" + cid + "|%'"; DataTable dt = db.getDataTable(strSql); for (int i = 0; i < dt.Rows.Count; i++) { xClass.treeNameUpdate(xc.SafeNum(dt.Rows[i]["Tid"].ToString().Trim())); } dt.Dispose(); xc.divError("", returnStr, 350, 150, "ClassList.aspx?tClass=" + typeClss, "goto"); } else { xc.divError("", "请填写分类名称!", 350, 150, "ClassList.aspx?tClass=" + typeClss, "goto"); } }
protected void good_Click(object sender, EventArgs e) { string[] strValue = new string[1]; strValue[0] = "1"; string ids = Request["batDel"]; if (!string.IsNullOrEmpty(ids as string)) { ids = ids.Replace(",", " or id="); ids = "id=" + ids; string returnStr = db.InsertUpdateDB("taobaoKe", "@isGood", strValue, ids); Response.Redirect(Server.UrlDecode(xc.errorUrlTwo) + "#foot", true); } else { xc.divError("", "请先选择后再操作!", 350, 150, Server.UrlDecode(xc.errorUrlTwo), "goto"); } }
protected void imgLogin_Click(object sender, ImageClickEventArgs e) { string uid = UID.Text.Trim().ToLower().ToString(); string pw = xc.GetMd5(PW.Text.ToString()); string strSql = "select * from AdminUser where userID='" + uid + "' and UserPW='" + pw + "' and loginFlag=2 "; DataTable dt = db.getDataTable(strSql); if (dt.Rows.Count < 1) { xc.divError("登陆提示", "您的帐号或密码不正确!", 350, 150, xc.AdminFileName, "top"); } else { long lgNums = xc.SafeNum(dt.Rows[0]["LoginNum"].ToString()) + 1; string strDim = "@SessionError,@LoginNum,@LoginDate,@LoginIP"; string rndNums = xc.GetRnd("abc", 8); Session.Add("AdminRndNums", rndNums); string[] strValue = new string[5]; strValue[0] = xc.GetMd5(rndNums); strValue[1] = lgNums.ToString(); strValue[2] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[3] = xc.GetIP(); db.InsertUpdateDB("AdminUser", strDim, strValue, "userID='" + uid + "'"); xc.insertMyLog(uid, "admin", "管理员登录"); HttpCookie XabaraAdminCookies = new HttpCookie("XabaraAdmin"); //cookies写入磁盘 XabaraAdminCookies.Values.Add("AdminID", uid); XabaraAdminCookies.Values.Add("AdminName", HttpUtility.UrlEncode(dt.Rows[0]["UserName"].ToString().Trim())); XabaraAdminCookies.Values.Add("AdminLgNums", lgNums.ToString()); XabaraAdminCookies.Values.Add("AdminLgDate", dt.Rows[0]["LoginDate"].ToString().Trim()); XabaraAdminCookies.Values.Add("AdminLgIP", dt.Rows[0]["LoginIP"].ToString().Trim()); XabaraAdminCookies.Expires = DateTime.Now.AddDays(15d); Response.Cookies.Add(XabaraAdminCookies); dt.Dispose(); Response.Redirect("admin.aspx", true); } }
protected void setAdmin_Click(object sender, EventArgs e) { string selectValue = Request["adminPopedomSelect"]; if (!string.IsNullOrEmpty(selectValue)) { selectValue = selectValue.Replace(",", "|"); string[] strValue = new string[2]; strValue[0] = "|" + selectValue + "|"; strValue[1] = "2"; xc.insertMyLog(xc.adminID, "admin", "修改管理员权限"); xc.divError("设置提示", db.InsertUpdateDB("AdminUser", "@UserAdmin,@loginFlag", strValue, "userID='" + xc.SafeSql(Request["id"].Trim()) + "'"), 350, 150, "userList.aspx", "goto"); } else { xc.divError("", "请选择相应权限后再设置!", 350, 150, "", ""); } }
protected void editAdmin_Click(object sender, EventArgs e) { string dimStr = "@classID,@UserName,@UserPW,@userEmail,@userTel,@userMobile,@userQQ"; string[] strValue = new string[7]; strValue[0] = adminClass.Text; strValue[1] = adminName.Text.Trim(); string pw = adminPW.Text; if (!string.IsNullOrEmpty(pw as string)) { pw = xc.GetMd5(pw); } else { pw = oldPWHidden.Value; } strValue[2] = pw; strValue[3] = adminMail.Text.Trim(); strValue[4] = adminTel.Text.Trim(); strValue[5] = adminMobile.Text.Trim(); strValue[6] = adminQQ.Text.Trim(); if (db.InsertUpdateDB("AdminUser", dimStr, strValue, "userID='" + xc.adminID + "'").Equals("更新成功")) { xc.insertMyLog(xc.adminID, "admin", "修改资料"); Session.Add("AdminRndNums", string.Empty); xc.divError("", "更新资料成功!", 350, 150, xc.AdminFileName, "top"); } else { xc.divError("", "更新资料失败!", 350, 150, "userEdit.aspx", "goto"); } }
protected void addAdmin_Click(object sender, EventArgs e) { string adminIDTemp = xc.SafeSql(adminID.Text.Trim().ToLower()); string strSql = "select * from AdminUser where userID='" + adminIDTemp + "'"; if (db.getDataTable(strSql).Rows.Count > 0) { xc.divError("", "已存在该管理员!", 350, 150, "", ""); } else { string dimStr = "@UserId,@UserName,@UserPW,@SessionError,@loginFlag,@LoginNum,@RegDate,@LoginDate,@LoginIP,@classID"; string[] strValue = new string[10]; strValue[0] = adminIDTemp; strValue[1] = adminName.Text.Trim(); strValue[2] = xc.GetMd5(adminPW.Text.Trim()); strValue[3] = "xabara.com"; strValue[4] = "1"; strValue[5] = "0"; strValue[6] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[7] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[8] = xc.GetIP().ToString(); strValue[9] = adminClass.Text; if (db.InsertUpdateDB("AdminUser", dimStr, strValue, string.Empty).Equals("发布成功")) { xc.insertMyLog(xc.adminID, "admin", "添加管理员:" + adminIDTemp); xc.divError("", "添加管理员成功,需对 " + adminName.Text.Trim() + " 进行权限设置后才可以正常登陆!", 500, 200, "userPopedom.aspx?id=" + adminIDTemp, "goto"); } else { xc.divError("", "添加管理员失败!", 350, 150, "", ""); } } }
protected void Page_Load(object sender, EventArgs e) { dbDataFunction db = new dbDataFunction(); xc.CheckAdminLogin(""); DataTable dt; string strDim = "@classID,@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@postID,@postDate,@postIP,@isBad,@isGood,@poster_id"; string[] strValue = new string[30]; string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); if (string.IsNullOrEmpty(appkey as string)) { Response.Redirect("../frame/otherSet.aspx", true); } string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID ITopClient client = new DefaultTopClient(url, appkey, appsecret); Response.Write("根据分类自动同步淘宝客开始,如出现死机或出错,重新点击<a href=\"taobao.aspx\">自动更新</a>即可;<br />"); Response.Flush(); this.js(); //定时刷新 //更新店铺 DateTime t = DateTime.Now.Date; string strSql = "select top 1 * from NewsTree with(nolock) where taobaoKe <>'' and PostDate<'" + t.ToString() + "' order by newid()"; dt = db.getDataTable(strSql); //当天不再请求更新 if (dt.Rows.Count > 0) { string classID = dt.Rows[0]["Tid"].ToString().Trim(); Response.Write("<br />" + dt.Rows[0]["treeNameTxt"].ToString().Trim() + " 同步完成!"); Response.Flush(); //System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10)); ItemsGetRequest req = new ItemsGetRequest(); req.Fields = "num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume"; req.Nicks = dt.Rows[0]["taobaoKe"].ToString().Trim(); req.PageNo = 1L; req.OrderBy = "volume"; req.StartPrice = 50L; req.EndPrice = 100000L; req.PageSize = 200L; //取最畅销前200个商品 ItemsGetResponse response = client.Execute(req); long shopNums = response.TotalResults; if (shopNums > 0) { strValue[0] = DateTime.Now.ToString(); db.InsertUpdateDB("NewsTree", "@PostDate", strValue, "Tid=" + classID); //更新店铺宝贝同步 for (int ii = 0; ii < response.Items.Count; ii++) { strValue[0] = classID; strValue[1] = response.Items[ii].NumIid.ToString(); strValue[2] = response.Items[ii].Title; strValue[3] = response.Items[ii].Nick; strValue[4] = response.Items[ii].PicUrl; strValue[5] = response.Items[ii].Price; strValue[6] = @"http://item.taobao.com/item.htm?id=" + response.Items[ii].NumIid.ToString(); strValue[7] = "0"; strValue[8] = "0"; strValue[9] = "0"; strValue[10] = "0"; strValue[11] = @"http://www.zdianpu.com"; strValue[12] = "0"; strValue[13] = "找店铺"; strValue[14] = response.Items[ii].Volume.ToString(); strValue[15] = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss"); //表示已过期 strValue[16] = "sys"; strValue[17] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[18] = xc.GetIP(); strValue[19] = "1"; strValue[20] = "0"; strValue[21] = "0"; if (response.Items[ii].Title.IndexOf("邮费") < 0 || response.Items[ii].Title.IndexOf("补差") < 0) { DataTable dtIf = db.getDataTable("select * from taobaoKe with(nolock) where num_iid=" + response.Items[ii].NumIid.ToString()); //防止重复插入 if (dtIf.Rows.Count > 0) { strValue[6] = dtIf.Rows[0]["click_url"].ToString().Trim(); strValue[7] = dtIf.Rows[0]["commission"].ToString().Trim(); strValue[8] = dtIf.Rows[0]["commission_rate"].ToString().Trim(); strValue[9] = dtIf.Rows[0]["commission_num"].ToString().Trim(); strValue[10] = dtIf.Rows[0]["commission_volume"].ToString().Trim(); strValue[11] = dtIf.Rows[0]["shop_click_url"].ToString().Trim(); strValue[12] = dtIf.Rows[0]["seller_credit_score"].ToString().Trim(); strValue[13] = dtIf.Rows[0]["item_location"].ToString().Trim(); strValue[15] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[17] = dtIf.Rows[0]["postDate"].ToString().Trim(); strValue[20] = dtIf.Rows[0]["isGood"].ToString().Trim(); strValue[21] = dtIf.Rows[0]["poster_id"].ToString().Trim(); //淘画报 db.InsertUpdateDB("taobaoKe", strDim, strValue, "num_iid=" + response.Items[ii].NumIid.ToString()); } else { db.InsertUpdateDB("taobaoKe", strDim, strValue, string.Empty); } dtIf.Dispose(); } } } else { strValue[0] = DateTime.Now.ToString(); db.InsertUpdateDB("NewsTree", "@PostDate", strValue, "Tid=" + classID); //更新店铺宝贝同步时出错或非淘宝客,防止死锁 } } //宝贝同步结束 dt.Dispose(); //淘宝客自动更新操作 for (int f = 0; f < 5; f++) { string id = string.Empty; DataTable tkIDs = db.getDataTable("select top 40 num_iid from taobaoKe where isBad>0 and updateDate<GETDATE() order by updateDate ASC"); //30天过期内的数据可再次更新 if (tkIDs.Rows.Count > 0) { for (int i = 0; i < tkIDs.Rows.Count; i++) { id += tkIDs.Rows[i]["num_iid"].ToString().Trim() + ","; } id = id.Substring(0, id.Length - 1); //锁定淘宝客更新条数 strValue[0] = "0"; string updateID = id.Replace(",", " or num_iid="); updateID = "num_iid=" + updateID; //Response.Write(updateID); //Response.End(); db.InsertUpdateDB("taobaoKe", "@isBad", strValue, updateID); Response.Write("<br />淘宝客数据转换已完成 " + ((f * 40) + tkIDs.Rows.Count).ToString()+",请等待10秒..."); Response.Flush(); } else { Response.Write("<br />当前淘宝客数据转换已全部完成,请明天再手动更新!"); break; } tkIDs.Dispose(); //Response.Write(id.ToString()); if (!string.IsNullOrEmpty(id as string)) { TaobaokeItemsConvertRequest req = new TaobaokeItemsConvertRequest(); req.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"; req.Nick = alimamaID; req.NumIids = id; TaobaokeItemsConvertResponse response = client.Execute(req); int tkCount = response.TaobaokeItems.Count; //转换后得到的淘客数量 strDim = "@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@isBad"; for (int i = 0; i < tkCount; i++) { strValue[0] = response.TaobaokeItems[i].NumIid.ToString(); strValue[1] = response.TaobaokeItems[i].Title.ToString(); strValue[2] = response.TaobaokeItems[i].Nick.ToString(); strValue[3] = response.TaobaokeItems[i].PicUrl.ToString(); strValue[4] = response.TaobaokeItems[i].Price.ToString(); strValue[5] = response.TaobaokeItems[i].ClickUrl.ToString(); strValue[6] = response.TaobaokeItems[i].Commission.ToString(); strValue[7] = response.TaobaokeItems[i].CommissionRate; strValue[8] = response.TaobaokeItems[i].CommissionNum.ToString(); strValue[9] = response.TaobaokeItems[i].CommissionVolume.ToString(); strValue[10] = response.TaobaokeItems[i].ShopClickUrl.ToString(); strValue[11] = response.TaobaokeItems[i].SellerCreditScore.ToString(); strValue[12] = response.TaobaokeItems[i].ItemLocation.ToString(); strValue[13] = response.TaobaokeItems[i].Volume.ToString(); strValue[14] = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss"); strValue[15] = "1"; db.InsertUpdateDB("taobaoKe", strDim, strValue, " num_iid =" + response.TaobaokeItems[i].NumIid.ToString()); } } } }
protected void Button1_Click(object sender, EventArgs e) { string RequestType = flag.Text.ToString().Trim(); string RequestTable = xc.SafeChar(Request["fTable"].Trim()); string UpFileReturnStr; string insertIframeCode = string.Empty; string fileName = uploadfile.FileName; if (RequestType.Equals("Img")) { if (WaterMark.Checked) { UpFileReturnStr = xc.UploadFile(uploadfile, RequestType, true); } else { UpFileReturnStr = xc.UploadFile(uploadfile, RequestType, false); } } else { UpFileReturnStr = xc.UploadFile(uploadfile, RequestType, false); } if (UpFileReturnStr.Equals("上传成功")) { //插入数据库 string insertName = Session["NewFile"].ToString(); string dimStr = "@fileID,@fileFlag,@fileTable,@fileName,@PostDate,@AdminIP,@AdminID"; string[] strValue = new string[7]; strValue[0] = Session["upFileID"].ToString(); //上传图片文件名ID关联" strValue[1] = RequestType; strValue[2] = RequestTable; strValue[3] = insertName; strValue[4] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[5] = xc.GetIP(); strValue[6] = xc.adminID; if (db.InsertUpdateDB("upFileName", dimStr, strValue, string.Empty).Equals("发布成功")) { UpFileReturnStr += " OK!"; } else { UpFileReturnStr += " NO!"; } switch (RequestType) { case "Img": insertIframeCode = @"<p><img alt='' src='" + xc.UploadFolder + insertName.Substring(5, 8) + "/" + insertName + "' /></p>"; break; case "Flash": insertIframeCode = "<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'><param name='quality' value='high' /><param name='movie' value='" + xc.UploadFolder + insertName.Substring(5, 8) + "/" + insertName + "' /><embed pluginspage='http://www.macromedia.com/go/getflashplayer' quality='high' src='" + xc.UploadFolder + insertName.Substring(5, 8) + "/" + insertName + "' type='application/x-shockwave-flash'></embed></object></p>"; break; default: insertIframeCode = "<a target='_blank' href=" + xc.UploadFolder + insertName.Substring(5, 8) + "/" + insertName + ">" + insertName + "</a>"; break; } insertIframeCode = insertIframeCode + "<p> </p>"; ClientScriptManager cs = Page.ClientScript; cs.RegisterClientScriptBlock(this.GetType(), "ClientScriptBlock", "<script>parent.CKEDITOR.instances.txtContent.insertHtml(\"" + insertIframeCode + "\");</script>"); lblinfo.Text = uploadfile.FileName.ToString() + " " + UpFileReturnStr; if (RequestType.Equals("Img")) { indexPicSet.Items.Add(new ListItem(insertName, insertName)); preImage.Visible = true; //预览图 delPreImg.Visible = true; //删除图片 preImage.ImageUrl = xc.UploadFolder.ToString() + insertName.Substring(5, 8) + "/" + insertName; } } else { lblinfo.Text = UpFileReturnStr; } }
protected void addClass_Click(object sender, EventArgs e) { string classNameTemp = className.Text.Trim(); string oldClassID = DropDownListClass.Text.Trim(); Session.Add(typeClss, oldClassID); //缓存 string strSql = "select * from NewsTree where TreeID=" + oldClassID + " and TreeName='" + classNameTemp + "' and TreeType='" + typeClss + "'"; if (db.getDataTable(strSql).Rows.Count > 0) { xc.divError("", "已存在该分类!", 350, 150, "ClassAdd.aspx?tClass=" + typeClss, "goto"); } else { string dimStr = "@TreeID,@ListID,@TidNums,@TreeName,@TreeType,@treeAdmin,@treeDel,@PostDate,@AdminIP,@AdminID,@TreeUrl,@taobaoKe"; string[] strValue = new string[12]; strValue[0] = oldClassID; if (string.IsNullOrEmpty(classList.Text)) { strValue[1] = "0"; } else { strValue[1] = classList.Text; } strValue[2] = "0"; strValue[3] = classNameTemp; strValue[4] = typeClss; strValue[5] = "0"; strValue[6] = "0"; strValue[7] = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss"); strValue[8] = xc.GetIP(); strValue[9] = xc.adminID; strValue[10] = classUrl.Text; strValue[11] = tk.Text; if (db.InsertUpdateDB("NewsTree", dimStr, strValue, string.Empty).Equals("发布成功")) { if (Convert.ToInt32(oldClassID) > 0) //更新子分类数 { string strSqlSelect = "select TreeID,TidNums,idLayerStr from NewsTree where Tid=" + oldClassID + " and TreeType='" + typeClss + "'"; DataTable dt = db.getDataTable(strSqlSelect); int tidNums = Convert.ToInt32(dt.Rows[0]["TidNums"]) + 1; strValue[0] = tidNums.ToString(); db.InsertUpdateDB("NewsTree", "@TidNums", strValue, "Tid=" + oldClassID + " and TreeType='" + typeClss + "'"); int tidTemp = Convert.ToInt32(dt.Rows[0]["TreeID"]); //更新关联字符串 if (tidTemp < 1) { strValue[0] = "|"; } else { strValue[0] = dt.Rows[0]["idLayerStr"].ToString(); } strValue[0] = strValue[0].Trim() + oldClassID.ToString() + "|"; db.InsertUpdateDB("NewsTree", "@idLayerStr", strValue, "TreeID=" + oldClassID + " and TreeName='" + classNameTemp + "' and TreeType='" + typeClss + "'"); dt.Dispose(); } xc.insertMyLog(xc.adminID, "admin", Server.UrlDecode(titleClass.Text + ":" + classNameTemp)); xc.divError("", Server.UrlDecode(titleClass.Text) + "成功!", 350, 150, "ClassAdd.aspx?tClass=" + typeClss + "&title=" + titleClass.Text, "goto"); } else { xc.divError("", Server.UrlDecode(titleClass.Text) + "失败!", 350, 150, "ClassAdd.aspx?tClass=" + typeClss + "&title=" + titleClass.Text, "goto"); } } }
protected void Page_Load(object sender, EventArgs e) { XabaraCom xc = new XabaraCom(); dbDataFunction db = new dbDataFunction(); xc.CheckAdminLogin(""); DataTable dt; string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); if (string.IsNullOrEmpty(appkey as string)) { Response.Redirect("../frame/otherSet.aspx", true); } string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID ITopClient client = new DefaultTopClient(url, appkey, appsecret); PosterChannelsGetRequest req = new PosterChannelsGetRequest(); PosterChannelsGetResponse response = client.Execute(req); Response.Write("自动同步淘画报频道ID,如出现死机或出错,重新点击自动更新即可;<br />"); Response.Flush(); string strDim = "@id,@channel_name,@name_en,@description,@postID,@postDate,@postIP,@isFlag"; string[] strValue = new string[7]; for (int ii = 0; ii < response.Channels.Count; ii++) { strValue[0] = response.Channels[ii].Id.ToString(); strValue[1] = response.Channels[ii].ChannelName.ToString(); strValue[2] = response.Channels[ii].NameEn.ToString(); if (string.IsNullOrEmpty(response.Channels[ii].Description as string)) { strValue[3] = string.Empty; } else { strValue[3] = response.Channels[ii].Description; } strValue[4] = xc.adminID; strValue[5] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[6] = xc.GetIP(); dt = db.getDataTable("select * from posterChannelIDs where id=" + response.Channels[ii].Id.ToString()); //防止重复插入 if (dt.Rows.Count > 0) { strDim = "@id,@channel_name,@name_en,@description,@postID,@postDate,@postIP"; db.InsertUpdateDB("posterChannelIDs", strDim, strValue, "id=" + response.Channels[ii].Id.ToString()); } else { db.InsertUpdateDB("posterChannelIDs", strDim, strValue, string.Empty); } dt.Dispose(); Response.Write("同步 " + strValue[1] + " [" + strValue[2] + "] " + " 已完成;<br />"); Response.Flush(); } //宝贝同步结束 }
protected void editMoney_Click(object sender, EventArgs e) { string imgFile = adImg.Text.Trim(); string uploadFileStr = string.Empty; if (!imgFile.Equals("Code")) { uploadFileStr = xc.UploadFile(imgUpload, imgFile, false); } string url = adHttp.Text; string newFile = upImg.Value; if (uploadFileStr.Equals("上传成功")) { if (!string.IsNullOrEmpty(newFile as string)) { xc.delFile(newFile.Substring(5, 8) + "/" + newFile); } newFile = Session["NewFile"].ToString().Trim(); } string strDim = "@classID,@adW,@adH,@adImg,@adHttp,@adCode,@starDate,@stopDate,@postDate,@postIP,@adminID"; string[] strValue = new string[11]; strValue[0] = adClass.Text; strValue[1] = adW.Text; strValue[2] = adH.Text; strValue[3] = newFile; strValue[4] = url; switch (imgFile) { case "Img": if (!string.IsNullOrEmpty(url as string)) { strValue[5] = "<a href=\"" + url + "\" target=\"_blank\"><img src=\"http://" + XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "webDomains") + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" style=\"boder:0px;width:" + adW.Text + "px;height:" + adH.Text + "px\" /></a>"; } else { strValue[5] = "<img src=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" style=\"boder:0px;width:" + adW.Text + "px;height:" + adH.Text + "px\" />"; } break; case "Flash": strValue[5] = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" height=\"" + adH.Text + "\" width=\"" + adW.Text + "\"><param name=\"quality\" value=\"high\" /><param name=\"movie\" value=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" /><embed height=\"" + adH.Text + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" type=\"application/x-shockwave-flash\" width=\"" + adW.Text + "\"></embed></object>"; break; default: strValue[5] = adCode.Text; break; } strValue[6] = pDate.Text; strValue[7] = eDate.Text; strValue[8] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[9] = xc.GetIP(); strValue[10] = xc.adminID; xc.insertMyLog(xc.adminID, "admin", "修改广告"); xc.divError("", db.InsertUpdateDB("ads", strDim, strValue, "aID=" + xc.SafeNum(Request["id"]).ToString()), 350, 150, "default.aspx", "goto"); }
protected void Page_Load(object sender, EventArgs e) { XabaraCom xc = new XabaraCom(); dbDataFunction db = new dbDataFunction(); xc.CheckAdminLogin(""); DataTable dt; string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); if (string.IsNullOrEmpty(appkey as string)) { Response.Redirect("../frame/otherSet.aspx", true); } string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID Response.Write("自动同步淘画报,如出现死机或出错,重新点击自动更新即可;<br /><br />"); Response.Flush(); string requestType = Request.QueryString["type"]; ITopClient client = new DefaultTopClient(url, appkey, appsecret); PosterPostersSearchRequest req = new PosterPostersSearchRequest(); req.PageSize = 20L; req.PageNo = 1L; req.EditorRecommend = 1L; req.SortType = 4L; string strDim = "@id,@channel_id,@cover_pic_url_w,@cover_pic_url_h,@title,@title_short,@tag,@hits,@weight,@create_date,@modified_date,@isGood,@postID,@postIP,@postDate,@flagID"; string[] strValue = new string[30]; string posterId = string.Empty; dt = db.getDataTable("select id from posterChannelIDs where isFlag>0 order by newid()"); for (int i = 0; i < dt.Rows.Count; i++) { //获取画报标题 req.ChannelIds = dt.Rows[i]["id"].ToString().Trim(); PosterPostersSearchResponse response = client.Execute(req); for (int ii = 0; ii < response.Posters.Count; ii++) { strValue[0] = response.Posters[ii].Id.ToString(); //标题ID赋值 posterId = strValue[0]; strValue[1] = response.Posters[ii].ChannelId.ToString(); strValue[2] = string.Empty; strValue[3] = string.Empty; string pic = response.Posters[ii].CoverPicUrl.ToString(); if (!string.IsNullOrEmpty(pic as string)) { string[] img = pic.Split(new char[] { ',' }); strValue[2] = img[0]; strValue[3] = img[img.GetUpperBound(0)]; } strValue[4] = response.Posters[ii].Title; strValue[5] = response.Posters[ii].TitleShort; strValue[6] = response.Posters[ii].Tag; strValue[7] = response.Posters[ii].Hits.ToString(); strValue[8] = response.Posters[ii].Weight.ToString(); strValue[9] = response.Posters[ii].CreateDate.ToString(); strValue[10] = response.Posters[ii].ModifiedDate.ToString(); strValue[11] = "0"; strValue[12] = xc.adminID; strValue[13] = xc.GetIP(); strValue[14] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[15] = "1"; //默认正常 DataTable dtIF = db.getDataTable("select * from posterChannelTitle where id=" + posterId); //防止重复插入 if (dtIF.Rows.Count > 0) { strValue[8] = dtIF.Rows[0]["weight"].ToString().Trim(); db.InsertUpdateDB("posterChannelTitle", strDim, strValue, "id=" + posterId); } else { db.InsertUpdateDB("posterChannelTitle", strDim, strValue, string.Empty); } dtIF.Dispose(); Response.Write("<br />同步 " + strValue[4] + " 已完成;<br />"); Response.Flush(); //获取关联商品 PosterPostauctionsGetRequest poster = new PosterPostauctionsGetRequest(); poster.PosterId = long.Parse(posterId); PosterPostauctionsGetResponse rsp = client.Execute(poster); int c = rsp.Posterauctions.Count; if (c > 9) { string strDim2 = "@classID,@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@postID,@postDate,@postIP,@isBad,@isGood,@poster_id,@auction_short_title"; for (int s = 0; s < c; s++) { strValue[0] = "0"; strValue[1] = rsp.Posterauctions[s].AuctionId.ToString(); strValue[2] = rsp.Posterauctions[s].AuctionShortTitle.ToString(); strValue[3] = "找店铺 ZdianPU.com"; strValue[4] = "/images/WaterMark.png"; strValue[5] = rsp.Posterauctions[s].AuctionPrice.ToString(); strValue[6] = @"http://item.taobao.com/item.htm?id=" + rsp.Posterauctions[s].AuctionId.ToString(); strValue[7] = "0"; strValue[8] = "0"; strValue[9] = "0"; strValue[10] = "0"; strValue[11] = @"http://www.zdianpu.com"; strValue[12] = "0"; strValue[13] = "找店铺"; strValue[14] = "0"; strValue[15] = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss"); //表示已过期 strValue[16] = xc.adminID; strValue[17] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[18] = xc.GetIP(); strValue[19] = "1"; strValue[20] = "0"; strValue[21] = rsp.Posterauctions[s].PosterId.ToString(); strValue[22] = rsp.Posterauctions[s].AuctionShortTitle.ToString(); DataTable dtIf = db.getDataTable("select * from taobaoKe with(nolock) where num_iid=" + rsp.Posterauctions[s].AuctionId.ToString()); //防止重复插入 if (dtIf.Rows.Count > 0) { strValue[0] = rsp.Posterauctions[s].PosterId.ToString(); strValue[1] = rsp.Posterauctions[s].AuctionShortTitle.ToString(); db.InsertUpdateDB("taobaoKe", "@poster_id,@auction_short_title", strValue, "num_iid=" + rsp.Posterauctions[s].AuctionId.ToString()); } else { db.InsertUpdateDB("taobaoKe", strDim2, strValue, string.Empty); } dtIf.Dispose(); } //淘宝客自动更新操作 for (int f = 0; f < 100; f++) { string id = string.Empty; DataTable tkIDs = db.getDataTable("select top 40 num_iid from taobaoKe where poster_id=" + posterId + " and isBad>0 and updateDate<GETDATE() order by updateDate ASC"); //30天过期内的数据可再次更新 if (tkIDs.Rows.Count > 0) { Response.Write("淘宝客数据转换已完成 " + ((f * 40) + tkIDs.Rows.Count).ToString() + "<br />"); Response.Flush(); for (int t = 0; t < tkIDs.Rows.Count; t++) { id += tkIDs.Rows[t]["num_iid"].ToString().Trim() + ","; } id = id.Substring(0, id.Length - 1); //锁定淘宝客更新条数 strValue[0] = "0"; string updateID = id.Replace(",", " or num_iid="); updateID = "num_iid=" + updateID; //Response.Write(updateID); //Response.End(); db.InsertUpdateDB("taobaoKe", "@isBad", strValue, updateID); } else { break; } tkIDs.Dispose(); //Response.Write(id.ToString()); if (!string.IsNullOrEmpty(id as string)) { TaobaokeItemsConvertRequest reqTk = new TaobaokeItemsConvertRequest(); reqTk.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"; reqTk.Nick = alimamaID; reqTk.NumIids = id; TaobaokeItemsConvertResponse responseTk = client.Execute(reqTk); int tkCount = responseTk.TaobaokeItems.Count; //转换后得到的淘客数量 string strDim3 = "@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@isBad"; for (int tk = 0; tk < tkCount; tk++) { strValue[0] = responseTk.TaobaokeItems[tk].NumIid.ToString(); strValue[1] = responseTk.TaobaokeItems[tk].Title.ToString(); strValue[2] = responseTk.TaobaokeItems[tk].Nick.ToString(); strValue[3] = responseTk.TaobaokeItems[tk].PicUrl.ToString(); strValue[4] = responseTk.TaobaokeItems[tk].Price.ToString(); strValue[5] = responseTk.TaobaokeItems[tk].ClickUrl.ToString(); strValue[6] = responseTk.TaobaokeItems[tk].Commission.ToString(); strValue[7] = responseTk.TaobaokeItems[tk].CommissionRate; strValue[8] = responseTk.TaobaokeItems[tk].CommissionNum.ToString(); strValue[9] = responseTk.TaobaokeItems[tk].CommissionVolume.ToString(); strValue[10] = responseTk.TaobaokeItems[tk].ShopClickUrl.ToString(); strValue[11] = responseTk.TaobaokeItems[tk].SellerCreditScore.ToString(); strValue[12] = responseTk.TaobaokeItems[tk].ItemLocation.ToString(); strValue[13] = responseTk.TaobaokeItems[tk].Volume.ToString(); strValue[14] = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss"); strValue[15] = "1"; db.InsertUpdateDB("taobaoKe", strDim3, strValue, " num_iid =" + responseTk.TaobaokeItems[tk].NumIid.ToString()); //更新商品一对多关联表 DataTable dtIf = db.getDataTable("select * from posterTkID with(nolock) where title_id=" + posterId + " and tK_num_iid=" + responseTk.TaobaokeItems[tk].NumIid.ToString()); if (dtIf.Rows.Count < 1) //防止重复插入 { strValue[0] = posterId; strValue[1] = responseTk.TaobaokeItems[tk].NumIid.ToString(); db.InsertUpdateDB("posterTkID", "@title_id,@tK_num_iid", strValue, ""); } dtIf.Dispose(); } } } } else { db.DelDB("posterChannelTitle", "id", response.Posters[ii].Id.ToString(), "", false, ""); } } } dt.Dispose(); }
protected void addMoney_Click(object sender, EventArgs e) { dbDataFunction db = new dbDataFunction(); string imgFile = adImg.Text.Trim(); string uploadFileStr = string.Empty; if (!imgFile.Equals("Code")) { uploadFileStr = xc.UploadFile(imgUpload, imgFile, false); } string url = adHttp.Text; string newFile = string.Empty; if (uploadFileStr.Equals("上传成功")) //上传文件判断 { newFile = Session["NewFile"].ToString().Trim(); } string strDim = "@classID,@adW,@adH,@adImg,@adHttp,@adCode,@starDate,@stopDate,@postDate,@postIP,@adminID"; string[] strValue = new string[11]; strValue[0] = adClass.Text; strValue[1] = adW.Text; strValue[2] = adH.Text; strValue[3] = newFile; strValue[4] = url; if (string.IsNullOrEmpty(adCode.Text as string)) { if (imgFile.Equals("Img")) { if (!string.IsNullOrEmpty(url as string)) { strValue[5] = "<a href=\"" + url + "\" target=\"_blank\"><img src=\"http://" + XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "webDomains") + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" style=\"boder:0px;width:" + adW.Text + "px;height:" + adH.Text + "px\" /></a>"; } else { strValue[5] = "<img src=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" style=\"boder:0px;width:" + adW.Text + "px;height:" + adH.Text + "px\" />"; } } else { strValue[5] = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" height=\"" + adH.Text + "\" width=\"" + adW.Text + "\"><param name=\"quality\" value=\"high\" /><param name=\"movie\" value=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" /><embed height=\"" + adH.Text + "\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"" + xc.UploadFolder + newFile.Substring(5, 8) + "/" + newFile + "\" type=\"application/x-shockwave-flash\" width=\"" + adW.Text + "\"></embed></object>"; } } else { strValue[5] = adCode.Text; } strValue[6] = pDate.Text; strValue[7] = eDate.Text; strValue[8] = DateTime.Now.ToString(); strValue[9] = xc.GetIP(); strValue[10] = xc.adminID; if (!string.IsNullOrEmpty(newFile as string) || !string.IsNullOrEmpty(adCode.Text as string)) { xc.insertMyLog(xc.adminID, "admin", "发布广告"); xc.divError("", db.InsertUpdateDB("ads", strDim, strValue, string.Empty), 350, 150, "default.aspx", "goto"); } else { xc.divError("", "请上传广告图片或直接粘贴广告代码!", 350, 150, "add.aspx", "goto"); } }
protected void Page_Load(object sender, EventArgs e) { dbDataFunction db = new dbDataFunction(); xc.CheckAdminLogin(""); DataTable dt; string strDim = "@classID,@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@postID,@postDate,@postIP,@isBad,@isGood,@poster_id"; string[] strValue = new string[30]; string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); if (string.IsNullOrEmpty(appkey as string)) { Response.Redirect("../frame/otherSet.aspx", true); } string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID ITopClient client = new DefaultTopClient(url, appkey, appsecret); Response.Write("根据分类自动同步淘宝客开始,如出现死机或出错,重新点击<a href=\"taobao.aspx\">自动更新</a>即可;<br />"); Response.Flush(); this.js(); //定时刷新 //更新店铺 DateTime t = DateTime.Now.Date; string strSql = "select top 1 * from NewsTree with(nolock) where taobaoKe <>'' and PostDate<'" + t.ToString() + "' order by newid()"; dt = db.getDataTable(strSql); //当天不再请求更新 if (dt.Rows.Count > 0) { string classID = dt.Rows[0]["Tid"].ToString().Trim(); Response.Write("<br />" + dt.Rows[0]["treeNameTxt"].ToString().Trim() + " 同步完成!"); Response.Flush(); //System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 10)); ItemsGetRequest req = new ItemsGetRequest(); req.Fields = "num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume"; req.Nicks = dt.Rows[0]["taobaoKe"].ToString().Trim(); req.PageNo = 1L; req.OrderBy = "volume"; req.StartPrice = 50L; req.EndPrice = 100000L; req.PageSize = 200L; //取最畅销前200个商品 ItemsGetResponse response = client.Execute(req); long shopNums = response.TotalResults; if (shopNums > 0) { strValue[0] = DateTime.Now.ToString(); db.InsertUpdateDB("NewsTree", "@PostDate", strValue, "Tid=" + classID); //更新店铺宝贝同步 for (int ii = 0; ii < response.Items.Count; ii++) { strValue[0] = classID; strValue[1] = response.Items[ii].NumIid.ToString(); strValue[2] = response.Items[ii].Title; strValue[3] = response.Items[ii].Nick; strValue[4] = response.Items[ii].PicUrl; strValue[5] = response.Items[ii].Price; strValue[6] = @"http://item.taobao.com/item.htm?id=" + response.Items[ii].NumIid.ToString(); strValue[7] = "0"; strValue[8] = "0"; strValue[9] = "0"; strValue[10] = "0"; strValue[11] = @"http://www.zdianpu.com"; strValue[12] = "0"; strValue[13] = "找店铺"; strValue[14] = response.Items[ii].Volume.ToString(); strValue[15] = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss"); //表示已过期 strValue[16] = "sys"; strValue[17] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[18] = xc.GetIP(); strValue[19] = "1"; strValue[20] = "0"; strValue[21] = "0"; if (response.Items[ii].Title.IndexOf("邮费") < 0 || response.Items[ii].Title.IndexOf("补差") < 0) { DataTable dtIf = db.getDataTable("select * from taobaoKe with(nolock) where num_iid=" + response.Items[ii].NumIid.ToString()); //防止重复插入 if (dtIf.Rows.Count > 0) { strValue[6] = dtIf.Rows[0]["click_url"].ToString().Trim(); strValue[7] = dtIf.Rows[0]["commission"].ToString().Trim(); strValue[8] = dtIf.Rows[0]["commission_rate"].ToString().Trim(); strValue[9] = dtIf.Rows[0]["commission_num"].ToString().Trim(); strValue[10] = dtIf.Rows[0]["commission_volume"].ToString().Trim(); strValue[11] = dtIf.Rows[0]["shop_click_url"].ToString().Trim(); strValue[12] = dtIf.Rows[0]["seller_credit_score"].ToString().Trim(); strValue[13] = dtIf.Rows[0]["item_location"].ToString().Trim(); strValue[15] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[17] = dtIf.Rows[0]["postDate"].ToString().Trim(); strValue[20] = dtIf.Rows[0]["isGood"].ToString().Trim(); strValue[21] = dtIf.Rows[0]["poster_id"].ToString().Trim(); //淘画报 db.InsertUpdateDB("taobaoKe", strDim, strValue, "num_iid=" + response.Items[ii].NumIid.ToString()); } else { db.InsertUpdateDB("taobaoKe", strDim, strValue, string.Empty); } dtIf.Dispose(); } } } else { strValue[0] = DateTime.Now.ToString(); db.InsertUpdateDB("NewsTree", "@PostDate", strValue, "Tid=" + classID); //更新店铺宝贝同步时出错或非淘宝客,防止死锁 } } //宝贝同步结束 dt.Dispose(); //淘宝客自动更新操作 for (int f = 0; f < 5; f++) { string id = string.Empty; DataTable tkIDs = db.getDataTable("select top 40 num_iid from taobaoKe where isBad>0 and updateDate<GETDATE() order by updateDate ASC"); //30天过期内的数据可再次更新 if (tkIDs.Rows.Count > 0) { for (int i = 0; i < tkIDs.Rows.Count; i++) { id += tkIDs.Rows[i]["num_iid"].ToString().Trim() + ","; } id = id.Substring(0, id.Length - 1); //锁定淘宝客更新条数 strValue[0] = "0"; string updateID = id.Replace(",", " or num_iid="); updateID = "num_iid=" + updateID; //Response.Write(updateID); //Response.End(); db.InsertUpdateDB("taobaoKe", "@isBad", strValue, updateID); Response.Write("<br />淘宝客数据转换已完成 " + ((f * 40) + tkIDs.Rows.Count).ToString() + ",请等待10秒..."); Response.Flush(); } else { Response.Write("<br />当前淘宝客数据转换已全部完成,请明天再手动更新!"); break; } tkIDs.Dispose(); //Response.Write(id.ToString()); if (!string.IsNullOrEmpty(id as string)) { TaobaokeItemsConvertRequest req = new TaobaokeItemsConvertRequest(); req.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"; req.Nick = alimamaID; req.NumIids = id; TaobaokeItemsConvertResponse response = client.Execute(req); int tkCount = response.TaobaokeItems.Count; //转换后得到的淘客数量 strDim = "@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@isBad"; for (int i = 0; i < tkCount; i++) { strValue[0] = response.TaobaokeItems[i].NumIid.ToString(); strValue[1] = response.TaobaokeItems[i].Title.ToString(); strValue[2] = response.TaobaokeItems[i].Nick.ToString(); strValue[3] = response.TaobaokeItems[i].PicUrl.ToString(); strValue[4] = response.TaobaokeItems[i].Price.ToString(); strValue[5] = response.TaobaokeItems[i].ClickUrl.ToString(); strValue[6] = response.TaobaokeItems[i].Commission.ToString(); strValue[7] = response.TaobaokeItems[i].CommissionRate; strValue[8] = response.TaobaokeItems[i].CommissionNum.ToString(); strValue[9] = response.TaobaokeItems[i].CommissionVolume.ToString(); strValue[10] = response.TaobaokeItems[i].ShopClickUrl.ToString(); strValue[11] = response.TaobaokeItems[i].SellerCreditScore.ToString(); strValue[12] = response.TaobaokeItems[i].ItemLocation.ToString(); strValue[13] = response.TaobaokeItems[i].Volume.ToString(); strValue[14] = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss"); strValue[15] = "1"; db.InsertUpdateDB("taobaoKe", strDim, strValue, " num_iid =" + response.TaobaokeItems[i].NumIid.ToString()); } } } }
protected void Page_Load(object sender, EventArgs e) { dbDataFunction db = new dbDataFunction(); xc.CheckAdminLogin(""); string strDim = string.Empty; string[] strValue = new string[30]; string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); if (string.IsNullOrEmpty(appkey as string)) { Response.Redirect("../frame/otherSet.aspx", true); } string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID ITopClient client = new DefaultTopClient(url, appkey, appsecret); Response.Write("只针对于过期或无效淘宝客再次请求转换有效链接,如出现死机或出错,重新点击<a href=\"taobaoke.aspx\">自动更新</a>即可;<br />"); Response.Flush(); string strSql = string.Empty; //淘宝客自动更新操作 for (int f = 0; f < 5; f++) { string id = string.Empty; DataTable tkIDs = db.getDataTable("select top 40 num_iid from taobaoKe where updateDate<GETDATE() order by newid()"); //30天过期内的数据可再次更新 if (tkIDs.Rows.Count > 0) { Response.Write("<br />淘宝客数据转换已完成 " + ((f * 40) + tkIDs.Rows.Count).ToString()); Response.Flush(); for (int i = 0; i < tkIDs.Rows.Count; i++) { id += tkIDs.Rows[i]["num_iid"].ToString().Trim() + ","; } id = id.Substring(0, id.Length - 1); //锁定淘宝客更新条数 strValue[0] = "0"; string updateID = id.Replace(",", " or num_iid="); updateID = "num_iid=" + updateID; //Response.Write(updateID); //Response.End(); db.InsertUpdateDB("taobaoKe", "@isBad", strValue, updateID); } else { Response.Write("<br />当前淘宝客数据转换已全部完成!"); break; } tkIDs.Dispose(); //Response.Write(id.ToString()); if (!string.IsNullOrEmpty(id as string)) { TaobaokeItemsConvertRequest req = new TaobaokeItemsConvertRequest(); req.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"; req.Nick = alimamaID; req.NumIids = id; TaobaokeItemsConvertResponse response = client.Execute(req); int tkCount = response.TaobaokeItems.Count; //转换后得到的淘客数量 strDim = "@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@isBad"; for (int i = 0; i < tkCount; i++) { strValue[0] = response.TaobaokeItems[i].NumIid.ToString(); strValue[1] = response.TaobaokeItems[i].Title.ToString(); strValue[2] = response.TaobaokeItems[i].Nick.ToString(); strValue[3] = response.TaobaokeItems[i].PicUrl.ToString(); strValue[4] = response.TaobaokeItems[i].Price.ToString(); strValue[5] = response.TaobaokeItems[i].ClickUrl.ToString(); strValue[6] = response.TaobaokeItems[i].Commission.ToString(); strValue[7] = response.TaobaokeItems[i].CommissionRate; strValue[8] = response.TaobaokeItems[i].CommissionNum.ToString(); strValue[9] = response.TaobaokeItems[i].CommissionVolume.ToString(); strValue[10] = response.TaobaokeItems[i].ShopClickUrl.ToString(); strValue[11] = response.TaobaokeItems[i].SellerCreditScore.ToString(); strValue[12] = response.TaobaokeItems[i].ItemLocation.ToString(); strValue[13] = response.TaobaokeItems[i].Volume.ToString(); strValue[14] = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss"); strValue[15] = "1"; db.InsertUpdateDB("taobaoKe", strDim, strValue, " num_iid =" + response.TaobaokeItems[i].NumIid.ToString()); } } } Response.Clear(); this.js(); //定时刷新 }
protected void taobaoKe_Click(object sender, EventArgs e) { Session.Add("shopClass", classID.Text); string id = ids.Text.Trim(); string appkey = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppKey"); string appsecret = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAppSecret"); string url = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeUrl"); string alimamaID = XmlReader.GetConfig(Server.MapPath("~/xabara.config"), "taobaoKeAlimamaID"); //淘宝客推广ID ITopClient client = new DefaultTopClient(url, appkey, appsecret); TaobaokeItemsConvertRequest req = new TaobaokeItemsConvertRequest(); req.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume"; req.Nick = alimamaID; req.NumIids = id; TaobaokeItemsConvertResponse response = client.Execute(req); int tkCount = response.TaobaokeItems.Count; //转换后得到的淘客数量 string strDim = "@classID,@num_iid,@title,@nick,@pic_url,@price,@click_url,@commission,@commission_rate,@commission_num,@commission_volume,@shop_click_url,@seller_credit_score,@item_location,@volume,@updateDate,@postID,@postDate,@postIP,@isBad,@isGood"; string[] strValue = new string[30]; string strSql; for (int i = 0; i < tkCount; i++) { strValue[0] = classID.Text; strValue[1] = response.TaobaokeItems[i].NumIid.ToString(); strValue[2] = response.TaobaokeItems[i].Title.ToString(); strValue[3] = response.TaobaokeItems[i].Nick.ToString(); strValue[4] = response.TaobaokeItems[i].PicUrl.ToString(); strValue[5] = response.TaobaokeItems[i].Price.ToString(); strValue[6] = response.TaobaokeItems[i].ClickUrl.ToString(); strValue[7] = response.TaobaokeItems[i].Commission.ToString(); strValue[8] = response.TaobaokeItems[i].CommissionRate; strValue[9] = response.TaobaokeItems[i].CommissionNum.ToString(); strValue[10] = response.TaobaokeItems[i].CommissionVolume.ToString(); strValue[11] = response.TaobaokeItems[i].ShopClickUrl.ToString(); strValue[12] = response.TaobaokeItems[i].SellerCreditScore.ToString(); strValue[13] = response.TaobaokeItems[i].ItemLocation.ToString(); strValue[14] = response.TaobaokeItems[i].Volume.ToString(); strValue[15] = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd HH:mm:ss"); strValue[16] = xc.adminID; strValue[17] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strValue[18] = xc.GetIP(); strValue[19] = "1"; strValue[20] = "0"; strSql = "select * from taobaoKe where num_iid =" + response.TaobaokeItems[i].NumIid.ToString(); DataTable dt = db.getDataTable(strSql); if (dt.Rows.Count > 0) { strValue[18] = Convert.ToDateTime(dt.Rows[0]["postDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); strValue[20] = dt.Rows[0]["isGood"].ToString(); db.InsertUpdateDB("taobaoKe", strDim, strValue, " num_iid =" + response.TaobaokeItems[i].NumIid.ToString()); } else { db.InsertUpdateDB("taobaoKe", strDim, strValue, ""); } dt.Dispose(); } Response.Redirect("default.aspx", true); }