Example #1
0
        public void Main()
        {
            ConfigurationSettings settings = new ConfigurationSettings();
            ObjectPool.Instance.Register<ConfigurationSettings>().ImplementedBy(settings);

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
            dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = settings.ConnectionString.ConnectionString,
                IsDefault = true,
                Name = settings.ConnectionString.Name,
                ProviderName = settings.ConnectionString.ProviderName
            });

            ObjectPool.Instance.Register<PetapocoDbManager>().ImplementedBy(dbManager);
        }
Example #2
0
        private void Initiliaze(DbConnection connection)
        {
            ResourceSqlLoader loader = new ResourceSqlLoader("resources.sql.loader",
                                                             string.Join(".", new string[] { this.GetType().Namespace, "SqlFiles" }),
                                                             System.Reflection.Assembly.GetAssembly(this.GetType()));

            dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(loader);
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = ((DbConnection)connection).ConnectionString,
                IsDefault        = true,
                ProviderName     = ((DbConnection)connection).ProviderName,
                Name             = "smsgw"
            });
        }
Example #3
0
        private void InitializeDatabase()
        {
            ApplicationSettings applicationSettings = (ApplicationSettings)ObjectPool.Instance.Resolve <GSMServer.Configuration.IConfiguration>();

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(new ResourceSqlLoader("resources-sql-loader", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ConnectionString,
                IsDefault        = true,
                Name             = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].Name,
                ProviderName     = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ProviderName
            });

            ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
        }
Example #4
0
        private void Initiliaze(DbConnection connection)
        {
            ResourceSqlLoader loader = new ResourceSqlLoader("resources.sql.loader", 
                string.Join(".", new string[] { this.GetType().Namespace, "SqlFiles" }), 
                System.Reflection.Assembly.GetAssembly(this.GetType()));

            dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(loader);
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = ((DbConnection)connection).ConnectionString,
                IsDefault = true,
                ProviderName = ((DbConnection)connection).ProviderName,
                Name = "smsgw"
            });

        }
Example #5
0
        public void Main()
        {
            ConfigurationSettings settings = new ConfigurationSettings();

            ObjectPool.Instance.Register <ConfigurationSettings>().ImplementedBy(settings);

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);

            dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = settings.ConnectionString.ConnectionString,
                IsDefault        = true,
                Name             = settings.ConnectionString.Name,
                ProviderName     = settings.ConnectionString.ProviderName
            });

            ObjectPool.Instance.Register <PetapocoDbManager>().ImplementedBy(dbManager);
        }
Example #6
0
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                ApplicationSettings settings = null;
                string formattedConnectionString;
                string connectionString;
                IDbManager dbManager;

                while (settings == null)
                {
                    settings = ObjectPool.Instance.Resolve <ApplicationSettings>();

                    if (settings != null)
                    {
                        formattedConnectionString = ConfigurationManager.AppSettings.Get("FormattedConnectionString");
                        connectionString          = string.Format(formattedConnectionString, settings.Database.Server, settings.Database.Name, settings.Database.Username, settings.Database.Password);

                        dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
                        dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SMSGatewayWpf.SqlFiles", Assembly.GetAssembly(this.GetType())));
                        dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                        {
                            ConnectionString = connectionString,
                            IsDefault        = true,
                            Name             = settings.Database.Name,
                            ProviderName     = settings.Database.ProviderName
                        });

                        ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
                        break;
                    }

                    Thread.Sleep(5000);
                }
            });
        }
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() => 
            {
                ApplicationSettings settings = null;
                string formattedConnectionString;
                string connectionString;
                IDbManager dbManager;

                while (settings == null)
                {
                    settings = ObjectPool.Instance.Resolve<ApplicationSettings>();

                    if (settings != null)
                    {
                        formattedConnectionString = ConfigurationManager.AppSettings.Get("FormattedConnectionString");
                        connectionString = string.Format(formattedConnectionString, settings.Database.Server, settings.Database.Name, settings.Database.Username, settings.Database.Password);

                        dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
                        dbManager.AddSqlLoader(new ResourceSqlLoader("filesql", "SMSGatewayWpf.SqlFiles", Assembly.GetAssembly(this.GetType())));
                        dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                        {
                            ConnectionString = connectionString,
                            IsDefault = true,
                            Name = settings.Database.Name,
                            ProviderName = settings.Database.ProviderName
                        });

                        ObjectPool.Instance.Register<IDbManager>().ImplementedBy(dbManager);
                        break;
                    }

                    Thread.Sleep(5000);
                }
                
            });
        }
Example #8
0
        private void InitializeDatabase()
        {
            ApplicationSettings applicationSettings = (ApplicationSettings)ObjectPool.Instance.Resolve<GSMServer.Configuration.IConfiguration>();  

            PetapocoDbManager dbManager = new Texaco.Database.Petapoco.PetapocoDbManager(null, null);
            dbManager.AddSqlLoader(new ResourceSqlLoader("resources-sql-loader", "SqlFiles", Assembly.GetCallingAssembly()));
            dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
            {
                ConnectionString = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ConnectionString,
                IsDefault = true,
                Name = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].Name,
                ProviderName = applicationSettings.ConnectionStrings[DatabaseNames.SMSGW].ProviderName
            });

            ObjectPool.Instance.Register<IDbManager>().ImplementedBy(dbManager); 
        }