Пример #1
0
        //public static int AddSchemaVersion(
        //    Guid applicationID,
        //    string applicationName,
        //    int major,
        //    int minor,
        //    int build,
        //    int revision)
        //{
        //    return dbPortal.SchemaVersion_AddSchemaVersion(
        //        applicationID,
        //        applicationName,
        //        major,
        //        minor,
        //        build,
        //        revision);

        //}

        public static bool UpdateSchemaVersion(
            Guid applicationId,
            string applicationName,
            int major,
            int minor,
            int build,
            int revision)
        {
            if (!DBPortal.SchemaVersionExists(applicationId))
            {
                return(DBPortal.SchemaVersionAddSchemaVersion(
                           applicationId,
                           applicationName,
                           major,
                           minor,
                           build,
                           revision));
            }

            return(DBPortal.SchemaVersionUpdateSchemaVersion(
                       applicationId,
                       applicationName,
                       major,
                       minor,
                       build,
                       revision));
        }
Пример #2
0
        public static Version DBSchemaVersion()
        {
            // this should never change
            // its the last version before auto upgrades
            int major    = 2;
            int minor    = 2;
            int build    = 1;
            int revision = 4;

            bool found = false;

            try
            {
                using (IDataReader reader = DBPortal.SchemaVersionGetSchemaVersion(GetApplicationId()))
                {
                    if (reader.Read())
                    {
                        major    = Convert.ToInt32(reader["Major"]);
                        minor    = Convert.ToInt32(reader["Minor"]);
                        build    = Convert.ToInt32(reader["Build"]);
                        revision = Convert.ToInt32(reader["Revision"]);

                        found = true;
                    }
                }

                if (!found)
                {
                    DBPortal.SchemaVersionAddSchemaVersion(
                        GetApplicationId(),
                        GetApplicationName(),
                        major,
                        minor,
                        build,
                        revision);
                }
            }
            catch (DbException) { }
            catch (InvalidOperationException) { }


            return(new Version(major, minor, build, revision));
        }