/// <summary>
 /// 添加信息到缓存
 /// </summary>
 /// <param name="objUser"></param>
 public static void AddDataCache(string strFlagAcc, _GoodsFreshStr objInfo)
 {
     lock (pInfoList)
     {
         pInfoList[strFlagAcc] = objInfo;
     }
 }
 /// <summary>
 /// 添加信息到缓存
 /// </summary>
 /// <param name="objUser"></param>
 public static void AddDataCache(_GoodsFreshStr objInfo)
 {
     lock (pInfoList)
     {
         pInfoList[objInfo.strAcc] = objInfo;
     }
 }
        public bool AddAddress(_GoodsFreshStr goodInfo)
        {
            string strCheckOutUrl = "https://shopping.vancl.com/checkout";
            string strRet = m_webPost.GetHttpPage(strCheckOutUrl,
                    "utf-8", "get", "", "",
                    "http://shopping.vancl.com/mycart?showbuy=false",
                    "*/*", "");
            if (strRet.IndexOf("确认提交订单") < 0)
            {
                goodInfo.strFreshStatus = "加载定单填写页面失败";
                return false;
            }
            string strName = goodInfo.strReceiver;
            string strProvince = goodInfo.strProvince;
            string strCity = goodInfo.strCity;
            string strTown = goodInfo.strTown;
            string strAddr = goodInfo.strAddr;
            string strPostCode = goodInfo.strPostCode;
            string strMobile = goodInfo.strPhone;

            strName = HttpUtility.UrlEncode(strName, Encoding.GetEncoding("UTF-8"));

            strProvince = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strProvince, Encoding.GetEncoding("UTF-8")) );
            strCity = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strCity, Encoding.GetEncoding("UTF-8")) );
            strTown = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strTown, Encoding.GetEncoding("UTF-8")) );
            strAddr = HttpUtility.UrlEncode(strAddr, Encoding.GetEncoding("UTF-8"));
            string strAddrData = string.Format("model.FullName={0}&model.Province={1}&model.City={2}&model.Area={3}&model.Address={4}&model.PostalCode={5}&model.MobilePhone={6}&model.Phone=&model.AddressId=0",
                strName,
                strProvince,
                strCity,
                strTown,
                strAddr,
                strPostCode,
                strMobile);
            string strAddrUrl = "https://shopping.vancl.com/checkout/saveinlandaddress";
            strRet = m_webPost.GetHttpPage(strAddrUrl,
                    "utf-8", "post", "", strAddrData,
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("收货地址:") < 0)
            {
                goodInfo.strFreshStatus = "设置收货地址出错";
                return false;
            }
            return true;
        }
        public bool AddAddress(_GoodsFreshStr goodInfo)
        {
            string strCheckOutUrl = "https://www.vjia.com/shopping/shopping_confirm.aspx";
            string strRet = m_webPost.GetHttpPage(strCheckOutUrl,
                    "utf-8", "get", "", "",
                    "",
                    "*/*", "");
            if (strRet.IndexOf("确认订单信息") < 0)
            {
                goodInfo.strFreshStatus = "加载定单填写页面失败";
                return false;
            }
            string strName = goodInfo.strReceiver;
            string strProvince = goodInfo.strProvince;
            string strCity = goodInfo.strCity;
            string strTown = goodInfo.strTown;
            string strAddr = goodInfo.strAddr;
            string strPostCode = goodInfo.strPostCode;
            string strMobile = goodInfo.strPhone;

            strName = HttpUtility.UrlEncode(strName, Encoding.GetEncoding("UTF-8"));

            strProvince = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strProvince, Encoding.GetEncoding("UTF-8")) );
            strCity = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strCity, Encoding.GetEncoding("UTF-8")) );
            strTown = HttpUtility.UrlEncode( HttpUtility.UrlEncode(strTown, Encoding.GetEncoding("UTF-8")) );
            strAddr = HttpUtility.UrlEncode(strAddr, Encoding.GetEncoding("UTF-8"));
            string strAddrData = string.Format("cmd=addorupdateaddresseeinfo&addresseeid=0&addresseename={0}&province={1}&city={2}&area={3}&address={4}&postalcode={5}&mobilephone={6}&phone=",
                strName,
                strProvince,
                strCity,
                strTown,
                strAddr,
                strPostCode,
                strMobile);
            string strAddrUrl = "https://www.vjia.com/shopping/process/order.ashx";
            strRet = m_webPost.GetHttpPage(strAddrUrl,
                    "utf-8", "post", "", strAddrData,
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("\"Step\"") < 0)
            {
                goodInfo.strFreshStatus = "设置收货地址出错";
                return false;
            }
            return true;
        }
        private void ModifyViewItem(_GoodsFreshStr goodInfo)
        {
            for (int i = 0; i < listView.Items.Count;i++ )
            {
                if (listView.Items[i].SubItems[1].Text.ToString() == goodInfo.strAcc)
                {
                    if (goodInfo.strSynStatus != "")
                    {
                        listView.Items[i].SubItems[8].Text = goodInfo.strSynStatus;
                    }
                    if (goodInfo.iNeedAddCount > 0)
                    {
                        listView.Items[i].BackColor = Color.FromArgb(100, 200, 100, 50);
                    }
                    else if (goodInfo.iSynchronizeCount < 1)
                    {
                        listView.Items[i].BackColor = Color.FromArgb(100, 200, 0, 0);
                    }
            //                     Hashtable hTable = new Hashtable();
            //                     bool bRet = DataContrl.GetNeedAddData(goodInfo.strAcc, ref hTable);
            //                     if (bRet)
            //                     {
            //                         goodInfo.iNeedAddCount = hTable.Count;
            //                     }
                    if (goodInfo.bModify)
                    {
                        listView.Items[i].SubItems[5].Text = string.Format("{0}/{1}/{2}/{3}",goodInfo.iNeedAddCount, goodInfo.iModifySucCount, goodInfo.iModifyCount,goodInfo.iSynchronizeCount);
                        listView.Items[i].SubItems[7].Text = goodInfo.strModifyStatus;
                    }
                    else
                    {
                        listView.Items[i].SubItems[3].Text = string.Format("{0}/{1}/{2}", goodInfo.iFreshSucCount, goodInfo.iFreshFailCount, goodInfo.iFreshCount);
                        listView.Items[i].SubItems[4].Text = string.Format("{0}/{1}", goodInfo.iFreshSucNumCount, goodInfo.iFreshNumCount);
                        listView.Items[i].SubItems[6].Text = goodInfo.strFreshStatus;
                    }

                    //strLastFreshQuickTime
                    //int idd = listView.Items[i].SubItems.Count;

                    if (!string.IsNullOrEmpty(goodInfo.strQuickFreshTimeLeft) && !string.IsNullOrEmpty(goodInfo.strLastFreshQuickTime))
                    {
                        listView.Items[i].SubItems[9].Text = goodInfo.strQuickFreshTimeLeft + "/" + goodInfo.strLastFreshQuickTime;
                    }

                    break;
                }
            }
        }
Beispiel #6
0
        public bool SubmitOrder(_GoodsFreshStr goodInfo, string strCheckCode)
        {
            string strCheckOutUrl = "https://www.vjia.com/shopping/shopping_confirm.aspx";
            string strData        = "";

            //payment=29&InvoiceTitle=&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true
            //payment=29&radioInvoice=yes&InvoiceTitle=%E7%94%9F%E6%B4%BB%E7%94%A8%E5%93%81&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true
            strData = "payment=29&radioInvoice=yes&InvoiceTitle=%E7%94%9F%E6%B4%BB%E7%94%A8%E5%93%81&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true";
            if (strCheckCode != "")
            {
                strData += string.Format("&verifycode={0}", strCheckCode);
            }

            string strSubmitUrl = "https://www.vjia.com/shopping/Shopping_Complete.aspx";
            string strRet       = m_webPost.GetHttpPage(strSubmitUrl,
                                                        "utf-8", "post", "", strData,
                                                        strCheckOutUrl,
                                                        "*/*", "");

            /*
             * <span>   <label class="error">请输入验证码</label></span>
             *      <span>  <a id="verify-code-link">换一题</a> </span>
             *      <span>  <input type="text" id="verify-code-txt" name="verifycode" />  </span>
             *      <span>  <img id="verify-code-img" alt="" src="/VerifyingCode.ashx?380"/> </span>
             *      <span id="verify-code" data-valid-error="答案错误,请重新输入"> </span>
             *      <span id="verify-code-tip">验证码:</span>
             */
            strRet = strRet.ToLower();
            string strFlag  = "请输入验证码";
            string strFlag1 = "<img id=\"verify-code-img\"";

            if (strRet.IndexOf(strFlag) > 0 && strRet.IndexOf(strFlag1) > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf(strFlag1));
                string strCheckCodeUrl = "https://shopping.vancl.com" + GetKeyString(strRet, "src=\"", "\"");
                m_objForm.GetCheckCode(m_webPost, "", out goodInfo.strFreshStatus, out strCheckCode, strCheckCodeUrl, strCheckOutUrl);
                goodInfo.iFreshNumCount++;
                if (goodInfo.iFreshNumCount > 3)
                {
                    return(false);
                }
                return(SubmitOrder(goodInfo, strCheckCode));
            }

            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return(false);
            }
            else if (strRet.IndexOf("订单已提交成功") < 0)
            {
                goodInfo.strFreshStatus = "提交订单出错,可能提交订单太频繁,需要验证码,【不要同时使用多个软件,用同样的账号】,也可以考虑在失败后换IP";
                return(false);
            }
            strRet = strRet.Substring(strRet.IndexOf("订单已提交成功"));
            strRet = strRet.Substring(strRet.IndexOf("tbody"));
            goodInfo.strOrderID     = GetKeyString(strRet, "<td>", "</td>");
            goodInfo.strFreshStatus = "下单成功:" + goodInfo.strOrderID;
            return(true);
        }
 public static bool GetDataCache(string strAcc, ref _GoodsFreshStr objInfo)
 {
     bool bExist = false;
     lock (pInfoList)
     {
         bExist = pInfoList.ContainsKey(strAcc);
         if (bExist)
         {
             objInfo = pInfoList[strAcc];
         }
     }
     return bExist;
 }
 public bool GetOrderTrackInfo(_GoodsFreshStr goodInfo, string strUrl)
 {
     string strRet = goodInfo.webPost.GetHttpPage(strUrl,
             "utf-8", "get", "", "",
             "",
             "*/*", "");
     int iIndex = strRet.IndexOf("id=\"ordertrack\"");
     if (iIndex < 0)
         return false;
     string strContent = GetKeyString(strRet, "<tr><td>", "</table>");
     strContent = strContent.Replace("</td></tr>", "\r\n");
     strContent = strContent.Replace("<tr><td>", "");
     strContent = strContent.Replace("</td><td>", "    ");
     goodInfo.strOrderDetail = strContent;
     AddGotOrder(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 void btnImportGoodFile_Click(object sender, EventArgs e)
        {
            int iCount = DataContrl.GetModifyCount();
            if (iCount > 0 && m_bIsStartFresh)
            {
                MessageBox.Show("正在修改中,请等待修改完后再执行此操作!");
                return;
            }
            //选择文件夹
            FolderBrowserDialog find = new FolderBrowserDialog();
            if (find.ShowDialog() != DialogResult.OK)
            {
                return;
            }

               DataContrl.ClearModifyData();
               DirectoryInfo dInfo = new DirectoryInfo(find.SelectedPath);

               foreach (FileInfo fileInfo in dInfo.GetFiles())
               {
               Hashtable hTable = new Hashtable();
               hTable.Clear();
               string strName = fileInfo.Name;
               string[] strNameArray = strName.Split('.');
               if (strNameArray.Length != 2)
               {
                   ShowLogString("文件名不合法:" + strName);
                   continue;
               }
            //                if (strNameArray[1] != "txt")    //不是文本文档
            //                {
            //                    continue;
            //                }

               if (strNameArray[1] != "xls")    //不是文本文档
               {
                   ShowLogString("文件名不合法:" + strName);
                   continue;
               }

               string strAcc = strNameArray[0];  //以账号名为商品对应的账号
               if (!DataContrl.IsInCache(strAcc))//如果此账号不存在
               {
                   ShowLogString("此账号不存在:" + strAcc);
                   continue;
               }

               //得到账号名后,判断是否已经对此账号进行过同步
               _GoodsFreshStr goodInfo = new _GoodsFreshStr();
               if (!DataContrl.GetDataCache(strAcc, ref goodInfo))
               {
                   ShowLogString("此账号不存在:" + strAcc);
                   continue;
               }
               if (goodInfo.iSynchronizeCount < 1)
               {
                   goodInfo.strSynStatus = "尚未同步,要修改价格请先同步";
                   goodInfo.strModifyStatus = "尚未同步,要修改价格请先同步";
                   ShowInfo(goodInfo);
                   ShowLogString("尚未同步,要修改价格请先同步");
                   continue;
               }
               goodInfo.iNeedAddCount = 0;
               string strContent = ReadFileLineXls(find.SelectedPath + "\\" + strName);
               string[] strArray = strContent.Split('\n');

               float fPrice = 0;
               Hashtable hTableSyn = new Hashtable();
               Hashtable hTableSynNumber = new Hashtable();
               Hashtable hTableNeedAdd = new Hashtable();
               bool bRet = DataContrl.GetSynData(strAcc, ref hTableSyn);

               if (!bRet)
               {
                   goodInfo.strModifyStatus = "获取同步商品信息失败";
                   ShowInfo(goodInfo);
                   ShowLogString("获取同步商品信息失败");
                   continue;
               }
               foreach (string strLine in strArray)
               {
                   //品牌+型号,商品价格

                   string[] strInfo = strLine.Split(',');
                   if (strInfo.Length < 2)
                   {
                       ShowLogString("导入文件内容格式错误");
                       continue;
                   }
                   string strGoodNoEx = strInfo[0].Trim();
                   strGoodNoEx = strGoodNoEx.Trim();
                   if (strGoodNoEx.Length < 1)
                   {
                       ShowLogString("导入文件内容格式错误");
                       continue;
                   }
                   string strNoList = DataContrl.GetSynNumberData(goodInfo.strAcc + strGoodNoEx).Trim();
                   if (strNoList == "")
                   {
                       float.TryParse(strInfo[1], out fPrice);
                       _GoodsModifyStr goodModify = new _GoodsModifyStr();
                       goodModify.strNo = strGoodNoEx;
                       goodModify.strNoEx = strGoodNoEx;
                       goodModify.fPrice = fPrice;
                       //加入需要添加的列表
                       if (!hTableNeedAdd.ContainsKey(strGoodNoEx))
                       {
                           hTableNeedAdd.Add(strGoodNoEx, goodModify);
                       }
                       //ShowLogString("未找到匹配的同步信息");
                       continue;
                   }
                   string[] strNolistArray = strNoList.Split(',');

                   //当等待修改的商品名称在同步列表中时,才添加
                   foreach (string strNo in strNolistArray)
                   {
                       if (strNo == "")
                       {
                           continue;
                       }
                       if (hTable.Contains(strNo))
                       {
                           continue;
                       }
                       float.TryParse(strInfo[1], out fPrice);
                       _GoodsModifyStr goodModify = new _GoodsModifyStr();
                       _GoodsModifyStr goodModifySyn = new _GoodsModifyStr();
                       if (hTableSyn.ContainsKey(strNo))
                       {
                           goodModifySyn = (_GoodsModifyStr)hTableSyn[strNo];
                           goodModify.strNo = goodModifySyn.strNo;
                           goodModify.strNoEx = goodModifySyn.strNoEx;
                           goodModify.strName = goodModifySyn.strName;
                           goodModify.fLowPrice = goodModifySyn.fLowPrice;
                           goodModify.fHighPrice = goodModifySyn.fHighPrice;

                           goodModify.fPrice = fPrice;
                           if (goodModify.fPrice < goodModify.fLowPrice)
                           {
                               goodModify.fPrice = goodModify.fLowPrice;
                           }
                           else if (goodModify.fPrice > goodModify.fHighPrice)
                           {
                               goodModify.fPrice = goodModify.fHighPrice;
                           }
                           hTable.Add(strNo, goodModify);
                       }
                       else
                       {
                           //此处还少商品名
                           goodModify.strNo = strGoodNoEx;
                           goodModify.strNoEx = strGoodNoEx;
                           goodModify.fPrice = fPrice;
                           //加入需要添加的列表
                           if (!hTableNeedAdd.ContainsKey(strNo))
                           {
                               hTableNeedAdd.Add(strNo, goodModify);
                           }
                       }
                   }
               }
               DataContrl.AddNeedAddList(strAcc, hTableNeedAdd);
               goodInfo.iNeedAddCount = hTableNeedAdd.Count;
               goodInfo.iModifyCount = hTable.Count;
               goodInfo.strModifyStatus = "等待修改";
               goodInfo.bModify = true;
               ShowInfo(goodInfo);
               DataContrl.AddModifyList(strAcc, hTable);
               ShowLogString(string.Format("{0} 添加了 {1} 条价格修改信息", strAcc, hTable.Count));
            }
        }
 private void AddToList(_GoodsFreshStr goodInfo)
 {
     ModifyViewItem(goodInfo);
 }
        public bool GetOrderDetailInfo(_GoodsFreshStr goodInfo, string strContent)
        {
            try
            {
                strContent = strContent.Replace("\r", "");
                strContent = strContent.Replace("\n", "");
                strContent = strContent.Replace("\r\n", "");
                Match match = Regex.Match(strContent, "<dd class=\"widdent_w(.+?)</dd>");

                int match_num = 0;		//总共匹配到的数量
                string matchValue = "";
                int nIndex = 0;
                while (match.Success)
                {
                    matchValue = match.Groups[1].Value.ToLower();
                    nIndex++;
                    if (nIndex == 1)
                    {
                        //class="product_id"
                        goodInfo.strOrderID = GetKeyString(matchValue, "product_id\"", "<");
                        goodInfo.strOrderID = goodInfo.strOrderID.Replace(">", "").Trim();
                    }
                    if (nIndex == 2)
                    {

                        goodInfo.strAddr = GetKeyString(matchValue, "class=\"popupbod_cen\">", "</div>");
                        goodInfo.strAddr = goodInfo.strAddr.Trim().Replace("<br />", "\r\n").Replace(" ", "");
                    }
                    if (nIndex == 3)
                    {
                        goodInfo.strOrderStatus = GetKeyString(matchValue, "<span>", "</span>");
                        //OrderTrackLine('212092635851','trackDiv','上海','6')"
                        string strTemp = GetKeyString(matchValue, "ordertrackline(", ")\">");
                        strTemp = strTemp.Replace("'", "");
                        string[] strArray = strTemp.Split(',');
                        if (strArray.Length == 4)
                        {
                            string strProvince = Escape(strArray[2]);
                            string strDetailUrl = string.Format("http://my.vancl.com/Order/OrderTrackLine/{0}?province={1}&status={2}&_={3}", goodInfo.strOrderID, strProvince, strArray[3], DateTime.Now.ToFileTime());
                            GetOrderTrackInfo(goodInfo, strDetailUrl);
                        }
                    }
                    if (nIndex == 4)
                    {
                    }
                    match = match.NextMatch();
                }
                return true;
            }
            catch (System.Exception ex)
            {

            }
            return false;
        }
        public bool AddToCartEx(_GoodsFreshStr goodInfo, string strGoodId, string strSkuId, bool bFirst)
        {
            /*

            string strRet = m_webPost.GetHttpPage(strGoodUrl,
                   "utf-8", "get", "", "",
                   "",
                   "", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet == "")
            {
                goodInfo.strFreshStatus = "加载商品页面出错";
                return false;
            }

            strRet = strRet.ToLower();
            if (bFirst)
                goodInfo.strGoodName = GetKeyString(strRet, "<title>", "</title>");//<title>流金幻彩松紧女短靴 咖啡色 - 鞋 女鞋 靴子 时尚女靴 - VANCL 凡客诚品</title>
            */
            string strGoodUrl = string.Format("http://item.vjia.com/{0}.html", strGoodId);
            string strPrice = "2.00";
            string strAddtoCartUrl = string.Format("http://www.vjia.com/Shopping/Process/AddProduct.ashx?addType=single&amount=1&skuId={0}&callback=jsonp1352295903572&ref=",
                strSkuId,
                strPrice,
                goodInfo.strNum,
                DateTime.Now.ToFileTime());
               string strRet = m_webPost.GetHttpPage(strAddtoCartUrl,
                    "utf-8", "get", "", "",
                    strGoodUrl,
                    "*/*", "");
            strRet = strRet.ToLower();

            if (strRet.IndexOf("出错了") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("\"出错了"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "content\":\"", "\"");
                return false;
            }
            else if (strRet.IndexOf("\"totalprice\"") < 0)
            {
                goodInfo.strFreshStatus = "加入购物车出错";
                return false;
            }
            return true;
        }
        private void btnImportAcc_Click(object sender, EventArgs e)
        {
            string strPath = "";
            OpenFileDialog find = new OpenFileDialog();
            find.Filter = "TXT文件(*.txt)|*.txt";

            if (find.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DataContrl.DeleteAllAccount();
            listView.Items.Clear();

            strPath = find.FileName;
            string strContent = ReadFileLine(strPath);
            string[] strArray = strContent.Split('\n');
            int nCount = 0;
            foreach (string strLine in strArray)
            {
                //userid|pwd|goodid|skuid|num|name|phone|postcode|province|city|town|addr
                string[] strInfo = strLine.Split('|');
                if (strInfo.Length < 3)
                {
                    continue;
                }
                if (DataContrl.IsInCache(strInfo[0]))
                {
                    continue;
                }
                if (strInfo[0].Length < 1 || strInfo[1].Length < 1)
                {
                    continue;
                }
                _GoodsFreshStr GoodInfo = new _GoodsFreshStr();
                GoodInfo.strAcc = strInfo[0];
                GoodInfo.strPwd = strInfo[1];
                GoodInfo.strNewPwd = strInfo[2];
                GoodInfo.strSynStatus = "初始状态";
                GoodInfo.webPost = new ClassHttpPost();
                string strFlagAcc = string.Format("{0}_{1}", GoodInfo.strAcc, nCount);
                nCount++;
                DataContrl.AddDataCache(GoodInfo.strAcc, GoodInfo);
            }
            ShowLogString(string.Format("共导入{0}个账号", DataContrl.GetAccCount()));
            DataContrl.InitFreshAccount();
        }
        private void AddViewItem(_GoodsFreshStr goodInfo)
        {
            if (goodInfo.bModify)
            {
                goodInfo.listItem.SubItems[2].Text = goodInfo.strFreshStatus;
                return;
            }

            ListViewItem li = new ListViewItem();
            li.SubItems.Clear();
            li.SubItems[0].Text = "";

            if (goodInfo.bShowAcc)
            {
                li.SubItems[0].Text = listView.Items.Count.ToString();
                li.SubItems.Add(goodInfo.strAcc);
                li.SubItems.Add(goodInfo.strFreshStatus);
                li.SubItems.Add("");
                li.SubItems.Add("");
                li.SubItems.Add("");
                li.SubItems.Add("");
                listView.Items.Add(li);
                goodInfo.listItem = li;
            }
            else
            {
                goodInfo.nAddCount++;
                li.SubItems.Add("");
                li.SubItems.Add("");
                li.SubItems.Add(goodInfo.strOrderID);
                li.SubItems.Add(goodInfo.strOrderStatus);
                li.SubItems.Add(goodInfo.strOrderDetail);
                li.SubItems.Add(goodInfo.strAddr);
                int iIndex = listView.Items.IndexOf(goodInfo.listItem) + goodInfo.nAddCount;
                if(iIndex > listView.Items.Count)
                    iIndex = listView.Items.IndexOf(goodInfo.listItem) + 1;
                listView.Items.Insert(iIndex, li);

                WriteLogOrder(string.Format("{0}    {1}    {2}    {3}    {4}     ", goodInfo.strAcc,
                goodInfo.strOrderID, goodInfo.strOrderStatus, goodInfo.strOrderDetail, goodInfo.strAddr));
            }
        }
 private void AddGotOrder(_GoodsFreshStr goodInfo)
 {
     goodInfo.bShowAcc = false;
     goodInfo.bModify = false;
     ShowStatusInfo(goodInfo);
 }
 private void TimerFunction()
 {
     //判断是否到了刷新时间段
     if (!IsInFreshduration())
     {
         m_bIsInFreshduration = false;
         return;
     }
     if (m_bIsInFreshduration == false)
     {
         ShowLogString(string.Format("首次进入当日的刷新时间段,初始化数据"));
         //刚进入时间段,需要初始化次数
         m_iHaveFreshedTime = 0;
         DataContrl.InitFreshTime(m_iRefreshTime);
         //ShowInfo
         string[] strArray = DataContrl.GetAllAccount().Split(',');
         _GoodsFreshStr goodInfo = new _GoodsFreshStr();
         foreach (string strAcc in strArray)
         {
             if (strAcc == "")
             {
                 break;
             }
             bool bRet = DataContrl.GetDataCache(strAcc, ref goodInfo);
             if (bRet)
             {
                 ShowInfo(goodInfo);
             }
         }
     }
     m_bIsInFreshduration = true;
     if (m_iHaveFreshedTime >= m_iRefreshTime)
     {
         ShowLogString(string.Format("已经达到设定的当日刷新次数"));
         return;
     }
     //判断是否超过了刷新间隔
     TimeSpan tSpan = DateTime.Now - m_dLastFreshTime;
     int i = (int)tSpan.TotalMinutes;
     if (i < m_iRefreshInterval * 60)   //未到刷新间隔
     {
         return;
     }
     m_dLastFreshTime = DateTime.Now;
     //将列表中的所有账号加入等待刷新队列
     DataContrl.InitFreshAccount();
     m_iHaveFreshedTime++;
     ShowLogString(string.Format("达到刷新间隔时间,初始化刷新账号队列,刷新类型:{0}",m_iFreshType==0?"一键刷新":"自定义刷新"));
 }
        public bool SetTransTypeAndPayType(_GoodsFreshStr goodInfo)
        {
            string strCheckOutUrl = "https://www.vjia.com/shopping/shopping_confirm.aspx";
            string strDeleverUrl = "https://www.vjia.com/shopping/process/order.ashx";

            string strData = "cmd=settransfer&transferid=01&transfertimeid=0&istransferloadorder=false";
            string strRet = m_webPost.GetHttpPage(strDeleverUrl,
                    "utf-8", "post", "", strData,
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("\"Step\":2") < 0)
            {
                goodInfo.strFreshStatus = "设置寄送方式出错";
                return false;
            }

            strData = "cmd=setpayment&cashondelivertypeid=0&kqbankid=&paymenttypeid=29";
            string strPayTypeUrl = "https://www.vjia.com/shopping/process/order.ashx";
            strRet = m_webPost.GetHttpPage(strPayTypeUrl,
                    "utf-8", "post", "", strData,
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("\"Step\":3") < 0)
            {
                goodInfo.strFreshStatus = "设置支付方式出错";
                return false;
            }
            goodInfo.iFreshNumCount = 0;
            return SubmitOrder(goodInfo, "");
        }
 public void ShowInfo(_GoodsFreshStr goodInfo)
 {
     try
     {
         if (listView.InvokeRequired)
         {
             ShowEventHandler _myInvoke = new ShowEventHandler(AddToList);
             this.Invoke(_myInvoke, new object[] { goodInfo });
         }
         else
         {
             AddToList(goodInfo);
         }
     }
     catch(Exception e)
     {
         string strError = e.Message;
     }
 }
        public bool SubmitOrder(_GoodsFreshStr goodInfo, string strCheckCode)
        {
            string strCheckOutUrl = "https://www.vjia.com/shopping/shopping_confirm.aspx";
            string strData = "";

            //payment=29&InvoiceTitle=&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true
            //payment=29&radioInvoice=yes&InvoiceTitle=%E7%94%9F%E6%B4%BB%E7%94%A8%E5%93%81&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true
            strData = "payment=29&radioInvoice=yes&InvoiceTitle=%E7%94%9F%E6%B4%BB%E7%94%A8%E5%93%81&InvoiceType=%E6%98%8E%E7%BB%86&textComment=%E5%A3%B0%E6%98%8E%EF%BC%9A%E5%A4%87%E6%B3%A8%E4%B8%AD%E6%9C%89%E5%85%B3%E9%85%8D%E9%80%81%E5%9C%B0%E5%9D%80%E3%80%81%E9%85%8D%E9%80%81%E6%96%B9%E5%BC%8F%E3%80%81%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%E3%80%81%E5%8F%91%E7%A5%A8%E4%BF%A1%E6%81%AF%E7%AD%89%E8%B4%AD%E4%B9%B0%E8%A6%81%E6%B1%82%E4%B8%80%E5%BE%8B%E4%BB%A5%E4%B8%8A%E9%9D%A2%E7%9A%84%E9%80%89%E6%8B%A9%E4%B8%BA%E5%87%86%EF%BC%8C%E5%A4%87%E6%B3%A8%E6%97%A0%E6%95%88%E3%80%82&Action_Step_5=true";
            if (strCheckCode != "")
                strData += string.Format("&verifycode={0}", strCheckCode);

            string strSubmitUrl = "https://www.vjia.com/shopping/Shopping_Complete.aspx";
            string strRet = m_webPost.GetHttpPage(strSubmitUrl,
                    "utf-8", "post", "", strData,
                    strCheckOutUrl,
                    "*/*", "");

            /*
             <span>   <label class="error">请输入验证码</label></span>
                    <span>  <a id="verify-code-link">换一题</a> </span>
                    <span>  <input type="text" id="verify-code-txt" name="verifycode" />  </span>
                    <span>  <img id="verify-code-img" alt="" src="/VerifyingCode.ashx?380"/> </span>
                    <span id="verify-code" data-valid-error="答案错误,请重新输入"> </span>
                    <span id="verify-code-tip">验证码:</span>
             */
            strRet = strRet.ToLower();
            string strFlag = "请输入验证码";
            string strFlag1 = "<img id=\"verify-code-img\"";
            if (strRet.IndexOf(strFlag) > 0 && strRet.IndexOf(strFlag1) > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf(strFlag1));
                string strCheckCodeUrl = "https://shopping.vancl.com" + GetKeyString(strRet, "src=\"", "\"");
                m_objForm.GetCheckCode(m_webPost, "", out goodInfo.strFreshStatus, out strCheckCode, strCheckCodeUrl, strCheckOutUrl);
                goodInfo.iFreshNumCount++;
                if (goodInfo.iFreshNumCount > 3)
                    return false;
                return SubmitOrder(goodInfo, strCheckCode);
            }

            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("订单已提交成功") < 0)
            {
                goodInfo.strFreshStatus = "提交订单出错,可能提交订单太频繁,需要验证码,【不要同时使用多个软件,用同样的账号】,也可以考虑在失败后换IP";
                return false;
            }
            strRet = strRet.Substring(strRet.IndexOf("订单已提交成功"));
            strRet = strRet.Substring(strRet.IndexOf("tbody"));
            goodInfo.strOrderID = GetKeyString(strRet, "<td>", "</td>");
            goodInfo.strFreshStatus = "下单成功:" + goodInfo.strOrderID;
            return true;
        }
        private void btnImportAcc_Click(object sender, EventArgs e)
        {
            string strPath = "";
            OpenFileDialog find = new OpenFileDialog();
            find.Filter = "TXT文件(*.txt)|*.txt";

            if (find.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            strPath = find.FileName;
            string strContent = ReadFileLine(strPath);
            string[] strArray = strContent.Split('\n');
            foreach (string strLine in strArray)
            {
                //解析帐号密码
                string[] strInfo = strLine.Split(',');
                if (strInfo.Length < 2)
                {
                    continue;
                }
                if (DataContrl.IsInCache(strInfo[0]))
                {
                    continue;
                }
                if (strInfo[0].Length < 1 || strInfo[1].Length < 1)
                {
                    continue;
                }
                _GoodsFreshStr GoodInfo = new _GoodsFreshStr();
                GoodInfo.strAcc = strInfo[0];
                GoodInfo.strPwd = strInfo[1];
                GoodInfo.webPost = new ClassHttpPost();
                GoodInfo.iFreshCount = 0;
                GoodInfo.iFreshSucCount = 0;
                GoodInfo.iFreshFailCount = 0;
                ShowLogString(string.Format("正在加载 {0} 的商品同步信息", GoodInfo.strAcc));
                //此处需要添加已经同步好的文本文档,以便添加修改文件时对比,得出需要添加的商品
                string strSynPath = System.AppDomain.CurrentDomain.BaseDirectory + "synfile\\" + GoodInfo.strAcc + ".txt";
                if (!File.Exists(strSynPath))
                {
                    GoodInfo.iSynchronizeCount = 0;
                    GoodInfo.strSynStatus = "未找到同步信息文件";
                    ShowLogString(GoodInfo.strSynStatus);
                }
                else
                {
                    //加载同步信息
                    string strInfoEx = ReadFileLine(strSynPath);
                    string[] strArrayEx = strInfoEx.Split('\n');
                    Hashtable hSynTable = new Hashtable();
                    Hashtable hNoList = new Hashtable();
                    foreach (string strGoodInfo in strArrayEx)
                    {
                        string[] strSynInfo = strGoodInfo.Split(',');
                        if (strSynInfo.Length < 7)
                        {
                            continue;
                        }
                        _GoodsModifyStr goodModify = new _GoodsModifyStr();
                        goodModify.strNo = strSynInfo[0];
                        goodModify.strNoEx = strSynInfo[1];
                        goodModify.strName = "";
                        float.TryParse(strSynInfo[2], out goodModify.fPrice);
                        float.TryParse(strSynInfo[3], out goodModify.fLowPrice);
                        float.TryParse(strSynInfo[4], out goodModify.fHighPrice);
                        if (strSynInfo.Length > 7)
                        {
                            for (int i = 5; i < strSynInfo.Length - 2;i++ )
                            {
                                goodModify.strName += strSynInfo[i];
                            }
                        }
                        else{
                            goodModify.strName = strSynInfo[5];
                        }
                        if (hNoList.ContainsKey(goodModify.strNoEx))
                        {
                            hNoList[goodModify.strNoEx] = (string)hNoList[goodModify.strNoEx] + "," + goodModify.strNo;
                        }
                        else{
                            hNoList[goodModify.strNoEx] = goodModify.strNo;
                        }
                        hSynTable.Add(goodModify.strNo, goodModify);
                    }

                    foreach (DictionaryEntry dEntry in hNoList)
                    {
                        DataContrl.AddSynNumberList(GoodInfo.strAcc + (string)dEntry.Key, (string)dEntry.Value);
                    }
                    GoodInfo.iSynchronizeCount = hSynTable.Count;
                    DataContrl.AddSynList(GoodInfo.strAcc, hSynTable);
                    ShowLogString(string.Format("导入同步信息 {0} 条", hSynTable.Count));
                }

                DataContrl.AddDataCache(GoodInfo);
                AddViewItem(GoodInfo.strAcc, GoodInfo.strPwd);
                GoodInfo.bModify = true;
                //导入上次一键刷新的时间
                GoodInfo.strQuickFreshTimeLeft = "未知";
                GoodInfo.strLastFreshQuickTime = IniUtility.GetIniKeyValue("set", GoodInfo.strAcc+"_lastFreshTime", "");
                if (GoodInfo.strLastFreshQuickTime=="")
                {
                    GoodInfo.strLastFreshQuickTime = "未刷新过";
                }
                if (GoodInfo.iSynchronizeCount < 1)
                {
                    GoodInfo.strSynStatus = "尚未同步";
                }
                ShowInfo(GoodInfo);
            }
        }
        public bool ModifyPwd(_GoodsFreshStr goodInfo)
        {
            string strCheckCode = "";
            string strReffer = "https://my.vancl.com/user/EditPassword2";
            string strCheckCodeUrl = string.Format("https://my.vancl.com/ImgCode/GetImg?type=1&x=0.{0}", DateTime.Now.ToFileTime());
            if (!m_objForm.GetCheckCode(m_webPost, "", out goodInfo.strFreshStatus, out strCheckCode, strCheckCodeUrl, strReffer))
            {
                goodInfo.strFreshStatus = "修改密码失败: 获取验证码失败:" + goodInfo.strFreshStatus;
                return false;
            }
            string strData = string.Format("PassWord={0}&RePassWord1={1}&RePassWord2={1}&code={2}", goodInfo.strPwd, goodInfo.strNewPwd, strCheckCode);

            string strPostUrl = "https://my.vancl.com/User/EditPassword";
            string strRet = m_webPost.GetHttpPage(strPostUrl,
                    "utf-8", "POST", "", strData,
                    strReffer,
                    "*/*", "");
            if (strRet == "\"4\"")
            {
                return true;
            }
            if (strRet.Length > 3)
                strRet = strRet.Substring(0, 3);
            goodInfo.strFreshStatus = "修改密码失败:" + strRet;
            return false;
        }
        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);
        }
        public bool SubmitOrder(_GoodsFreshStr goodInfo, string strCheckCode)
        {
            string strCheckOutUrl = "https://shopping.vancl.com/checkout";
            string strData = "";
            strData = "comments=&requireInvoice=true&InvoiceCustom=Personal&invoicetitle=%E4%B8%AA%E4%BA%BA&InvoiceContent=Details&InvoiceTaxNo=&requireedm=true";
            if (strCheckCode != "")
                strData += string.Format("&verifycode={0}", strCheckCode);

            string strSubmitUrl = "https://shopping.vancl.com/checkout/save";
            string strRet = m_webPost.GetHttpPage(strSubmitUrl,
                    "utf-8", "post", "", strData,
                    strCheckOutUrl,
                    "*/*", "");

            /*
             <span>   <label class="error">请输入验证码</label></span>
                    <span>  <a id="verify-code-link">换一题</a> </span>
                    <span>  <input type="text" id="verify-code-txt" name="verifycode" />  </span>
                    <span>  <img id="verify-code-img" alt="" src="/VerifyingCode.ashx?380"/> </span>
                    <span id="verify-code" data-valid-error="答案错误,请重新输入"> </span>
                    <span id="verify-code-tip">验证码:</span>
             */
            strRet = strRet.ToLower();
            string strFlag = "请输入验证码";
            string strFlag1 = "<img id=\"verify-code-img\"";
            if (strRet.IndexOf(strFlag) > 0 && strRet.IndexOf(strFlag1) > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf(strFlag1));
                string strCheckCodeUrl = "https://shopping.vancl.com" + GetKeyString(strRet, "src=\"", "\"");
                m_objForm.GetCheckCode(m_webPost, "", out goodInfo.strFreshStatus, out strCheckCode, strCheckCodeUrl, strCheckOutUrl);
                goodInfo.iFreshNumCount++;
                if (goodInfo.iFreshNumCount > 3)
                    return false;
                return SubmitOrder(goodInfo, strCheckCode);
            }

            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("订单已提交成功") < 0)
            {
                goodInfo.strFreshStatus = "提交订单出错,可能提交订单太频繁,需要验证码,【不要同时使用多个软件,用同样的账号】,也可以考虑在失败后换IP";
                return false;
            }
            strRet = strRet.Substring(strRet.IndexOf("订单已提交成功"));
            strRet = strRet.Substring(strRet.IndexOf("tbody"));
            goodInfo.strOrderID = GetKeyString(strRet, "<td>", "</td>");
            goodInfo.strFreshStatus = "下单成功:" + goodInfo.strOrderID;
            return true;
        }
        public bool AddToCart(_GoodsFreshStr goodInfo)
        {
            string strCartUrl = "https://www.vjia.com/shopping/shopping.aspx";
            string strCartDelUrl = "https://www.vjia.com/shopping/process/cart.ashx";

            string strData = "type=delete&deleteType=atype=load";
            string strRet = m_webPost.GetHttpPage(strCartDelUrl,
                    "utf-8", "post", "", strData,
                    strCartUrl,
                    "*/*", "");

            string[] strArrayGoodId = goodInfo.goodId.Split('-');
            string[] strArraySkuId = goodInfo.skuId.Split('-');
            if (strArrayGoodId.Length != strArraySkuId.Length)
            {
                goodInfo.strFreshStatus = "商品ID与型号ID数不匹配";
                return false;
            }
            for (int i = 0; i < strArrayGoodId.Length; i++)
            {
                if(!AddToCartEx(goodInfo, strArrayGoodId[i], strArraySkuId[i], i==0))
                    return false;
            }
            return true;
        }
        public bool GetOrderInfo(_GoodsFreshStr goodInfo)
        {
            goodInfo.strFreshStatus = "正在获取订单信息...";
            ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
            ShowFreshInfo(goodInfo);
            string strOrderBase = "http://my.vancl.com/Order/?ref=my_left_left_Order";
            string strRet = goodInfo.webPost.GetHttpPage(strOrderBase,
                    "utf-8", "get", "", "",
                    "",
                    "*/*", "");
            if (strRet == "")
            {
                goodInfo.strFreshStatus = "获取订单信息失败";
                ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
                return false;
            }
            strRet = strRet.ToLower();
            string strFlagOrder = "id=\"hidposttime\"";

            strRet = strRet.Substring(0, strRet.IndexOf(strFlagOrder));

            strRet = strRet.Substring(strRet.LastIndexOf('<'));
            string strHiddenTime = GetKeyString(strRet, "value=\"", "\"");
            //GetKeyString
            //进行中的
            string strOrderUrl = "http://my.vancl.com/Order/OrderList4";

            string strPostDate = string.Format("{0}%2C{1}", DateTime.Now.AddDays(2).AddMonths(-1).ToString("yyyy-MM-dd"), DateTime.Now.AddDays(2).ToString("yyyy-MM-dd") );
            string strData = string.Format("datestring=30%E5%A4%A9%E5%86%85%E7%9A%84%E8%AE%A2%E5%8D%95&isPageing=false&orderstatus=%E8%BF%9B%E8%A1%8C%E4%B8%AD(1000)&hidPostTime={0}&X-Requested-With=XMLHttpRequest", strHiddenTime);
            strRet = goodInfo.webPost.GetHttpPage(strOrderUrl,
                    "utf-8", "post", "", strData,
                    strOrderBase,
                    "*/*", "");
            if (strRet == "")
            {
                goodInfo.strFreshStatus = "获取订单信息失败";
                ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
                return false;
            }
            string strFlag = "\"widdent_info\"";
            int iIndex = strRet.IndexOf(strFlag);
            int nCount = 0;
            while (iIndex >= 0)
            {
                strRet = strRet.Substring(iIndex + strFlag.Length);
                int iIndex1 = strRet.IndexOf(strFlag);
                nCount++;
                goodInfo.strFreshStatus = string.Format("正在获取第{0}订单信息...", nCount);
                ShowLogString(goodInfo.strFreshStatus + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
                if (iIndex1 > 0)
                {
                    string strTemp = strRet.Substring(0, iIndex1);
                    //dd/dddd
                    GetOrderDetailInfo(goodInfo, strTemp);
                    strRet = strRet.Substring(iIndex1);
                    iIndex = strRet.IndexOf(strFlag);
                }
                else
                {
                    GetOrderDetailInfo(goodInfo, strRet);
                    break;
                }
            }

            if (nCount < 1)
            {
                goodInfo.strFreshStatus = "无正在进行中的订单";
                ShowLogString(goodInfo.strFreshStatus + ":" + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
            }
            else
            {
                goodInfo.strFreshStatus = string.Format("获取订单信息完成:{0}", nCount);
                ShowLogString(goodInfo.strFreshStatus + ":" + goodInfo.strAcc);
                ShowFreshInfo(goodInfo);
            }
            return true;
        }
        public bool SetTransTypeAndPayType(_GoodsFreshStr goodInfo)
        {
            string strCheckOutUrl = "https://shopping.vancl.com/checkout";
            string strDeleverUrl = "https://shopping.vancl.com/checkout/setdelivery?transferId=01&transferTime=AnyTime";
            string strRet = m_webPost.GetHttpPage(strDeleverUrl,
                    "utf-8", "get", "", "",
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("配送方式:") < 0)
            {
                goodInfo.strFreshStatus = "设置寄送方式出错";
                return false;
            }

            string strPayTypeUrl = "https://shopping.vancl.com/checkout/setpayment?identifier=-1%24-1%24False%24False";
            strRet = m_webPost.GetHttpPage(strPayTypeUrl,
                    "utf-8", "get", "", "",
                    strCheckOutUrl,
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet.IndexOf("在线支付") < 0)
            {
                goodInfo.strFreshStatus = "设置支付方式出错";
                return false;
            }
            goodInfo.iFreshNumCount = 0;
            return SubmitOrder(goodInfo, "");
        }
        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 bool AddToCart(_GoodsFreshStr goodInfo)
        {
            string strCartUrl = "http://shopping.vancl.com/mycart";
            string strCartDelUrl = "http://shopping.vancl.com/mycart/batchdelcart";

            string strRet = m_webPost.GetHttpPage(strCartDelUrl,
                    "utf-8", "get", "", "",
                    strCartUrl,
                    "*/*", "");

            string strGoodUrl = string.Format("http://item.vancl.com/{0}.html", goodInfo.goodId);

             strRet = m_webPost.GetHttpPage(strGoodUrl,
                    "utf-8", "get", "", "",
                    "",
                    "*/*", "");
            if (strRet.IndexOf("<h2>出错了</h2>") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("<h2>出错了</h2>"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "<p>", "</p>");
                return false;
            }
            else if (strRet == "")
            {
                goodInfo.strFreshStatus = "加载商品页面出错";
                return false;
            }

            strRet = strRet.ToLower();
            goodInfo.strGoodName = GetKeyString(strRet, "<title>", "</title>");//<title>流金幻彩松紧女短靴 咖啡色 - 鞋 女鞋 靴子 时尚女靴 - VANCL 凡客诚品</title>
            string strPrice = "2.00";
            string strAddtoCartUrl = string.Format("http://shopping.vancl.com/mycart/batchadd?sku={0}&price={1}&qty={2}&async=true&callback=jQuery171013180430320374498_1343624828578&_={3}",
                goodInfo.skuId,
                strPrice,
                goodInfo.strNum,
                DateTime.Now.ToFileTime());
            strRet = m_webPost.GetHttpPage(strAddtoCartUrl,
                    "utf-8", "get", "", "",
                    strGoodUrl,
                    "*/*", "");
            strRet = strRet.ToLower();

            //jQuery171013180430320374498_1343624828578({"Type":"Normal","Title":"出错了","Content":"您要订购的商品不存在或者已下架。","LinkUrl":null})
            if (strRet.IndexOf("出错了") > 0)
            {
                strRet = strRet.Substring(strRet.IndexOf("\"出错了"));
                goodInfo.strFreshStatus = GetKeyString(strRet, "content\":\"", "\"");
                return false;
            }
            else if (strRet.IndexOf("\"totalproducts\"") < 0)
            {
                goodInfo.strFreshStatus = "加入购物车出错";
                return false;
            }
            return true;
        }
        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 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;
        }
Beispiel #32
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);
        }