Esempio n. 1
0
        public static void CheckDBVersion()
        {
            DynamicUpdate.DynamicUpdateSqlite du = new DynamicUpdate.DynamicUpdateSqlite(connstr);

            int dbversion = 0;

            DataSet dsX = du.GetData("sqlite_master", "select [sql] from sqlite_master where [type] = 'table' and lower(name) = ?", new object[] { "dbversion" });
            bool has_dbversion = (dsX.Tables["sqlite_master"].Rows.Count > 0);
            if (has_dbversion)
            {
                dsX = du.GetData("dbversion", "select version from dbversion");
                if (dsX.Tables["dbversion"].Rows.Count > 0)
                {
                    dbversion = Convert.ToInt32(dsX.Tables["dbversion"].Rows[0]["version"]);
                }
            }
            int lastversioin = 0;
            for (int i = 0; i < DBInitSQL.InitSql.Length; )
            {
                lastversioin = (int)DBInitSQL.InitSql[i];
                if (dbversion < lastversioin)
                {
                    i++;
                    string[] sqls = (string[])DBInitSQL.InitSql[i];
                    for (int j = 0; j < sqls.Length; j++)
                    {
                        du.ExecSQL(sqls[j]);
                    }
                }
                else
                {
                    i++;
                }

                i++;
            }
            if (dbversion < lastversioin)
            {
                du.ExecSQL("delete from dbversion");
                du.ExecSQL("insert into dbversion(version, note) values(?, ?)", new object[] { lastversioin, "" });
            }
        }
Esempio n. 2
0
        public static bool SaveLicense(string Aserial, string Aenterprise, decimal Acluster_node_num, string Atype, DateTime Aexpiration, string Aregistration_code, string Asignature)
        {
            bool re = false;

            DynamicUpdate.DynamicUpdateSqlite du = new DynamicUpdate.DynamicUpdateSqlite(connstr);

            string sqldel = @"delete from wlt_license where enterprise=? and registration_code=?";
            string sqlins = @"insert into wlt_license(serial, enterprise, cluster_node_num, type, expiration, registration_code, signature) values(?, ?, ?, ?, ?, ?, ?)";
            du.ExecSQL(new string[] { sqldel, sqlins },
                new object[][]{
                    new object[] { Aenterprise, Aregistration_code },
                    new object[] { Aserial, Aenterprise, Acluster_node_num, Atype, Aexpiration, Aregistration_code, Asignature }});
            re = true;

            return re;
        }