public int InsertMillesimo(int idMillesimo, decimal valore, UserInfo userinfo) { var windsorRep = new WindsorConfigRepository(); try { windsorRep.BeginTransaction(userinfo); var repo = new MillesimoRepository(userinfo, windsorRep); var item = repo.Update(idMillesimo, valore); windsorRep.Commit(); return item; } catch (Exception ex) { _log.ErrorFormat("Errore nell'inserimento di un millesimo - {0} - millesimo:{1} - valore:{2} - azienda:{3}", ex, Utility.GetMethodDescription(), idMillesimo, valore, userinfo.Azienda); windsorRep.Rollback(); throw; } }
public bool Update(int idMillesimo, int idConto, int idUnita, decimal valore) { try { var isInserimento = false; var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda); var millesimo = daoFactory.GetMillesimoDao().GetByContoSoggetto(idConto, idUnita); var repo = new MillesimoRepository(_info, _windsorRepository); if (millesimo != null) repo.Update(millesimo.ID, valore); else { repo.Insert(idConto, idUnita, valore); isInserimento = true; } return isInserimento; } catch (Exception ex) { _log.Error("Errore nel salvataggio dei millesimi: " + Library.Utility.GetMethodDescription() + " - idMillesimo:" + idMillesimo + " - idConto:" + idConto + " - idUnita:" + idUnita + " - valore: " + valore, ex); throw; } }
public void UpdateMillesimo(List<MillesimoUpdateDTO> millesimi, UserInfo userinfo) { var retryCount = 5; var success = false; var windsorRep = new WindsorConfigRepository(); while (retryCount >= 0 && !success) { try { windsorRep.BeginTransaction(userinfo); var repo = new MillesimoRepository(userinfo, windsorRep); repo.Update(millesimi); windsorRep.Commit(); success = true; } catch (Exception ex) { _log.ErrorFormat("Errore nell'aggiornamento dei millesimi - TENTATIVO:{0} - {1} - azienda:{2} - number:{3}", ex, (6 - retryCount), Utility.GetMethodDescription(), userinfo.Azienda, getExceptionId(ex)); windsorRep.Rollback(); if (!isRetryException(ex)) throw; // Add delay here if you wish. System.Threading.Thread.Sleep(1000 * (6 - retryCount)); retryCount--; _log.InfoFormat("Aggiornamento dei millesimi - TENTATIVO:{0} - {1} - azienda:{2}", (6 - retryCount), Utility.GetMethodDescription(), userinfo.Azienda); } } if (!success) windsorRep.Rollback(); }