private void ReadUserCookies() { string userCookies = ShopConfig.ReadConfigInfo().UserCookies; string userCookiesValue = CookiesHelper.ReadCookieValue(userCookies); if (!string.IsNullOrEmpty(userCookiesValue)) { try { string[] strArray = userCookiesValue.Split(new char[] { '|' }); string ciphertext = strArray[0]; string userID = strArray[1]; string userName = strArray[2]; string moneyUsed = strArray[3]; string gradeID = strArray[4]; string mobile = strArray[5]; string groupID = strArray[6]; string companyID = strArray[7]; string realName = strArray[8]; if (FormsAuthentication.HashPasswordForStoringInConfigFile(userID + userName + moneyUsed.ToString() + gradeID.ToString() + mobile + groupID.ToString() + companyID.ToString() + realName + ShopConfig.ReadConfigInfo().SecureKey + ClientHelper.Agent, "MD5").ToLower() == ciphertext.ToLower()) { this.UserID = Convert.ToInt32(userID); this.UserName = HttpContext.Current.Server.UrlDecode(userName); this.MoneyUsed = Convert.ToDecimal(moneyUsed); this.GradeID = Convert.ToInt32(gradeID); this.UserMobile = mobile; this.UserGroupID = Convert.ToInt32(groupID); this.UserCompanyID = Convert.ToInt32(companyID); this.UserRealName = HttpContext.Current.Server.UrlDecode(realName); } else { CookiesHelper.DeleteCookie(userCookies); } } catch { CookiesHelper.DeleteCookie(userCookies); } } if (this.GradeID == 0) { this.GradeID = UserGradeBLL.ReadUserGradeByMoney(0M).ID; } }
protected void Page_Load(object sender, EventArgs e) { string appKey = ShopConfig.ReadConfigInfo().AppKey; string appSecret = ShopConfig.ReadConfigInfo().AppSecret; if ((RequestHelper.GetQueryString <string>("code") != string.Empty) || (RequestHelper.GetQueryString <string>("error") != string.Empty)) { string queryString = RequestHelper.GetQueryString <string>("code"); string content = string.Empty; try { string url = "https://oauth.taobao.com/token"; string postData = "grant_type=authorization_code&code=" + queryString + "&redirect_uri=http://" + base.Request.ServerVariables["Http_Host"] + "&client_id=" + appKey + "&client_secret=" + appSecret; AccessData data = (AccessData)JavaScriptConvert.DeserializeObject(HttpHelper.WebRequestPost(url, postData), typeof(AccessData)); string str8 = data.access_token; string str9 = string.Empty; int totalCount = 0; int pageSize = 200; str9 = this.GetProductID(str8, appKey, appSecret, pageSize, 1, ref totalCount); int num3 = (int)Math.Ceiling((decimal)(totalCount / pageSize)); int currentPage = 2; while (currentPage <= num3) { str9 = str9 + "," + this.GetProductID(str8, appKey, appSecret, pageSize, currentPage, ref totalCount); currentPage++; } decimal discount = UserGradeBLL.ReadUserGradeByMoney(0M).Discount; foreach (string str10 in str9.Split(new char[] { ',' })) { ProductInfo info; string str11 = "http://gw.api.taobao.com/router/rest?"; string[] strArray2 = StringHelper.BubbleSortASC(new string[] { "method=taobao.item.get", "timestamp=" + RequestHelper.DateNow.ToString("yyyy-MM-dd HH:mm:ss"), "app_key=" + appKey, "v=2.0", "sign_method=md5", "fields=title,desc,created,seller_cids,pic_url,num,price", "num_iid=" + str10 }); string str12 = string.Empty; string str13 = string.Empty; for (currentPage = 0; currentPage < strArray2.Length; currentPage++) { str13 = str13 + strArray2[currentPage].Replace("=", string.Empty); str12 = str12 + "&" + strArray2[currentPage]; } string xml = HttpHelper.WebRequestGet(str11 + "sign=" + FormsAuthentication.HashPasswordForStoringInConfigFile(appSecret + str13 + appSecret, "MD5") + str12); XmlDocument document = new XmlDocument(); document.LoadXml(xml); info = new ProductInfo(); info.Name = document.SelectSingleNode("item_get_response/item/title").InnerText; info.Spelling = ChineseCharacterHelper.GetFirstLetter(info.Name); info.Introduction = document.SelectSingleNode("item_get_response/item/desc").InnerText; info.Summary = StringHelper.Substring(StringHelper.KillHTML(info.Introduction), 200); info.AddDate = Convert.ToDateTime(document.SelectSingleNode("item_get_response/item/created").InnerText); info.ClassID = this.ReadSystemClassID(document.SelectSingleNode("item_get_response/item/seller_cids").InnerText); info.Photo = document.SelectSingleNode("item_get_response/item/pic_url").InnerText; info.TotalStorageCount = Convert.ToInt32(document.SelectSingleNode("item_get_response/item/num").InnerText); info.MarketPrice = (100M * Convert.ToDecimal(document.SelectSingleNode("item_get_response/item/price").InnerText)) / discount; info.TaobaoID = Convert.ToInt64(str10); ProductBLL.TaobaoProduct(info); } string str15 = "<script language='javascript'>window.close();</script>"; ResponseHelper.Write(str15); ResponseHelper.End(); } catch (Exception exception) { content = exception.Message.ToString(); } if (content == string.Empty) { content = RequestHelper.GetQueryString <string>("error"); } if (content != string.Empty) { ResponseHelper.Write(content); } } else { ResponseHelper.Redirect("https://oauth.taobao.com/authorize?response_type=code&client_id=" + appKey + "&redirect_uri=" + ("http://" + base.Request.ServerVariables["Http_Host"] + "/Admin/TaobaoProductAdd.aspx")); } }