Esempio n. 1
0
        /// <summary>
        /// Servizio per il reperimento dei ruoli dato un utente
        /// </summary>
        /// <param name="request"></param>
        /// <returns>Response</returns>
        public Services.Roles.GetRoles.GetRolesResponse GetRoles(Services.Roles.GetRoles.GetRolesRequest request)
        {
            logger.Info("BEGIN");
            Services.Roles.GetRoles.GetRolesResponse response = Manager.RolesManager.GetRoles(request);

            Utils.CheckFaultException(response);
            logger.Info("END");
            return(response);
        }
Esempio n. 2
0
        public static Services.Roles.GetRoles.GetRolesResponse GetRoles(Services.Roles.GetRoles.GetRolesRequest request)
        {
            Services.Roles.GetRoles.GetRolesResponse response = new Services.Roles.GetRoles.GetRolesResponse();

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

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

                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.UserID))
                {
                    throw new PisException("REQUIRED_USERID");
                }

                Domain.Role[] roleResponse = null;

                DocsPaVO.utente.Utente utenteDaCercare = null;
                ArrayList arrayRuoli = new ArrayList();

                if (!string.IsNullOrEmpty(request.UserID))
                {
                    utenteDaCercare = BusinessLogic.Utenti.UserManager.getUtente(request.UserID, Utils.GetIdAmministrazione(request.UserID));
                }
                else
                {
                    throw new PisException("REQUIRED_USERID");
                }

                if (utenteDaCercare != null)
                {
                    DocsPaVO.utente.InfoUtente infoUtenteDaCercare = new DocsPaVO.utente.InfoUtente(utenteDaCercare, Utils.GetRuoloPreferito(utenteDaCercare.idPeople));
                    arrayRuoli = BusinessLogic.Utenti.UserManager.getRuoliUtente(infoUtenteDaCercare.idPeople);
                    if (arrayRuoli != null && arrayRuoli.Count > 0)
                    {
                        roleResponse = new Domain.Role[arrayRuoli.Count];
                        int i = 0;
                        foreach (DocsPaVO.utente.Ruolo rol in arrayRuoli)
                        {
                            Domain.Role roleTemp = new Domain.Role();
                            roleTemp.Code        = rol.codiceRubrica;
                            roleTemp.Description = rol.descrizione;
                            roleTemp.Id          = rol.idGruppo;
                            roleResponse[i]      = roleTemp;
                            i++;
                        }
                    }
                    else
                    {
                        throw new PisException("USER_NO_ROLES");
                    }
                }
                else
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }

                response.Roles = roleResponse;

                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);
        }