示例#1
0
        /// <summary>
        /// 同步会员信息
        /// </summary>
        /// <param name="strNick"></param>
        /// <param name="strSessionKey"></param>
        /// <returns></returns>
        public Boolean SynicBuyersInformation(string strNick, string strSessionKey)
        {
            List <CrmMember> buyers = null;
            int  PageNo = 1, PageSize = 100, nProcess;
            long total = 0;

            //交易同步
            List <Trade> allTrades   = new List <Trade>();
            Int64        tradePageNo = 1;
            Boolean      hasNext     = false;
            TBTrade      tbTrade     = new TBTrade();

            do
            {
                //获取卖家3个月的交易数据
                List <Trade> partTrades = tbTrade.GetBuyerTrades(strSessionKey, tradePageNo, ref hasNext);

                if (partTrades != null && partTrades.Count > 0)
                {
                    allTrades.AddRange(partTrades);//将list加入到末尾
                }
                tradePageNo++;
            } while (hasNext);//hasNext表示是否有下一页
            if (allTrades == null)
            {
                Console.WriteLine("卖家" + strNick + "的3个月的交易量:null");
                return(false);
            }
            Console.WriteLine("卖家" + strNick + "的3个月的交易量:" + allTrades.Count.ToString());

            do
            {
                try
                {
                    //获取买家信息
                    buyers = GetTBBuyerList(strSessionKey, PageNo, PageSize, ref total);
                    if (buyers == null)
                    {
                        Console.WriteLine("卖家" + strNick + "的买家数量:null");
                        continue;
                    }
                    //Console.WriteLine("卖家" + strNick + "的买家数量:" + buyers.Count.ToString());
                    SynchronizeBuyerInfoWithSeller(strNick, strSessionKey, buyers, allTrades);
                    if (total != 0)
                    {
                        nProcess = (int)(PageNo * PageSize * 100F / total);
                    }
                    else
                    {
                        nProcess = 0;
                    }
                    if (nProcess > 100)
                    {
                        nProcess = 100;
                    }
                    SellersBLL.SetSyncProcess(strNick, nProcess);
                }
                catch (Exception ex)
                {
                    ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                }
            } while (PageNo++ *PageSize < total);
            return(true);
        }