Ejemplo n.º 1
0
        public static void _exec(long id)
        {
            string Url    = $@"http://api.beisenapp.com/RecruitV2/{setting.Tenant_ID}/Applicant/ById/{id}?language={1}&photo_base64={0}&has_Long={1}";
            var    Result = HttpHelper.HttpGet(Url, setting.AccessToken);

            if (string.IsNullOrEmpty(Result) || Result == "[]")
            {
                return;
            }

            List <Applicant> AppList = JsonConvert.DeserializeObject <List <Applicant> >(Result);
            var app     = AppList[0];
            var ItemObj = app.Profile.Items.Find(x => x.PropertyName == "Name");

            if (ItemObj == null)
            {
                //ErrorLog.WriteLog(new Msd_V2.ErrorObj()
                //{
                //    ErrorMsg ="用户名为空",
                //    ID = id,
                //    UserName =""
                //});
                return;
            }


            //获取用户名和邮箱
            var LastName  = ItemObj.Value.Substring(0, 1);
            var FirstName = ItemObj.Value.Substring(1);
            var EmailObj  = app.Profile.Items.Find(x => x.PropertyName == "email");

            if (EmailObj == null)
            {
                //ErrorLog.WriteLog(new Msd_V2.ErrorObj()
                //{
                //    ErrorMsg ="未填写邮箱",
                //    ID = id,
                //    UserName = ItemObj.Value
                //});
                Console.WriteLine(ItemObj.Value + "未填写邮箱");
                return;
            }

            var Email = EmailObj.Value;
            //if (Email.IndexOf("@qq.com") > 0 || Email.IndexOf("@163.com") > 0) {
            //    return;
            //}

            //判断邮箱是否已发送过五次以上
            var emailSendCount = SelectCountByEmail(Email);

            if (emailSendCount > 5)
            {
                //ErrorLog.WriteLog(new Msd_V2.ErrorObj()
                //{
                //    ErrorMsg ="已连续发送超过5次,可能是标记不成功,已跳过",
                //    ID = id,
                //    UserName = ItemObj.Value
                //}, "RepeatEmail.txt");
                return;
            }

            //重复发送测评
            //if (Result.IndexOf("extshfxychffscp_102854_2003095649") > 0)
            //{
            //    UpdateEmailToSending(Email);
            //    return;
            //}

            //Email = "*****@*****.**";

            //获取JobID(根据JOBID获取岗位序列)
            string jobid = app.ApplyJobSummaries[app.ApplyJobSummaries.Count - 1].JobCustomFields.Find(x => x.PropertyName == "extJobSequence_102854_300134805")?.Value;

            jobid = GetJobID(jobid);

            if (string.IsNullOrEmpty(jobid) || jobid == "0")
            {
                //ErrorLog.WriteLog(new Msd_V2.ErrorObj()
                //{
                //    ErrorMsg = "JobID为空",
                //    ID = id,
                //    UserName = ItemObj.Value
                //});
                return;
            }

            //根据该ID 在测评做完之后 更新测评状态
            string jobid2 = app.ApplyJobSummaries[app.ApplyJobSummaries.Count - 1].JobId;
            //获取NormsetId
            string NormsetId = app.ApplyJobSummaries[app.ApplyJobSummaries.Count - 1].JobCustomFields.Find(x => x.PropertyName == "extszcpcmlx_102854_1709877407")?.Code;

            if (string.IsNullOrEmpty(NormsetId))
            {
                //ErrorLog.WriteLog(new Msd_V2.ErrorObj()
                //{
                //    ErrorMsg = "NormsetId为空",
                //    ID = id,
                //    UserName = ItemObj.Value
                //});
                return;
            }

            NormsetId = string.IsNullOrEmpty(NormsetId) ? "1100" : NormsetId;

            NormsetId = NorID.Nors.ContainsKey(NormsetId) ? NorID.Nors[NormsetId] : "1060";

            //app.ApplyJobSummaries.ForEach(x =>
            //{
            //    SignJobToU15(app.ApplicantId, x.JobId);
            //    jobid2 += string.IsNullOrEmpty(jobid2) ? x.JobId:string.Empty;
            //    jobid += string.IsNullOrEmpty(jobid) ? x.JobCustomFields[0].Code : string.Empty;
            //});

            long EntryID = 0;

            //如果已经投递过岗位并且已完成测评 则按新职位(需要更新该CadidateId的JobID)模拟请求Callback
            if (IsTested(app.CadidateId, out EntryID))
            {
                //更新该用户的岗位编号
                UpdateJobID(EntryID, Convert.ToInt64(jobid));
                //模拟请求
                SimulationExec(app.CadidateId);
                return;
            }


            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            var responese = new MaptqCN.ws().runWSobj(new MaptqCN.wsRequestObj()
            {
                CandidateId  = app.CadidateId,
                LastName     = FirstName,
                FirstName    = LastName,
                ClientId     = "10000010",
                ProjectId    = "10000383",
                SecureCode   = "f97c3ded78e44adf18bc35780916b6df",
                ReturnUrl    = "https://app.askform.cn/Custom/MSDReport/SHDTCallBack-v2.ashx",
                EmailAddress = Email,
                RequestType  = "page_candhub_autoregister",
                LanguageId   = 19,
                NormsetId    = NormsetId
            });

            //只有接口请求成功的时候才修改状态
            if (responese.ErrorCode == 0)
            {
                //添加Entry
                EntryID = AskForm_Entry_Insert();

                AddValueForFieldName(EntryID, setting.ApplicantIdFieldID, app.ApplicantId.ToString());
                AddValueForFieldName(EntryID, setting.NameFieldID, ItemObj.Value);
                AddValueForFieldName(EntryID, setting.CadidateIdFieldID, app.CadidateId);
                AddValueForFieldName(EntryID, setting.EmailFieldID, Email);
                AddValueForFieldName(EntryID, setting.JobIdFieldID, jobid);
                AddValueForFieldName(EntryID, setting.JobIdsFieldID, jobid2);
                AddValueForFieldName(EntryID, setting.NormsetIdFieldID, NormsetId);
                //加入邮件消息队列
                AddEmailSendList(EntryID, Email, responese.RedirectUrl, ItemObj.Value);

                Console.WriteLine("编号:" + id + " ,姓名:" + ItemObj.Value + " ,邮箱:" + EmailObj.Value);
            }

            SignJobToU15(app.ApplicantId, jobid2);
        }