/// <summary>
        /// 获取所有的校区和城市列表
        /// <para>作     者:Huang GaoLiang  </para>
        /// <para>创建时间: 2019-09-17 </para>
        /// </summary>
        /// <returns>返回校区列表集合</returns>
        public List <SchoolResponse> GetAllSchoolList()
        {
            try
            {
                HrSystem            sys         = new HrSystem();
                List <SchoolData>   schoolDatas = sys.GetSchoolData();
                List <CityResponse> cityList    = GetAllCityList();

                List <SchoolResponse> result = (from s in schoolDatas
                                                join c in cityList on s.CityId equals c.CityId into sc
                                                from cc in sc.DefaultIfEmpty()
                                                select new SchoolResponse
                {
                    CompanyId = s.CompanyId,
                    Company = s.CompanyName,
                    SchoolId = s.Id,
                    SchoolName = s.OrganizationName,
                    CityId = s.CityId,
                    CityName = cc == null ? "" : cc.CityName
                }).ToList();
                return(result);
            }
            catch (Exception e)
            {
                LogWriter.Write("GetSchoolData", $"获取所有的校区{e.Message}", LoggerType.Error);
            }
            return(new List <SchoolResponse>());
        }
        /// <summary>
        /// 获取城市信息
        /// <para> 作     者:Huang GaoLiang  </para>
        /// <para> 创建时间: 2019-09-17 </para>
        /// </summary>
        /// <returns>返回城市列表集合</returns>
        public List <CityResponse> GetAllCityList()
        {
            try
            {
                HrSystem          sys         = new HrSystem();
                List <SchoolData> schoolDatas = sys.GetSchoolData();
                var cityIds = schoolDatas.Select(t => t.CityId.ToString()).ToList();

                AreaSdk         area      = new AreaSdk();
                List <AreaData> areaDatas = area.GetAreaInfos(area.AreaData, cityIds);

                List <CityResponse> cityList = areaDatas.Select(m => new CityResponse
                {
                    CityId   = Convert.ToInt32(m.ID),
                    CityName = m.Name
                }).Distinct().ToList();

                cityList = cityList.Where((x, i) => cityList.FindIndex(z => z.CityId == x.CityId) == i).ToList();
                return(cityList);
            }
            catch (Exception e)
            {
                LogWriter.Write("GetAreaInfos", $"获取城市信息{e.Message}", LoggerType.Error);
            }

            return(new List <CityResponse>());
        }
Beispiel #3
0
class App { // Client
    public static void Main()
    {
        HrSystem hs = new HrSystem();

        hs.Process();
        //...
    }
        public List <SchoolEmployeeResponse> GetBySchoolId()
        {
            List <SchoolEmployeeResponse> res = new List <SchoolEmployeeResponse>();

            try
            {
                res = new HrSystem()
                      .GetPersonnelDataByCompanyId(new List <string>())
                      .Where(x => x.DepartmentInfo.OrgId == _schoolId)
                      .Select(m => new SchoolEmployeeResponse
                {
                    EmployeeId   = m.UserId,
                    EmployeeName = m.UserName,
                    Status       = m.Status,
                })
                      .ToList();
            }
            catch (Exception e)
            {
                base.AntWriteLog("PersonalService->GetBySchoolId", "根据校区下的人员信息", "YMM.HRS.SDK", e.Message, e);
                throw new ApplicationException("人员信息获取失败");
            }

            return(res);
        }
        public static SchoolEmployeeResponse GetByEmployeeId(string uId)
        {
            SchoolEmployeeResponse res = null;

            try
            {
                res = new HrSystem()
                      .GetPersonnelDataByPersonnelId(new List <string> {
                    uId
                })
                      .Select(m => new SchoolEmployeeResponse
                {
                    EmployeeId   = m.UserId,
                    EmployeeName = m.UserName,
                    Status       = m.Status
                })
                      .FirstOrDefault();
            }
            catch (Exception e)
            {
                RequestLog("PersonalService->GetByEmployeeId", "YMM.HRS.SDK 人员信息获取失败", e.Message, e);
                throw new ApplicationException("人员信息获取失败");
            }

            return(res);
        }
        public List <PersonnelOfDeptData> GetPersonnelOfDeptData()
        {
            HrSystem hrSystem = new HrSystem();

            //未知查询条件,查询所有转换再处理
            var personList = hrSystem.GetPersonnelDataByCompanyId(new List <string>());


            return(personList);
        }
        /// <summary>
        /// 获取人事系统所有人员信息进行转换
        /// <para>作    者:zhiwei.Tang</para>
        /// <para>创建时间:2019-01-14</para>
        /// </summary>
        /// <returns>人员信息列表</returns>
        private static List <EmployeeInfo> GetAllConvertEmployee()
        {
            HrSystem hrSystem = new HrSystem();

            try
            {
                //未知查询条件,查询所有转换再处理
                var personList = hrSystem.GetPersonnelDataByCompanyId(new List <string>());

                //当人员记录数为0时记录日记,以便跟踪
                if (personList == null || personList.Count <= 0)
                {
                    RequestLog("EmployeeService->GetAllConvertEmployee", $"YMM.HRS.SDK.HrSystem 人员信息获为0条", "", null);
                }

                var result = personList.Select(x => new EmployeeInfo
                {
                    BirthDate      = x.BirthDate,
                    CheckStatus    = x.CheckStatus,
                    CityId         = x.DepartmentInfo.CityId,
                    Company        = x.DepartmentInfo.Company,
                    CompanyId      = x.DepartmentInfo.CompanyId,
                    DeptId         = x.DepartmentInfo.DeptId,
                    DeptName       = x.DepartmentInfo.DeptName,
                    Email          = x.Email,
                    EmployeeId     = x.UserId,
                    EmployeeName   = x.UserName,
                    HeadPic        = x.HeadPic,
                    IdentityCardNo = x.IdentityCardNo,
                    Mobile         = x.Mobile,
                    Number         = x.Number,
                    OrgId          = x.DepartmentInfo.OrgId,
                    OrgName        = x.DepartmentInfo.OrgName,
                    PositionId     = x.DepartmentInfo.PositionId,
                    PositionName   = x.DepartmentInfo.PositionName,
                    SchoolSno      = x.DepartmentInfo.SchoolSno,
                    Sex            = x.Sex,
                    Status         = x.Status,
                    UserSno        = x.UserSno,
                    Watermark      = x.Watermark,
                    LeaveDate      = x.LeaveDate
                }).ToList();

                return(result);
            }
            catch (Exception ex)
            {
                RequestLog("EmployeeService->GetAllConvertEmployee", "YMM.HRS.SDK.HrSystem 人员信息获取失败", ex.Message, ex);
                throw new ApplicationException("人员信息获取失败");
            }
        }
        /// <summary>
        /// 根据组织架构获取用户信息
        /// by:Huang GaoLiang 2018年11月1日
        /// </summary>
        /// <param name="userId">当前操作人编号</param>
        /// <returns></returns>
        public List <EmployeeInfo> GetSchoolEmployeeByCompanyId(string userId = null)
        {
            List <EmployeeInfo> employeeList = new List <EmployeeInfo>();

            if (string.IsNullOrWhiteSpace(_schoolId))
            {
                return(employeeList);
            }
            try
            {
                List <string> schoolIds = new List <string>
                {
                    _schoolId
                };
                HrSystem      rr = new HrSystem();
                List <string> s  = new List <string>();
                List <PersonnelOfDeptData> res = rr.GetPersonnelDataByCompanyId(s);

                foreach (PersonnelOfDeptData item in res)
                {
                    if (!schoolIds.Contains(item.DepartmentInfo.OrgId))
                    {
                        continue;
                    }
                    EmployeeInfo info = new EmployeeInfo();

                    info.CompanyId    = item.DepartmentInfo.CompanyId;
                    info.Company      = item.DepartmentInfo.Company;
                    info.EmployeeId   = item.UserId;
                    info.EmployeeName = item.UserName;
                    info.Status       = item.Status;
                    employeeList.Add(info);
                }
            }
            catch (Exception e)
            {
                base.AntWriteLog("GetPersonnelDataByCompanyId", "根据组织架构获取用户信息", "", e.Message, e);
            }

            employeeList = employeeList.Where((x, i) => employeeList.FindIndex(z => z.EmployeeId == x.EmployeeId) == i).ToList();
            return(employeeList);
        }
        /// <summary>
        /// 获取人员信息
        /// </summary>
        /// <returns></returns>
        public static List <SchoolEmployeeResponse> GetAll()
        {
            List <SchoolEmployeeResponse> res = new List <SchoolEmployeeResponse>();

            try
            {
                res = new HrSystem()
                      .GetPersonnelDataByCompanyId(new List <string>())
                      .Select(m => new SchoolEmployeeResponse
                {
                    EmployeeId   = m.UserId,
                    EmployeeName = m.UserName,
                    Status       = m.Status,
                })
                      .ToList();
            }
            catch (Exception e)
            {
                RequestLog("PersonalService->GetAll", "YMM.HRS.SDK 人员信息获取失败", e.Message, e);
                throw new ApplicationException("人员信息获取失败");
            }

            return(res);
        }