コード例 #1
0
        public List <PlayBoard_PlayUsetDTO> GetPlayUsersByOPType(int opTypeUID, int?funcOrgID)
        {
            var query = systemUserOrgRepository.GetMany(x => x.OPType_OrganizationUID == opTypeUID && x.System_Users.Enable_Flag == true);

            if (funcOrgID.HasValue)
            {
                query = query.Where(x => x.Funplant_OrganizationUID == funcOrgID);
            }
            var accountUIDList = query.Select(x => x.Account_UID).ToList();
            var users          = systemUserRepository.GetMany(x => accountUIDList.Contains(x.Account_UID));
            var dtoList        = new List <PlayBoard_PlayUsetDTO>();

            foreach (var item in users)
            {
                //播放看板固定角色PlayBoardPlayUser 播放看板播放账号
                var role = item.System_User_Role.FirstOrDefault(x => x.System_Role.Role_ID == "PlayBoardPlayUser");
                if (role != null)
                {
                    var dto = AutoMapper.Mapper.Map <PlayBoard_PlayUsetDTO>(item);
                    dto.Role_ID   = role.System_Role.Role_ID;
                    dto.Role_Name = role.System_Role.Role_Name;
                    dtoList.Add(dto);
                }
            }
            return(dtoList);
        }
コード例 #2
0
ファイル: FlowChartPCMHService.cs プロジェクト: HJ520134/PIS
        public string InsertBomUserInfo(List <FlowChartPCMHRelationshipVM> list)
        {
            if (list.Count() == 0)
            {
                return(string.Empty);
            }
            //var MHRoleUid =
            //    systemRoleRepository.GetMany(m => m.Role_Name == "维护角色").Select(m => m.Role_UID).FirstOrDefault();
            var ErrorInfo = "";

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    var languageUID = list.First().FlowchartPCDTOItem.System_Language_UID;
                    foreach (var item in list)
                    {
                        var flowchartPCItem = AutoMapper.Mapper.Map <FlowChart_PC_MH_Relationship>(item.FlowchartPCDTOItem);

                        var hasExistUserItem = systemUserRepository.GetMany(m => m.User_NTID.ToUpper().Equals(item.UserNTID.ToUpper())).FirstOrDefault();
                        if (hasExistUserItem == null)
                        {
                            int maxAccountID = flowChartPCMHRelationshipRepository.InsertBomUserInfo(list);

                            System_Users userItem = new System_Users();
                            userItem.Account_UID         = maxAccountID + 1;
                            userItem.User_NTID           = item.UserNTID;
                            userItem.User_Name           = item.UserNTID;
                            userItem.Enable_Flag         = true;
                            userItem.Email               = "";
                            userItem.System_Language_UID = languageUID;
                            userItem.Modified_UID        = item.FlowchartPCDTOItem.Modified_UID;
                            userItem.Modified_Date       = item.FlowchartPCDTOItem.Modified_Date;
                            userItem.MH_Flag             = true;
                            userItem.EmployeePassword    = JGP.Common.PasswordUtil.EncryptionHelper.Encrypt("123456", "");
                            systemUserRepository.Add(userItem);

                            userItem.FlowChart_PC_MH_Relationship1.Add(flowchartPCItem);

                            //SystemUserRoleDTO userRoleDTO = new SystemUserRoleDTO();
                            //userRoleDTO.Account_UID = userDTO.Account_UID;
                            //userRoleDTO.Modified_UID = this.CurrentUser.AccountUId;
                            //userRoleDTO.Modified_Date = userDTO.Modified_Date;
                        }
                        else
                        {
                            hasExistUserItem.FlowChart_PC_MH_Relationship1.Add(flowchartPCItem);
                        }
                        //数据提交后才能查找的到值,才能判断是否重复UserNTID
                        unitOfWork.Commit();
                    }

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                ErrorInfo = "插入数据失败!" + e.ToString();
            }
            return(ErrorInfo);
        }