Ejemplo n.º 1
0
        public JsonResult UserLogin(string account = "", string password = "", string companyName = "")
        {
            var company = companyDb.GetCompanyByCompanyCode(companyName);

            if (company == null)
            {
                return(Json(new { result = 0, msg = "公司、用户名或密码错误!" }, JsonRequestBehavior.AllowGet));
            }
            CurrentCompany            = company;
            CurrentUserConnectionInfo = new ApplicationCommon().GetUserDBConnection(company);
            userDb = new UserDb(CurrentUserConnectionInfo);
            var user = userDb.GetUserByUsername(account);

            if (user == null)
            {
                return(Json(new { result = 0, msg = "公司、用户名或密码错误!" }, JsonRequestBehavior.AllowGet));
            }
            if (!user.password.Trim().Equals(password.GetMd5(2), StringComparison.CurrentCultureIgnoreCase))
            {
                return(Json(new { result = 0, msg = "公司、用户名或密码错误!" }, JsonRequestBehavior.AllowGet));
            }
            if (user.status == 2)
            {
                return(Json(new { result = 0, msg = "账户已被冻结!" }, JsonRequestBehavior.AllowGet));
            }
            CurrentUser = user;
            return(Json(new { result = 1, msg = "" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 验证token是否存在
 /// </summary>
 /// <param name="token"></param>
 /// <returns></returns>
 public bool VerifyToken(string token)
 {
     try
     {
         token = token.Replace("[", "=");
         var    arry          = token.Split(';');
         var    userName      = "";
         var    password      = "";
         var    companyName   = "";
         byte[] userNameBytes = Convert.FromBase64String(arry[0]);
         userName = System.Text.Encoding.Default.GetString(userNameBytes);
         byte[] passwdBytes = Convert.FromBase64String(arry[1]);
         password = System.Text.Encoding.Default.GetString(passwdBytes);
         byte[] companyNameBytes = Convert.FromBase64String(arry[2]);
         companyName = System.Text.Encoding.Default.GetString(companyNameBytes);
         var company = companyDb.GetCompanyById(companyName);
         if (company == null)
         {
             return(false);
         }
         var currentUserConnectionInfo = new ApplicationCommon().GetUserDBConnection(company);
         userDb = new UserDb(currentUserConnectionInfo);
         var user = userDb.GetUserByUsername(userName);
         if (user == null)
         {
             return(false);
         }
         if (!user.password.Trim().Equals(password.GetMd5(2), StringComparison.CurrentCultureIgnoreCase))
         {
             return(false);
         }
         if (user.status == 2)
         {
             return(false);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public string UserLogin([FromBody] LoginModel loginData)
        {
            string companyName = loginData.companyName;
            string userName    = loginData.employeeNo;
            string password    = loginData.password;
            var    apiReturn   = new ApiReturn();
            var    company     = companyDb.GetCompanyByCompanyCode(companyName);

            if (company == null)
            {
                apiReturn.Flag   = 1;
                apiReturn.Result = "公司、用户名或密码错误!";
                return(JsonConvert.SerializeObject(apiReturn));
            }
            var currentUserConnectionInfo = new ApplicationCommon().GetUserDBConnection(company);

            userDb = new UserDb(currentUserConnectionInfo);
            var user = userDb.GetUserByUsername(userName);

            if (user == null)
            {
                apiReturn.Flag   = 1;
                apiReturn.Result = "公司、用户名或密码错误!";
                return(JsonConvert.SerializeObject(apiReturn));
            }
            if (!user.password.Trim().Equals(password.GetMd5(2), StringComparison.CurrentCultureIgnoreCase))
            {
                apiReturn.Flag   = 1;
                apiReturn.Result = "公司、用户名或密码错误!";
                return(JsonConvert.SerializeObject(apiReturn));
            }
            if (user.status == 2)
            {
                apiReturn.Flag   = 1;
                apiReturn.Result = "账户被冻结!";
                return(JsonConvert.SerializeObject(apiReturn));
            }
            apiReturn.Flag   = 0;
            apiReturn.Result = company.company_id;
            return(JsonConvert.SerializeObject(apiReturn));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 检查用户名重命名
        /// </summary>
        /// <param name="param"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public JsonResult CheckUserName(string param, string userId)
        {
            userDb = new UserDb(CurrentUserConnectionInfo);
            var user   = userDb.GetUserByUsername(param);
            var result = true;

            if (user == null)
            {
                result = false;
            }
            else
            {
                if (user.user_id == userId)
                {
                    result = false;
                }
            }
            var status = result ? "n" : "y";
            var info   = result ? "用户名已存在" : "";

            return(Json(new { status, info }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public string ResumeSearch(ResumeSearchEntity entity)
        {
            var reponseJson  = string.Empty;
            var jsSerializer = new JavaScriptSerializer();

            try
            {
                entity.EmployeeNo = string.IsNullOrEmpty(entity.EmployeeNo) ? "" : entity.EmployeeNo.Trim();
                if (string.IsNullOrEmpty(entity.EmployeeNo))
                {
                    return(jsSerializer.Serialize(new { Falg = 1, Info = "请登录", Result = "[]" }));
                }

                var company = companyDb.GetCompanyById(new TokenManage().GetCompanyId(entity.token));
                if (company == null)
                {
                    reponseJson = jsSerializer.Serialize(new { Flag = 4, Info = "公司不存在", Result = "[]" });
                    return(reponseJson);
                }

                resumeDb = new ResumeDb(new ApplicationCommon().GetUserDBConnection(company));
                userDb   = new UserDb(new ApplicationCommon().GetUserDBConnection(company));

                var user = userDb.GetUserByUsername(new TokenManage().GetUserName(entity.token));
                if (user == null)
                {
                    reponseJson = jsSerializer.Serialize(new { Flag = 4, Info = "该账号不存在", Result = "[]" });
                    return(reponseJson);
                }


                entity.Birth                   = string.IsNullOrEmpty(entity.Birth) ? "" : entity.Birth.Trim();
                entity.Sex                     = string.IsNullOrEmpty(entity.Sex) ? "" : entity.Sex.Trim();
                entity.School                  = string.IsNullOrEmpty(entity.School) ? "" : entity.School.Trim();
                entity.CompanyAll              = entity.Company;
                entity.Company                 = string.IsNullOrEmpty(entity.Company) ? "" : Regex.Replace(entity.Company.Trim(), "有限|责任|公司|分公司|股份|集团|工作室|技术|软件|计算机|信息|科技|网络|系统", "");
                entity.ExtId                   = string.IsNullOrEmpty(entity.ExtId) ? "" : entity.ExtId.Trim();
                entity.SiteCode                = string.IsNullOrEmpty(entity.SiteCode) ? "" : entity.SiteCode.Trim();
                entity.CandidateName           = string.IsNullOrEmpty(entity.CandidateName) ? "" : entity.CandidateName.Trim();
                entity.Email                   = string.IsNullOrEmpty(entity.Email) ? "" : entity.Email.Trim();
                entity.Mobile                  = string.IsNullOrEmpty(entity.Mobile) ? "" : entity.Mobile.Trim();
                entity.MobileLast              = string.IsNullOrEmpty(entity.MobileLast) ? "" : entity.MobileLast.Trim();
                entity.GraduateYear            = string.IsNullOrEmpty(entity.GraduateYear) ? "" : entity.GraduateYear.Trim();
                entity.Cities                  = string.IsNullOrEmpty(entity.Cities) ? "" : entity.Cities.Trim();
                entity.Registry                = string.IsNullOrEmpty(entity.Registry) ? "" : entity.Registry.Trim();
                entity.ExtraDatas.UserName     = string.IsNullOrEmpty(entity.ExtraDatas.UserName) ? "" : entity.ExtraDatas.UserName.Trim();
                entity.ExtraDatas.HidResumeId  = string.IsNullOrEmpty(entity.ExtraDatas.HidResumeId) ? "" : entity.ExtraDatas.HidResumeId.Trim();
                entity.ExtraDatas.ResumeUserId = string.IsNullOrEmpty(entity.ExtraDatas.ResumeUserId) ? "" : entity.ExtraDatas.ResumeUserId.Trim();
                SiteEnum site = (SiteEnum)Convert.ToInt32(entity.SiteCode);

                List <SearchReturnEntity> returnResult = SearchResumeBaseFunction(entity);
                if (returnResult.Count == 0)
                {
                    reponseJson = jsSerializer.Serialize(new { Flag = (entity.SearchType == 0 ? 0 : 2), Info = string.Empty, Result = "[]" });
                    return(reponseJson);
                }
                if (entity.SearchType == 0)
                {
                    returnResult.ForEach(r => r.CanUpdate = false);
                }
                //var result = returnResult.Where(p => p.Score > 0f);
                reponseJson = jsSerializer.Serialize(new { Flag = 0, Info = string.Empty, Result = returnResult });
                return(reponseJson);
            }
            catch (Exception ex)
            {
                reponseJson = jsSerializer.Serialize(new { Flag = 2, Info = ex.Message, Result = "[]" });//搜索异常
                return(reponseJson);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 简历结构化入库(新增或更新具体方法)
        /// </summary>
        /// <param name="structuredResumeModel"></param>
        /// <param name="username"></param>
        /// <param name="companyId"></param>
        /// <param name="flag"></param>
        /// <param name="resumeOldId"></param>
        /// <param name="importFrom"></param>
        /// <returns></returns>
        public StoreResult AddOrUpdateResume(StructuredResumeModel structuredResumeModel, string username, string companyId, int flag,
                                             string resumeOldId = "", int importFrom = 0)
        {
            StoreResult result  = new StoreResult();
            var         company = companyDb.GetCompanyById(companyId);

            if (company == null)
            {
                result.Flag    = 4;
                result.Message = "公司不存在";
                return(result);
            }

            resumeDb = new ResumeDb(new ApplicationCommon().GetUserDBConnection(company));
            userDb   = new UserDb(new ApplicationCommon().GetUserDBConnection(company));

            var user = userDb.GetUserByUsername(username);

            if (user == null)
            {
                result.Flag    = 4;
                result.Message = "该账号不存在";
                return(result);
            }

            //简历基础表
            var resumeModel = new ResumeModel();

            resumeModel.account          = structuredResumeModel.basic.account;
            resumeModel.account_province = structuredResumeModel.basic.account_province;
            resumeModel.address          = structuredResumeModel.basic.address;
            resumeModel.address_province = structuredResumeModel.basic.address;
            resumeModel.age = structuredResumeModel.basic.age.ToString();
            if (!string.IsNullOrWhiteSpace(structuredResumeModel.basic.birth))
            {
                var birthArrary = structuredResumeModel.basic.birth.Split('-');
                if (birthArrary.Length == 1)
                {
                    resumeModel.birth = Convert.ToDateTime(structuredResumeModel.basic.birth + "-1-1");
                }
                else if (birthArrary.Length == 2)
                {
                    resumeModel.birth = Convert.ToDateTime(structuredResumeModel.basic.birth + "-1");
                }
                else
                {
                    resumeModel.birth = Convert.ToDateTime(structuredResumeModel.basic.birth);
                }
            }
            resumeModel.can_buy                   = "1";
            resumeModel.company_id                = companyId;
            resumeModel.resume_id                 = flag == 1 ? resumeOldId : Guid.NewGuid().ToString();
            resumeModel.import_from               = importFrom;
            resumeModel.import_type               = Convert.ToInt32(structuredResumeModel.importType);
            resumeModel.created_by                = user.user_id;
            resumeModel.created_time              = DateTime.Now;
            resumeModel.current_salary            = structuredResumeModel.basic.current_salary;
            resumeModel.current_status            = structuredResumeModel.basic.current_status;
            resumeModel.degree                    = structuredResumeModel.basic.degree;
            resumeModel.email                     = structuredResumeModel.contact.email;
            resumeModel.expect_annual_salary_from = structuredResumeModel.basic.expect_annual_salary_from;
            resumeModel.expect_annual_salary_to   = structuredResumeModel.basic.expect_annual_salary_to;
            resumeModel.expect_bonus              = structuredResumeModel.basic.expect_bonus;
            resumeModel.expect_city_ids           = structuredResumeModel.basic.expect_city_ids;
            resumeModel.expect_industry_name      = structuredResumeModel.basic.expect_industry_name;
            resumeModel.expect_position_name      = structuredResumeModel.basic.expect_position_name;
            resumeModel.expect_salary_from        = structuredResumeModel.basic.expect_salary_from;
            resumeModel.expect_salary_month       = structuredResumeModel.basic.expect_salary_month;
            resumeModel.expect_salary_to          = structuredResumeModel.basic.expect_salary_to;
            resumeModel.expect_type               = structuredResumeModel.basic.expect_type;
            resumeModel.expect_work_at            = structuredResumeModel.basic.expect_work_at;
            resumeModel.gender                    = structuredResumeModel.basic.gender;
            resumeModel.graduate_date             = structuredResumeModel.basic.graduate_date;
            resumeModel.htmlContent               = structuredResumeModel.htmlContent;
            resumeModel.interests                 = structuredResumeModel.basic.interests;
            resumeModel.is_fertility              = structuredResumeModel.basic.is_fertility;
            resumeModel.is_house                  = structuredResumeModel.basic.is_house;
            resumeModel.last_updated_by           = user.user_id;
            resumeModel.last_updated_time         = resumeModel.created_time;
            resumeModel.live_family               = structuredResumeModel.basic.live_family;
            resumeModel.marital                   = structuredResumeModel.basic.marital;
            resumeModel.msn              = structuredResumeModel.contact.msn;
            resumeModel.name             = structuredResumeModel.basic.name;
            resumeModel.nation           = structuredResumeModel.basic.nation;
            resumeModel.noHtmlContent    = structuredResumeModel.noHtmlContent;
            resumeModel.other_info       = structuredResumeModel.basic.other_info;
            resumeModel.overseas         = structuredResumeModel.basic.overseas;
            resumeModel.phone            = structuredResumeModel.contact.phone;
            resumeModel.photo            = structuredResumeModel.basic.photo;
            resumeModel.political_status = structuredResumeModel.basic.political_status;
            resumeModel.qq                = structuredResumeModel.contact.qq;
            resumeModel.resume_hideId     = structuredResumeModel.basic.hidId;
            resumeModel.resume_orginalId  = structuredResumeModel.basic.id;
            resumeModel.resume_status     = 0;
            resumeModel.resume_updated_at = string.IsNullOrWhiteSpace(structuredResumeModel.update_info.updated_at)
                ? (DateTime?)null
                : Convert.ToDateTime(structuredResumeModel.update_info.updated_at);
            resumeModel.resume_userId = structuredResumeModel.basic.resumeUserId;
            resumeModel.school        = structuredResumeModel.basic.school;
            resumeModel.self_remark   = structuredResumeModel.basic.self_remark;
            resumeModel.sina          = structuredResumeModel.contact.sina;
            if (structuredResumeModel.src != null)
            {
                var srcString = "";
                for (int i = 0; i < structuredResumeModel.src.Length; i++)
                {
                    srcString = srcString == ""
                        ? structuredResumeModel.src[i].ToString()
                        : ("," + structuredResumeModel.src[i].ToString());
                }
                resumeModel.src = srcString;
            }
            else
            {
                resumeModel.src = "-1";
            }
            resumeModel.tel             = structuredResumeModel.contact.tel;
            resumeModel.ten             = structuredResumeModel.contact.ten;
            resumeModel.wechat          = structuredResumeModel.contact.wechat;
            resumeModel.work_experience = structuredResumeModel.basic.work_experience;

            //简历证书
            var certificateList = new List <ResumeCertificateModel>();

            if (structuredResumeModel.certificate != null)
            {
                foreach (var cerInfo in structuredResumeModel.certificate)
                {
                    var certificateTemp = new ResumeCertificateModel();
                    certificateTemp.description = cerInfo.description;
                    certificateTemp.name        = cerInfo.name;
                    certificateTemp.resume_id   = resumeModel.resume_id;
                    certificateTemp.start_time  = cerInfo.start_time;
                    certificateList.Add(certificateTemp);
                }
            }

            //简历教育经历
            var educationList = new List <ResumeEducationModel>();

            if (structuredResumeModel.education != null)
            {
                foreach (var eduInfo in structuredResumeModel.education)
                {
                    var educationTemp = new ResumeEducationModel();
                    educationTemp.degree          = eduInfo.degree;
                    educationTemp.discipline_desc = eduInfo.discipline_desc;
                    educationTemp.discipline_name = eduInfo.discipline_name;
                    educationTemp.end_time        = eduInfo.end_time;
                    educationTemp.is_entrance     = eduInfo.is_entrance;
                    educationTemp.resume_id       = resumeModel.resume_id;
                    educationTemp.school_name     = eduInfo.school_name;
                    educationTemp.so_far          = eduInfo.so_far;
                    educationTemp.start_time      = eduInfo.start_time;
                    educationList.Add(educationTemp);
                }
            }

            //简历语言
            var languageList = new List <ResumeLanguageModel>();

            if (structuredResumeModel.language != null)
            {
                foreach (var lanInfo in structuredResumeModel.language)
                {
                    var languageTemp = new ResumeLanguageModel();
                    languageTemp.certificate = lanInfo.certificate;
                    languageTemp.level       = lanInfo.level;
                    languageTemp.name        = lanInfo.name;
                    languageTemp.resume_id   = resumeModel.resume_id;
                    languageList.Add(languageTemp);
                }
            }

            //项目经验
            var projectList = new List <ResumeProjectModel>();

            if (structuredResumeModel.project != null)
            {
                foreach (var proInfo in structuredResumeModel.project)
                {
                    var projectTemp = new ResumeProjectModel();
                    projectTemp.describe         = proInfo.describe;
                    projectTemp.develop_tool     = proInfo.develop_tool;
                    projectTemp.end_time         = proInfo.end_time;
                    projectTemp.hard_env         = proInfo.hard_env;
                    projectTemp.name             = proInfo.name;
                    projectTemp.responsibilities = proInfo.responsibilities;
                    projectTemp.resume_id        = resumeModel.resume_id;
                    projectTemp.so_far           = proInfo.so_far;
                    projectTemp.soft_env         = proInfo.soft_env;
                    projectTemp.start_time       = proInfo.start_time;
                    projectList.Add(projectTemp);
                }
            }

            //技能信息
            var skillList = new List <ResumeSkillModel>();

            if (structuredResumeModel.skill != null)
            {
                foreach (var skiInfo in structuredResumeModel.skill)
                {
                    var skillTemp = new ResumeSkillModel();
                    skillTemp.level     = skiInfo.level;
                    skillTemp.name      = skiInfo.name;
                    skillTemp.period    = skiInfo.period;
                    skillTemp.resume_id = resumeModel.resume_id;
                    skillList.Add(skillTemp);
                }
            }

            //培训信息
            var trainList = new List <ResumeTrainingModel>();

            if (structuredResumeModel.training != null)
            {
                foreach (var traInfo in structuredResumeModel.training)
                {
                    var trainTemp = new ResumeTrainingModel();
                    trainTemp.authority   = traInfo.authority;
                    trainTemp.certificate = traInfo.certificate;
                    trainTemp.city        = traInfo.city;
                    trainTemp.description = traInfo.description;
                    trainTemp.end_time    = traInfo.end_time;
                    trainTemp.name        = traInfo.name;
                    trainTemp.resume_id   = resumeModel.resume_id;
                    trainTemp.so_far      = traInfo.so_far;
                    trainTemp.start_time  = traInfo.start_time;
                    trainList.Add(trainTemp);
                }
            }

            //工作经验
            var workList = new List <ResumeWorkExperienceModel>();

            if (structuredResumeModel.work != null)
            {
                foreach (var workInfo in structuredResumeModel.work)
                {
                    var workTemp = new ResumeWorkExperienceModel();
                    workTemp.annual_salary_from = workInfo.annual_salary_from;
                    workTemp.annual_salary_to   = workInfo.annual_salary_to;
                    workTemp.architecture_name  = workInfo.architecture_name;
                    workTemp.basic_salary_from  = workInfo.basic_salary_from;
                    workTemp.basic_salary_to    = workInfo.basic_salary_to;
                    workTemp.bonus                 = workInfo.bonus;
                    workTemp.city                  = workInfo.city;
                    workTemp.corporation_desc      = workInfo.corporation_desc;
                    workTemp.corporation_name      = workInfo.corporation_name;
                    workTemp.corporation_type      = workInfo.corporation_type;
                    workTemp.end_time              = workInfo.end_time;
                    workTemp.industry_name         = workInfo.industry_name;
                    workTemp.management_experience = workInfo.management_experience;
                    workTemp.position_name         = workInfo.position_name;
                    workTemp.reporting_to          = workInfo.reporting_to;
                    workTemp.responsibilities      = workInfo.responsibilities;
                    workTemp.resume_id             = resumeModel.resume_id;
                    workTemp.salary_month          = workInfo.salary_month;
                    workTemp.scale                 = workInfo.scale;
                    workTemp.so_far                = workInfo.so_far;
                    workTemp.start_time            = workInfo.salary_month;
                    workTemp.station_name          = workInfo.station_name;
                    workTemp.subordinates_count    = workInfo.subordinates_count;
                    workList.Add(workTemp);
                }
            }

            if (flag == 1)
            {
                if (string.IsNullOrEmpty(resumeOldId))
                {
                    result.Flag    = 4;
                    result.Message = "简历不存在";
                    return(result);
                }
                else
                {
                    var oldResume = resumeDb.GetResumeById(resumeOldId);
                    if (oldResume == null)
                    {
                        result.Flag    = 4;
                        result.Message = "简历不存在";
                        return(result);
                    }
                    resumeModel.created_by        = oldResume.created_by;
                    resumeModel.created_time      = oldResume.created_time;
                    resumeModel.last_updated_time = DateTime.Now;
                    if (oldResume.last_updated_time.Value.AddDays(14) > resumeModel.last_updated_time.Value)
                    {
                        result.Flag     = 3;
                        result.Message  = "重复简历更新时间在两周内,无法覆盖";
                        result.ResumeId = resumeModel.resume_id;
                        return(result);
                    }
                    if (string.IsNullOrEmpty(resumeModel.name))
                    {
                        result.Flag    = 1;
                        result.Message = "姓名不能为空";
                        return(result);
                    }
                    if (string.IsNullOrEmpty(resumeModel.phone) && string.IsNullOrEmpty(resumeModel.email))
                    {
                        result.Flag    = 2;
                        result.Message = "手机和邮箱为空或格式错误";
                        return(result);
                    }
                    var dbReturn = resumeDb.UpdateResumeDetails(resumeModel, certificateList, educationList,
                                                                languageList, projectList, skillList, trainList, workList);
                    if (dbReturn)
                    {
                        result.Flag     = 0;
                        result.ResumeId = resumeModel.resume_id;
                        result.Message  = "简历覆盖成功";
                        return(result);
                    }
                    else
                    {
                        result.Flag    = 5;
                        result.Message = "异常";
                        return(result);
                    }
                }
            }
            else
            {
                var returnVal = resumeDb.InsertResumeDetails(resumeModel, certificateList, educationList,
                                                             languageList, projectList, skillList, trainList, workList);
                if (returnVal)
                {
                    return(result);
                }
                else
                {
                    result.Flag    = 5;
                    result.Message = "异常";
                    return(result);
                }
            }
        }