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(); }
static void Main(string[] args) { MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql(). ConnectionString(x => x.FromConnectionStringWithKey("Remote")); DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null; ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration) .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); }); dd.Drop(); Console.WriteLine("Database dropped."); Thread.Sleep(1000); dd.Create(); Console.WriteLine("Database created."); ISession session = sessionFactory.OpenSession(); using (ITransaction tx = session.BeginTransaction()) { dd.Seed(new List<IDataSeeder> { new AccountSeeder(session) }); tx.Commit(); } session.Close(); sessionFactory.Close(); Console.WriteLine("Seed data added."); Thread.Sleep(2000); }
static void Main(string[] args) { MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x => x.Is(ConnectionStrings.Get())); DatabaseDeployer dd = null; ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration) .Build(cfg => { dd = new DatabaseDeployer(cfg); }); dd.Drop(); Console.WriteLine(""); Console.WriteLine("Database dropped."); Thread.Sleep(1000); dd.Create(); Console.WriteLine(""); Console.WriteLine("Database created."); ISession session = sessionFactory.OpenSession(); using (ITransaction tx = session.BeginTransaction()) { dd.Seed(new List<IDataSeeder> { //add data seeders here. new UserSeeder(session) }); tx.Commit(); } session.Close(); sessionFactory.Close(); Console.WriteLine(""); Console.WriteLine("Seed data added."); Thread.Sleep(2000); }
static void Main(string[] args) { MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x => x.FromConnectionStringWithKey("Rainfall")); ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration).Build(); ISession session = sessionFactory.OpenSession(); var weatherData = new WorldWeatherOnline(session); weatherData.SaveDataFromPast(); weatherData.SaveDailyData(); session.Close(); sessionFactory.Close(); }
private static void Main(string[] args) { try { string connectionString = ConnectionStrings.Get(); MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql(). ConnectionString(x => x.Is(connectionString)); DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null; ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration) .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); }); dd.Drop(); Console.WriteLine("Database dropped."); Thread.Sleep(1000); dd.Create(); Console.WriteLine("Database created."); ISession session = sessionFactory.OpenSession(); using (ITransaction tx = session.BeginTransaction()) { dd.Seed(new List<IDataSeeder> { new UserSeeder(session), new ProjectEntitySeeder(session), new UserTypeEntitySeeder(session), new UserHistoryEntitySeeder(session) }); tx.Commit(); } session.Close(); sessionFactory.Close(); Console.WriteLine("Seed data added."); Thread.Sleep(2000); } catch (Exception ex) { String innerMessage = (ex.InnerException != null) ? ex.InnerException.Message : ""; Console.WriteLine(ex.Message); Console.WriteLine(innerMessage); string n = Console.ReadLine(); } }
static void Main(string[] args) { MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x => x.FromConnectionStringWithKey("Rainfall")); DatabaseDeployer dd = null; ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration) .Build(cfg => { dd = new DatabaseDeployer(cfg); }); using (var sess = sessionFactory.OpenSession()) { using (IDbCommand cmd = sess.Connection.CreateCommand()) { cmd.ExecuteSqlFile("dropForeignKeys.sql"); cmd.ExecuteSqlFile("dropPrimaryKeys.sql"); cmd.ExecuteSqlFile("dropTables.sql"); } } Console.WriteLine(""); Console.WriteLine("Database dropped."); //Thread.Sleep(1000); dd.Create(); Console.WriteLine(""); Console.WriteLine("Database created."); ISession session = sessionFactory.OpenSession(); using (ITransaction tx = session.BeginTransaction()) { dd.Seed(new List<IDataSeeder> { //add data seeders here. //new SeedAlamanacDays(session) new SeedCity(session) }); tx.Commit(); } session.Close(); sessionFactory.Close(); Console.WriteLine(""); Console.WriteLine("Seed data added."); //Thread.Sleep(2000); }
static void Main(string[] args) { args = args.Select(x => x.ToLower()).ToArray(); bool noArgs = !args.Any(); ConnectionStringSettings connectionStringSettings = ConnectionStrings.Get(); MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString( x => x.Is(connectionStringSettings.ConnectionString)) .Dialect<MsSqlAzureDialect>(); CreateDatabaseIfNotExists(connectionStringSettings); DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null; ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration, new EntityInterceptor()) .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); }); if (noArgs || args.Contains("drop")) { using (ISession sess = sessionFactory.OpenSession()) { using (IDbCommand cmd = sess.Connection.CreateCommand()) { cmd.ExecuteSqlFile("dropForeignKeys.sql"); //cmd.ExecuteSqlFile("dropPrimaryKeys.sql"); cmd.ExecuteSqlFile("dropTables.sql"); } } dd.Drop(); Console.WriteLine(""); Console.WriteLine("Database dropped."); } if (noArgs || args.Contains("create")) { dd.Create(); Console.WriteLine(""); Console.WriteLine("Database created."); } else if (args.Contains("update")) { dd.Update(); Console.WriteLine(""); Console.WriteLine("Database updated."); } if (noArgs || args.Contains("seed")) { ISession session = sessionFactory.OpenSession(); using (ITransaction tx = session.BeginTransaction()) { dd.Seed(new List<IDataSeeder> { //add data seeders here. new UserSeeder(session) }); tx.Commit(); } session.Close(); sessionFactory.Close(); Console.WriteLine(""); Console.WriteLine("Seed data added."); } Console.WriteLine("Done"); }