Ejemplo n.º 1
0
 public ContattoRepository(int idPersona, UserInfo info, WindsorConfigRepository windsorRepository)
 {
     _info = info;
     _windsorRepository = windsorRepository;
     var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
     _persona = daoFactory.GetPersonaDao().GetById(idPersona, false);
 }
Ejemplo n.º 2
0
        public MovimentoBancarioRepository(UserInfo info, WindsorConfigRepository windsorRepository)
        {
            _windsorRepository = windsorRepository;
            _info = info;
            _daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
            IList<CausaleACBI> lista = _daoFactory.GetCausaleACBIDao().GetAll();
            _causaliACBI = new Dictionary<string, CausaleACBI>(lista.Count);
            foreach (CausaleACBI caus in lista)
                _causaliACBI.Add(caus.Codice, caus);

        }
Ejemplo n.º 3
0
 public DisposizioneRepository(UserInfo info, WindsorConfigRepository windsorRepository)
 {
     _info = info;
     _windsorRepository = windsorRepository;
     _daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
 }
Ejemplo n.º 4
0
        public UtenteVerificaDTO VerifyUser(string codiceAzienda, string username, string password, ComputerDTO computerInfo, out IWindsorContainer container)
        {
            try
            {
                IDaoFactory daoFactory = null;
                container = null;
                var sc = new SymmetricCryptography<TripleDESCryptoServiceProvider>(Login.Instance.Key, Login.Instance.IV);
                username = sc.Decrypt(username);
                password = sc.Decrypt(password);

                var windsorConfigRepository = new WindsorConfigRepository();
                Azienda azienda = null;
                if (!string.IsNullOrEmpty(codiceAzienda))
                {
                    try
                    {
                        codiceAzienda = sc.Decrypt(codiceAzienda);
                        container = windsorConfigRepository.GetContainer(codiceAzienda);
                        daoFactory = windsorConfigRepository.GetDaoFactory(codiceAzienda);

                        if(daoFactory != null)
                            azienda = daoFactory.GetAziendaDao().GetByCodice(codiceAzienda);
                        else
                            return null;
                    }
                    catch (Exception ex)
                    {
                        _log.ErrorFormat("Errore nel riconoscimento dell'utente - {0} - codiceAzienda:{1} - user:{2} - pwd:{3}", ex, Utility.GetMethodDescription(), codiceAzienda, username, password);
                        throw;
                    }
                }
                else
                {
                    var userAzienda = username.Split('&');
                    if (userAzienda.Length == 2)
                    {
                        codiceAzienda = userAzienda[1];
                        container = windsorConfigRepository.GetContainer(codiceAzienda); 
                        username = userAzienda[0];
                        daoFactory = windsorConfigRepository.GetDaoFactory(codiceAzienda);
                        azienda = daoFactory.GetAziendaDao().GetByCodice(codiceAzienda);
                    }
                }

                if (azienda != null || string.IsNullOrEmpty(codiceAzienda))
                {
                    IList<Utente> users = new List<Utente>();
                    if (azienda != null)
                    {
                        container = windsorConfigRepository.GetContainer(azienda.ID);
                        users = daoFactory.GetUtenteDao().GetByAzienda(username, password, azienda);
                    }
                    else
                    {
                        // Mi trovo nel caso di validare la password principale, l'utente principale si trova sempre nell'azienda principale "ZETH"
                        try
                        {
                            daoFactory = windsorConfigRepository.GetDaoFactory("ZETH");
                            container = windsorConfigRepository.GetContainer("ZETH");
                            var utente = daoFactory.GetUtenteDao().GetByUsername(username, codiceAzienda);
                            if (utente.Password == password)
                                users.Add(utente);
                        }
                        catch (Exception ex)
                        {
                            _log.ErrorFormat("Errore nel riconoscimento dell'utente - ZETH - {0} - user:{1} - pwd:{2} - codiceAzienda:{3}", ex, Utility.GetMethodDescription(), username, password, codiceAzienda);
                            throw;
                        }
                    }

                    if (users.Count > 0)
                    {
                        if (users.Count > 1)
                            _log.ErrorFormat("Trovati più di un utente con stesso username e stessa password - {0} - user:{1} - pwd:{2}", Utility.GetMethodDescription(), username, password);

                        int? idAzienda = null;
                        if (azienda != null)
                            idAzienda = azienda.ID;

                        // Memorizzo log di login
                        if (azienda != null && computerInfo != null)
                        {
                            try
                            {
                                if (container != null)
                                {
                                    var context = OperationContext.Current;
                                    var messageProperties = context.IncomingMessageProperties;
                                    var endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                                    IpAddress clientIp = null;
                                    if (endpointProperty != null)
                                        clientIp = new IpAddress { IpNumber = endpointProperty.Address, IpPort = endpointProperty.Port };

                                    var logService = container.Resolve<ILogTransazioneService>();
                                    logService.AddLog(users[0], computerInfo, clientIp, AzioneUtente.Login);
                                }
                           }
                            catch (Exception ex)
                            {
                                _log.ErrorFormat("Errore nella memorizzazione di informazioni sul computer di collegamento - {0} - user:{1} - password:{2} - nomeComputer:{3} - versioneSO:{4} - versioneFramework:{5}", ex, Utility.GetMethodDescription(), username, password, computerInfo.ComputerName, computerInfo.OsVersionString,  computerInfo.FrameworkVersion);
                            }
                        }

                        var utenteVerificaDTO =  new UtenteVerificaDTO
                            {
                                Id = users[0].ID,
                                Username = users[0].Username,
                                Password = users[0].Password,
                                IdAzienda = idAzienda
                            };

                        if (users[0].Referente != null)
                        {
                            utenteVerificaDTO.Cognome = users[0].Referente.PersonaRiferimento.Cognome;
                            utenteVerificaDTO.Nome = users[0].Referente.PersonaRiferimento.Nome;
                        }
                        else
                        {
                            utenteVerificaDTO.Cognome = users[0].Cognome;
                            utenteVerificaDTO.Nome = users[0].Nome;
                        }

                        return utenteVerificaDTO;
                    }
                    return null;
                }
                return null;
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nel riconoscimento dell'utente - {0} - codiceAzienda:{1} - user:{2} - pwd:{3}", ex, Utility.GetMethodDescription(), codiceAzienda, username, password);
                throw;
            }
        }