Ejemplo n.º 1
0
        public SystemUserDTO GetSystemUserByNTId(string ntid, int islogin)
        {
            var           query      = systemUserRepository.GetFirstOrDefault(q => q.User_NTID == ntid);
            SystemUserDTO returnUser = (query == null ? null : AutoMapper.Mapper.Map <SystemUserDTO>(query));

            //获取相关参数IsMulitProject、flowChartMaster_Uid
            if (returnUser != null)
            {
                //获取物料员的专案信息
                var flIdAndVersionList = flowChartPCMHRelationshipRepository.GetMany(m => m.MH_UID == returnUser.Account_UID && !m.FlowChart_Detail.FlowChart_Master.Is_Closed)
                                         .Select(m => new { m.FlowChart_Detail.FlowChart_Master_UID, m.FlowChart_Detail.FlowChart_Version }).Distinct().ToList();

                //获取所有专案信息
                var flMasterList = flowChartMasterRepository.GetAll().ToList();

                //将两边数据进行匹配,判断该用户是否有多个专案
                int count = 0;
                foreach (var item in flIdAndVersionList)
                {
                    //只有最大版本的数据才是正确的
                    var hasExist = flMasterList.Exists(m => m.FlowChart_Master_UID == item.FlowChart_Master_UID && m.FlowChart_Version == item.FlowChart_Version);
                    if (hasExist)
                    {
                        //跳转到ProductInput会用到
                        returnUser.flowChartMaster_Uid = item.FlowChart_Master_UID;
                        count++;
                    }
                }
                if (count > 1)
                {
                    returnUser.IsMulitProject = true;
                }
                else
                {
                    returnUser.IsMulitProject = false;
                }

                if (query.System_User_Role.Count > 0)
                {
                    var roleList = query.System_User_Role.Select(x => x.System_Role).ToList();
                    returnUser.RoleList = AutoMapper.Mapper.Map <List <SystemRoleDTO> >(roleList);
                }
            }
            else
            {
                if (islogin == 1)
                {
                    try
                    {
                        int test        = Convert.ToInt32(ntid);
                        var eqpuserlist = flowChartMasterRepository.GetByUserId(ntid);
                        if (eqpuserlist.Count > 0)
                        {
                            returnUser             = new SystemUserDTO();
                            returnUser.Account_UID = eqpuserlist[0].EQPUser_Uid;
                            returnUser.User_Name   = eqpuserlist[0].User_Name;
                            returnUser.Enable_Flag = true;
                            returnUser.MH_Flag     = true;
                            returnUser.User_NTID   = "EQPUser";
                        }
                    }
                    catch
                    {
                    }
                }
            }



            return(returnUser);
        }