public ActionResult SaveWorkForm(ResumeWork model) { bool status = false; if (!ModelState.IsValid) { return(this.JsonFormat(ModelState, !status, "ERROR")); } var member_cd = SessionHelper.Get("MEMBER_CD"); MST_RESUME_DTL dtl = new MST_RESUME_DTL(); dtl.RESUME_CD = model.RESUME_CD; dtl.MEMBER_CD = member_cd; dtl.RESUME_DTL1 = model.workLink; dtl.RESUME_DTL2 = model.workDesc; resume_dtlManager.Add(dtl); status = true; return(this.JsonFormat(dtl, !status, "保存成功")); }
public static List <ResumeWork> DeserializeWorkingExperiences(HtmlDocument document) { var node = document.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div/h3[1][. = '工作经历']"); if (node == null) { return(null); } var experiences = new List <ResumeWork>(); while ((node = node.NextSibling) != null) { if (node.Name == "#text") { continue; } if (node.Name != "h2") { throw new Exception("格式化工作经验失败!"); } ResumeWork experience; do { // From DeserializeWorkingExperiences/Standard.html // e.g. 2015.02 - 2015.06 北京星石投资管理有限公司 (4个月) // e.g. 2012.08 - 至今 HiAll (3年4个月) // e.g. 2012.09 - 2012.09 强生 var match = Regex.Match(node.InnerText.Trim(), @"^(?s:(\d{4}\.\d{2})\s+-\s+(至今|\d{4}\.\d{2})( |\s){2,}(.*?))$"); // Sample was not found yet. if (!match.Success) { throw new Exception("格式化工作经验失败!"); } experience = new ResumeWork(); experience.Begin = match.Result("$1"); experience.End = match.Result("$2"); match = Regex.Match(match.Result("$4"), @"^(?s:(.*?)(( |\s){2,}|)((((\d+年|)(\d+个月|)))|))$"); // Sample was not found yet. if (!match.Success) { throw new FormatException("Working experience summary format was unexpected."); } experience.Company = match.Result("$1") ?? ""; // From DeserializeWorkingExperiences/Standard.html // From DeserializeWorkingExperiences/Not-Contains-Duration.html //experience.Duration = match.Result("$5"); experiences.Add(experience); while ((node = node.NextSibling)?.Name == "#text") { } if (node == null) { break; } if (node.Name != "h5") { throw new FormatException($"Working experience node ({node.Name}) was unexpected."); } // From DeserializeWorkingExperiences/Standard.html // e.g. 杭州分销办事处 | 销售主管 | 6001-8000元/月 // e.g. 系统部高级专员 | 2001-4000元/月 match = Regex.Match(node.InnerText, @"^(.*?)(\s+[|]\s+((\d+-|)\d+元/月(以下|以上|)|保密|)|)\s*$"); // Sample was not found yet. if (!match.Success) { throw new FormatException("Working experience position format was unexpected."); } //experience.Salary = match.Result("$3"); match = Regex.Match(match.Result("$1"), @"^\s*((.*?)\s+[|]\s+|)\s*(.*?)\s*$"); // Sample was not found yet. if (match.Success) { //throw new FormatException("Working experience position format was unexpected."); experience.Department = match.Result("$2"); experience.Position = match.Result("$3"); } experience.Department = experience.Department ?? ""; experience.Position = experience.Position ?? ""; // From DeserializeWorkingExperiences/Not-Contains-Salary.html // e.g. 社会科学处 | 助理研究员 // From DeserializeWorkingExperiences/Not-Contains-Department.html // e.g. 网络管理员 // From DeserializeWorkingExperiences/Not-Contains-Position.html while ((node = node.NextSibling)?.Name == "#text") { } if (node == null) { break; } if (node.Name != "div") { throw new FormatException($"Working experience node ({node.Name}) was unexpected."); } // From DeserializeWorkingExperiences/Standard.html // From DeserializeWorkingExperiences/Not-Contains-Nature.html // e.g. 教育/培训/院校 // e.g. 耐用消费品(服饰/纺织/皮革/家具/家电) | 企业性质:民营 // e.g. 房地产/建筑/建材/工程 | 企业性质:民营 | 规模:1000-9999人 foreach (var data in node.InnerText.Split('|')) { match = Regex.Match(data.Trim(), @"^(.+?):(.+?)$"); if (match.Success) { var name = match.Result("$1"); if (name == "规模") { experience.Size = match.Result("$2"); } else if (name == "企业性质") { experience.Nature = match.Result("$2"); } else { throw new FormatException($"Working experience company ({name}) was undefined."); } } else { experience.Industry = data.Trim(); } } experience.Nature = experience.Nature ?? ""; experience.Size = experience.Size ?? ""; experience.Industry = experience.Industry ?? ""; while ((node = node.NextSibling)?.Name == "#text") { } }while (node?.Name == "h2"); if (node == null) { break; } if (node.Name != "div") { throw new FormatException($"Working experience node ({node.Name}) was unexpected."); } //experience.Managements = new List<Management>(); // From DeserializeWorkingExperiences/Standard.html if (node.SelectNodes("table/tr[1]/td[1]") != null) { foreach (var td in node.SelectNodes("table/tr[1]/td[1]")) { var name = td.InnerText.Trim(); if (name == "工作描述:") { experience.Description = td.SelectSingleNode("../td[2]").InnerHtml.Trim(); experience.Description = RemoveHtmlTag(experience.Description); } /*else if (name == "管理经验:") * { * var match = Regex.Match(td.SelectSingleNode("../td[2]").InnerHtml.Trim(), @"^(?s:\s*(.*?)\s*(<br>|)(业绩描述:\s*(.*?)\s*|))$"); * * // Sample was not found yet. * * if (!match.Success) * { * throw new FormatException("Working experience management format was unexpected."); * } * * var management = new Management * { * Achievement = match.Result("$4") * }; * * experience.Managements.Add(management); * * // From DeserializeWorkingExperiences/Standard.html * * var value = match.Result("$1"); * * if (string.IsNullOrEmpty(value)) * { * continue; * } * * var mapping = new Dictionary<string, string> * { * { "汇报对象", null }, * { "下属人数", null }, * { "直接下属", null }, * { "年收入", null } * }; * * foreach (var data in match.Result("$1").Split('|')) * { * match = Regex.Match(data, @"^\s*(.+?):(.+?)\s*$"); * * if (!match.Success) * { * throw new FormatException("Working experience management format was unexpected."); * } * * name = match.Result("$1"); * * if (!mapping.ContainsKey(name)) * { * throw new FormatException($"Working experience management ({name}) was undefined."); * } * * mapping[name] = match.Result("$2"); * } * * // From DeserializeWorkingExperiences/Standard.doc * * management.Leader = mapping["汇报对象"]; * * management.SubordinateCount = mapping["下属人数"]; * * management.SubordinateType = mapping["直接下属"]; * * management.AnnualEarnings = mapping["年收入"]; * } * else * { * throw new FormatException($"Working experience ({name}) was undefined."); * }*/ } } experience.Description = experience.Description ?? ""; } return(experiences); }
public static SourceResume ConvertTo_Dtl_V5(string content) { var dto = new SourceResume(); var source = JsonConvert.DeserializeObject <dynamic>(content); dto.Id = source.resumeNo; var Dtl = JsonConvert.DeserializeObject <dynamic>(source.detialJSonStr.ToString()); if (source.userDetials != null) { dto.Name = source.userDetials.userName; dto.Gender = source.userDetials.gender; dto.MaritalStatus = source.userDetials.maritalStatus; dto.Cellphone = source.userDetials.mobilePhone; dto.Email = source.userDetials.email; dto.Birthday = source.userDetials.birthStr; dto.CurrentResidence = source.userDetials.cityId; dto.RegisteredResidenc = source.userDetials.hUKOUCityId; } else { dto.Name = Dtl.UserMasterName; dto.Gender = Dtl.Gender; dto.MaritalStatus = Dtl.MaritalStatus; dto.Birthday = Dtl.BirthYear; } dto.ResumeId = Dtl.ResumeId; dto.ResumeName = Dtl.Name; dto.UserMasterId = Dtl.UserMasterId; dto.UserMasterExtId = Dtl.UserMasterExtId; dto.ResumeNumber = Dtl.ResumeNumber; dto.WorkStarts = Dtl.WorkYearsRangeId; dto.Degree = Dtl.CurrentEducationLevel; dto.JobStatus = Dtl.DesiredPosition[0].CurrentCareerStatus; dto.Intention = new ResumeIntention(); if (Dtl.DesiredPosition != null && Dtl.DesiredPosition.Count > 0) { dto.Intention.JobType = Dtl.DesiredPosition[0].DesiredEmploymentType; dto.Intention.Salary = Dtl.DesiredPosition[0].DesiredSalaryScope; dto.Intention.Industry = Dtl.DesiredPosition[0].DesiredIndustry; dto.Intention.Function = Dtl.DesiredPosition[0].DesiredJobType; dto.Intention.Location = Dtl.DesiredPosition[0].DesiredCity; } else { dto.Intention.JobType = "默认"; dto.Intention.Salary = "面议"; dto.Intention.Industry = "默认"; dto.Intention.Function = "中国"; dto.Intention.Location = "中国"; } if (Dtl.SelfEvaluate != null && Dtl.SelfEvaluate.Count > 0) { dto.Intention.Evaluation = Dtl.SelfEvaluate[0]?.CommentContent; } else { dto.Intention.Evaluation = ""; } #region 工作经验 if (Dtl.WorkExperience != null && Dtl.WorkExperience.Count > 0) { dto.Works = new List <ResumeWork>(); foreach (var o in Dtl.WorkExperience) { var work = new ResumeWork(); work.Begin = o.DateStart; work.End = o.DateEnd; work.Company = o.CompanyName; work.Industry = o.CompanyIndustry; work.Size = o.CompanySize; work.Nature = o.CompanyProperty; work.Department = o.ResideDepartment; work.Position = o.JobTitle; work.Description = o.WorkDescription; dto.Works.Add(work); } } #endregion #region 项目经验 if (Dtl.ProjectExperience != null && Dtl.ProjectExperience.Count > 0) { dto.Projects = new List <ResumeProject>(); foreach (var o in Dtl.ProjectExperience) { var project = new ResumeProject(); project.Begin = o.DateStart; project.End = o.DateEnd; project.Company = ""; project.Name = o.ProjectName; project.Description = o.ProjectDescription; project.Duty = o.ProjectResponsibility; dto.Projects.Add(project); } } #endregion #region 教育经历 if (Dtl.EducationExperience != null && Dtl.EducationExperience.Count > 0) { dto.Educations = new List <ResumeEducation>(); foreach (var o in Dtl.EducationExperience) { var edu = new ResumeEducation(); edu.Begin = o.DateStart; edu.End = o.DateEnd; edu.School = o.SchoolName; edu.Degree = o.EducationLevel; edu.Description = ""; edu.Major = o.MajorName; dto.Educations.Add(edu); } } #endregion #region 培训经历 if (Dtl.Training != null && Dtl.Training.Count > 0) { dto.Trainings = new List <ResumeTraining>(); foreach (var o in Dtl.Training) { var train = new ResumeTraining(); train.Begin = o.DateStart; train.End = o.DateEnd; train.Course = o.Course; train.Institution = o.Institution; train.Description = o.TrainingDescription; train.Location = o.Location; dto.Trainings.Add(train); } } #endregion #region 技能/语言 if (Dtl.ProfessionnalSkill != null && Dtl.ProfessionnalSkill.Count > 0) { dto.Skills = new List <ResumeSkill>(); foreach (var o in Dtl.ProfessionnalSkill) { var skill = new ResumeSkill { Name = o.SkillName, Level = o.MasterDegree.ToString() + "|" + o.UsedMonths.ToString() + "个月", Description = "" }; dto.Skills.Add(skill); } } if (Dtl.LanguageSkill != null && Dtl.LanguageSkill.Count > 0) { if (dto.Skills == null) { dto.Skills = new List <ResumeSkill>(); } foreach (var o in Dtl.LanguageSkill) { var skill = new ResumeSkill { Name = o.LanguageName, Level = "听说" + o.HearSpeakSkill.ToString() + "|读写" + o.ReadWriteSkill.ToString(), Description = "" }; dto.Skills.Add(skill); } } #endregion #region 证书 if (Dtl.AchieveCertificate != null && Dtl.AchieveCertificate.Count > 0) { dto.Certificates = new List <ResumeCertificate>(); foreach (var o in Dtl.AchieveCertificate) { try { var cert = new ResumeCertificate { Time = Convert.ToDateTime(o.AchieveDate), CertName = o.CertificateName, Description = o.CertificateDescription }; dto.Certificates.Add(cert); } catch { // ignored } } } #endregion #region 校内荣誉 if (Dtl.AchieveAward != null && Dtl.AchieveAward.Count > 0) { dto.Honors = new List <SchoolHonor>(); foreach (var o in Dtl.AchieveAward) { try { var cert = new SchoolHonor { Time = o.AchieveDate, Honor = o.AwardName, Description = o.Description }; dto.Honors.Add(cert); } catch { // ignored } } } #endregion #region 校内实践 if (Dtl.PracticeExperience != null && Dtl.PracticeExperience.Count > 0) { dto.Practices = new List <SchoolPractice>(); foreach (var o in Dtl.PracticeExperience) { try { var cert = new SchoolPractice { Name = o.PracticeName, Begin = o.DateStart, End = o.DateEnd, Description = o.PracticeDescription }; dto.Practices.Add(cert); } catch { // ignored } } } #endregion #region 其他 if (Dtl.Other != null && Dtl.Other.Count > 0) { dto.Others = new List <OtherInfo>(); foreach (var o in Dtl.Other) { try { var cert = new OtherInfo { Title = o.Name, Description = o.Description }; dto.Others.Add(cert); } catch { // ignored } } } #endregion return(dto); }