init lserp cs 5.0

This commit is contained in:
cyf
2026-07-10 15:25:05 +08:00
commit 90f3fda86a
3799 changed files with 976868 additions and 0 deletions
@@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlClient;
using Zhaizj.Framework.ORM;
namespace Zhaizj.Framework.Data {
internal class SQLServerDatabaseChecker : IDatabaseChecker {
private static readonly ILog logger = LogManager.GetLogger( typeof( SQLServerDatabaseChecker ) );
private String _connectionString;
private DatabaseType _databaseType;
public String ConnectionString {
get { return _connectionString; }
set { _connectionString = value; }
}
public DatabaseType DatabaseType {
get { return _databaseType; }
set { _databaseType = value; }
}
private List<String> existTables = new List<String>();
public void CheckDatabase() {
if (strUtil.IsNullOrEmpty( _connectionString )) {
throw new Exception( "[sqlserver] connection String is not found" );
}
IDatabaseDialect dialect = DataFactory.GetDialect( DatabaseType.SqlServer );
if (strUtil.IsNullOrEmpty( dialect.GetConnectionItem( _connectionString, ConnectionItemType.Server ) )) {
throw new Exception( "[sqlserver] address is empty" );
}
if (strUtil.IsNullOrEmpty( dialect.GetConnectionItem( _connectionString, ConnectionItemType.Database ) )) {
throw new Exception( "[sqlserver] database is empty" );
}
}
public void CheckTable( MappingClass mapping, String db ) {
logger.Info( "[sqlserver] begin check table" );
SqlConnection connection = new SqlConnection( _connectionString );
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
cmd.CommandText = "SELECT OBJECT_NAME(id) as name FROM sysobjects WHERE xtype='U' AND OBJECTPROPERTY(id, 'IsMSShipped') = 0";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
existTables.Add( reader["name"].ToString() );
logger.Info( "table found" + reader["name"].ToString() );
}
reader.Close();
existTables = new SqlServerTableBuilder().CheckMappingTableIsExist( cmd, db, existTables, mapping );
connection.Close();
}
public List<String> GetTables() {
return existTables;
}
}
}