Beispiel #1
0
        public List<AbiDTO> GetAllAbi()
        {
            string abiPath;
            if (ApplicationDeployment.IsNetworkDeployed)
                abiPath = ApplicationDeployment.CurrentDeployment.DataDirectory + @"\" + "TabAbi.txt";
            else if (!ConfigurationManager.AppSettings["AbiCabPath"].Contains(":"))
                abiPath = Application.StartupPath + @"\" + ConfigurationManager.AppSettings["AbiPath"];
            else
                abiPath = ConfigurationManager.AppSettings["AbiCabPath"];

            if (abiPath != string.Empty)
            {
                _listaAbi.Clear();
                using (var csv = new CsvReader(new StreamReader(abiPath), true, '\t'))
                {
                    while (csv.ReadNextRecord())
                    {
                        try
                        {
                            var abi = new AbiDTO
                            {
                                Codice = csv["AbiCode"],
                                Descrizione = csv["Descrizione"]
                            };

                            _listaAbi.Add(abi);
                        }
                        catch (Exception ex)
                        {
                            _log.Error("Errore nel caricamento di una riga Abi - " + Utility.GetMethodDescription() + " - csv index:" + csv.CurrentRecordIndex, ex);
                            throw;
                        }
                    }

                }

                return _listaAbi;
            }
            return null;
        }
Beispiel #2
0
        public void LoadAbi()
        {
            try
            {
                string abiPath;
                if (ApplicationDeployment.IsNetworkDeployed)
                    abiPath = ApplicationDeployment.CurrentDeployment.DataDirectory + "\\" + "TabAbi.txt";
                else if (!ConfigurationManager.AppSettings["AbiCabPath"].Contains(":"))
                    abiPath = Application.StartupPath + @"\" + ConfigurationManager.AppSettings["AbiPath"];
                else
                    abiPath = ConfigurationManager.AppSettings["AbiCabPath"];

                if (abiPath != string.Empty)
                {
                    var listaAbi = new List<AbiDTO>();
                    using (var csv = new CsvReader(new StreamReader(abiPath), true, '\t'))
                    {
                        while (csv.ReadNextRecord())
                        {
                            try
                            {
                                var abi = new AbiDTO
                                {
                                    Codice = csv["AbiCode"],
                                    Descrizione = csv["Descrizione"]
                                };

                                listaAbi.Add(abi);
                            }
                            catch (Exception ex)
                            {
                                _log.Error("Errore nel caricamento di una riga Abi - " + Utility.GetMethodDescription() + " - csv index:" + csv.CurrentRecordIndex, ex);
                                throw;
                            }
                        }

                    }

                    _cache.Add("AllAbi", listaAbi, CacheItemPriority.Normal, new CollectionCacheRefreshAction(),
                        new AbsoluteTime(DateTime.Now.AddMinutes(300)));
                }
            }
            catch (Exception ex)
            {
                _log.Error("Errore nel caricamento della tabella Abi - " + Utility.GetMethodDescription(), ex);
                throw;
            }
        }
Beispiel #3
0
        public List<AbiDTO> GetAbiByExample(AbiDTO item)
        {
            var banche = from abi in GetAllAbi()
                         where (item.Codice == null || abi.Codice == item.Codice) &&
                         (item.Descrizione == null || abi.Descrizione.ToLower().StartsWith(item.Descrizione.ToLower()))
                         select abi;

            return new List<AbiDTO>(banche.ToList());
        }
 private AbiDTO setAbiDto(Banca item)
 {
     if (item != null)
     {
         var dto = new AbiDTO
         {
             Codice = item.ID,
             Descrizione = item.Descrizione
         };
         return dto;
     }
     return null;
 }