Example #1
0
        /// <summary>
        /// Metodo per la ricerca di un utente
        /// </summary>
        /// <param name="request"></param>
        /// <returns>response</returns>
        public Services.AddressBook.SearchUsers.SearchUsersResponse SearchUsers(Services.AddressBook.SearchUsers.SearchUsersRequest request)
        {
            logger.Info("BEGIN");
            Services.AddressBook.SearchUsers.SearchUsersResponse response = Manager.AddressBookManager.SearchUsers(request);

            Utils.CheckFaultException(response);
            logger.Info("END");

            return(response);
        }
Example #2
0
        public static Services.AddressBook.SearchUsers.SearchUsersResponse SearchUsers(Services.AddressBook.SearchUsers.SearchUsersRequest request)
        {
            Services.AddressBook.SearchUsers.SearchUsersResponse response = new Services.AddressBook.SearchUsers.SearchUsersResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

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

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

                if (request.Filters == null || request.Filters.Length == 0)
                {
                    throw new PisException("REQUIRED_FILTER");
                }

                //Chiamata al metodo CheckFilterType(request.Filters)
                Utils.CheckFilterTypes(request.Filters);

                //Filtri ricerca rubrica
                DocsPaVO.rubrica.ParametriRicercaRubrica      qco = new DocsPaVO.rubrica.ParametriRicercaRubrica();
                BusinessLogic.Rubrica.DPA3_RubricaSearchAgent ccs = new BusinessLogic.Rubrica.DPA3_RubricaSearchAgent(infoUtente);
                DocsPaVO.rubrica.SmistamentoRubrica           smistamentoRubrica = new DocsPaVO.rubrica.SmistamentoRubrica();
                qco.caller          = new DocsPaVO.rubrica.ParametriRicercaRubrica.CallerIdentity();
                qco.caller.IdUtente = infoUtente.idPeople;
                qco.caller.IdRuolo  = infoUtente.idGruppo;
                qco.caller.filtroRegistroPerRicerca = null;
                qco.doUtenti = true;
                qco.calltype = DocsPaVO.rubrica.ParametriRicercaRubrica.CallType.CALLTYPE_PROTO_IN;
                //

                bool filterFound = false;

                foreach (VtDocsWS.Domain.Filter fil in request.Filters)
                {
                    if (fil != null && !string.IsNullOrEmpty(fil.Value))
                    {
                        if (fil.Name.ToUpper().Equals("NATIONAL_IDENTIFICATION_NUMBER"))
                        {
                            filterFound = true;
                            qco.cf_piva = fil.Value;
                        }
                        if (fil.Name.ToUpper().Equals("USER_MAIL"))
                        {
                            filterFound = true;
                            qco.email   = fil.Value;
                        }
                        if (fil.Name.ToUpper().Equals("USER_NAME"))
                        {
                            filterFound     = true;
                            qco.descrizione = fil.Value;
                        }
                        if (fil.Name.ToUpper().Equals("USER_SURNAME"))
                        {
                            filterFound     = true;
                            qco.descrizione = fil.Value;
                        }

                        if (!filterFound)
                        {
                            throw new PisException("FILTER_NOT_FOUND");
                        }
                    }
                }
                Domain.User[] userResponse = null;

                ArrayList objElementiRubrica = ccs.Search(qco, smistamentoRubrica);

                if (objElementiRubrica != null && objElementiRubrica.Count > 0)
                {
                    userResponse = new Domain.User[objElementiRubrica.Count];
                    for (int i = 0; i < objElementiRubrica.Count; i++)
                    {
                        Domain.User userTemp = new Domain.User();
                        userTemp.Id          = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).idPeople;
                        userTemp.Description = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).descrizione;
                        userTemp.UserId      = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).codice;
                        userTemp.Name        = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).nome;
                        userTemp.Surname     = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).cognome;
                        userTemp.NationalIdentificationNumber = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]).cf_piva;
                        userResponse[i] = userTemp;
                    }
                    response.Users = userResponse;
                }
                else
                {
                    //throw new PisException("USERS_NOT_FOUND");
                    userResponse   = new Domain.User[0];
                    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);
        }