Esempio n. 1
0
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            //GetImageEx
            GoodsFresh    objFreshEx = new GoodsFresh();
            ClassHttpPost webPost    = new ClassHttpPost();

            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                                                "gb2312", "get", "", "",
                                                "",
                                                "*/*", "");
            string strError = "";

            //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");

            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\"");;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                                           strCode
                                           );

            strRet = webPost.GetHttpPage(strUrl,
                                         "gb2312", "POST", "", strData,
                                         "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                                         "*/*", "");
        }
Esempio n. 2
0
        public void Fresh()
        {
            _GoodsFreshStr goodInfo     = new _GoodsFreshStr();
            GoodsFresh     objFresh     = new GoodsFresh();
            DateTime       tOldShowTime = DateTime.Now.AddHours(-1);

            while (m_bFresh)
            {
                //get the page no
                int nPage = GetNextPage();
                if (nPage != m_iGetPage)
                {
                    if (m_bMainPageFinished)
                    {
                        string strUrl = GetNextUrl();
                        if (strUrl != "")
                        {
                            m_nGetMainPageCount++;
                            GetDetailData(strUrl);
                            m_nGetMainPageCount--;
                        }
                        else
                        {
                            string strUrlEx = GetNextUrlEx();
                            if (strUrlEx != "")
                            {
                                GetDetailDataEx(strUrlEx);
                            }
                            else
                            {
                                if (m_nGetMainPageCount == 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    m_bMainPageFinished = false;
                    ShowLogString(string.Format("开始获取第 {0} 页数据", m_iGetPage));
                    GetPageData(nPage);
                    m_bMainPageFinished = true;
                    ShowLogString(string.Format("第 {0} 页数据获取完成", m_iGetPage));
                }
                Thread.Sleep(1000);
            }
            ShowLogString(string.Format("线程退出"));
            m_nExitThreadCount++;
            if (m_nExitThreadCount == m_iThreadCount)
            {
                ShowLogString(string.Format("所有线程退出"));
                ResetButton("");
            }
        }
        public void Fresh()
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            GoodsFresh objFresh = new GoodsFresh();
            bool bRet = false;
            string strFreshAcc = "";
            string strModifyAcc = "";
            string strSynAcc = "";
            DateTime tOldShowTime = DateTime.Now.AddHours(-1);
            while (m_bFresh)
            {
                //从刷新列表获取,有则刷新,无则继续循环
                strFreshAcc = DataContrl.GetFirstAccount();
                if (strFreshAcc == "")
                {
                    Thread.Sleep(100);
                    break;
                }
                bRet = DataContrl.GetDataCache(strFreshAcc, ref goodInfo);
                if (!bRet)
                {
                    Thread.Sleep(100);
                    break;
                }
                if (m_bSuspendFresh)
                {
                    MessageBox.Show("请确定在继续之前IP已经变化", "确认");
                }

                objFresh.m_objForm = this;
                objFresh.SetWebPost(goodInfo.webPost);
                FreshQuick(goodInfo, objFresh);
                Thread.Sleep(1000);
            }
        }
        private bool FreshQuick(_GoodsFreshStr goodInfo, GoodsFresh objFresh)
        {
            string strError = "";
            goodInfo.strFreshStatus = "正在登录...";
            ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
            ShowFreshInfo(goodInfo);
            bool bRet = Login(goodInfo.webPost, goodInfo.strAcc, goodInfo.strPwd, ref strError, false);
            if (!bRet)
            {
                if (strError.IndexOf("为保证账户安全,请填写验证码") < 0)
                {
                    ShowLogString("为保证账户安全,请填写验证码");
                    goodInfo.strFreshStatus = "登录失败:" + strError;
                    ShowFreshInfo(goodInfo);
                    if(m_iFreshType ==1 )
                        WriteLogModifyPwd(string.Format("{0}    {1}     {2}    {3}", goodInfo.strAcc, goodInfo.strPwd, goodInfo.strNewPwd, goodInfo.strFreshStatus), false);
                    return false;
                }
                bRet = Login(goodInfo.webPost, goodInfo.strAcc, goodInfo.strPwd, ref strError, true);
                if (!bRet)
                {
                    goodInfo.strFreshStatus = "登录失败:" + strError;
                    ShowLogString(goodInfo.strFreshStatus);
                    ShowFreshInfo(goodInfo);
                    if (m_iFreshType == 1)
                        WriteLogModifyPwd(string.Format("{0}    {1}     {2}    {3}", goodInfo.strAcc, goodInfo.strPwd, goodInfo.strNewPwd, goodInfo.strFreshStatus), false);
                    return false;
                }
            }

            if (m_iFreshType == 1)  // 修改密码
            {
                goodInfo.strFreshStatus = "正在修改密码...";
                ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
                if (objFresh.ModifyPwd(goodInfo))
                {
                    goodInfo.strFreshStatus = "修改密码成功";
                    ShowFreshInfo(goodInfo);
                    ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
                    WriteLogModifyPwd(string.Format("{0}    {1}     {2}", goodInfo.strAcc, goodInfo.strPwd, goodInfo.strNewPwd), true);
                    return true;
                }
                else {
                    ShowLogString(goodInfo.strFreshStatus);
                    WriteLogModifyPwd(string.Format("{0}    {1}     {2}    {3}", goodInfo.strAcc, goodInfo.strPwd, goodInfo.strNewPwd, goodInfo.strFreshStatus), false);
                }
                return false;
            }

            return GetOrderInfo(goodInfo);
        }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            goodInfo.strAcc = "testAcc";
            goodInfo.strOrderID = "222222222222222";
            goodInfo.bShowAcc = true;
            AddViewItem(goodInfo);

            _GoodsFreshStr goodInfo1 = new _GoodsFreshStr();
            goodInfo1.strAcc = "testAcc111";
            goodInfo1.strOrderID = "BBBBBBBBBBB";
            goodInfo1.bShowAcc = true;
            AddViewItem(goodInfo1);

            goodInfo.strOrderID = "3333333333";
            goodInfo.bShowAcc = false;
            AddViewItem(goodInfo);

            goodInfo.strOrderID = "4444444444";
            goodInfo.bShowAcc = false;
            AddViewItem(goodInfo);

            goodInfo.strOrderID = "4444444444";
            goodInfo.bShowAcc = false;
            goodInfo.bModify = true;
            goodInfo.strFreshStatus = "获取订单成功";
            AddViewItem(goodInfo);

            goodInfo1.strOrderID = "55555555555555";
            goodInfo1.bShowAcc = false;
            AddViewItem(goodInfo1);
            goodInfo1.strOrderID = "6666666666666666";
            goodInfo1.bShowAcc = false;
            AddViewItem(goodInfo1);
            return;
            //%u4E0A%u6D77
            string strProvince = strProvince = Escape("上海");//, Encoding.GetEncoding("gb2312"));
            return;
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            clsMCI cm = new clsMCI();
            cm.FileName = "Notice.mp3";
            cm.play();
            return;
            _GoodsFreshStr goodInfo = null;
            DataContrl.GetDataCache("*****@*****.**", ref goodInfo);
            goodInfo.strFreshStatus = "下单成功";
            ShowStatusInfo(goodInfo);

            DataContrl.GetDataCache("[email protected]", ref goodInfo);
            goodInfo.strFreshStatus = "失败";
            ShowStatusInfo(goodInfo);

            DataContrl.GetDataCache("[email protected]", ref goodInfo);
            goodInfo.strFreshStatus = "登录中...";
            ShowStatusInfo(goodInfo);

            return;
            string strShow = string.Format("{0}", DateTime.Now.ToFileTime());
            MessageBox.Show(strShow);
            return;
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
        private bool Fresh(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh,bool bSynFlag)
        {
            //http://m.pconline.com.cn/member/product/products_onsell.htm?&pageSize=60&pageNo=1
            goodInfo.strModifyStatus = "";
            goodInfo.bModify = false;
            string strError = "";
            if (bSynFlag)
            {
                goodInfo.strSynStatus = "登录中...";
            }
            else{
                goodInfo.strFreshStatus = "登录中...";
            }
            ShowInfo(goodInfo);
            bool bRet = false;

            bRet = objFresh.PaoPaoLogin(goodInfo.strAcc, goodInfo.strPwd, "", out strError,false);
            if (!bRet)
            {
                //strError = "登录失败";
                if (bSynFlag)
                {
                    goodInfo.strSynStatus = strError;
                }
                else
                {
                    goodInfo.strFreshStatus = strError;
                }
                ShowLogString(strError);
                ShowInfo(goodInfo);
                return false;
            }
            goodInfo.strMid = strError;
            int iCurPage = 1;
            int iRet = -1;
            int iFreshCount;
            int iGoodCount;
            bool bBreak = false;

            if (bSynFlag)
            {
                goodInfo.strSynStatus = "正在同步...";
            }
            else
            {
                goodInfo.strFreshStatus = "正在刷新...";
            }
            ShowInfo(goodInfo);
            Hashtable hWaitTable = new Hashtable();
            Hashtable hFailTable = new Hashtable(); //修改失败的价格列表
            Hashtable hSynTable = new Hashtable(); //同步列表
            Hashtable hSynDuplicateTable = new Hashtable(); //同步列表
            int iNetErrorCount = 0;
            while (m_bFresh && !bBreak)
            {
                if (bSynFlag)
                {
                    iRet = objFresh.Synchronize(out strError, out iFreshCount, out iGoodCount, out bBreak, iCurPage + 1, ref iNetErrorCount, ref hSynTable, ref hSynDuplicateTable,goodInfo.strMid);
                }
                else{
                    iRet = objFresh.Fresh(out strError, out iFreshCount, out iGoodCount, out bBreak, iCurPage + 1, false, ref hWaitTable, ref hFailTable, ref iNetErrorCount);
                }
                
                //成功
                if (iRet == 0)
                {
                    goodInfo.iFreshNumCount = iGoodCount;
                    if (bSynFlag)
                    {
                        goodInfo.iFreshSucNumCount = hSynTable.Count;
                        goodInfo.iSynchronizeCount = hSynTable.Count;
                    }
                    else
                        goodInfo.iFreshSucNumCount += iFreshCount;

                    if (bSynFlag)
                    {
                        goodInfo.strSynStatus = "正在同步";
                    }
                    else
                    {
                        goodInfo.strFreshStatus = "正在刷新";
                    }
                    if (bBreak)
                    {
                        if (bSynFlag)
                        {
                            goodInfo.strSynStatus = "同步完成";
                        }
                        else
                        {
                            goodInfo.strFreshStatus = "刷新完成";
                        }
                    }
                }
                else if (iRet == -1)
                {
                    goodInfo.strFreshStatus = strError;
                    goodInfo.strSynStatus = strError;
                    goodInfo.strModifyStatus = strError;
                    bRet = false;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                    break;
                }
                else
                {                    
                    goodInfo.strFreshStatus = strError;
                    ShowLogString(string.Format("{0} {1}",iCurPage,strError));
                }
                ShowInfo(goodInfo);
                if (iRet != -3)
                {
                    iCurPage++;
                }                
                if (bBreak)
                {
                    if (bSynFlag)
                    {
                        //保存到文件
                        StringBuilder strBuilder = new StringBuilder();
                        _GoodsModifyStr objStru = new _GoodsModifyStr();

                        string[] keyArray = new string[hSynTable.Count];
                        string[] valueArray = new string[hSynTable.Count];
                        hSynTable.Keys.CopyTo(keyArray, 0);
                        int i=0;
                        foreach (string skey in keyArray)
                        {
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            valueArray[i] = objStru.strNoEx;
                            i++;
                        }
                        Array.Sort(valueArray, keyArray);
                        foreach (string skey in keyArray)
                        {
                            /*
                               public string strTicket;
        public string strPay;
        public string strSequence;
        public string strTrueprice;
        public string strMid;
        public string strOtherInfo;  //表示特价等的字符串
        public string dealerPriceId;
        public string oldstatus;
        public string refprice;
        public string productname;
        public string strAdvert;
                             */
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            strBuilder.Append(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},\r\n", objStru.strNo, objStru.strNoEx.Trim(),
                                objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice,
                                objStru.dealerPriceId,
                                objStru.oldstatus,
                                objStru.refprice,
                                objStru.strOtherInfo,
                                objStru.strAdvert                               
                                ));
                        }
                        string strDirectory = System.AppDomain.CurrentDomain.BaseDirectory + "synfile";
                        string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";

                        WriteInfo(strDirectory, strBuilder, goodInfo.strAcc);
                        SaveToExcel(strDirectoryXls, hSynTable, goodInfo.strAcc);

                        if (hSynDuplicateTable.Count > 0)
                        {
                            StringBuilder strBuilderEx = new StringBuilder();

                            string[] keyArrayDup = new string[hSynDuplicateTable.Count];
                            string[] valueArrayDup = new string[hSynDuplicateTable.Count];
                            hSynDuplicateTable.Keys.CopyTo(keyArrayDup, 0);
                            int ii = 0;
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];
                                valueArrayDup[ii] = objStru.strNoEx;
                                ii++;
                            }
                            Array.Sort(valueArrayDup, keyArrayDup);
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];

                                strBuilderEx.Append(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},\r\n", objStru.strNo, objStru.strNoEx.Trim(),
                                objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice,
                                objStru.dealerPriceId,
                                objStru.oldstatus,
                                objStru.refprice,
                                objStru.strOtherInfo,
                                objStru.strAdvert
                                ));
                            }
                            
                            WriteInfo(strDirectory, strBuilderEx, goodInfo.strAcc + "_duplicate");
                            SaveToExcel(strDirectoryXls, hSynDuplicateTable, goodInfo.strAcc + "_duplicate");
                        }                        
                    }
                    break;
                }
                Thread.Sleep(500);
            }            
            return true;
        }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
        private bool Modify(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh)
        {
            goodInfo.strFreshStatus = "";
            goodInfo.bModify = true;
            string strError = "";

            Hashtable hWaitTable = new Hashtable();
            Hashtable hFailTable = new Hashtable(); //修改失败的价格列表
            bool bRet = DataContrl.GetModifyData(goodInfo.strAcc, ref hWaitTable);   //得到等待刷新的商品列表
            if (!bRet)
            {
                goodInfo.strModifyStatus = "无价格刷新列表";
                ShowInfo(goodInfo);
                ShowLogString(strError);
                return true;
            }
            int iTotalCount = hWaitTable.Count;
            goodInfo.iModifyCount = iTotalCount;
            goodInfo.strModifyStatus = "登录中...";
            ShowInfo(goodInfo);

            #if __PAOPAO
            string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
            if (!Directory.Exists(strDirect))
            {
                Directory.CreateDirectory(strDirect);
            }
            string strFile = string.Format("{0}\\{1}.bmp", strDirect, goodInfo.strAcc);
            bRet = objFresh.GetImage(strFile,out strError);
            string strCheckCode = "";
            if (bRet)
            {
                lock (m_hLockTable)
                {
                    GetCodeHandler _myInvoke = new GetCodeHandler(GetCode);
                    strCheckCode = (string)this.Invoke(_myInvoke, new object[] { strFile });
                    if (strCheckCode.Length != 4)
                    {
                        goodInfo.strFreshStatus = "验证码错误";
                        ShowInfo(goodInfo);
                        return false;
                    }
                }
            }
            else
            {
                goodInfo.strFreshStatus = strError;
                ShowInfo(goodInfo);
                ShowLogString(strError);
                return false;
            }
            bRet = objFresh.PaoPaoLogin(goodInfo.strAcc, goodInfo.strPwd, strCheckCode, out strError);
            #else
            bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd, false);
            #endif
            if (!bRet)
            {
                strError = "登录失败";
                goodInfo.strModifyStatus = strError;
                ShowInfo(goodInfo);
                ShowLogString(strError);
                return false;
            }
            goodInfo.strModifyStatus = "修改中...";
            ShowInfo(goodInfo);
            int iCurPage = 1;
            int iRet = -1;
            int iModifyCount = 0;
            int iGoodCount = 0;
            bool bBreak = false;

            int iNetErrorCount = 0;
            while (m_bFresh && !bBreak)
            {

            #if __PAOPAO
                //FreshPaoPao
                iRet = objFresh.FreshPaoPao(out strError, out iModifyCount, out iGoodCount, out bBreak, iCurPage + 1, true, ref hWaitTable, ref hFailTable, ref iNetErrorCount);
            #else
                iRet = objFresh.Fresh(out strError, out iModifyCount, out iGoodCount, out bBreak, iCurPage + 1, true, ref hWaitTable, ref hFailTable, ref iNetErrorCount);
            #endif

                goodInfo.strModifyStatus = strError;
                //成功
                if (iRet == 0)
                {
                    goodInfo.iModifyCount = iTotalCount;
                    goodInfo.iModifySucCount += iModifyCount;
                    goodInfo.strModifyStatus = "修改中...";
                    if (bBreak)
                    {
                        goodInfo.strModifyStatus = "修改完成";
                    }
                }
                else if (iRet == -3)//网络错误
                {
                    goodInfo.strModifyStatus = strError;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                else if (iRet == -1)//数据错误,直接退出
                {
                    ShowLogString("发生数据错误,退出");
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                else
                {
                    goodInfo.strModifyStatus = strError;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                ShowInfo(goodInfo);
                if ( iRet != -3 )
                {
                    iCurPage++;
                }
                if (bBreak)
                {
                    bRet = true;
                    break;
                }
                if (iRet == -1)
                {
                    bRet = false;
                    break;
                }
                Thread.Sleep(500);
            }
            //DataContrl.AddNeedAddList(goodInfo.strAcc, hFailTable);
            return bRet;
        }
Esempio n. 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            // _GoodsFreshStr objInfoEx = new _GoodsFreshStr();
            //objInfoEx.strAcc = "aaa";
            TestStr1 bulder = new TestStr1();

            bulder.strAcc = "AAA";
            Hashtable tblHash = new Hashtable();

            bulder.strAcc = "AAABBB";

            _GoodsFreshStr objInfoExEx = new _GoodsFreshStr();

            string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";

            SaveToExcel(strDirectoryXls, null, "aaaaa");
            return;

            GoodsFresh    objFreshEx = new GoodsFresh();
            ClassHttpPost webPost    = new ClassHttpPost();

            objFreshEx.SetWebPost(webPost);

            string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";

            if (!Directory.Exists(strDirect))
            {
                Directory.CreateDirectory(strDirect);
            }

            return;

            //string str = System.Web.HttpUtility.UrlEncode("你好", Encoding.GetEncoding("gb2312"));
            string str = string.Format("{0}    {1}", 519.0, 535.01);

            MessageBox.Show(str);
            return;

            TimerFunction();
            return;

            string         strAcc  = "heilongjiangjt";
            _GoodsFreshStr objInfo = new _GoodsFreshStr();

            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            objInfo.iFreshCount = 2;
            //DataContrl.InitFreshTime();
            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            return;

            IsSetIllegal(); return;

            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            bool           bRet     = DataContrl.GetDataCache("heilongjiangjt", ref goodInfo);

            if (!bRet)
            {
                return;
            }
            GoodsFresh objFresh = new GoodsFresh();

            objFresh.SetWebPost(goodInfo.webPost);
            bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd, true);
            string strError = "";

            objFresh.FreshQuick(out strError, out strError);
        }
        private bool Fresh(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh,bool bSynFlag)
        {
            //http://m.pconline.com.cn/member/product/products_onsell.htm?&pageSize=60&pageNo=1
            goodInfo.strModifyStatus = "";
            goodInfo.bModify = false;
            string strError = "";

            bool bRet = false;

            int iCurPage = 0;
            int iRet = -1;
            int iFreshCount;
            int iGoodCount;
            bool bBreak = false;

            if (bSynFlag)
            {
                goodInfo.strFreshStatus = "正在同步...";
            }
            else
            {
                goodInfo.strFreshStatus = "正在刷新...";
            }
            ShowInfo(goodInfo);

            Hashtable hWaitTable = new Hashtable();
            Hashtable hFailTable = new Hashtable(); //修改失败的价格列表
            Hashtable hSynTable = new Hashtable(); //同步列表
            Hashtable hSynDuplicateTable = new Hashtable(); //同步列表
            int iNetErrorCount = 0;
            string strContent = "";// "为了方便在太平洋商城的店主们  批量  更新商品信息,      \r\n我们特别为店主们量身定做了一款批量刷新、    \r\n同步商品信息,       \r\n批量修改商品价格信息的软件.        \r\n 以达到商家的商品一直排前, 提高客户关注度.            \r\n在商品价格需要修改时, 只需要导入一个Excel 文件,  即可实现批量修改价格.       让商家从繁复的操作中解脱出来, 从战略的角度考虑商品销售.        \r\n另可定制各种商城的同类刷新修改软件:             \r\n如: 中关村在线,  pcpop,  天极等商城.";
            //strContent = strContent + "          \r\n 详情请联系QQ: 1194410385 请注明[太平洋刷新] ";

            strContent = m_strMsgSend;
            //strContent = "test info111";
            goodInfo.iFreshNumCount = 0;
            while (m_bFresh && !bBreak)
            {
                if (bSynFlag)
                {
                    iRet = objFresh.SynchronizeSeller(out strError, out iFreshCount, out iGoodCount, out bBreak, iCurPage + 1, ref iNetErrorCount, ref hSynTable, ref hSynDuplicateTable,goodInfo.strAcc);
                }
                else{
                    bBreak = true;
                    goodInfo.strFreshStatus = "正在获取验证码...";
                    ShowInfo(goodInfo);
                    //获取验证码
                    string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
                    if (!Directory.Exists(strDirect))
                    {
                        Directory.CreateDirectory(strDirect);
                    }
                    m_strCheckCode = "SDFKD";
                    string strName = goodInfo.strAcc;
                    strName = strName.Replace(":", "");
                    strName = strName.Replace(".", "");
                    strName = strName.Replace("\\", "");
                    strName = strName.Replace("/", "");
                    string strFile = string.Format("{0}\\{1}.bmp", strDirect, strName);
                    string strMemo = "";
                    string strTarget = "";
                    if (m_strCheckCode == "")
                    {
                        bRet = objFresh.GetImage(goodInfo.strAcc, strFile, out strError, out strMemo, out strTarget);
                        if (!bRet)
                        {
                            goodInfo.strFreshStatus = "获取验证码失败";
                            ShowInfo(goodInfo);
                            return false;
                        }
                        lock (m_hLockTable)
                        {
                            GetCodeHandler _myInvoke = new GetCodeHandler(GetCode);
                            m_strCheckCode = (string)this.Invoke(_myInvoke, new object[] { strFile });
                            if (m_strCheckCode.Length < 1)
                            {
                                goodInfo.strFreshStatus = "验证码错误";
                                ShowInfo(goodInfo);
                                return false;
                            }
                        }
                    }

                    iRet = objFresh.AddNotie(goodInfo.strAcc, strContent, m_strCheckCode, strMemo, strTarget,out strError);
                    iGoodCount = 0;
                    iFreshCount = 0;
                }

                //成功
                if (iRet == 0)
                {
                    goodInfo.iFreshNumCount += iGoodCount;
                    if (bSynFlag)
                    {
                        goodInfo.iFreshSucNumCount = hSynTable.Count;
                        goodInfo.iSynchronizeCount = hSynTable.Count;
                    }
                    else
                        goodInfo.iFreshSucNumCount += iFreshCount;

                    if (bSynFlag)
                    {
                        goodInfo.strFreshStatus = string.Format("正在同步:{0}", goodInfo.iFreshSucNumCount);
                    }
                    else
                    {
                        goodInfo.strFreshStatus = "发送成功";
                    }
                    if (bBreak)
                    {
                        if (bSynFlag)
                        {
                          //  goodInfo.strFreshStatus = "同步完成";
                            goodInfo.strFreshStatus = string.Format("同步完成:{0},需要重启", goodInfo.iFreshSucNumCount);
                        }
                        else
                        {
                            goodInfo.strFreshStatus = "发广告成功";
                            //将发送成功的URL地址写入新的配置文件
                            IniUtility.FilePath = System.AppDomain.CurrentDomain.BaseDirectory + "\\setEx.ini";
                            IniUtility.WriteIniKey("setex", goodInfo.strAcc, "1");
                            goodInfo.iSynchronizeCount = 1;
                        }
                    }
                }
                else if (iRet == -1)
                {
                    goodInfo.strFreshStatus = strError;
                    goodInfo.strSynStatus = strError;
                    goodInfo.strModifyStatus = strError;
                    bRet = false;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                    break;
                }
                else
                {
                    goodInfo.strFreshStatus = strError;
                    ShowLogString(string.Format("{0} {1}",iCurPage,strError));
                }
                ShowInfo(goodInfo);
                if (iRet != -3)
                {
                    iCurPage++;
                }
                if (bBreak)
                {
                    if (bSynFlag)
                    {
                        //保存到文件
                        StringBuilder strBuilder = new StringBuilder();
                        _GoodsModifyStr objStru = new _GoodsModifyStr();

                        string[] keyArray = new string[hSynTable.Count];
                        string[] valueArray = new string[hSynTable.Count];
                        hSynTable.Keys.CopyTo(keyArray, 0);
                        int i=0;
                        foreach (string skey in keyArray)
                        {
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            valueArray[i] = objStru.strNoEx;
                            i++;
                        }
                        Array.Sort(valueArray, keyArray);
                        foreach (string skey in keyArray)
                        {
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            strBuilder.Append(string.Format("{0},{1},{2},{3},{4},{5},\r\n", objStru.strNo, objStru.strNoEx, objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice, objStru.strName));
                        }
                        string strDirectory = System.AppDomain.CurrentDomain.BaseDirectory + "synfile";
                        string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";

                        WriteInfo(strDirectory, strBuilder, goodInfo.strAcc);
                        SaveToExcel(strDirectoryXls, hSynTable, goodInfo.strAcc);

                        if (hSynDuplicateTable.Count > 0)
                        {
                            StringBuilder strBuilderEx = new StringBuilder();

                            string[] keyArrayDup = new string[hSynDuplicateTable.Count];
                            string[] valueArrayDup = new string[hSynDuplicateTable.Count];
                            hSynTable.Keys.CopyTo(keyArrayDup, 0);
                            int ii = 0;
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];
                                valueArrayDup[ii] = objStru.strNoEx;
                                ii++;
                            }
                            Array.Sort(valueArrayDup, keyArrayDup);
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];
                                strBuilder.Append(string.Format("{0},{1},{2},{3},{4},{5},\r\n", objStru.strNo, objStru.strNoEx, objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice, objStru.strName));
                            }

                            WriteInfo(strDirectory, strBuilderEx, goodInfo.strAcc + "_duplicate");
                            SaveToExcel(strDirectoryXls, hSynDuplicateTable, goodInfo.strAcc + "_duplicate");
                        }
                    }
                    break;
                }
                Thread.Sleep(500);
            }
            return true;
        }
 //sohu reg
 private void button2_Click(object sender, EventArgs e)
 {
     //GetImageEx
     GoodsFresh objFreshEx = new GoodsFresh();
     ClassHttpPost webPost = new ClassHttpPost();
     objFreshEx.SetWebPost(webPost);
     string strRet = webPost.GetHttpPage("http://passport.sohu.com/web/dispatchAction.action?registerType=Passport&showAllType=1",
             "gb2312", "get","", "",
             "",
             "*/*", "");
     string strError = "";
     objFreshEx.GetImageEx("c:\\ddddddd.bmp", out strError);
     //
     string strCode = "";
     string strNumber = "";
     strCode = "hfabe3a8";
     strNumber = "SCYLSLALELJLAPCLSLELSLAJYJPLYPJPNPULYJPLELYPNJSLJLAJSLYLAPUJUPCLAPLPJPNLYLAJSLYLAPUJUPCLSLAPLPNLALEPJLYLAPCJUPJLYLSLAJYJPLELYPCLEPNJPLEJYLEPNPJPCPJLALSPCPJLALYLEJSPULEJSPNPCPJLAPJLEJUPJLEJSPULEJPJY";
     string strData = string.Format("checkRegType=on&shortname=testregidnew2&user.password=wawawo20&password2=wawawo20&user.question=%CE%D2%BE%CD%B6%C1%B5%C4%D3%D7%B6%F9%D4%B0%C3%FB%B3%C6&questionbak=&answer=%B3%A4%BD%AD%D0%A1%D1%A7&validate={1}&privacy=1&uuidCode={0}&app_para=registerType%3DPassport%26showAllType%3D1&ot_registerid=&registerid=&appid=9998&autologin=1&ru=&domainName=sohu.com&registerType=Passport&showAllType=1",
         strNumber,
         strCode
         );
     strRet = webPost.GetHttpPage("https://passport.sohu.com/web/Passportregister.action",
             "gb2312", "POST","", strData,
             "https://passport.sohu.com/web/dispatchAction.action?registerType=Passport&showAllType=1",
             "*/*", "");
 }
        public void Fresh()
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            GoodsFresh objFresh = new GoodsFresh();
            bool bRet = false;
            string strFreshAcc = "";
            string strModifyAcc = "";
            string strSynAcc = "";
            DateTime tOldShowTime = DateTime.Now.AddHours(-1);
            while (m_bFresh)
            {
                //从刷新列表获取,有则刷新,无则继续循环
                strFreshAcc = DataContrl.GetFirstAccount();
                if (strFreshAcc == "")
                {
                    Thread.Sleep(100);
                    continue;
                }
                bRet = DataContrl.GetDataCache(strFreshAcc, ref goodInfo);
                if (!bRet)
                {
                    Thread.Sleep(100);
                    continue;
                }
                string strUrl = "";
                string strRet = "";
                string strCheckCode = "";
                ClassHttpPost m_webPost = goodInfo.webPost;
                goodInfo.strFreshStatus = "正在充值...";
                ShowInfo(goodInfo);
                while (m_bFresh)
                {
                    //获取验证码
                    string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
                    if (!Directory.Exists(strDirect))
                    {
                        Directory.CreateDirectory(strDirect);
                    }
                    string strFile = string.Format("{0}\\{1}.bmp", strDirect, goodInfo.strAcc);
                    bRet = GetImage(m_webPost,strFile);
                    if (!bRet)
                    {
                        //获取验证码失败
                        ShowLogString("获取验证码失败");
                        Thread.Sleep(500);
                        continue;
                    }
                    //识别验证码,拿到结果

                    strCheckCode = GetCheckCode(strFile);
                    ShowLogString(strCheckCode);
                    //拿到结果了,
                    if (strCheckCode.Length != 6)
                    {
                        ShowLogString("验证码识别错误");
                        Thread.Sleep(500);
                        continue;
                    }

                    //验证验证码是否正确
                    strUrl = string.Format("http://www.0753game.com/ckcode.php?ckcode={0}", strCheckCode);
                    strRet = m_webPost.GetHttpPage(strUrl,
                   "gb2312", "get", "", "",
                   "",
                   "*/*", "");
                    strRet = strRet.Trim();
                    if (strRet != "0")
                    {
                        goodInfo.strFreshStatus = "验证码错误,正在重试 。。。";
                        ShowInfo(goodInfo);
                        ShowLogString("验证码错误");
                        Thread.Sleep(500);
                        continue;
                    }
                    ShowLogString("验证码正确,开始提交数据");
                    goodInfo.strFreshStatus = "正在提交数据...";
                    ShowInfo(goodInfo);
                    //开始提交数据
                    string strData = string.Format("chargename={0}&chargenamerepeat={0}&chargecard={1}&chargepwd={2}&ckcode={3}&step=1",
                        goodInfo.strModifyStatus,
                        goodInfo.strAcc,
                        goodInfo.strPwd,
                        strCheckCode);
                    strRet = m_webPost.GetHttpPage("http://www.0753game.com/Charge_card.php",
                    "gb2312", "post", "", strData,
                    "http://www.0753game.com/Charge_card.php",
                    "*/*", "");
                    if (strRet == "")
                    {
                        ShowLogString("网络错误");
                        goodInfo.strFreshStatus = "网络错误";
                        ShowInfo(goodInfo);
                        Thread.Sleep(500);
                        continue;
                    }
                    if (strRet.IndexOf("充值确认") < 0)
                    {
                        ShowLogString("充值失败,账号或密码错误");
                        goodInfo.strFreshStatus = "充值失败,账号或密码错误";
                        ShowInfo(goodInfo);
                        break;
                    }
                    strData = "step=2";
                    strRet = m_webPost.GetHttpPage("http://www.0753game.com/Charge_card.php",
                    "gb2312", "post", "", strData,
                    "http://www.0753game.com/Charge_card.php",
                    "*/*", "");
                    //判断是否成功
                    goodInfo.strFreshStatus = strRet;
                    ShowInfo(goodInfo);
                    break;
                }
            }
        }
        public void Fresh()
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            GoodsFresh objFresh = new GoodsFresh();
            bool bRet = false;
            string strFreshAcc = "";
            string strModifyAcc = "";
            string strSynAcc = "";
            DateTime tOldShowTime = DateTime.Now.AddHours(-1);
            while (m_bFresh)
            {
                //同步列表
                strSynAcc = DataContrl.GetFirstSynAccount();
                if (strSynAcc != "")
                {
                    ShowLogString(string.Format("{0} 开始同步商品信息!", strSynAcc));
                    bRet = DataContrl.GetDataCache(strSynAcc, ref goodInfo);
                    if (!bRet)
                    {
                        Thread.Sleep(100);
                        continue;
                    }
                    objFresh.SetWebPost(goodInfo.webPost);
                    bRet = Fresh(ref goodInfo, objFresh,true);
                    if (bRet)
                    {
                        goodInfo.strSynStatus = "同步成功,需要重启";
                        ShowLogString(string.Format("{0} 同步成功,需要重启", goodInfo.strAcc));
                    }
                    else
                    {
                        //goodInfo.strSynStatus = "同步失败";
                        ShowLogString(string.Format("{0} 同步失败:{1}", goodInfo.strAcc, goodInfo.strSynStatus));
                    }
                    ShowInfo(goodInfo);
                    Thread.Sleep(1000);
                    continue;
                }
                //从修改价格列表获取,如果有,则修改
                strModifyAcc = DataContrl.GetFirstModifyAccount();
                if (strModifyAcc != "")
                {
                    ShowLogString(string.Format("{0} 开始修改价格!", strModifyAcc));
                    bRet = DataContrl.GetDataCache(strModifyAcc, ref goodInfo);
                    if (!bRet)
                    {
                        Thread.Sleep(100);
                        continue;
                    }
                    objFresh.SetWebPost(goodInfo.webPost);
                    bRet = Modify(ref goodInfo, objFresh);
                    if (bRet)
                    {
                        ShowLogString(string.Format("{0} 修改成功", goodInfo.strAcc));
                    }
                    else
                    {
                        goodInfo.iFreshFailCount += 1;
                        ShowLogString(string.Format("{0} 修改失败:{1}", goodInfo.strAcc, goodInfo.strFreshStatus));
                    }
                    Thread.Sleep(1000);
                    continue;
                }

            #if __PAOPAO
                Thread.Sleep(500);
                continue;
            #endif
                if (m_bSuspendFresh)
                {
                    TimeSpan tSpan = DateTime.Now - tOldShowTime;
                    if (tSpan.TotalMinutes > 2)
                    {
                        ShowLogString("刷新暂停中...");
                        tOldShowTime = DateTime.Now;
                    }
                    Thread.Sleep(500);
                    continue;
                }
                //从刷新列表获取,有则刷新,无则继续循环
                strFreshAcc = DataContrl.GetFirstAccount();
                if (strFreshAcc == "")
                {
                    Thread.Sleep(100);
                    continue;
                }
                bRet = DataContrl.GetDataCache(strFreshAcc, ref goodInfo);
                if (!bRet)
                {
                    Thread.Sleep(100);
                    continue;
                }
                objFresh.SetWebPost(goodInfo.webPost);
                if (m_iFreshType == 0) //一键刷新
                {
                    goodInfo.bModify = false;
                    bRet = FreshQuick(ref goodInfo, objFresh);
                }
                else
                {
                    bRet = Fresh(ref goodInfo, objFresh,false);
                }

                if (bRet)
                {
                    goodInfo.strFreshStatus = "刷新成功";
                    goodInfo.iFreshSucCount += 1;
                    ShowLogString(string.Format("{0} 刷新成功", goodInfo.strAcc));
                }
                else
                {
                    goodInfo.iFreshFailCount += 1;
                    ShowLogString(string.Format("{0} 刷新失败:{1}", goodInfo.strAcc, goodInfo.strFreshStatus));
                }
                ShowInfo(goodInfo);
                Thread.Sleep(1000);
            }
        }
        public void Fresh()
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            GoodsFresh objFresh = new GoodsFresh();
            DateTime tOldShowTime = DateTime.Now.AddHours(-1);
            while (m_bFresh)
            {
                //get the page no
                int nPage = GetNextPage();
                if (nPage != m_iGetPage)
                {
                    if (m_bMainPageFinished)
                    {
                        string strUrl = GetNextUrl();
                        if (strUrl != "")
                        {
                            m_nGetMainPageCount++;
                            GetDetailData(strUrl);
                            m_nGetMainPageCount--;
                        }
                        else
                        {

                            string strUrlEx = GetNextUrlEx();
                            if (strUrlEx != "")
                            {
                                GetDetailDataEx(strUrlEx);
                            }
                            else
                            {
                                if (m_nGetMainPageCount == 0)
                                    break;
                            }
                        }
                    }
                }
                else
                {
                    m_bMainPageFinished = false;
                    ShowLogString(string.Format("开始获取第 {0} 页数据", m_iGetPage));
                    GetPageData(nPage);
                    m_bMainPageFinished = true;
                    ShowLogString(string.Format("第 {0} 页数据获取完成", m_iGetPage));
                }
                Thread.Sleep(1000);
            }
            ShowLogString(string.Format("线程退出"));
            m_nExitThreadCount++;
            if (m_nExitThreadCount == m_iThreadCount)
            {
                ShowLogString(string.Format("所有线程退出"));
                ResetButton("");

            }
        }
        private bool FreshQuick(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh)
        {
            string strError = "";
            if (string.IsNullOrEmpty(goodInfo.strLastFreshQuickTime))
            {
                goodInfo.strLastFreshQuickTime = "未知";
            }

            //得到还有的次数显示
            goodInfo.strQuickFreshTimeLeft = "未知";
            goodInfo.strFreshStatus = "正在登录...";
            ShowInfo(goodInfo);
            bool bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd,true);
            if (!bRet)
            {
                strError = "登录失败";
                goodInfo.strFreshStatus = strError;
                return false;
            }
            goodInfo.strFreshStatus = "正在刷新...";
            ShowInfo(goodInfo);
            string strLeft = "";
            int iRet = objFresh.FreshQuick(out strError, out strLeft);
            if (iRet != 0)
            {
                goodInfo.strFreshStatus = strError;
                if (strError == "您今天的刷新次数已用完" || strError == "没有一键刷新权限")
                {
                    goodInfo.strQuickFreshTimeLeft = "0";
                }
                ShowInfo(goodInfo);
                return false;
            }
            //写入配置文件
            goodInfo.strLastFreshQuickTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //得到还有的次数显示
            goodInfo.strQuickFreshTimeLeft = strLeft;
            ShowInfo(goodInfo);
            IniUtility.WriteIniKey("set", goodInfo.strAcc + "_lastFreshTime", goodInfo.strLastFreshQuickTime);
            return true;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            GoodsFresh objFresh = new GoodsFresh();

            goodInfo.strAcc = "*****@*****.**";
            goodInfo.strPwd = "wawawo23";
            goodInfo.goodId = "2892042";
            goodInfo.skuId = "25063749";
            goodInfo.strReceiver = "陈兵";
            goodInfo.strProvince = "广东";
            goodInfo.strCity = "深圳市";
            goodInfo.strTown = "南山区";
            goodInfo.strAddr = "南油地区";
            goodInfo.strPostCode = "518052";
            goodInfo.strPhone = "13028272672";

            goodInfo.webPost = new ClassHttpPost();
            string strError = "";
            Login(goodInfo.webPost, goodInfo.strAcc, goodInfo.strPwd, ref strError, true);
            MessageBox.Show(strError);

            objFresh.m_objForm = this;
            objFresh.SetWebPost(goodInfo.webPost);
            objFresh.AddToCart(goodInfo);
            objFresh.SetTransTypeAndPayType(goodInfo);

            /*
            ClassHttpPost webpost = new ClassHttpPost();
            string strError = "";
            bool bRet = Login(webpost, "*****@*****.**", "wawawo20", ref strError);
            if (!bRet)
            {
                MessageBox.Show(strError);
                return;
            }
            GoodsFresh fresh = new GoodsFresh();
            fresh.SetWebPost(webpost);
            fresh.AddToCart(textBoxGoodId.Text, textBoxSizeNo.Text, textBoxNum.Text);
            fresh.AddAddress(out strError);
            string strOrderNo = "";
            fresh.SetTransTypeAndPayType(out strOrderNo);
            if (strOrderNo != "")
                MessageBox.Show(strOrderNo);
            */
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // _GoodsFreshStr objInfoEx = new _GoodsFreshStr();
            //objInfoEx.strAcc = "aaa";
            TestStr1 bulder = new TestStr1();
            bulder.strAcc = "AAA";
            Hashtable tblHash = new Hashtable();
            bulder.strAcc = "AAABBB";

            _GoodsFreshStr objInfoExEx = new _GoodsFreshStr();

            string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";
            SaveToExcel(strDirectoryXls, null, "aaaaa");
            return;
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);

            string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
            if (!Directory.Exists(strDirect))
            {
                Directory.CreateDirectory(strDirect);
            }

            return;
            //string str = System.Web.HttpUtility.UrlEncode("你好", Encoding.GetEncoding("gb2312"));
            string str = string.Format("{0}    {1}", 519.0, 535.01);
            MessageBox.Show(str);
            return;
            TimerFunction();
            return;
            string strAcc = "heilongjiangjt";
            _GoodsFreshStr objInfo = new _GoodsFreshStr();
            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            objInfo.iFreshCount = 2;
            //DataContrl.InitFreshTime();
            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            return;

            IsSetIllegal(); return;
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            bool bRet = DataContrl.GetDataCache("heilongjiangjt", ref goodInfo);
            if (!bRet)
            {
                return;
            }
            GoodsFresh objFresh = new GoodsFresh();
            objFresh.SetWebPost(goodInfo.webPost);
            bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd,true);
            string strError = "";
            objFresh.FreshQuick(out strError,out strError);
        }
        private bool FreshQuick(_GoodsFreshStr goodInfo, GoodsFresh objFresh)
        {
            lock (m_hLockTableEx)
            {
                //如果无货,循环检测
                while (!m_bHaveGood)
                {
                    TimeSpan tSpan = DateTime.Now - m_dateLastCheckTime;
                    if (tSpan.TotalSeconds > m_iCheckGoodInterval)
                    {
                        m_bHaveGood = IsGoodExist(goodInfo);
                        m_dateLastCheckTime = DateTime.Now;
                        if (m_bHaveGood)
                        {
                            ShowLogString("商品有货了   " + DateTime.Now.ToString());
                            break;
                        }
                        else
                        {
                            ShowLogString("商品无货 " +DateTime.Now.ToString());
                        }
                    }
                    System.Threading.Thread.Sleep(1500);
                }
            }
            string strError = "";
            goodInfo.strFreshStatus = "正在登录...";
            ShowStatusInfo(goodInfo);
            bool bRet = Login(goodInfo.webPost, goodInfo.strAcc, goodInfo.strPwd, ref strError, false);
            if (!bRet)
            {
                if (strError.IndexOf("为保证账户安全,请填写验证码") < 0)
                {
                    ShowLogString("为保证账户安全,请填写验证码");
                    goodInfo.strFreshStatus = "登录失败:" + strError;
                    ShowStatusInfo(goodInfo);
                    return false;
                }
                bRet = Login(goodInfo.webPost, goodInfo.strAcc, goodInfo.strPwd, ref strError, true);
                if (!bRet)
                {
                    goodInfo.strFreshStatus = "登录失败:" + strError;
                    ShowStatusInfo(goodInfo);
                    return false;
                }
            }
            goodInfo.strFreshStatus = "正在添加商品至购物车...";
            ShowStatusInfo(goodInfo);

            bRet = objFresh.AddToCart(goodInfo);
            if (!bRet)
            {
                goodInfo.strFreshStatus = "加入购物车失败:" + goodInfo.strFreshStatus;
                ShowStatusInfo(goodInfo);
                return false;
            }

            goodInfo.strFreshStatus = "正在设置寄送地址...";
            ShowStatusInfo(goodInfo);
            bRet = objFresh.AddAddress(goodInfo);
            if (!bRet)
            {
                goodInfo.strFreshStatus = "设置寄送地址失败:" + goodInfo.strFreshStatus;
                ShowStatusInfo(goodInfo);
            }

            goodInfo.strFreshStatus = "正在设置寄送方式、支持方式、提交定单...";
            ShowStatusInfo(goodInfo);
            bRet = objFresh.SetTransTypeAndPayType(goodInfo);
            if (!bRet)
            {
                goodInfo.strFreshStatus = "设置寄送方式、支持方式、提交定单失败:" + goodInfo.strFreshStatus;
                ShowStatusInfo(goodInfo);
            }
            return true;
        }
        private bool Fresh(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh,bool bSynFlag)
        {
            //http://m.pconline.com.cn/member/product/products_onsell.htm?&pageSize=60&pageNo=1
            goodInfo.strModifyStatus = "";
            goodInfo.bModify = false;
            string strError = "";
            if (bSynFlag)
            {
                goodInfo.strSynStatus = "登录中...";
            }
            else{
                goodInfo.strFreshStatus = "登录中...";
            }
            ShowInfo(goodInfo);
            bool bRet = false;
            #if __PAOPAO
            string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
            if (!Directory.Exists(strDirect))
            {
                Directory.CreateDirectory(strDirect);
            }
            string strFile = string.Format("{0}\\{1}.bmp", strDirect, goodInfo.strAcc);
            bRet = objFresh.GetImage(strFile, out strError);
            string strCheckCode = "";
            if (bRet)
            {
                lock(m_hLockTable)
                {
                    GetCodeHandler _myInvoke = new GetCodeHandler(GetCode);
                    strCheckCode = (string)this.Invoke(_myInvoke, new object[] { strFile });
                    if (strCheckCode.Length != 4)
                    {
                        goodInfo.strFreshStatus = "验证码错误";
                        ShowInfo(goodInfo);
                        return false;
                    }
                }
            }
            else
            {
                goodInfo.strFreshStatus = strError;
                ShowInfo(goodInfo);
                return false;
            }
            bRet = objFresh.PaoPaoLogin(goodInfo.strAcc, goodInfo.strPwd, strCheckCode, out strError);
            #else
            bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd, false);
            #endif

            if (!bRet)
            {
                //strError = "登录失败";
                if (bSynFlag)
                {
                    goodInfo.strSynStatus = strError;
                }
                else
                {
                    goodInfo.strFreshStatus = strError;
                }
                ShowLogString(strError);
                ShowInfo(goodInfo);
                return false;
            }
            int iCurPage = 1;
            int iRet = -1;
            int iFreshCount;
            int iGoodCount;
            bool bBreak = false;

            if (bSynFlag)
            {
                goodInfo.strSynStatus = "正在同步...";
            }
            else
            {
                goodInfo.strFreshStatus = "正在刷新...";
            }
            ShowInfo(goodInfo);
            Hashtable hWaitTable = new Hashtable();
            Hashtable hFailTable = new Hashtable(); //修改失败的价格列表
            Hashtable hSynTable = new Hashtable(); //同步列表
            Hashtable hSynDuplicateTable = new Hashtable(); //同步列表
            int iNetErrorCount = 0;
            while (m_bFresh && !bBreak)
            {
                if (bSynFlag)
                {
                    iRet = objFresh.Synchronize(out strError, out iFreshCount, out iGoodCount, out bBreak, iCurPage + 1, ref iNetErrorCount, ref hSynTable, ref hSynDuplicateTable);
                }
                else{
                    iRet = objFresh.Fresh(out strError, out iFreshCount, out iGoodCount, out bBreak, iCurPage + 1, false, ref hWaitTable, ref hFailTable, ref iNetErrorCount);
                }

                //成功
                if (iRet == 0)
                {
                    goodInfo.iFreshNumCount = iGoodCount;
                    if (bSynFlag)
                    {
                        goodInfo.iFreshSucNumCount = hSynTable.Count;
                        goodInfo.iSynchronizeCount = hSynTable.Count;
                    }
                    else
                        goodInfo.iFreshSucNumCount += iFreshCount;

                    if (bSynFlag)
                    {
                        goodInfo.strSynStatus = "正在同步";
                    }
                    else
                    {
                        goodInfo.strFreshStatus = "正在刷新";
                    }
                    if (bBreak)
                    {
                        if (bSynFlag)
                        {
                            goodInfo.strSynStatus = "同步完成";
                        }
                        else
                        {
                            goodInfo.strFreshStatus = "刷新完成";
                        }
                    }
                }
                else if (iRet == -1)
                {
                    goodInfo.strFreshStatus = strError;
                    goodInfo.strSynStatus = strError;
                    goodInfo.strModifyStatus = strError;
                    bRet = false;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                    break;
                }
                else
                {
                    goodInfo.strFreshStatus = strError;
                    ShowLogString(string.Format("{0} {1}",iCurPage,strError));
                }
                ShowInfo(goodInfo);
                if (iRet != -3)
                {
                    iCurPage++;
                }
                if (bBreak)
                {
                    if (bSynFlag)
                    {
                        //保存到文件
                        StringBuilder strBuilder = new StringBuilder();
                        _GoodsModifyStr objStru = new _GoodsModifyStr();

                        string[] keyArray = new string[hSynTable.Count];
                        string[] valueArray = new string[hSynTable.Count];
                        hSynTable.Keys.CopyTo(keyArray, 0);
                        int i=0;
                        foreach (string skey in keyArray)
                        {
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            valueArray[i] = objStru.strNoEx;
                            i++;
                        }
                        Array.Sort(valueArray, keyArray);
                        foreach (string skey in keyArray)
                        {
                            objStru = (_GoodsModifyStr)hSynTable[skey];
                            strBuilder.Append(string.Format("{0},{1},{2},{3},{4},{5},\r\n", objStru.strNo, objStru.strNoEx.Trim(), objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice, objStru.strName));
                        }
                        string strDirectory = System.AppDomain.CurrentDomain.BaseDirectory + "synfile";
                        string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";

                        WriteInfo(strDirectory, strBuilder, goodInfo.strAcc);
                        SaveToExcel(strDirectoryXls, hSynTable, goodInfo.strAcc);

                        if (hSynDuplicateTable.Count > 0)
                        {
                            StringBuilder strBuilderEx = new StringBuilder();

                            string[] keyArrayDup = new string[hSynDuplicateTable.Count];
                            string[] valueArrayDup = new string[hSynDuplicateTable.Count];
                            hSynTable.Keys.CopyTo(keyArrayDup, 0);
                            int ii = 0;
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];
                                valueArrayDup[ii] = objStru.strNoEx;
                                ii++;
                            }
                            Array.Sort(valueArrayDup, keyArrayDup);
                            foreach (string skey in keyArrayDup)
                            {
                                objStru = (_GoodsModifyStr)hSynDuplicateTable[skey];
                                strBuilder.Append(string.Format("{0},{1},{2},{3},{4},{5},\r\n", objStru.strNo, objStru.strNoEx.Trim(), objStru.fPrice, objStru.fLowPrice, objStru.fHighPrice, objStru.strName));
                            }

                            WriteInfo(strDirectory, strBuilderEx, goodInfo.strAcc + "_duplicate");
                            SaveToExcel(strDirectoryXls, hSynDuplicateTable, goodInfo.strAcc + "_duplicate");
                        }
                    }
                    break;
                }
                Thread.Sleep(500);
            }
            return true;
        }
        private bool Modify(ref _GoodsFreshStr goodInfo, GoodsFresh objFresh)
        {
            goodInfo.strFreshStatus = "";
            goodInfo.bModify = true;
            string strError = "";

            Hashtable hWaitTable = new Hashtable();
            Hashtable hFailTable = new Hashtable(); //修改失败的价格列表
            bool bRet = DataContrl.GetModifyData(goodInfo.strAcc, ref hWaitTable);   //得到等待刷新的商品列表
            if (!bRet)
            {
                goodInfo.strModifyStatus = "无价格刷新列表";
                ShowInfo(goodInfo);
                ShowLogString(strError);
                return true;
            }
            int iTotalCount = hWaitTable.Count;
            goodInfo.iModifyCount = iTotalCount;
            goodInfo.strModifyStatus = "登录中...";
            ShowInfo(goodInfo);

            bRet = objFresh.PaoPaoLogin(goodInfo.strAcc, goodInfo.strPwd, "", out strError,true);
            if (!bRet)
            {
                strError = "登录失败";
                goodInfo.strModifyStatus = strError;
                ShowInfo(goodInfo);
                ShowLogString(strError);
                return false;
            }
            goodInfo.strModifyStatus = "修改中...";
            ShowInfo(goodInfo);
            int iCurPage = 1;
            int iRet = -1;
            int iModifyCount = 0;
            int iGoodCount = 0;
            bool bBreak = false;

            goodInfo.strMid = strError;
            int iNetErrorCount = 0;
            while (m_bFresh && !bBreak)
            {

                iRet = objFresh.Fresh(out strError, out iModifyCount, out iGoodCount, out bBreak, iCurPage + 1, true, ref hWaitTable, ref hFailTable, ref iNetErrorCount);

                goodInfo.strModifyStatus = strError;
                //成功
                if (iRet == 0)
                {
                    goodInfo.iModifyCount = iTotalCount;
                    goodInfo.iModifySucCount += iModifyCount;
                    goodInfo.strModifyStatus = "修改中...";
                    if (bBreak)
                    {
                        goodInfo.strModifyStatus = "修改完成";
                    }
                }
                else if (iRet == -3)//网络错误
                {
                    goodInfo.strModifyStatus = strError;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                else if (iRet == -1)//数据错误,直接退出
                {
                    ShowLogString("发生数据错误,退出");
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                else
                {
                    goodInfo.strModifyStatus = strError;
                    ShowLogString(string.Format("{0} {1}", iCurPage, strError));
                }
                
                ShowInfo(goodInfo);
                if ( iRet != -3 )
                {
                    iCurPage++;
                }                
                if (bBreak)
                {                    
                    bRet = true;
                    break;
                }
                if (iRet == -1)
                {
                    bRet = false;
                    break;
                }
                Thread.Sleep(150);
            }
            //DataContrl.AddNeedAddList(goodInfo.strAcc, hFailTable);
            return bRet;
        }