示例#1
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);
        }
示例#2
0
        public static Services.AddressBook.SearchCorrespondents.SearchCorrespondentsResponse SearchCorrespondents(Services.AddressBook.SearchCorrespondents.SearchCorrespondentsRequest request)
        {
            Services.AddressBook.SearchCorrespondents.SearchCorrespondentsResponse response = new Services.AddressBook.SearchCorrespondents.SearchCorrespondentsResponse();

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

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

                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");
                }
                bool          idFromRC   = false;
                Domain.Filter filtroIDRC = (from filtro in request.Filters where (filtro != null && !string.IsNullOrEmpty(filtro.Name) && filtro.Name.ToUpper() == "EXTRACT_ID_COMMONADDRESSBOOK") select filtro).FirstOrDefault();
                if (filtroIDRC != null && filtroIDRC.Value.ToUpper() == "TRUE")
                {
                    idFromRC = true;
                }
                //Chiamata al metodo CheckFilterType(request.Filters)
                Utils.CheckFilterTypes(request.Filters);

                DocsPaVO.rubrica.ParametriRicercaRubrica qco = Utils.GetParametriRicercaRubricaFromPis(request.Filters, infoUtente);

                BusinessLogic.Rubrica.DPA3_RubricaSearchAgent corrSearcher = new BusinessLogic.Rubrica.DPA3_RubricaSearchAgent(infoUtente);

                // DocsPaDB.Query_DocsPAWS.Rubrica query = new DocsPaDB.Query_DocsPAWS.Rubrica(infoUtente);
                DocsPaVO.rubrica.SmistamentoRubrica smistamentoRubrica = new DocsPaVO.rubrica.SmistamentoRubrica();
                ArrayList objElementiRubrica = corrSearcher.Search(qco, smistamentoRubrica);
                //ArrayList objElementiRubrica = query.GetElementiRubrica(qco);


                Domain.Correspondent[] correspondentsRespone = null;

                if (objElementiRubrica != null && objElementiRubrica.Count > 0)
                {
                    correspondentsRespone = new Domain.Correspondent[objElementiRubrica.Count];
                    for (int i = 0; i < objElementiRubrica.Count; i++)
                    {
                        Domain.Correspondent             userTemp        = new Domain.Correspondent();
                        DocsPaVO.rubrica.ElementoRubrica elementoRubrica = ((DocsPaVO.rubrica.ElementoRubrica)objElementiRubrica[i]);

                        userTemp.Id          = elementoRubrica.systemId;
                        userTemp.Description = elementoRubrica.descrizione;
                        userTemp.Code        = elementoRubrica.codice;
                        userTemp.Name        = elementoRubrica.nome;
                        userTemp.Surname     = elementoRubrica.cognome;
                        userTemp.NationalIdentificationNumber = elementoRubrica.cf_piva;
                        userTemp.IsCommonAddress = elementoRubrica.isRubricaComune;
                        userTemp.Type            = (elementoRubrica.interno ? "I" : "E");
                        if (!String.IsNullOrEmpty(elementoRubrica.tipo))
                        {
                            userTemp.CorrespondentType = elementoRubrica.tipo;
                        }

                        if (idFromRC && string.IsNullOrEmpty(elementoRubrica.systemId))
                        {
                            DocsPaVO.utente.Corrispondente userTemp2 = BusinessLogic.Utenti.UserManager.getCorrispondenteByCodRubricaRubricaComune(elementoRubrica.codice, infoUtente);
                            userTemp.Id = userTemp2.systemId;
                        }


                        correspondentsRespone[i] = userTemp;
                    }
                    response.Correspondents = correspondentsRespone;
                }
                else
                {
                    //throw new PisException("CORRESPONDENTS_NOT_FOUND");
                    correspondentsRespone   = new Domain.Correspondent[0];
                    response.Correspondents = correspondentsRespone;
                }

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