public ModelInvokeResult <ServerPK> Create(Server server) { ModelInvokeResult <ServerPK> result = new ModelInvokeResult <ServerPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); if (server.ServerId == "自动生成") { server.ServerId = GlobalManager.getPK(server.GetMappingTableName(), "ServerId"); } /***********************begin 自定义代码*******************/ /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = server.GetCreateMethodName(), ParameterObject = server.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); bool needDatabaseConnect = server.ServerId.StartsWith("Job"); if (needDatabaseConnect) { /***********************begin 自定义代码*******************/ DatabaseConnect databaseConnect = new DatabaseConnect { ConnectId = "Job-" + server.ServerId, ConnectName = "作业-" + server.ServerName, Provider = GlobalManager.DIKey_00015_SqlServer2005, ServerName = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(server.IpAddress), DatabaseName = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Host_Database), UserCode = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Database_User), UserPassword = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Database_Password), IBatisMapId = "SqlMap-Job-" + server.ServerId, IbatisConfigFileRefer = GlobalManager.IbatisConfigFileRefer, IbatisConfigFileValue = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.IbatisConfigFileValue_Job) }; statements.Add(new IBatisNetBatchStatement { StatementName = databaseConnect.GetCreateMethodName(), ParameterObject = databaseConnect.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); /***********************end 自定义代码*********************/ } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new ServerPK { ServerId = server.ServerId }; if (needDatabaseConnect) { //注册数据连接ase GlobalManager.RegisterDatabaseConnections(); } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public ModelInvokeResult <DatabaseConnectPK> Create(DatabaseConnect databaseConnect) { ModelInvokeResult <DatabaseConnectPK> result = new ModelInvokeResult <DatabaseConnectPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); if (databaseConnect.ConnectId == "自动生成") { databaseConnect.ConnectId = GlobalManager.getPK(databaseConnect.GetMappingTableName(), "ConnectId"); } /***********************begin 自定义代码*******************/ databaseConnect.ServerName = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(databaseConnect.ServerName); databaseConnect.DatabaseName = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(databaseConnect.DatabaseName); databaseConnect.UserCode = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(databaseConnect.UserCode); databaseConnect.UserPassword = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(databaseConnect.UserPassword); databaseConnect.IbatisConfigFileValue = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(databaseConnect.IbatisConfigFileValue); /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = databaseConnect.GetCreateMethodName(), ParameterObject = databaseConnect.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new DatabaseConnectPK { ConnectId = databaseConnect.ConnectId }; //注册数据连接ase GlobalManager.RegisterDatabaseConnections(); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }