Пример #1
0
        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;
        }
Пример #2
0
 public bool GetCheckCode(ClassHttpPost webPost, string strAcc, out string strError, out string strCheckCode, string strUrl, string strReffer)
 {
     string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
     if (!Directory.Exists(strDirect))
     {
         Directory.CreateDirectory(strDirect);
     }
     string strFile = string.Format("{0}\\{1}_{2}.bmp", strDirect, strAcc, DateTime.Now.ToFileTime());
     bool bRet = GetImage(webPost, strFile, out strError, strUrl, strReffer);
     strCheckCode = "";
     if (bRet)
     {
         lock (m_hLockTable)
         {
             GetCodeHandler _myInvoke = new GetCodeHandler(GetCode);
             strCheckCode = (string)this.Invoke(_myInvoke, new object[] { strFile });
         }
     }
     else
     {
         strError = "获取验证码失败";
         return false;
     }
     return true;
 }
Пример #3
0
        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;
        }
Пример #4
0
        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;
        }