コード例 #1
0
        public static Services.AddressBook.GetCorrespondent.GetCorrespondentResponse GetCorrespondent(Services.AddressBook.GetCorrespondent.GetCorrespondentRequest request)
        {
            Services.AddressBook.GetCorrespondent.GetCorrespondentResponse response = new Services.AddressBook.GetCorrespondent.GetCorrespondentResponse();

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

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

                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.IdCorrespondent))
                {
                    //Id del corrispondente non presente
                    throw new PisException("REQUIRED_IDCORRESPONDENT");
                }

                DocsPaVO.utente.Corrispondente corr = BusinessLogic.Utenti.UserManager.getCorrispondenteBySystemID(request.IdCorrespondent);

                if ((corr == null) || (corr != null && string.IsNullOrEmpty(corr.systemId) && string.IsNullOrEmpty(corr.codiceRubrica)))
                {
                    bool rubricaComuneAbilitata = BusinessLogic.RubricaComune.Configurazioni.GetConfigurazioni(infoUtente).GestioneAbilitata;
                    if (rubricaComuneAbilitata)
                    {
                        corr = BusinessLogic.Utenti.UserManager.getCorrispondenteByCodRubricaRubricaComune(request.IdCorrespondent, infoUtente);
                    }

                    if (corr == null)
                    {
                        //Corrispondente non trovato
                        throw new PisException("CORRESPONDENT_NOT_FOUND");
                    }
                    else
                    {
                        corr.inRubricaComune = true;
                    }
                }
                else
                {
                    corr.inRubricaComune = false;
                }

                Domain.Correspondent corrResponse = Utils.GetCorrespondent(corr, infoUtente);
                response.Correspondent = corrResponse;

                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);
        }
コード例 #3
0
        public static Services.AddressBook.AddCorrespondent.AddCorrespondentResponse AddCorrespondent(Services.AddressBook.AddCorrespondent.AddCorrespondentRequest request)
        {
            Services.AddressBook.AddCorrespondent.AddCorrespondentResponse response = new Services.AddressBook.AddCorrespondent.AddCorrespondentResponse();
            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

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

                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.Correspondent == null)
                {
                    //Corrispondente non trovato
                    throw new PisException("REQUIRED_CORRESPONDENT");
                }

                if (string.IsNullOrEmpty(request.Correspondent.CorrespondentType) || (!request.Correspondent.CorrespondentType.Equals("U") && !request.Correspondent.CorrespondentType.Equals("P")))
                {
                    //Inserire il tipo U o P
                    throw new PisException("REQUIRED_CORRESPONDENTTYPE");
                }

                if (request.Correspondent.CorrespondentType.Equals("U"))
                {
                    if (string.IsNullOrEmpty(request.Correspondent.Description))
                    {
                        //richiesta descrizione
                        throw new PisException("REQUIRED_DESCRIPTION_CORREPONDENT");
                    }
                }

                if (request.Correspondent.CorrespondentType.Equals("P"))
                {
                    if (string.IsNullOrEmpty(request.Correspondent.Name) || string.IsNullOrEmpty(request.Correspondent.Surname))
                    {
                        //richiesta descrizione
                        throw new PisException("REQUIRED_N_S_CORREPONDENT");
                    }
                }

                DocsPaVO.utente.Corrispondente corrResult   = null;
                Domain.Correspondent           corrResponse = null;

                //Posso creare solo esterni
                request.Correspondent.Type = "E";

                DocsPaVO.utente.Corrispondente corr = Utils.GetCorrespondentFromPisNewInsert(request.Correspondent, infoUtente);


                if (corr != null && !string.IsNullOrEmpty(corr.tipoCorrispondente) && !corr.tipoCorrispondente.Equals("O") && !BusinessLogic.Utenti.addressBookManager.VerificaInserimentoCorrispondente(corr, null))
                {
                    //Codice corrispondente già presente
                    throw new PisException("CODE_CORRESPONDENT_EXISTS");
                }

                corrResult = BusinessLogic.Utenti.addressBookManager.insertCorrispondente(corr, null);

                corrResponse = Utils.GetCorrespondent(corrResult, infoUtente);

                if (corrResponse != null)
                {
                    List <DocsPaVO.utente.MailCorrispondente> casella = new List <DocsPaVO.utente.MailCorrispondente>();
                    casella.Add(new DocsPaVO.utente.MailCorrispondente()
                    {
                        Email      = corrResult.email,
                        Note       = "",
                        Principale = "1"
                    });

                    BusinessLogic.Utenti.addressBookManager.InsertMailCorrispondente(casella, corrResult.systemId);
                    response.Correspondent = corrResponse;
                    response.Success       = true;
                }
                else
                {
                    //Corrispondente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
            }
            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);
        }