Example #1
0
        /// <summary>
        /// Servizio per il reperimento degli utenti in un ruolo
        /// </summary>
        /// <param name="request"></param>
        /// <returns>Response</returns>
        public Services.Roles.GetUsersInRole.GetUsersInRoleResponse GetUsersInRole(Services.Roles.GetUsersInRole.GetUsersInRoleRequest request)
        {
            logger.Info("BEGIN");
            Services.Roles.GetUsersInRole.GetUsersInRoleResponse response = Manager.RolesManager.GetUsersInRole(request);

            Utils.CheckFaultException(response);
            logger.Info("END");
            return(response);
        }
Example #2
0
        public static Services.Roles.GetUsersInRole.GetUsersInRoleResponse GetUsersInRole(Services.Roles.GetUsersInRole.GetUsersInRoleRequest request)
        {
            Services.Roles.GetUsersInRole.GetUsersInRoleResponse response = new Services.Roles.GetUsersInRole.GetUsersInRoleResponse();

            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "GetUsersInRole");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (string.IsNullOrEmpty(request.CodeRole))
                {
                    throw new PisException("REQUIRED_CODE_ROLE");
                }

                Domain.User[] userResponse = null;

                DocsPaVO.utente.Ruolo ruolo = null;

                if (!string.IsNullOrEmpty(request.CodeRole))
                {
                    ruolo = BusinessLogic.Utenti.UserManager.getRuoloByCodice(request.CodeRole);
                    if (ruolo != null)
                    {
                        List <DocsPaVO.utente.UserMinimalInfo> userList = BusinessLogic.Utenti.UserManager.GetUsersInRoleMinimalInfo(ruolo.idGruppo);
                        if (userList != null && userList.Count > 0)
                        {
                            int i = 0;
                            userResponse = new Domain.User[userList.Count];
                            foreach (DocsPaVO.utente.UserMinimalInfo minimalUser in userList)
                            {
                                Domain.User            tempUser = new Domain.User();
                                DocsPaVO.utente.Utente utenteU  = BusinessLogic.Utenti.UserManager.getUtenteById(minimalUser.SystemId);
                                tempUser.Description = utenteU.descrizione;
                                tempUser.Name        = utenteU.nome;
                                tempUser.Surname     = utenteU.cognome;
                                tempUser.UserId      = utenteU.userId;
                                tempUser.Id          = utenteU.idPeople;
                                userResponse[i]      = tempUser;
                                i++;
                            }
                        }
                    }
                    else
                    {
                        //Ruolo non trovato
                        throw new PisException("ROLE_NO_EXIST");
                    }
                }
                else
                {
                    throw new PisException("REQUIRED_CODE_ROLE");
                }

                response.Users = userResponse;

                response.Success = true;
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }