/// <summary>
        /// 處理簡歷列表
        /// </summary>
        /// <param name="resumes"></param>
        /// <param name="unhandled"></param>
        /// <param name="staff"></param>
        /// <param name="isWhile"></param>
        /// <param name="cookieContainer"></param>
        private static void HandleResumes(dynamic resumes, int unhandled, ZhaopinStaff staff, ref bool isWhile, CookieContainer cookieContainer)
        {
            var stopwatch = new Stopwatch();

            foreach (var item in resumes)
            {
                #region Handle resume

                try
                {
                    stopwatch.Restart();

                    #region Save resume and Upload

                    var requestResult = RequestFactory.QueryRequest($"http://ihr.zhaopin.com/resumesearch/getresumedetial.do?resumeNo={item.id}_{item.jobNumber}_{item.number}_1_1&resumeSource=3", cookieContainer: cookieContainer);

                    if (!requestResult.IsSuccess)
                    {
                        Trace.TraceWarning(requestResult.ErrorMsg);

                        continue;
                    }

                    var content = JsonConvert.DeserializeObject <dynamic>(requestResult.Data);

                    if ((int)content.code == 6001) // 登录过期
                    {
                        using (var db = new MangningXssDBEntities())
                        {
                            var zhaopinStaff = db.ZhaopinStaff.FirstOrDefault(f => f.Id == staff.Id);

                            if (zhaopinStaff != null)
                            {
                                zhaopinStaff.Cookie = null;

                                db.SaveChanges();

                                dictionary.TryRemove(staff.Id, out companyId);
                            }
                        }

                        Trace.WriteLine($"{DateTime.Now} > Loging Timeout ! Username = {staff.Username}, Message = {content.message}.");

                        isWhile = false;

                        break;
                    }

                    if ((int)content.code != 1)
                    {
                        Trace.WriteLine($"{DateTime.Now} > Get Resume Detail Error ! Username = {staff.Username}, Message = {content.message}.");

                        continue;
                    }

                    var resumeData = content.data;

                    var resumeDetail = JsonConvert.DeserializeObject(resumeData.detialJSonStr.ToString());

                    var refreshTime = BaseFanctory.GetTime((string)resumeDetail.DateLastReleased).ToUniversalTime();

                    resumeData.detialJSonStr = resumeDetail;

                    var resumeNumber = ((string)resumeData.resumeNo).Substring(0, 10);

                    var userId = (int)resumeData.userDetials.userMasterId;

                    var resumeId = resumeData.resumeId != null ? (int)resumeData.resumeId : resumeDetail.ResumeId != null ? (int)resumeDetail.ResumeId : 0;

                    var status = "Handle";

                    using (var db = new MangningXssDBEntities())
                    {
                        var resume = db.ZhaopinResume.FirstOrDefault(f => f.Id == resumeId);

                        if (!(resume?.RefreshTime != null && resume.RefreshTime.Value.Date >= refreshTime.Date))
                        {
                            if (resume != null)
                            {
                                resume.RandomNumber = resumeNumber;
                                resume.RefreshTime  = refreshTime;
                                resume.UpdateTime   = DateTime.UtcNow;
                                if (string.IsNullOrEmpty(resume.UserExtId))
                                {
                                    resume.UserExtId = resumeDetail.UserMasterExtId.ToString();
                                }
                                resume.Source = !resume.Source.Contains("Deliver") ? resume.Source += ",Deliver" : resume.Source;
                                resume.Flag   = 0xE;
                            }
                            else
                            {
                                resume = new ZhaopinResume
                                {
                                    Id             = resumeId,
                                    RandomNumber   = resumeNumber,
                                    UserId         = userId,
                                    RefreshTime    = refreshTime,
                                    UpdateTime     = DateTime.UtcNow,
                                    UserExtId      = resumeDetail.UserMasterExtId.ToString(),
                                    DeliveryNumber = null,
                                    Source         = "Deliver",
                                    Flag           = 0xE
                                };

                                db.ZhaopinResume.Add(resume);
                            }

                            var user = db.ZhaopinUser.FirstOrDefault(f => f.Id == userId);

                            if (user != null)
                            {
                                if (!user.Source.Contains("MANUAL"))
                                {
                                    user.ModifyTime = BaseFanctory.GetTime((string)resumeDetail.DateModified).ToUniversalTime();
                                    user.CreateTime = BaseFanctory.GetTime((string)resumeDetail.DateCreated).ToUniversalTime();
                                    user.Cellphone  = resumeData.userDetials.mobilePhone.ToString();
                                    user.Email      = resumeData.userDetials.email.ToString();
                                    user.Name       = resumeData.userDetials.userName.ToString();
                                    user.UpdateTime = DateTime.UtcNow;
                                    user.Username   = resumeData.userDetials.email.ToString();
                                }
                            }
                            else
                            {
                                user = new ZhaopinUser
                                {
                                    Id         = userId,
                                    Source     = "Deliver",
                                    ModifyTime = BaseFanctory.GetTime((string)resumeDetail.DateModified).ToUniversalTime(),
                                    CreateTime = BaseFanctory.GetTime((string)resumeDetail.DateCreated).ToUniversalTime(),
                                    Cellphone  = resumeData.userDetials.mobilePhone.ToString(),
                                    Email      = resumeData.userDetials.email.ToString(),
                                    Name       = resumeData.userDetials.userName.ToString(),
                                    UpdateTime = DateTime.UtcNow,
                                    Username   = resumeData.userDetials.email.ToString()
                                };

                                db.ZhaopinUser.Add(user);
                            }

                            var resumeContent = JsonConvert.SerializeObject(resumeData);

                            using (var jsonStream = new MemoryStream(GZip.Compress(Encoding.UTF8.GetBytes(resumeContent))))
                            {
                                mangningOssClient.PutObject(mangningBucketName, $"Zhaopin/Resume/{resumeId}", jsonStream);
                            }

                            var resumePath = $"{uploadFilePath}{resumeId}.json";

                            File.WriteAllText(resumePath, JsonConvert.SerializeObject(resumeData));

                            db.SaveChanges();
                        }
                        else
                        {
                            status = "NoHandle";
                        }
                    }

                    #endregion

                    Thread.Sleep(3000);

                    #region SignResume

                    var data = HttpUtility.UrlEncode(JsonConvert.SerializeObject(new
                    {
                        signTag    = "noSuit",
                        resumeList = new List <dynamic>
                        {
                            new
                            {
                                resumeNo     = $"{item.jobNumber}_{item.number}_{item.version}_1",
                                resumenumber = item.number,
                                item.version,
                                lanType      = 1,
                                jobname      = ((string)resumeData?.jobName)?.Replace("\"", "\\\"").Replace("\\", "\\\\"),
                                jobno        = item.jobNumber,
                                resumesource = item.resumeSource,
                                resumeJobId  = item.id,
                                resumerName  = ((string)item?.userName).Replace("\r", "").Replace("\n", "").Replace("\"", "\\\""),
                                resumejlName = ((string)item?.name).Replace("\r", "").Replace("\n", "").Replace("\"", "\\'").Replace("\\", "\\\\"),
                                resumerId    = item.userId
                            }
                        },
                        mark = ""
                    }));

                    requestResult = RequestFactory.QueryRequest("https://ihr.zhaopin.com/resumemanage/resumesignstate.do", $"data={data}", RequestEnum.POST, cookieContainer);

                    if (!requestResult.IsSuccess)
                    {
                        Trace.TraceWarning(requestResult.ErrorMsg);

                        continue;
                    }

                    content = JsonConvert.DeserializeObject <dynamic>(requestResult.Data);

                    if ((int)content.code == 6001) // 登录过期
                    {
                        using (var db = new MangningXssDBEntities())
                        {
                            var zhaopinStaff = db.ZhaopinStaff.FirstOrDefault(f => f.Id == staff.Id);

                            if (zhaopinStaff != null)
                            {
                                zhaopinStaff.Cookie = null;

                                db.SaveChanges();

                                dictionary.TryRemove(staff.Id, out companyId);
                            }
                        }

                        Trace.WriteLine($"{DateTime.Now} > Loging Timeout ! Username = {staff.Username}, Message = {content.message}.");

                        isWhile = false;

                        break;
                    }

                    if ((int)content.code != 1)
                    {
                        Trace.WriteLine($"{DateTime.Now} > Sign Resume Error ! Username = {staff.Username}, Message = {content.message}, ResumeId = {resumeId}.");

                        continue;
                    }

                    #endregion

                    stopwatch.Stop();

                    var elapsed = stopwatch.ElapsedMilliseconds;

                    Interlocked.Increment(ref count);

                    Console.WriteLine($"{DateTime.Now} > {count} {status} {staff.Username}:Unhandled = {--unhandled}, RId = {resumeId}, Elapsed = {elapsed} ms.");
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.ToString());
                }

                #endregion
            }
        }
        /// <summary>
        /// 處理簡歷列表
        /// </summary>
        /// <param name="resumes"></param>
        /// <param name="unhandled"></param>
        /// <param name="staff"></param>
        /// <param name="isWhile"></param>
        /// <param name="cookieContainer"></param>
        /// <param name="isNewSystem"></param>
        private static void HandleResumes(dynamic resumes, ref int unhandled, ZhaopinStaff staff, ref bool isWhile, CookieContainer cookieContainer, bool isNewSystem)
        {
            var stopwatch = new Stopwatch();

            var time = 0;

            foreach (var item in resumes)
            {
                #region Handle resume

                try
                {
                    if (IsDownload((long)item.id, staff.CompanyId))
                    {
                        if (++time > 30)
                        {
                            break;
                        }

                        continue;
                    }

                    time = 0;

                    stopwatch.Restart();

                    #region Save resume and Upload

                    var requestResult = RequestFactory.QueryRequest($"http://ihr.zhaopin.com/resumesearch/getresumedetial.do?resumeNo={item.id}_{item.jobNumber}_{item.number}_1_1&resumeSource=3", cookieContainer: cookieContainer);

                    if (!requestResult.IsSuccess)
                    {
                        Trace.TraceWarning(requestResult.ErrorMsg);

                        continue;
                    }

                    var content = JsonConvert.DeserializeObject <dynamic>(requestResult.Data);

                    if ((int)content.code == 6001) // 登录过期
                    {
                        using (var db = new MangningXssDBEntities())
                        {
                            var zhaopinStaff = db.ZhaopinStaff.FirstOrDefault(f => f.Id == staff.Id);

                            if (zhaopinStaff != null)
                            {
                                zhaopinStaff.Cookie = null;

                                db.SaveChanges();

                                dictionary.TryUpdate(staff.Id, true, true);
                            }
                        }

                        Trace.WriteLine($"{DateTime.Now} > Loging Timeout ! Username = {staff.Username}, Message = {content.message}.");

                        isWhile = false;

                        break;
                    }

                    if ((int)content.code != 1)
                    {
                        Trace.WriteLine($"{DateTime.Now} > Get Resume Detail Error ! Username = {staff.Username}, Message = {content.message}.");

                        continue;
                    }

                    var resumeData = content.data;

                    var resumeDetail = JsonConvert.DeserializeObject(resumeData.detialJSonStr.ToString());

                    var refreshTime = BaseFanctory.GetTime((string)resumeDetail.DateLastReleased).ToUniversalTime();

                    resumeData.detialJSonStr = resumeDetail;

                    var resumeNumber = ((string)resumeData.resumeNo).Substring(0, 10);

                    var userId = (int)resumeData.userDetials.userMasterId;

                    var resumeId = resumeData.resumeId != null ? (int)resumeData.resumeId : resumeDetail.ResumeId != null ? (int)resumeDetail.ResumeId : 0;

                    var status = "Handle";

                    using (var db = new MangningXssDBEntities())
                    {
                        var resume = db.ZhaopinResume.FirstOrDefault(f => f.Id == resumeId);

                        if (!(resume?.RefreshTime != null && resume.RefreshTime.Value.Date >= refreshTime.Date))
                        {
                            if (resume != null)
                            {
                                resume.RandomNumber = resumeNumber;
                                resume.RefreshTime  = refreshTime;
                                resume.UpdateTime   = DateTime.UtcNow;
                                if (string.IsNullOrEmpty(resume.UserExtId))
                                {
                                    resume.UserExtId = resumeDetail.UserMasterExtId.ToString();
                                }
                                resume.Source = !resume.Source.Contains("Deliver") ? resume.Source += ",Deliver" : resume.Source;
                                resume.Flag   = 0xE;
                            }
                            else
                            {
                                resume = new ZhaopinResume
                                {
                                    Id             = resumeId,
                                    RandomNumber   = resumeNumber,
                                    UserId         = userId,
                                    RefreshTime    = refreshTime,
                                    UpdateTime     = DateTime.UtcNow,
                                    UserExtId      = resumeDetail.UserMasterExtId.ToString(),
                                    DeliveryNumber = null,
                                    Source         = "Deliver",
                                    Flag           = 0xE
                                };

                                db.ZhaopinResume.Add(resume);
                            }

                            var user = db.ZhaopinUser.FirstOrDefault(f => f.Id == userId);

                            if (user != null)
                            {
                                if (!user.Source.Contains("MANUAL"))
                                {
                                    user.ModifyTime = BaseFanctory.GetTime((string)resumeDetail.DateModified).ToUniversalTime();
                                    user.CreateTime = BaseFanctory.GetTime((string)resumeDetail.DateCreated).ToUniversalTime();
                                    user.Cellphone  = resumeData.userDetials.mobilePhone.ToString();
                                    user.Email      = resumeData.userDetials.email.ToString();
                                    user.Name       = resumeData.userDetials.userName.ToString();
                                    user.UpdateTime = DateTime.UtcNow;
                                    user.Username   = resumeData.userDetials.email.ToString();
                                }
                            }
                            else
                            {
                                user = new ZhaopinUser
                                {
                                    Id         = userId,
                                    Source     = "Deliver",
                                    ModifyTime = BaseFanctory.GetTime((string)resumeDetail.DateModified).ToUniversalTime(),
                                    CreateTime = BaseFanctory.GetTime((string)resumeDetail.DateCreated).ToUniversalTime(),
                                    Cellphone  = resumeData.userDetials.mobilePhone.ToString(),
                                    Email      = resumeData.userDetials.email.ToString(),
                                    Name       = resumeData.userDetials.userName.ToString(),
                                    UpdateTime = DateTime.UtcNow,
                                    Username   = resumeData.userDetials.email.ToString()
                                };

                                db.ZhaopinUser.Add(user);
                            }

                            var resumeContent = JsonConvert.SerializeObject(resumeData);

                            using (var jsonStream = new MemoryStream(GZip.Compress(Encoding.UTF8.GetBytes(resumeContent))))
                            {
                                mangningOssClient.PutObject(mangningBucketName, $"Zhaopin/Resume/{resumeId}", jsonStream);
                            }

                            var resumePath = $"{uploadFilePath}{resumeId}.json";

                            File.WriteAllText(resumePath, JsonConvert.SerializeObject(resumeData));
                        }
                        else
                        {
                            status = "NoHandle";
                        }

                        db.ZhaopinDeliveryLog.Add(new ZhaopinDeliveryLog
                        {
                            CompanyId  = staff.CompanyId,
                            DeliveryId = (long)item.id
                        });

                        db.ZhaopinDelivery.Add(new ZhaopinDelivery
                        {
                            CompanyId    = staff.CompanyId,
                            Id           = (long)item.id,
                            CreateTime   = DateTime.UtcNow,
                            ResumeId     = resumeId,
                            ResumeNumber = resumeData.resumeNo.ToString(),
                            JobNumber    = resumeData.jobNo.ToString(),
                            JobName      = resumeData.jobName.ToString()
                        });

                        db.SaveChanges();
                    }

                    #endregion

                    stopwatch.Stop();

                    var elapsed = stopwatch.ElapsedMilliseconds;

                    Interlocked.Increment(ref count);

                    var version = isNewSystem ? "NewSystem" : "5.5";

                    Console.WriteLine($"{DateTime.Now} > {version} {count} {status} {staff.Username}:Unhandled = {--unhandled}, RId = {resumeId}, Elapsed = {elapsed} ms.");

                    Thread.Sleep(interval);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.ToString());
                }

                #endregion
            }
        }