public override RcrtResume ParseHtmlContent(MimeMessage mimeMessage)
        {
            string subject = mimeMessage.Subject;

            if (subject.Contains("来自广告门", StringComparison.OrdinalIgnoreCase))
            {
                RcrtResume resume = new RcrtResume();
                RcrtResume model  = new RcrtResume();
                model.MessageId    = mimeMessage.MessageId;
                model.MessageFrom  = string.Join(";", mimeMessage.From.Mailboxes.Select(a => a.Address));
                subject            = subject.Substring(0, subject.LastIndexOf(':') + 1);
                model.ResumeName   = subject.ReplaceIgnoreCase("转发:", "").Trim();
                model.ResumeStatus = RcrtResumeStatus.Created;
                model.MessageDate  = mimeMessage.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
                //获取html内容
                string htmlPart = mimeMessage.HtmlBody;
                if (htmlPart.IsPresent())
                {
                    model.HtmlContent = htmlPart;
                }
                //获取txt内容,用于解析
                string messageText   = string.Empty;
                string plainTextPart = mimeMessage.GetTextBody(MimeKit.Text.TextFormat.Plain);
                if (plainTextPart.IsPresent())
                {
                    // The message had a text/plain version - show that one
                }
                return(resume);
            }
            return(null);
        }
Beispiel #2
0
        public override RcrtResume ParseHtmlContent(MimeMessage message)
        {
            string subject = message.Subject;

            if (subject.Contains("来自拉勾", Sys.StringComparison.OrdinalIgnoreCase))
            {
                RcrtResume model = new RcrtResume();
                model.MessageId   = message.MessageId;
                model.MessageFrom = string.Join(";", message.From.Mailboxes.Select(a => a.Address));

                model.ResumeStatus = RcrtResumeStatus.Created;
                model.MessageDate  = message.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
                model.Source       = "LaGou";
                //获取txt内容,用于解析
                string msgText = string.Empty;
                //获取html内容
                string htmlPart = message.HtmlBody;
                if (htmlPart.IsPresent())
                {
                    model.HtmlContent = htmlPart;
                    HtmlDocument hdoc = new HtmlDocument();
                    hdoc.LoadHtml(htmlPart);
                    model.ResumeName = hdoc.DocumentNode.SelectSingleNode("//table/tbody[1]/tr[2]/td[1]/div[2]/span[1]").InnerText.RemoveSpace();
                    string[] baseInfo = hdoc.DocumentNode.SelectSingleNode("//table/tbody[1]/tr[2]/td[1]/div[3]/div[1]").InnerText.Trim().Replace(" ", "", Sys.StringComparison.OrdinalIgnoreCase).Split('|');
                    if (baseInfo.Length > 4)
                    {
                        string[] address = baseInfo[4].Split("\r\n");
                        model.Address = address[0];
                        string[] edu = address[1].Substring("毕业院校:".Length).Split('·');
                        if (edu.Length > 1)
                        {
                            model.University = edu[1];
                        }
                    }
                    model.Education = baseInfo[2];

                    model.FullName = baseInfo[0].RemoveSpace();

                    model.Gender   = GetGender(baseInfo[1].RemoveSpace());
                    model.WorkLift = baseInfo[3].RemoveSpace();
                }
                else
                {
                    msgText = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
                }
                return(model);
            }
            return(null);
        }
Beispiel #3
0
        public override RcrtResume ParseHtmlContent(MimeMessage message)
        {
            string subject = message.Subject;

            if (subject.Contains("来自猎聘网", Sys.StringComparison.OrdinalIgnoreCase))
            {
                RcrtResume model = new RcrtResume();
                model.MessageId   = message.MessageId;
                model.MessageFrom = string.Join(";", message.From.Mailboxes.Select(a => a.Address));

                model.ResumeStatus = RcrtResumeStatus.Created;
                model.MessageDate  = message.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
                model.Source       = "LiePin";
                //获取txt内容,用于解析
                string msgText = string.Empty;
                //获取html内容
                string htmlPart = message.HtmlBody;
                if (htmlPart.IsPresent())
                {
                    model.HtmlContent = htmlPart;
                    HtmlDocument hdoc = new HtmlDocument();
                    hdoc.LoadHtml(htmlPart);
                    string   title  = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/p[1]/span[1]").InnerText;
                    string[] titles = title.Split('|');
                    if (titles.Length > 1)
                    {
                        model.Address = titles[1].RemoveSpace();
                    }
                    model.ResumeName = titles[0].RemoveSpace();
                    model.Emails     = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[4]/td[2]").InnerText.RemoveSpace();
                    model.FullName   = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[2]/td[2]").InnerText.RemoveSpace();

                    model.Mobile   = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[3]/td[2]").InnerText.RemoveSpace();
                    model.Gender   = GetGender(hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[3]/td[4]").InnerText.RemoveSpace());
                    model.WorkLift = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[2]/td[2]").InnerText.RemoveSpace();

                    model.Education = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]//table[2]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[5]/td[2]").InnerText.RemoveSpace();
                }
                else
                {
                    msgText = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
                }
                return(model);
            }
            return(null);
        }
Beispiel #4
0
        public override RcrtResume ParseHtmlContent(MimeMessage message)
        {
            string subject = message.Subject;

            if (subject.Contains("51job.com", Sys.StringComparison.OrdinalIgnoreCase))
            {
                RcrtResume model = new RcrtResume();
                model.MessageId   = message.MessageId;
                model.MessageFrom = string.Join(";", message.From.Mailboxes.Select(a => a.Address));

                model.ResumeStatus = RcrtResumeStatus.Created;
                model.MessageDate  = message.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
                model.Source       = "ZhongHuaYingCai";
                //获取txt内容,用于解析
                string msgText = string.Empty;
                //获取html内容
                string htmlPart = message.HtmlBody;
                if (htmlPart.IsPresent())
                {
                    model.HtmlContent = htmlPart;
                    HtmlDocument hdoc = new HtmlDocument();
                    hdoc.LoadHtml(htmlPart);
                    model.ResumeName = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[2]/table[1]/tbody[1]/tr[1]/td[2]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[2]").InnerText.RemoveSpace();
                    //hdoc.DocumentNode.SelectSingleNode("//table[1]//td[2]/table[1]//td[2]").InnerText;
                    model.Emails   = hdoc.DocumentNode.SelectSingleNode("//table[2]//table[1]//table[2]/tbody[1]//tr[1]/td[2]//td[2]/a").InnerHtml.RemoveSpace();
                    model.FullName = hdoc.DocumentNode.SelectSingleNode("//table[2]//table[1]//table[1]//td[1]/strong[1]").InnerText.RemoveSpace();
                    string[] baseInfo = hdoc.DocumentNode.SelectSingleNode("//table[2]//table[1]//table[1]//td[1]").InnerText.Trim().Replace(" ", "", Sys.StringComparison.OrdinalIgnoreCase).Split('|');

                    model.Address    = hdoc.DocumentNode.SelectSingleNode("//table[2]//table[1]//table[2]/tbody[1]//tr[2]/td[1]//td[2]").InnerText.RemoveSpace();
                    model.Mobile     = hdoc.DocumentNode.SelectSingleNode("//table[2]//table[1]//table[2]/tbody[1]//table[1]//td[2]").InnerText.RemoveSpace();
                    model.Gender     = GetGender(baseInfo[1].RemoveSpace());
                    model.WorkLift   = baseInfo[3].RemoveSpace();
                    model.Education  = hdoc.DocumentNode.SelectSingleNode("//table[2]/tbody[1]/tr[1]/td[1]/table[2]//tbody[1]/tr[1]/td[1]/table//tbody[1]/tr[1]/td[2]/table[1]/tbody[1]/tr[4]/td[2]").InnerText.RemoveSpace();
                    model.University = hdoc.DocumentNode.SelectSingleNode("//table[2]/tbody[1]/tr[1]/td[1]/table[2]//tbody[1]/tr[1]/td[1]/table//tbody[1]/tr[1]/td[2]/table[1]/tbody[1]/tr[3]/td[2]").InnerText.RemoveSpace();
                    model.Major      = hdoc.DocumentNode.SelectSingleNode("//table[2]/tbody[1]/tr[1]/td[1]/table[2]//tbody[1]/tr[1]/td[1]/table//tbody[1]/tr[1]/td[2]/table[1]/tbody[1]/tr[2]/td[2]").InnerText.RemoveSpace();
                }
                else
                {
                    msgText = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
                }
                return(model);
            }
            return(null);
        }
        public bool Analysis(MimeMessage mimeMessage, IEnumerable <RcrtResume> blacklist)
        {
            RcrtResume resume = ParseHtmlContent(mimeMessage);

            if (resume == null)
            {
                return(false);
            }
            if (blacklist.Any() && resume.Mobile.IsPresent())
            {
                //黑名单
                if (blacklist.Select(r => r.Mobile).Contains(resume.Mobile))
                {
                    return(false);
                }
            }
            resume.Attachment = ParseAttachment(mimeMessage);
            _dbContext.Insert(resume);
            return(true);
        }
 public override RcrtResume ParseHtmlContent(MimeMessage message)
 {
     if (message.Subject.Contains("Zhaopin.com", Sys.StringComparison.OrdinalIgnoreCase))
     {
         int        start   = message.Subject.IndexOf("(Zhaopin.com) 应聘", Sys.StringComparison.OrdinalIgnoreCase) + "(Zhaopin.com) 应聘".Length;
         int        length  = message.Subject.LastIndexOf('-') - start;
         string     subject = message.Subject.Substring(start, length);
         RcrtResume model   = new RcrtResume();
         model.MessageId    = message.MessageId;
         model.MessageFrom  = string.Join(";", message.From.Mailboxes.Select(a => a.Address));
         model.ResumeName   = subject.ReplaceIgnoreCase("转发:", "").Trim();
         model.ResumeStatus = RcrtResumeStatus.Created;
         model.MessageDate  = message.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
         //获取txt内容,用于解析
         string msgText = string.Empty;
         //获取html内容
         string htmlPart = message.HtmlBody;
         if (htmlPart.IsPresent())
         {
             model.HtmlContent = htmlPart;
             HtmlDocument hdoc = new HtmlDocument();
             hdoc.LoadHtml(htmlPart);
             HtmlNode table = hdoc.DocumentNode.SelectSingleNode("//table[2]");
             msgText = table.InnerText;
         }
         else
         {
             msgText = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
         }
         if (msgText.IsMissing())
         {
             return(model);
         }
         model.Source = "ZhiLianZhaoPin";
         using Sys.IO.StringReader sr = new Sys.IO.StringReader(msgText);
         string scontent = string.Empty;
         int    i        = 0;
         while ((scontent = sr.ReadLine()) != null)
         {
             if (scontent.Trim().StartsWith("ID:", Sys.StringComparison.OrdinalIgnoreCase))
             {
                 i = 2;
                 continue;
             }
             // 对s2操作
             if (scontent.Trim().IsPresent())
             {
                 i++;
             }
             else
             {
                 continue;
             }
             if (i == 3 || i < 3)
             {
                 i = 3;
                 //姓名
                 model.FullName = scontent;
             }
             if (i == 4)
             {
                 //男|3年工作经验|1992年6月|未婚
                 string[] baseInfo = scontent.Split('|');
                 //性别
                 model.Gender = GetGender(baseInfo[0]);
                 //工作年限
                 model.WorkLift = baseInfo[1];
             }
             if (i == 5)
             {
                 string[] otherInfo = scontent.Split('|');
                 if (otherInfo.Length > 1)
                 {
                     model.Address   = otherInfo[0];
                     model.Education = otherInfo[1];
                 }
             }
             if (i == 6)
             {
                 model.Mobile = RegexUtils.IsMobileNo(scontent) ? scontent : "";
             }
             if (i == 7)
             {
                 model.Emails = RegexUtils.IsEmail(scontent) ? scontent : "";
             }
         }
         return(model);
     }
     return(null);
 }
Beispiel #7
0
        public override RcrtResume ParseHtmlContent(MimeMessage message)
        {
            string subject = message.Subject;

            if (subject.Contains("Boss直聘", Sys.StringComparison.OrdinalIgnoreCase))
            {
                subject = subject.ReplaceIgnoreCase("转发:", "").Trim().Split(' ')[3];
                RcrtResume model = new RcrtResume();
                model.MessageId    = message.MessageId;
                model.MessageFrom  = string.Join(";", message.From.Mailboxes.Select(a => a.Address));
                model.ResumeName   = subject;
                model.ResumeStatus = RcrtResumeStatus.Created;
                model.MessageDate  = message.Date.DateTime.ToString("yyyy-MM-dd:HH:mm:ss");
                //获取txt内容,用于解析
                string msgText = string.Empty;
                //获取html内容
                string htmlPart = message.HtmlBody;
                if (htmlPart.IsPresent())
                {
                    model.HtmlContent = htmlPart;
                    HtmlDocument hdoc = new HtmlDocument();
                    hdoc.LoadHtml(htmlPart);
                    HtmlNode table = hdoc.DocumentNode.SelectSingleNode("//table");
                    msgText = table.InnerText;
                }
                else
                {
                    msgText = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
                }
                if (msgText.IsMissing())
                {
                    return(model);
                }
                model.Source = "Boss";
                using Sys.IO.StringReader sr = new Sys.IO.StringReader(msgText);
                string scontent = string.Empty;
                int    i        = 0;
                while ((scontent = sr.ReadLine()) != null)
                {
                    // 对s2操作
                    if (scontent.Trim().IsPresent())
                    {
                        i++;
                    }
                    else
                    {
                        continue;
                    }
                    if (i < 4)
                    {
                        continue;
                    }
                    if (i == 4)
                    {
                        //姓名
                        model.FullName = scontent;
                    }
                    if (i == 5)
                    {
                        model.Gender = GetGender(scontent);
                    }
                    if (i == 7)
                    {
                        string[] otherInfo = scontent.Split(' ');
                        //工作年限
                        if (otherInfo.Length > 1)
                        {
                            model.WorkLift  = otherInfo[1];
                            model.Education = otherInfo[0];
                        }
                    }
                    return(model);
                }
            }
            return(null);
        }