static void Main(string[] args) { MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql(). ConnectionString(x => x.FromConnectionStringWithKey("AutomatedCaseWorker")); ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration).Build(); ISession session = sessionFactory.OpenSession(); _caseRepository = new CaseRepository(session); _cases = _caseRepository.GetAllActive().ToList(); _repository = new Repository(session); _twilioMessageSender = new TwilioMessageSender(_repository); foreach (var @case in _cases) { TimeSpan ts = DateTime.Now.Subtract(@case.LastActivity); if(ts.TotalMinutes>=15) { _twilioMessageSender.Send(new OutgoingMessage(@case.CellPhoneNumber, String.Format("Su nĂºmero de caso es {0}", @case.CaseNumber()))); _caseRepository.MarkCaseAsInactive(@case); } } session.Close(); sessionFactory.Close(); }