예제 #1
0
        private void InitializeDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                IEncryptionAgent encryption;
                string passwd;

                IDbManager dbManager       = new Krokot.Database.Petapoco.PetapocoDbManager(null, null);
                IFileLoader resourceloader = new ResourceSqlLoader("resource-loader", "SqlFiles", Assembly.GetAssembly(this.GetType()));
                dbManager.AddSqlLoader(resourceloader);

                ConnectionStringCollection connections = ApplicationSettings.Instance.Database.Items;
                foreach (ConnectionStringElement connection in connections)
                {
                    encryption = new RijndaelEncryption(connection.Key, connection.IV);
                    passwd     = encryption.Decrypt(connection.Password);

                    dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor()
                    {
                        ConnectionString = string.Format(connection.ConnectionString, connection.UserId, passwd),
                        IsDefault        = connection.IsDefault,
                        Name             = connection.Name,
                        ProviderName     = connection.ProviderName
                    });
                }

                ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager);
            });
        }
예제 #2
0
        public static System.IO.StreamReader OpenExcelTemplate(this System.Web.Mvc.Controller controller, string name)
        {
            ResourceSqlLoader excelLoader = new ResourceSqlLoader("excel-template-loader", "ExcelTemplate", typeof(PIControllerExtensions).Assembly);

            excelLoader.Extensions.Clear();
            excelLoader.AddExtension("xlsx");
            return(excelLoader.GetStream(name));
        }
예제 #3
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"
            });
        }
예제 #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"
            });

        }