public static DateTime GetTalkContent(string nick, string session, DateTime now)
    {
        TalkRecodService trDal   = new TalkRecodService();
        SubUserService   userDal = new SubUserService();

        DateTime max = DateTime.Parse(now.AddDays(-6).ToShortDateString());

        trDal.CreateTable(DBHelp.DataHelper.Encrypt(nick));

        List <string> childNicks = new List <string>();
        //try
        //{
        IList <TaoBaoAPIHelper.SubUserInfo> userList    = TaoBaoAPI.GetChildNick(nick, session);
        List <TaoBaoAPIHelper.SubUserInfo>  hasuserList = userDal.GetAllChildNick(nick);

        foreach (TaoBaoAPIHelper.SubUserInfo uinfo in userList)
        {
            childNicks.Add(uinfo.nick);
            if (hasuserList.Where(o => o.nick == uinfo.nick).ToList().Count == 0)
            {
                userDal.InsertSubUserInfo(uinfo);
            }
        }

        foreach (string fromNick in childNicks)
        {
            max = trDal.GetMaxTime(nick, fromNick);

            //获取聊天对象列表,查询时间段<=7天,只支持xml返回
            if (max.AddDays(7) <= now)
            {
                max = now.AddDays(-6);
            }

            List <TaoBaoAPIHelper.TalkContent> allcontent = trDal.GetAllContent(max.AddHours(-16), max, nick, fromNick);

            List <TaoBaoAPIHelper.TalkObj> objList = TaoBaoAPIHelper.TaoBaoAPI.GetTalkObjList(fromNick.Replace("cntaobao", ""), session, max, now);
            foreach (TaoBaoAPIHelper.TalkObj obj in objList)
            {
                List <TaoBaoAPIHelper.TalkContent> contents = TaoBaoAPIHelper.TaoBaoAPI.GetTalkContentNow(session, fromNick.Replace("cntaobao", ""), obj.uid.Replace("cntaobao", ""), max, now);

                for (int i = 0; i < contents.Count; i++)
                {
                    contents[i].FromNick = fromNick.Replace("cntaobao", "");
                    contents[i].ToNick   = obj.uid.Replace("cntaobao", "");

                    if (allcontent.Contains(contents[i]))
                    {
                        continue;
                    }
                    trDal.InsertContent(contents[i], nick);
                }
            }
        }
        //}
        //catch (Exception ex)
        //{
        //    LogInfo.WriteLog("首次加载失败了", ex.Message);
        //}

        //返回获取聊天记录的开始时间
        return(max);
    }
        public void GetTalkRecordContent()
        {
            IList <TopNickSessionInfo> list    = new NickSessionService().GetAllNickSession(Enum.TopTaoBaoService.Temporary);
            TalkRecodService           trDal   = new TalkRecodService();
            SubUserService             userDal = new SubUserService();

            foreach (TopNickSessionInfo info in list)
            {
                DateTime now = trDal.GetMaxTime(info.Nick);

                ServiceLog.RecodeLog(info.Nick + "开始获取时间" + now);

                trDal.CreateTable(DBHelp.DataHelper.Encrypt(info.Nick));
                //List<GroupMember> memberList = TaoBaoAPI.GetNickGroupList(info.Nick, info.Session);

                List <SubUserInfo> hasuserList = userDal.GetAllChildNick(info.Nick);
                List <string>      childNicks  = new List <string>();

                //直接获取子帐号列表
                //if (memberList.Count == 0)
                //{
                IList <SubUserInfo> userList = TaoBaoAPI.GetChildNick(info.Nick, info.Session);

                foreach (SubUserInfo uinfo in userList)
                {
                    childNicks.Add(uinfo.nick);
                    if (hasuserList.Where(o => o.nick == uinfo.nick).ToList().Count == 0)
                    {
                        userDal.InsertSubUserInfo(uinfo);
                    }
                }
                //}
                //else
                //{
                //    foreach (GroupMember minfo in memberList)
                //    {
                //        foreach (string cnick in minfo.MemberIdList)
                //        {
                //            if (childNicks.Contains(cnick))
                //                continue;
                //            childNicks.Add(cnick);
                //        }
                //    }
                //}

                //foreach (GroupMember minfo in memberList)
                //{

                DateTime rnow = DateTime.Now;

                List <TalkContent> allcontent = trDal.GetAllContent(now.AddHours(-16), now, info.Nick);

                foreach (string fromNick in childNicks)
                {
                    List <TalkObj> objList = TaoBaoAPI.GetTalkObjList(fromNick.Replace("cntaobao", ""), info.Session, now, rnow);
                    foreach (TalkObj obj in objList)
                    {
                        List <TalkContent> contents = TaoBaoAPI.GetTalkContentNow(info.Session, fromNick.Replace("cntaobao", ""), obj.uid.Replace("cntaobao", ""), now, rnow);

                        for (int i = 0; i < contents.Count; i++)
                        {
                            contents[i].FromNick = fromNick.Replace("cntaobao", "");
                            contents[i].ToNick   = obj.uid.Replace("cntaobao", "");
                            if (allcontent.Contains(contents[i]))
                            {
                                continue;
                            }
                            trDal.InsertContent(contents[i], info.Nick);
                        }
                    }
                }
                //}
            }
        }