コード例 #1
0
        public static DbResult DropAndRecreate()
        {
            DbResult apiResult = new DbResult();

            try
            {
                SetConnectionStringInDatabaseHandler();
                IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection(SectionName) as IConfigurationSource;
                ActiveRecordStarter.Initialize(source, TypesToKeepTrackOf.ToArray());
                ActiveRecordStarter.DropSchema();
                ActiveRecordStarter.UpdateSchema();
                apiResult.SetSuccessAsStatusInResponseFields();
            }
            catch (Exception ex)
            {
                if (ex.Message.ToUpper().Contains("MORE THAN ONCE"))
                {
                    apiResult.StatusCode = DbGlobals.SUCCESS_STATUS_CODE;
                    apiResult.StatusDesc = "SUSPECTED DOUBLE INITIALIZE: " + ex.Message;
                }
                else
                {
                    apiResult.SetFailuresAsStatusInResponseFields(ExceptionLeadString + ex.Message);
                }
            }

            return(apiResult);
        }
コード例 #2
0
        public static void Main()
        {
            ActiveRecordStarter.Initialize(
                new XmlConfigurationSource("../appconfig.xml"),
                typeof(Company), typeof(Client), typeof(Firm), typeof(Person));

            // If you want to let AR to create the schema

            ActiveRecordStarter.CreateSchema();

            // Common usage

            Client.DeleteAll();
            Firm.DeleteAll();
            Company.DeleteAll();

            Company company = new Company("Keldor");

            company.Save();

            Firm firm = new Firm("Johnson & Norman");

            firm.Save();

            Client client = new Client("hammett", firm);

            client.Save();

            // Dropping the schema

            ActiveRecordStarter.DropSchema();
        }
コード例 #3
0
        private static void InitDatabase()
        {
            var config          = ActiveRecordSectionHandler.Instance;
            var assemblyLibrary = Assembly.Load("FileProccesor");

            ActiveRecordStarter.Initialize(assemblyLibrary, config);

            switch (ConfigurationManager.AppSettings["Enviroment"])
            {
            case "Development":
                ActiveRecordStarter.DropSchema();
                ActiveRecordStarter.CreateSchema();
                break;

            case "Testing":
                ActiveRecordStarter.UpdateSchema();
                break;

            default:
                break;
            }


            var callbackContext = new CallbackContext("Conectado a la Base de Datos", ActiveRecordStarter.ConfigurationSource.ToString());

            var notification = new Notification(_application.Name, _notificationType.Name, DateTime.Now.Ticks.ToString(), "InitDatabase", "OK");

            _growl.Notify(notification, callbackContext);
        }
コード例 #4
0
 public virtual void Drop()
 {
     try
     {
         ActiveRecordStarter.DropSchema();
     }
     catch (Exception)
     {
     }
 }
コード例 #5
0
ファイル: TestBase.cs プロジェクト: 605333616/Match
 public void InitDataBase()
 {
     if (!ActiveRecordStarter.IsInitialized)
     {
         IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection("activerecord") as
                                       IConfigurationSource;
         ActiveRecordStarter.Initialize(typeof(EntityBase).Assembly, source);
     }
     ActiveRecordStarter.DropSchema();
     ActiveRecordStarter.CreateSchema();
 }
コード例 #6
0
 public void Drop()
 {
     // if (disableDrop) return;
     try
     {
         ActiveRecordStarter.DropSchema();
     }
     catch (Exception)
     {
     }
 }
コード例 #7
0
        public void Terminate()
        {
            try
            {
                ActiveRecordStarter.DropSchema();
            }
            catch (Exception)
            {
            }

            container.Dispose();
        }
コード例 #8
0
        private static void InitDatabase()
        {
            var config          = ActiveRecordSectionHandler.Instance;
            var assemblyLibrary = Assembly.Load("FileProccesor");

            ActiveRecordStarter.Initialize(assemblyLibrary, config);

            switch (ConfigurationManager.AppSettings["Enviroment"])
            {
            case "Development":
                ActiveRecordStarter.DropSchema();
                ActiveRecordStarter.CreateSchema();
                break;

            case "Testing":
                ActiveRecordStarter.UpdateSchema();
                break;

            default:
                break;
            }
        }
コード例 #9
0
        internal ApiResult DropAndRecreate()
        {
            ApiResult apiResult = new ApiResult();

            try
            {
                IConfigurationSource source             = System.Configuration.ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
                List <Type>          typesToKeepTrackOf = GetTypesToKeepTrackOf();
                ActiveRecordStarter.Initialize(source, typesToKeepTrackOf.ToArray());
                ActiveRecordStarter.DropSchema();
                ActiveRecordStarter.UpdateSchema();
                Seed();
                apiResult.SetSuccessAsStatusInResponseFields();
            }
            catch (Exception ex)
            {
                HandleError("OnInitialize", "EXCEPTION", ex.Message);
                apiResult.SetFailuresAsStatusInResponseFields("FAILED TO INTIALIZE API");
            }

            return(apiResult);
        }
コード例 #10
0
 /// <summary>
 /// Drops the Schema of all tables that this has originally initialized with
 /// </summary>
 public static void DropSchema()
 {
     ActiveRecordStarter.DropSchema();
 }
コード例 #11
0
        public static void Main()
        {
            ActiveRecordStarter.Initialize(
                new XmlConfigurationSource("../appconfig.xml"),
                typeof(Blog), typeof(Post));

            // If you want to let AR to create the schema

            ActiveRecordStarter.CreateSchema();

            // Common usage

            Post.DeleteAll();
            Blog.DeleteAll();

            Blog blog = new Blog("somename");

            blog.Author = "hammett";
            blog.Save();

            Post post = new Post(blog, "title", "contents", "castle");

            post.Save();

            Post.DeleteAll();
            Blog.DeleteAll();

            // Using Session Scope

            using (new SessionScope())
            {
                blog        = new Blog("somename");
                blog.Author = "hammett";
                blog.Save();

                post = new Post(blog, "title", "contents", "castle");
                post.Save();
            }

            // Using transaction scope

            Post.DeleteAll();
            Blog.DeleteAll();

            TransactionScope transaction = new TransactionScope();

            try
            {
                blog        = new Blog("somename");
                blog.Author = "hammett";
                blog.Save();

                post = new Post(blog, "title", "contents", "castle");
                post.Save();
            }
            catch (Exception ex)
            {
                transaction.VoteRollBack();
            }
            finally
            {
                transaction.Dispose();
            }

            ActiveRecordStarter.DropSchema();
        }
コード例 #12
0
 private static void RecreateDatabase()
 {
     ActiveRecordStarter.DropSchema();
     ActiveRecordStarter.CreateSchema();
 }