Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["nick"] == null || string.IsNullOrEmpty(Request.Cookies["nick"].Value))
            {
                Response.Write("false");
                Response.End();
                return;
            }
            string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
            string session = Request.Cookies["nicksession"].Value;
            //"610062491512599df1afc0664ee3a7041eb4f8d0b200134204200856";//测试

            if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList().Count > 0)
            {
                DataHelper.GetAllGoods(nick, session);

                Response.Write("true");
                Response.End();
            }
            else
            {
                Response.Write("false");
                Response.End();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //签名验证
        top_appkey = "12579340";
        app_secret = "5b384ce1102e72ee0643c5b303e2a96a";

        string top_parameters = utils.NewRequest("top_parameters", utils.RequestType.QueryString).Replace(" ", "+");

        top_session = utils.NewRequest("top_session", utils.RequestType.QueryString).Replace(" ", "+");

        string top_sign = utils.NewRequest("top_sign", utils.RequestType.QueryString).Replace(" ", "+"); //字符串中的+在获取后会被替换成空格,要再替换回来

        string sign = utils.NewRequest("sign", utils.RequestType.QueryString).Replace(" ", "+");

        string leaseId = utils.NewRequest("leaseId", utils.RequestType.QueryString).Replace(" ", "+");     //可以从 QueryString 来获取,也可以固定

        string timestamp = utils.NewRequest("timestamp", utils.RequestType.QueryString).Replace(" ", "+"); //可以从 QueryString 来获取

        string agreementsign = utils.NewRequest("agreementsign", utils.RequestType.QueryString).Replace(" ", "+");


        if (!Taobao.Top.Api.Util.TopUtils.VerifyTopResponse(top_parameters, top_session, top_sign, top_appkey, app_secret))
        {
            Response.Write("top签名验证不通过,请不要非法注入");
            Response.End();
            return;
        }

        nick = Taobao.Top.Api.Util.TopUtils.DecodeTopParams(top_parameters)["visitor_nick"];

        if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList().Count == 0)
        {
            string baisouurl = Request.Url.AbsoluteUri.ToString().Replace("kfjx.7fshop", "search.fensehenhuo");
            Response.Redirect(baisouurl);
        }

        if (nick == null || nick == "")
        {
            Response.Write("top签名验证不通过,请不要非法注入");
            Response.End();
            return;
        }

        if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.KeFuJiXiao).ToList().Count != 0)
        {
            string tetuiurl = Request.Url.AbsoluteUri.ToString().Replace("kfjx.7fshop", "search.fensehenhuo");
            Response.Redirect(tetuiurl);
        }

        else
        {
            //插入信息
            InsertSession();
            Response.Redirect("InitData.aspx");
        }
    }
Exemple #3
0
    public static bool CheckNick(string nick)
    {
        IList <TopNickSessionInfo> list = CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList();

        if (list.Count == 0)
        {
            return(false);
        }
        if (!list[0].NickState)
        {
            return(false);
        }
        return(true);
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["nick"] == null || string.IsNullOrEmpty(Request.Cookies["nick"].Value))
            {
                Response.Write("false");
                Response.End();
                return;
            }
            string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
            string session = Request.Cookies["nicksession"].Value;

            if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList().Count > 0)
            {
                //try
                //{
                DateTime now = DateTime.Now;
                DataHelper.InsertGoodsOrder(DateTime.Parse(now.AddDays(-7).ToShortDateString()), now, session, nick);
                //获取聊天记录
                DateTime start = DataHelper.GetTalkContent(nick, session, now);

                //添加统计数据
                SiteTotalService taoDal = new SiteTotalService();
                for (DateTime i = DateTime.Parse(now.AddDays(-7).ToShortDateString()); i <= now; i = i.AddDays(1))
                {
                    DataHelper.UpdateSiteTotal(nick, session, i, taoDal);
                }

                //添加客服绩效统计
                DataHelper.GetKfjxTotal(nick, start, now);
                //}
                //catch (Exception ex)
                //{
                //    LogInfo.WriteLog("出错了", ex.Message);
                //}

                Response.Write("true");
                Response.End();
            }
            else
            {
                Response.Write("false");
                Response.End();
            }
        }
    }
Exemple #5
0
    /// <summary>
    /// 插入session
    /// </summary>
    private void InsertSession()
    {
        TopNickSessionInfo info = new TopNickSessionInfo();

        info.Nick      = nick;
        info.Session   = top_session;
        info.NickState = true;
        DateTime now = DateTime.Now;

        info.JoinDate         = now;
        info.LastGetOrderTime = now;
        info.ShopId           = shopId;
        info.ServiceId        = Enum.TopTaoBaoService.YingXiaoJueCe;
        info.RefreshToken     = refreshToken;
        //有则不添加
        if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList().Count == 0)
        {
            //先添加后删除缓存
            new NickSessionService().InsertSerssionNew(info);
            CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLNICKSESSIONINFO);
        }
        else
        {
            //新session赋值
            CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList()[0].Session = top_session;
        }
        //修改缓存后读取店铺信息
        //info.ShopId = TaoBaoAPI.GetShopInfo(nick, top_session);
        //更新店铺信息
        //new NickSessionService().UpdateSession(info);
        //更新缓存
        //CacheCollection.GetNickSessionList().Where(o => o.Nick == nick && o.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe).ToList()[0].ShopId = info.ShopId;

        HttpCookie cookie       = new HttpCookie("nick", HttpUtility.UrlEncode(nick));
        HttpCookie cooksession  = new HttpCookie("nicksession", top_session);
        HttpCookie cookietongji = new HttpCookie("istongji", "1");

        cookie.Expires       = DateTime.Now.AddDays(1);
        cooksession.Expires  = DateTime.Now.AddDays(1);
        cookietongji.Expires = DateTime.Now.AddDays(1);

        Response.Cookies.Add(cookie);
        Response.Cookies.Add(cooksession);
        Response.Cookies.Add(cookietongji);
    }
Exemple #6
0
    protected override void InitializeCulture()
    {
        string msg = "尊敬的用户您好,非常抱歉的告诉您,您尚未订购该功能,如需继续使用请购买该服务:<br><br>9元/月  <a href=' http://fuwu.taobao.com/item/subsc.htm?items=service-0-22762-6:1;' target='_blank'>立即购买</a><br>";

        if (!string.IsNullOrEmpty(Request.QueryString["nick"]) && !string.IsNullOrEmpty(Request.QueryString["nicksession"]) && !string.IsNullOrEmpty(Request.QueryString["mobile"]))
        {
            HttpCookie cookie = new HttpCookie("nick", HttpUtility.UrlEncode(Request.QueryString["nick"]));
            cookie.Expires = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookie);
            HttpCookie cookieSe = new HttpCookie("nicksession", Request.QueryString["nicksession"]);
            cookieSe.Expires = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookieSe);

            HttpCookie cookieM = new HttpCookie("mobile", Request.QueryString["nicksession"]);
            cookieM.Expires = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookieM);

            TeteShopService tss = new TeteShopService();
            if (CacheCollection.GetNickSessionList().Where(o => o.Short == Request.QueryString["nick"]).ToList().Count == 0)
            {
                TeteShopInfo info = new TeteShopInfo();
                info.Nick      = Encrypt(Request.QueryString["nick"]);
                info.Session   = Request.QueryString["nicksession"];
                info.Short     = Request.QueryString["nick"];
                info.Adddate   = DateTime.Now;
                info.Appkey    = "12132145";
                info.Appsecret = "1fdd2aadd5e2ac2909db2967cbb71e7f";
                tss.InsertShop(info);
                CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLNICKSESSIONINFO);
            }
        }
        else
        {
            if (Request.Cookies["nick"] == null || Request.Cookies["nicksession"] == null || Request.Cookies["mobile"] == null)
            {
                Response.Redirect("http://www.7fshop.com/top/market/buy.aspx?msg=" + msg);
            }
        }
        //else
        //{
        //    Session["nick"] = Request.Cookies["nick"].Value;
        //    Session["session"] = Request.Cookies["nicksession"].Value;
        //}
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["nick"] == null || string.IsNullOrEmpty(Request.Cookies["nick"].Value))
            {
                Response.Write("false");
                Response.End();
                return;
            }
            string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
            string session = Request.Cookies["nicksession"].Value;
            //"610062491512599df1afc0664ee3a7041eb4f8d0b200134204200856";//测试

            if (CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList().Count > 0)
            {
                DateTime now = DateTime.Now;
                DataHelper.InsertGoodsOrder(DateTime.Parse(now.AddDays(-7).ToShortDateString()), now, session, nick);
                //获取聊天记录
                DateTime start = DataHelper.GetTalkContent(nick, session, now);

                //添加统计数据
                SiteTotalService taoDal = new SiteTotalService();
                for (DateTime i = DateTime.Parse(now.AddDays(-7).ToShortDateString()); i <= now; i = i.AddDays(1))
                {
                    DataHelper.UpdateSiteTotal(nick, session, i, taoDal);
                }

                //添加客服绩效统计
                DataHelper.GetKfjxTotal(nick, start, now);

                Response.Write("true");
                Response.End();
            }
            else
            {
                Response.Write("false");
                Response.End();
            }
        }
    }
    protected void Btn_Update_Click(object sender, EventArgs e)
    {
        string nick    = HttpUtility.UrlDecode(Request.Cookies["nick"].Value);
        string session = Request.Cookies["nicksession"].Value;

        TeteShopCategoryService cateDal = new TeteShopCategoryService();

        IList <TeteShopInfo> list = CacheCollection.GetNickSessionList().Where(o => o.Short == nick && o.Session == session).ToList();

        TeteShopInfo info = null;

        if (list.Count > 0)
        {
            info = list[0];
        }
        if (info == null)
        {
            Page.RegisterStartupScript("错误", "<script>alert('您的身份不合法,请确定您已购买!');</script>");
            return;
        }

        IList <TeteShopCategoryInfo> cateList  = cateDal.GetAllTeteShopCategory(Encrypt(nick));
        IList <GoodsClassInfo>       classList = TaoBaoAPI.GetGoodsClassInfoList(info.Short, session, info.Appkey, info.Appsecret);

        if (classList == null)
        {
            Page.RegisterStartupScript("错误", "<script>alert('获取店铺分类出错!');</script>");
            return;
        }

        List <TeteShopCategoryInfo> addList = new List <TeteShopCategoryInfo>();

        List <TeteShopCategoryInfo> upList = new List <TeteShopCategoryInfo>();

        foreach (GoodsClassInfo cinfo in classList)
        {
            List <TeteShopCategoryInfo> clist = cateList.Where(o => o.Cateid == cinfo.cid).ToList();
            if (clist.Count > 0)
            {
                InitCate(nick, cinfo, clist[0]);
                clist[0].Catecount = classList.Count(o => o.parent_cid == cinfo.cid);
                upList.Add(clist[0]);
            }

            else
            {
                TeteShopCategoryInfo ainfo = new TeteShopCategoryInfo();
                InitCate(nick, cinfo, ainfo);
                ainfo.Catecount = classList.Count(o => o.parent_cid == cinfo.cid);

                addList.Add(ainfo);
            }
        }

        //添加
        foreach (TeteShopCategoryInfo cinfo in addList)
        {
            cateDal.AddTeteShopCategory(cinfo);
        }

        //修改
        foreach (TeteShopCategoryInfo cinfo in upList)
        {
            cateDal.ModifyTeteShopCategory(cinfo);
        }

        //删除
        //List<TeteShopCategoryInfo> delList = new List<TeteShopCategoryInfo>();
        //foreach (TeteShopCategoryInfo cinfo in cateList)
        //{
        //    if (upList.Where(o => o.Cateid == cinfo.Cateid).ToList().Count == 0)
        //    {
        //        delList.Add(cinfo);
        //    }
        //}

        //foreach (TeteShopCategoryInfo cinfo in upList)
        //{
        //    cateDal.DeleteTeteShopCategory(cinfo.Id);
        //}

        //更新商品
        ActionGoods(nick, session, info);
        //更新商品分类包含商品数量
        IList <TeteShopCategoryInfo> nowCateList = cateDal.GetAllTeteShopCategory(Encrypt(nick));
        TeteShopItemService          itemDal     = new TeteShopItemService();

        for (int i = 0; i < nowCateList.Count; i++)
        {
            int count = itemDal.GetItemCountByCId(nowCateList[i].Cateid);
            nowCateList[i].Catecount = count;
        }

        //修改
        foreach (TeteShopCategoryInfo cinfo in nowCateList)
        {
            cateDal.ModifyTeteShopCategory(cinfo);
        }

        Page.RegisterStartupScript("更新提示", "<script>alert('更新成功!');</script>");
    }
Exemple #9
0
    /// <summary>
    /// TOP API POST 请求
    /// </summary>
    /// <param name="method">API接口方法名</param>
    /// <param name="session">调用私有的sessionkey</param>
    /// <param name="param">请求参数</param>
    /// <param name="dataType">淘宝返回数据格式</param>
    /// <returns>返回字符串</returns>
    public static string Post(string nick, string method, string session, IDictionary <string, string> param, DataFormatType dataType)
    {
        #region -----API系统参数----

        string url = "http://gw.api.taobao.com/router/rest";
        //string appkey = "12287381";//"12159997";
        //string appSecret = "d3486dac8198ef01000e7bd4504601a4";//"614e40bfdb96e9063031d1a9e56fbed5";

        //免费版
        //string appkey = "12132145";
        //string appSecret = "1fdd2aadd5e2ac2909db2967cbb71e7f";

        param.Add("method", method);
        param.Add("session", session);
        param.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        param.Add("format", dataType.ToString());
        param.Add("v", "2.0");
        param.Add("sign_method", "md5");
        List <TopNickSessionInfo> nicks = CacheCollection.GetNickSessionList().Where(o => o.Nick == nick).ToList();
        if (nicks.Count > 0)
        {
            //订购多个服务
            foreach (TopNickSessionInfo ninfo in nicks)
            {
                //访问的当前服务
                if (ninfo.Session == session)
                {
                    //根据具体调用哪个服务,插入该服务appkey
                    if (ninfo.ServiceId == Enum.TopTaoBaoService.YingXiaoJueCe)
                    {
                        param.Add("app_key", newAppkey);
                        param.Add("sign", CreateSign(param, newAppSecret));
                    }
                    if (ninfo.ServiceId == Enum.TopTaoBaoService.Temporary)
                    {
                        param.Add("app_key", appkey);
                        param.Add("sign", CreateSign(param, appSecret));
                    }
                    break; //服务不同,session不可能相同
                }
            }
        }
        #endregion

        string result = string.Empty;

        #region ---- 完成 HTTP POST 请求----

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        req.Method      = "POST";
        req.KeepAlive   = true;
        req.Timeout     = 300000;
        req.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
        byte[] postData  = Encoding.UTF8.GetBytes(PostData(param));
        Stream reqStream = req.GetRequestStream();
        reqStream.Write(postData, 0, postData.Length);
        reqStream.Close();
        try
        {
            HttpWebResponse rsp      = (HttpWebResponse)req.GetResponse();
            Encoding        encoding = Encoding.GetEncoding(rsp.CharacterSet);
            Stream          stream   = null;
            StreamReader    reader   = null;
            stream = rsp.GetResponseStream();
            reader = new StreamReader(stream, encoding);
            result = reader.ReadToEnd();
            if (reader != null)
            {
                reader.Close();
            }
            if (stream != null)
            {
                stream.Close();
            }
            if (rsp != null)
            {
                rsp.Close();
            }
        }
        catch (Exception ex)
        {
            LogInfo.WriteLog("session:" + session + "获取淘宝服务响应错误", ex.Message);
        }
        #endregion

        return(Regex.Replace(result, @"[\x00-\x08\x0b-\x0c\x0e-\x1f]", ""));
    }