1015 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1015 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C#
		
	
	
	
| using FineUIPro;
 | |
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 人员信息
 | |
|     /// </summary>
 | |
|     public static class PersonService
 | |
|     {
 | |
|         public static Model.SGGLDB db = Funs.DB;
 | |
| 
 | |
|         #region 劳务人员列表
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count2
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 定义变量
 | |
|         /// </summary>
 | |
|         private static IQueryable<Model.View_SitePerson_Person> getDataLists = from x in db.View_SitePerson_Person
 | |
|                                                                                select x;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 数据列表
 | |
|         /// </summary>
 | |
|         /// <param name="projetcId"></param>
 | |
|         /// <param name="unitId"></param>
 | |
|         /// <param name="workPostId"></param>
 | |
|         /// <param name="name"></param>
 | |
|         /// <param name="idCard"></param>
 | |
|         /// <param name="states"></param>
 | |
|         /// <param name="Grid1"></param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable getListData(string projetcId, string unitId, string workPostId, string name, string idCard, string states, Grid Grid1)
 | |
|         {
 | |
|             IQueryable<Model.View_SitePerson_Person> getDataList = getDataLists.OrderBy(x => x.ProjectId).ThenBy(x => x.UnitId);
 | |
|             if (!string.IsNullOrEmpty(projetcId) && projetcId != Const._Null)
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.ProjectId == projetcId);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.UnitId == unitId);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null)
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.WorkPostId == workPostId);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(states) && states != "-2")
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.IsUsed == Convert.ToBoolean(states));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(name))
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.PersonName.Contains(name));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(idCard))
 | |
|             {
 | |
|                 getDataList = getDataList.Where(e => e.IdentityCard.Contains(idCard));
 | |
|             }
 | |
|             count2 = getDataList.Count();
 | |
|             if (count2 == 0)
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|             getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
 | |
|             return from x in getDataList
 | |
|                    select new
 | |
|                    {
 | |
|                        x.PersonId,
 | |
|                        x.PersonName,
 | |
|                        x.CardNo,
 | |
|                        x.IdentityCard,
 | |
|                        x.Sex,
 | |
|                        x.SexName,
 | |
|                        x.UnitId,
 | |
|                        x.UnitName,
 | |
|                        x.WorkPostId,
 | |
|                        x.WorkPostName,
 | |
|                        x.ProjectId,
 | |
|                        ProjectName = db.Base_Project.First(u => u.ProjectId == x.ProjectId).ProjectName,
 | |
|                        ShortName = db.Base_Project.First(u => u.ProjectId == x.ProjectId).ShortName,
 | |
|                        NativePlace = x.CountryName ?? "" + x.ProvinceName ?? "",
 | |
|                        x.TeamGroupId,
 | |
|                        x.TeamGroupName,
 | |
|                        x.InTime,
 | |
|                        x.OutTime,
 | |
|                        x.IsUsed,
 | |
|                        OutName = (x.IsUsed == false ? "是" : "否"),
 | |
|                    };
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 获取列表
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 定义变量
 | |
|         /// </summary>
 | |
|         private static IQueryable<Model.View_SitePerson_Person> getPersonLists = from x in db.View_SitePerson_Person select x;
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="PageIndex">页码</param>
 | |
|         /// <param name="PageSize">每页数量</param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable getListData(string projectId, string unitId, string personName, string identityCard, string treamGroupId, string workPostIds,
 | |
|                     bool ckTrain, string postType, bool ckJT, bool ckIdCardInfoNotOK, bool chManager, bool isHsse, bool isCQMS, Grid Grid1,bool isBlack=false)
 | |
|         {
 | |
|             IQueryable<Model.View_SitePerson_Person> getPersonList = getPersonLists.Where(x => x.ProjectId == projectId);
 | |
|             if (!string.IsNullOrEmpty(unitId))
 | |
|             {
 | |
|                 if (unitId == "0")
 | |
|                 {
 | |
|                     getPersonList = getPersonList.Where(x => x.UnitId == null);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     getPersonList = getPersonList.Where(x => x.UnitId == unitId);
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             if (isBlack == false)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsBlacklist != true || x.IsBlacklist == null);
 | |
|             }
 | |
|             else {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsBlacklist == true);
 | |
|             }
 | |
|             
 | |
|             if (!string.IsNullOrEmpty(personName))
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.PersonName.Contains(personName));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(identityCard))
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IdentityCard.Contains(identityCard));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(treamGroupId) && treamGroupId != Const._Null)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.TeamGroupId == treamGroupId);
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(workPostIds))
 | |
|             {
 | |
|                 List<string> wIds = Funs.GetStrListByStr(workPostIds, ',');
 | |
|                 getPersonList = getPersonList.Where(x => wIds.Contains(x.WorkPostId));
 | |
|             }
 | |
|             if (ckTrain)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.TrainCount == 0);
 | |
|             }
 | |
|             if (postType == "0")
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsUsed == false || x.InTime.Value > DateTime.Now
 | |
|                                 || (x.OutTime.HasValue && x.OutTime < DateTime.Now));
 | |
|             }
 | |
|             else if (postType == "1")
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime.Value > DateTime.Now));
 | |
|             }
 | |
| 
 | |
|             if (ckJT)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.RealNameAddTime == null);
 | |
|             }
 | |
|             if (chManager)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.PostType == Const.PostType_1);
 | |
|             }
 | |
|             if (isHsse == true)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsHsse == true);
 | |
|             }
 | |
|             if (isCQMS == true)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IsCQMS == true);
 | |
|             }
 | |
|             if (ckIdCardInfoNotOK)
 | |
|             {
 | |
|                 getPersonList = getPersonList.Where(x => x.IdentityCard == null || x.HeadImage == null || (x.IdentityCard.Length != 15 && x.IdentityCard.Length != 18));
 | |
|             }
 | |
|             count = getPersonList.Count();
 | |
|             if (count == 0)
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
| 
 | |
|             getPersonList = SortConditionHelper.SortingAndPaging(getPersonList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
 | |
|             return from x in getPersonList
 | |
|                    select new
 | |
|                    {
 | |
|                        x.PersonId,
 | |
|                        x.CardNo,
 | |
|                        x.PersonName,
 | |
|                        x.WorkPostName,
 | |
|                        x.UnitName,
 | |
|                        x.IdentityCard,
 | |
|                        x.TeamGroupName,
 | |
|                        x.InTime,
 | |
|                        x.OutTime,
 | |
|                        PersonState = getPersonState(x.IsUsed, x.AuditorDate, x.InTime, x.OutTime),
 | |
|                    };
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static string getPersonState(bool isUsed, DateTime? auditorDate, DateTime? inTime, DateTime? outTime)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             if (isUsed == false && !auditorDate.HasValue)
 | |
|             {
 | |
|                 name = "在审";
 | |
|             }
 | |
|             else if (isUsed == true && inTime <= DateTime.Now && (!outTime.HasValue || outTime >= DateTime.Now))
 | |
|             {
 | |
|                 name = "在岗";
 | |
|             }
 | |
|             else if (isUsed == true && outTime.HasValue && outTime <= DateTime.Now)
 | |
|             {
 | |
|                 name = "离岗";
 | |
|             }
 | |
|             else if (isUsed == false && auditorDate.HasValue)
 | |
|             {
 | |
|                 name = "打回";
 | |
|             }
 | |
| 
 | |
|             return name;
 | |
|             ////在审
 | |
|             //int count0 = getViews.Where(x => x.IsUsed == false && !x.AuditorDate.HasValue).Count();
 | |
|             ////在岗
 | |
|             //int count1 = getViews.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)).Count();
 | |
|             ////离岗
 | |
|             //int count2 = getViews.Where(x => x.IsUsed == true && x.OutTime <= DateTime.Now).Count();
 | |
|             ////打回
 | |
|             //int count3 = getViews.Where(x => x.IsUsed == false && x.AuditorDate.HasValue).Count();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.SitePerson_Person GetPersonById(string personId)
 | |
|         {
 | |
|             return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据主键获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static string GetPersonNameById(string personId)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             var getp = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
 | |
|             if (getp != null)
 | |
|             {
 | |
|                 name = getp.PersonName;
 | |
|             }
 | |
|             return name;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据UserId主键获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="userId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static string GetPersonIdByUserId(string userId)
 | |
|         {
 | |
|             string personId = userId;
 | |
|             var getPerson = GetPersonById(userId);
 | |
|             if (getPerson == null)
 | |
|             {
 | |
|                 var getUser = UserService.GetUserByUserId(userId);
 | |
|                 if (getUser != null)
 | |
|                 {
 | |
|                     getPerson = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == getUser.IdentityCard);
 | |
|                     if (getPerson != null)
 | |
|                     {
 | |
|                         personId = getPerson.PersonId;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             return personId;
 | |
|         }
 | |
| 
 | |
|         #region 根据多用户ID得到用户名称字符串
 | |
|         /// <summary>
 | |
|         /// 根据多用户ID得到用户名称字符串
 | |
|         /// </summary>
 | |
|         /// <param name="bigType"></param>
 | |
|         /// <returns></returns>
 | |
|         public static string getPersonsPersonIds(List<string> personIds)
 | |
|         {
 | |
|             string personName = string.Empty;
 | |
|             foreach (string id in personIds)
 | |
|             {
 | |
|                 var q = GetPersonNameById(id);
 | |
|                 if (q != null)
 | |
|                 {
 | |
|                     personName += q + ",";
 | |
|                 }
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(personName))
 | |
|             {
 | |
|                 personName = personName.Substring(0, personName.Length - 1); ;
 | |
|             }
 | |
|             return personName;
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据UserId主键获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="userId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static Model.SitePerson_Person GetPersonByUserId(string userId, string projectId)
 | |
|         {
 | |
|             var getPerson = GetPersonById(userId);
 | |
|             if (getPerson == null)
 | |
|             {
 | |
|                 var getUser = UserService.GetUserByUserId(userId);
 | |
|                 if (getUser != null)
 | |
|                 {
 | |
|                     getPerson = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == getUser.IdentityCard && e.ProjectId == projectId);
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             return getPerson;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据项目单位获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.SitePerson_Person> GetPersonLitsByprojectIdUnitId(string projectId, string unitId)
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(unitId))
 | |
|             {
 | |
|                 return (from x in Funs.DB.SitePerson_Person
 | |
|                         where x.ProjectId == projectId && x.UnitId == unitId
 | |
|                         orderby x.PersonName
 | |
|                         select x).ToList();
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return (from x in Funs.DB.SitePerson_Person
 | |
|                         where x.ProjectId == projectId
 | |
|                         orderby x.PersonName
 | |
|                         select x).ToList();
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据项目单位获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.SitePerson_Person> GetPersonLitsByprojectIdUnitIdTeamGroupId(string projectId, string unitId, string teamGroupId)
 | |
|         {
 | |
|             var getPersons = GetPersonLitsByprojectIdUnitId(projectId, unitId);
 | |
|             if (!string.IsNullOrEmpty(teamGroupId))
 | |
|             {
 | |
|                 getPersons = getPersons.Where(x => x.TeamGroupId == teamGroupId).OrderBy(x => x.PersonName).ToList();
 | |
|             }
 | |
| 
 | |
|             return getPersons;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取最大的人员位置
 | |
|         /// </summary>
 | |
|         /// <returns>最大的人员位置</returns>
 | |
|         public static int? GetMaxPersonIndex(string projectId)
 | |
|         {
 | |
|             return (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectId select x.PersonIndex).Max();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据单位Id查询所有人员的数量
 | |
|         /// </summary>
 | |
|         /// <param name="unitId">单位Id</param>
 | |
|         /// <returns>人员的数量</returns>
 | |
|         public static int GetPersonCountByUnitId(string unitId, string projectId, DateTime inTime, bool isOutside)
 | |
|         {
 | |
|             var q = (from x in Funs.DB.SitePerson_Person where x.UnitId == unitId && x.ProjectId == projectId && x.InTime <= inTime && x.IsUsed == true && x.IsOutside == isOutside select x).ToList();
 | |
|             return q.Count();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据单位Id查询所有HSE人员的数量
 | |
|         /// </summary>
 | |
|         /// <param name="unitId">单位Id</param>
 | |
|         /// <returns>HSE人员的数量</returns>
 | |
|         public static int GetHSEPersonCountByUnitId(string unitId, string projectId, DateTime inTime)
 | |
|         {
 | |
|             var q = (from x in Funs.DB.SitePerson_Person
 | |
|                      join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
 | |
|                      where x.UnitId == unitId && x.ProjectId == projectId && x.InTime <= inTime && y.IsHsse == true && x.IsUsed == true
 | |
|                      select x).ToList();
 | |
|             //var q = (from x in Funs.DB.SitePerson_Person where x.UnitId == unitId && x.ProjectId == projectId && (x.WorkPostId == BLL.Const.WorkPost_HSSEEngineer || x.WorkPostId == BLL.Const.WorkPost_SafetyManager) && x.IsUsed == true select x).ToList();
 | |
|             return q.Count();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取所有人员位置集合
 | |
|         /// </summary>
 | |
|         /// <returns>所有人员位置集合</returns>
 | |
|         public static List<int?> GetPersonIndexs(string projectId)
 | |
|         {
 | |
|             return (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectId select x.PersonIndex).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据卡号查询人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="cardNo">卡号</param>
 | |
|         /// <returns>人员实体</returns>
 | |
|         public static Model.SitePerson_Person GetPersonByCardNo(string projectId, string cardNo)
 | |
|         {
 | |
|             return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.ProjectId == projectId && e.CardNo == cardNo);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据卡号查询所有人员的数量
 | |
|         /// </summary>
 | |
|         /// <param name="cardNo">卡号</param>
 | |
|         /// <returns>人员的数量</returns>
 | |
|         public static int GetPersonCountByCardNo(string projectId, string cardNo)
 | |
|         {
 | |
|             var q = (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectId && x.CardNo == cardNo select x).ToList();
 | |
|             return q.Count();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据人员姓名和所在单位判断人员是否存在
 | |
|         /// </summary>
 | |
|         /// <param name="unitId"></param>
 | |
|         /// <param name="personName"></param>
 | |
|         /// <returns></returns>
 | |
|         public static bool IsExistPersonByUnit(string unitId, string personName, string projectId)
 | |
|         {
 | |
|             var q = from x in Funs.DB.SitePerson_Person where x.UnitId == unitId && x.PersonName == personName && x.ProjectId == projectId select x;
 | |
|             if (q.Count() > 0)
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据身份证号Id获取人员的数量
 | |
|         /// </summary>
 | |
|         /// <param name="identityCard">身份证号</param>
 | |
|         /// <returns>人员的数量</returns>
 | |
|         public static Model.SitePerson_Person GetPersonCountByIdentityCard(string identityCard, string projectId)
 | |
|         {
 | |
|             var q = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == identityCard && x.ProjectId == projectId);
 | |
|             return q;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取人员信息列表
 | |
|         /// </summary>
 | |
|         /// <param name="projectId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.SitePerson_Person> GetPersonList(string projectId)
 | |
|         {
 | |
|             return (from x in Funs.DB.SitePerson_Person where x.ProjectId == projectId select x).ToList();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 增加人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="person">人员实体</param>
 | |
|         public static void AddPerson(Model.SitePerson_Person person)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 Model.SitePerson_Person newPerson = new Model.SitePerson_Person
 | |
|                 {
 | |
|                     PersonId = person.PersonId,
 | |
|                     CardNo = person.CardNo,
 | |
|                     PersonName = person.PersonName,
 | |
|                     Sex = person.Sex,
 | |
|                     IdentityCard = person.IdentityCard,
 | |
|                     Address = person.Address,
 | |
|                     ProjectId = person.ProjectId,
 | |
|                     UnitId = person.UnitId,
 | |
|                     TeamGroupId = person.TeamGroupId,
 | |
|                     WorkAreaId = person.WorkAreaId,
 | |
|                     WorkPostId = person.WorkPostId,
 | |
|                     OutTime = person.OutTime,
 | |
|                     OutResult = person.OutResult,
 | |
|                     Telephone = person.Telephone,
 | |
|                     Email = person.Email,
 | |
|                     PositionId = person.PositionId,
 | |
|                     PostTitleId = person.PostTitleId,
 | |
|                     PhotoUrl = person.PhotoUrl,
 | |
|                     HeadImage = person.HeadImage,
 | |
|                     IsUsed = person.IsUsed,
 | |
|                     IsCardUsed = person.IsCardUsed,
 | |
|                     DepartId = person.DepartId,
 | |
|                     FromPersonId = person.FromPersonId,
 | |
|                     Password = GetPersonPassWord(person.IdentityCard),
 | |
|                     AuditorId = person.AuditorId,
 | |
|                     AuditorDate = person.AuditorDate,
 | |
|                     IsForeign = person.IsForeign,
 | |
|                     IsOutside = person.IsOutside,
 | |
|                     EduLevel = person.EduLevel,
 | |
|                     MaritalStatus = person.MaritalStatus,
 | |
|                     Isprint = "0",
 | |
|                     MainCNProfessionalId = person.MainCNProfessionalId,
 | |
|                     ViceCNProfessionalId = person.ViceCNProfessionalId,
 | |
|                     Birthday = person.Birthday,
 | |
|                     IdcardType = person.IdcardType,
 | |
|                     IdcardStartDate = person.IdcardStartDate,
 | |
|                     IdcardEndDate = person.IdcardEndDate,
 | |
|                     IdcardForever = person.IdcardForever,
 | |
|                     PoliticsStatus = person.PoliticsStatus,
 | |
|                     IdcardAddress = person.IdcardAddress,
 | |
|                     Nation = person.Nation,
 | |
|                     CountryCode = person.CountryCode,
 | |
|                     ProvinceCode = person.ProvinceCode,
 | |
|                     IsCardNoOK=IDCardValid.CheckIDCard(person.IdentityCard),
 | |
|                     IsSafetyMonitoring = person.IsSafetyMonitoring,
 | |
|                 };
 | |
|                 newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
 | |
|                 newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
 | |
|                 if (person.InTime.HasValue)
 | |
|                 {
 | |
|                     newPerson.InTime = person.InTime;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     newPerson.InTime = Funs.GetNewDateTime(DateTime.Now.ToShortDateString());
 | |
|                 }
 | |
| 
 | |
|                 db.SitePerson_Person.InsertOnSubmit(newPerson);
 | |
|                 db.SubmitChanges();
 | |
| 
 | |
|                 ////增加一条编码记录
 | |
|                 BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.PersonListMenuId, person.ProjectId, person.UnitId, person.PersonId, person.InTime);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 修改人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="person">人员实体</param>
 | |
|         public static void UpdatePerson(Model.SitePerson_Person person)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 Model.SitePerson_Person newPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == person.PersonId);
 | |
|                 if (newPerson != null)
 | |
|                 {
 | |
|                     newPerson.FromPersonId = person.FromPersonId;
 | |
|                     newPerson.CardNo = person.CardNo;
 | |
|                     newPerson.PersonName = person.PersonName;
 | |
|                     newPerson.Sex = person.Sex;
 | |
|                     if (newPerson.IdentityCard != person.IdentityCard)
 | |
|                     {
 | |
|                         PersonInOutService.UpdateRealNameInOut(newPerson.PersonId, newPerson.IdentityCard, person.IdentityCard);                            
 | |
|                         newPerson.IdentityCard = person.IdentityCard;
 | |
|                     }                   
 | |
|                     newPerson.Address = person.Address;
 | |
|                     newPerson.ProjectId = person.ProjectId;
 | |
|                     newPerson.UnitId = person.UnitId;
 | |
|                     newPerson.TeamGroupId = person.TeamGroupId;
 | |
|                     newPerson.WorkAreaId = person.WorkAreaId;
 | |
|                     newPerson.WorkPostId = person.WorkPostId;
 | |
|                     newPerson.InTime = person.InTime;
 | |
|                     newPerson.OutTime = person.OutTime;
 | |
|                     newPerson.OutResult = person.OutResult;
 | |
|                     newPerson.Telephone = person.Telephone;
 | |
|                     newPerson.Email = person.Email;
 | |
|                     newPerson.PositionId = person.PositionId;
 | |
|                     newPerson.PostTitleId = person.PostTitleId;                   
 | |
|                     if (newPerson.PhotoUrl != person.PhotoUrl && !string.IsNullOrEmpty(person.PhotoUrl))
 | |
|                     {
 | |
|                         newPerson.PhotoUrl = person.PhotoUrl;
 | |
|                         newPerson.ExchangeTime = null;
 | |
|                         newPerson.HeadImage = person.HeadImage;
 | |
|                     }
 | |
|                     
 | |
|                     newPerson.IsUsed = person.IsUsed;
 | |
|                     newPerson.IsCardUsed = person.IsCardUsed;
 | |
|                     newPerson.EduLevel = person.EduLevel;
 | |
|                     newPerson.MaritalStatus = person.MaritalStatus;
 | |
|                     newPerson.DepartId = person.DepartId;
 | |
|                     newPerson.QRCodeAttachUrl = person.QRCodeAttachUrl;
 | |
|                     newPerson.IsSafetyMonitoring = person.IsSafetyMonitoring;
 | |
|                     newPerson.Password = GetPersonPassWord(person.IdentityCard);
 | |
|                     if (!newPerson.OutTime.HasValue)
 | |
|                     {
 | |
|                         newPerson.OutTime = null;
 | |
|                         newPerson.ExchangeTime = null;
 | |
|                     }
 | |
|                     newPerson.ExchangeTime2 = null;
 | |
|                     newPerson.RealNameUpdateTime = null;
 | |
|                     if (!string.IsNullOrEmpty(person.AuditorId))
 | |
|                     {
 | |
|                         newPerson.AuditorId = person.AuditorId;
 | |
|                     }
 | |
|                     if (person.AuditorDate.HasValue)
 | |
|                     {
 | |
|                         newPerson.AuditorDate = person.AuditorDate;
 | |
|                     }
 | |
|                    
 | |
|                     newPerson.IsForeign = person.IsForeign;
 | |
|                     newPerson.IsOutside = person.IsOutside;
 | |
|                     newPerson.Birthday = person.Birthday;
 | |
|                     newPerson.MainCNProfessionalId = person.MainCNProfessionalId;
 | |
|                     newPerson.ViceCNProfessionalId = person.ViceCNProfessionalId;
 | |
|                     newPerson.IdcardType = person.IdcardType;
 | |
|                     newPerson.IdcardStartDate = person.IdcardStartDate;
 | |
|                     newPerson.IdcardEndDate = person.IdcardEndDate;
 | |
|                     newPerson.IdcardForever = person.IdcardForever;
 | |
|                     newPerson.PoliticsStatus = person.PoliticsStatus;
 | |
|                     newPerson.IdcardAddress = person.IdcardAddress;
 | |
|                     newPerson.Nation = person.Nation;
 | |
|                     newPerson.CountryCode = person.CountryCode;
 | |
|                     newPerson.ProvinceCode = person.ProvinceCode;
 | |
|                     newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
 | |
| 
 | |
|                     newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
 | |
|                     newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
 | |
|                     db.SubmitChanges();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         public static void UpdateDoorPerson(Model.SitePerson_Person person)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 Model.SitePerson_Person newPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == person.PersonId);
 | |
|                 if (newPerson != null)
 | |
|                 {
 | |
|                     
 | |
|                     newPerson.PersonName = person.PersonName;
 | |
|                     newPerson.Sex = person.Sex;
 | |
|                     if (newPerson.IdentityCard != person.IdentityCard)
 | |
|                     {
 | |
|                         PersonInOutService.UpdateRealNameInOut(newPerson.PersonId, newPerson.IdentityCard, person.IdentityCard);
 | |
|                         newPerson.IdentityCard = person.IdentityCard;
 | |
|                     }
 | |
|                     newPerson.Address = person.Address;                
 | |
|                     newPerson.UnitId = person.UnitId;
 | |
|                     newPerson.TeamGroupId = person.TeamGroupId;
 | |
|                     newPerson.WorkAreaId = person.WorkAreaId;
 | |
|                     newPerson.WorkPostId = person.WorkPostId;
 | |
|                     newPerson.InTime = person.InTime;
 | |
|                     newPerson.OutTime = person.OutTime;
 | |
|                     newPerson.OutResult = person.OutResult;
 | |
|                     newPerson.Telephone = person.Telephone;
 | |
|                     newPerson.Email = person.Email;
 | |
|                     newPerson.PhotoUrl = person.PhotoUrl;
 | |
|                     newPerson.HeadImage = person.HeadImage;
 | |
|                     newPerson.IsUsed = person.IsUsed;
 | |
| 
 | |
|                     if (!newPerson.OutTime.HasValue)
 | |
|                     {
 | |
|                         newPerson.OutTime = null;
 | |
|                         newPerson.ExchangeTime = null;
 | |
|                     }
 | |
|                     if (!string.IsNullOrEmpty(person.AuditorId))
 | |
|                     {
 | |
|                         newPerson.AuditorId = person.AuditorId;
 | |
|                     }
 | |
|                     if (person.AuditorDate.HasValue)
 | |
|                     {
 | |
|                         newPerson.AuditorDate = person.AuditorDate;
 | |
|                     }
 | |
|                     newPerson.Birthday = person.Birthday;
 | |
|                     newPerson.IdcardType = person.IdcardType;
 | |
|                     newPerson.IdcardStartDate = person.IdcardStartDate;
 | |
|                     newPerson.IdcardEndDate = person.IdcardEndDate;
 | |
|                     newPerson.IdcardForever = person.IdcardForever;
 | |
|                     newPerson.IdcardAddress = person.IdcardAddress;
 | |
|                     newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
 | |
|                     db.SubmitChanges();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 修改密码
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <param name="password"></param>
 | |
|         public static void UpdateSitePersonPassword(string personId, string password)
 | |
|         {
 | |
|             var m = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
 | |
|             if (m != null)
 | |
|             {
 | |
|                 m.RawPassword = password;
 | |
|                 m.Password = Funs.EncryptionPassword(password);
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         ///  人员离岗
 | |
|         /// </summary>
 | |
|         /// <param name="person"></param>
 | |
|         public static void PersonOut(string personId, DateTime date)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
 | |
|                 if (person != null)
 | |
|                 {
 | |
|                     person.OutTime = date;
 | |
|                     person.IsUsed = true;
 | |
|                     person.ExchangeTime = null;
 | |
|                     person.ExchangeTime2 = null;
 | |
|                     person.RealNameUpdateTime = null;
 | |
|                    db.SubmitChanges();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public static void UpdatePhotoUrl(string personId, string photoUrl, System.Data.Linq.Binary headImage )
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
 | |
|                 if (person != null)
 | |
|                 {
 | |
|                     person.PhotoUrl = photoUrl;
 | |
|                     person.HeadImage = headImage;
 | |
|                     db.SubmitChanges();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据人员Id删除一个人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId">人员Id</param>
 | |
|         public static void DeletePerson(string personId)
 | |
|         {
 | |
|             Model.SitePerson_Person person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
 | |
|             if (person != null)
 | |
|             {
 | |
|                 ///删除编码表记录
 | |
|                 BLL.CodeRecordsService.DeleteCodeRecordsByDataId(personId);
 | |
| 
 | |
|                 //删除特岗人员资质
 | |
|                 var personQuality = PersonQualityService.GetPersonQualityByPersonId(personId);
 | |
|                 if (personQuality != null)
 | |
|                 {
 | |
|                     CodeRecordsService.DeleteCodeRecordsByDataId(personQuality.PersonQualityId);//删除编号
 | |
|                     CommonService.DeleteAttachFileById(personQuality.PersonQualityId);//删除附件
 | |
|                     Funs.DB.QualityAudit_PersonQuality.DeleteOnSubmit(personQuality);
 | |
|                     Funs.DB.SubmitChanges();
 | |
|                 }
 | |
|                 //删除安全人员资质
 | |
|                 Model.QualityAudit_SafePersonQuality safePersonQuality = Funs.DB.QualityAudit_SafePersonQuality.FirstOrDefault(e => e.PersonId == personId);
 | |
|                 if (safePersonQuality != null)
 | |
|                 {
 | |
|                     CodeRecordsService.DeleteCodeRecordsByDataId(safePersonQuality.SafePersonQualityId);
 | |
|                     CommonService.DeleteAttachFileById(safePersonQuality.SafePersonQualityId);
 | |
|                     Funs.DB.QualityAudit_SafePersonQuality.DeleteOnSubmit(safePersonQuality);
 | |
|                     Funs.DB.SubmitChanges();
 | |
|                 }
 | |
|                 ///违规人员
 | |
|                 var getViolation = from x in Funs.DB.Check_ViolationPerson where x.PersonId == person.PersonId select x;
 | |
|                 if (getViolation.Count() > 0)
 | |
|                 {
 | |
|                     Funs.DB.Check_ViolationPerson.DeleteAllOnSubmit(getViolation);
 | |
|                     Funs.DB.SubmitChanges();
 | |
|                 }
 | |
|                 ///删除培训任务
 | |
|                 var getTask = from x in Funs.DB.Training_Task where x.UserId == person.PersonId select x;
 | |
|                 if (getTask.Count() > 0)
 | |
|                 {
 | |
|                     foreach (var item in getTask)
 | |
|                     {
 | |
|                         TrainingTaskService.DeleteTaskById(item.TaskId);
 | |
|                     }
 | |
|                 }
 | |
|                 ///删除培训记录
 | |
|                 var getTrainRecord = from x in Funs.DB.EduTrain_TrainRecordDetail where x.PersonId == person.PersonId select x;
 | |
|                 if (getTrainRecord.Count() > 0)
 | |
|                 {
 | |
|                     foreach (var item in getTrainRecord)
 | |
|                     {
 | |
|                         EduTrain_TrainRecordDetailService.DeleteTrainDetailByTrainDetail(item.TrainDetailId);
 | |
|                     }
 | |
|                 }
 | |
|                 ///删除考试记录
 | |
|                 var getTestRecode = from x in Funs.DB.Training_TestRecord where x.TestManId == person.PersonId select x;
 | |
|                 if (getTestRecode.Count() > 0)
 | |
|                 {
 | |
|                     foreach (var item in getTestRecode)
 | |
|                     {
 | |
|                         TestRecordService.DeleteTestRecordByTestRecordId(item.TestRecordId);
 | |
|                     }
 | |
|                 }
 | |
|                 ///删除人员绩效
 | |
|                 var getPerfomances = from x in Funs.DB.Perfomance_PersonPerfomance where x.PersonId == person.PersonId select x;
 | |
|                 if (getPerfomances.Count() > 0)
 | |
|                 {
 | |
|                     foreach (var item in getPerfomances)
 | |
|                     {
 | |
|                         PersonPerfomanceService.DeletePersonPerfomanceById(item.PersonPerfomanceId);
 | |
|                     }
 | |
|                 }
 | |
|                 ///删除人员出入场记录
 | |
|                 BLL.PersonInOutService.DeletePersonInOutByPersonId(person.PersonId);
 | |
| 
 | |
|                 ///删除编码表记录
 | |
|                 BLL.CodeRecordsService.DeleteCodeRecordsByDataId(personId);
 | |
|                 Funs.DB.SitePerson_Person.DeleteOnSubmit(person);
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据身份证号获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="identityCard">身份证号</param>
 | |
|         /// <returns>人员信息</returns>
 | |
|         public static Model.SitePerson_Person GetPersonByIdentityCard(string projectId, string identityCard)
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(identityCard))
 | |
|             {
 | |
|                 return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.ProjectId == projectId && e.IdentityCard == identityCard);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据身份证号获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="identityCard">身份证号</param>
 | |
|         /// <returns>人员信息</returns>
 | |
|         public static Model.SitePerson_Person GetPersonByProjectCodeIdentityCard(string projectCode, string identityCard)
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(identityCard))
 | |
|             {
 | |
|                 var getProject = ProjectService.GetProjectByProjectCode(projectCode);
 | |
|                 if (getProject != null)
 | |
|                 {
 | |
|                     return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == identityCard);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == identityCard && e.ProjectId == null);
 | |
|                 }
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 根据身份证号获取人员信息
 | |
|         /// </summary>
 | |
|         /// <param name="name">姓名</param>
 | |
|         /// <returns>人员信息</returns>
 | |
|         public static Model.SitePerson_Person GetPersonByName(string projectId, string name)
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(name))
 | |
|             {
 | |
|                 return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.ProjectId == projectId && e.PersonName == name);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 保存发卡信息
 | |
|         /// </summary>
 | |
|         /// <param name="personId"></param>
 | |
|         /// <param name="cardNo"></param>
 | |
|         public static void SaveSendCard(string personId, string cardNo, int personIndex)
 | |
|         {
 | |
|             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
 | |
|             {
 | |
|                 Model.SitePerson_Person card = db.SitePerson_Person.FirstOrDefault(e => e.CardNo == cardNo);
 | |
|                 if (card != null)
 | |
|                 {
 | |
|                     card.CardNo = null;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     Model.SitePerson_Person person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
 | |
|                     person.CardNo = cardNo;
 | |
|                     person.PersonIndex = personIndex;
 | |
|                     //person.CardNo = sendCardNo;
 | |
|                 }
 | |
| 
 | |
|                 db.SubmitChanges();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 根据作业区域获取人员
 | |
|         /// </summary>
 | |
|         /// <param name="workAreaId"></param>
 | |
|         /// <returns></returns>
 | |
|         public static List<Model.SitePerson_Person> GetPersonListByWorkAreaId(string workAreaId)
 | |
|         {
 | |
|             return (from x in Funs.DB.SitePerson_Person where x.WorkAreaId == workAreaId select x).ToList();
 | |
|         }
 | |
| 
 | |
|         #region 表下拉框
 | |
|         /// <summary>
 | |
|         ///  表下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="dropName">下拉框名字</param>
 | |
|         /// <param name="isShowPlease">是否显示请选择</param>
 | |
|         public static void InitPersonByProjectUnitDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, bool isShowPlease)
 | |
|         {
 | |
|             dropName.DataValueField = "PersonId";
 | |
|             dropName.DataTextField = "PersonName";
 | |
|             dropName.DataSource = GetPersonLitsByprojectIdUnitId(projectId, unitId);
 | |
|             dropName.DataBind();
 | |
|             if (isShowPlease)
 | |
|             {
 | |
|                 Funs.FineUIPleaseSelect(dropName);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         ///  表下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="dropName">下拉框名字</param>
 | |
|         /// <param name="isShowPlease">是否显示请选择</param>
 | |
|         public static void InitPersonByProjectUnitTeamGroupDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, string teamGroupId, bool isShowPlease)
 | |
|         {
 | |
|             dropName.DataValueField = "PersonId";
 | |
|             dropName.DataTextField = "PersonName";
 | |
|             dropName.DataSource = GetPersonLitsByprojectIdUnitIdTeamGroupId(projectId, unitId, teamGroupId);
 | |
|             dropName.DataBind();
 | |
|             if (isShowPlease)
 | |
|             {
 | |
|                 Funs.FineUIPleaseSelect(dropName);
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取人员密码
 | |
|         /// </summary>
 | |
|         /// <param name="idCard"></param>
 | |
|         /// <returns></returns>
 | |
|         public static string GetPersonPassWord(string idCard)
 | |
|         {
 | |
|             string passWord = Funs.EncryptionPassword(Const.Password);
 | |
|             ////现场人员密码
 | |
|             if (!string.IsNullOrEmpty(idCard))
 | |
|             {
 | |
|                 if (idCard.Length > 3)
 | |
|                 {
 | |
|                     passWord = Funs.EncryptionPassword(idCard.Substring(idCard.Length - 4));
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     passWord = Funs.EncryptionPassword(idCard);
 | |
|                 }
 | |
|             }
 | |
|             return passWord;
 | |
|         }
 | |
| 
 | |
|         public static Model.SitePerson_Person GetPersonImgByIdentityCard(string identityCard)
 | |
|         {
 | |
|             if (!string.IsNullOrEmpty(identityCard))
 | |
|             {
 | |
|                 return Funs.DB.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == identityCard);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |