public void ConfigTerminal(Replica replica, Table table, List<Insert> valuesToInsert) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrTerminalUser, replica.StrTerminalPassword, replica.StrTerminalIPAddress, replica.IntTerminalPort.ToString(), replica.StrTerminalDatabase); sqlDatabaseAccess.CreateReplicaLogs(); sqlDatabaseAccess.createTable(table); sqlDatabaseAccess.ExecuteMultipleInsert(valuesToInsert); sqlDatabaseAccess.CreateTrigger(table); }
public Table ConfigSource(Replica replica) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); sqlDatabaseAccess.CreateReplicaLogs(); //GEtTabe Table table = sqlDatabaseAccess.getTableStructure(replica.StrSourceDatabase, replica.StrSourceTable); //valuesToInsert = sqlDatabaseAccess.GetCurrentRows(table); sqlDatabaseAccess.CreateTrigger(table); return table; }
public Table ConfigSource(Replica replica) { MysqlDatabaseDA sqlDatabaseAccess = new MysqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); sqlDatabaseAccess.CreateReplicaLogs(); Table table = sqlDatabaseAccess.getTableStructure(replica.StrSourceDatabase, replica.StrSourceTable); sqlDatabaseAccess.CreateTriggerDelete(table); sqlDatabaseAccess.CreateTriggerInsert(table); sqlDatabaseAccess.CreateTriggerUpdate(table); return table; }
public ReplicaView(Replica replica) { //IdReplica = replica.IntIdReplica; //IdSourceEngine = replica.IntIdSourceEngine; SourceEngine = replica.StrSourceEngine; SourceIPAddress = replica.StrSourceIPAddress; SourcePort = replica.IntSourcePort; SourceUser = replica.StrSourceUser; SourcePassword = replica.StrSourcePassword; SourceDatabase = replica.StrSourceDatabase; SourceTable = replica.StrSourceTable; //IdTerminalEngine = replica.IntIdTerminalEngine; TerminalEngine = replica.StrTerminalEngine; TerminalIPAddress = replica.StrTerminalIPAddress; TerminalPort = replica.IntTerminalPort; TerminalUser = replica.StrTerminalUser; TerminalPassword = replica.StrTerminalPassword; TerminalDatabase = replica.StrTerminalDatabase; Enable = replica.BoolEnable; Created =replica.StrCreated; LastCheckOnSource = replica.StrLastCheckOnSource; LastCheckOnTerminal = replica.StrLastCheckOnTerminal; }
public Boolean TableSyncTerminal(Replica replica, ReplicaLog replicaLog) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrTerminalUser, replica.StrTerminalPassword, replica.StrTerminalIPAddress, replica.IntTerminalPort.ToString(), replica.StrTerminalDatabase); return sqlDatabaseAccess.TableSync(replica.StrSourceTable, replicaLog.StrReplicaTransaction); }
public Boolean SetReplicaTerminalLogSync(Replica replica, ReplicaLog oreplicaLog) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrTerminalUser, replica.StrTerminalPassword, replica.StrTerminalIPAddress, replica.IntTerminalPort.ToString(), replica.StrTerminalDatabase); return sqlDatabaseAccess.SetReplicaLogSync(oreplicaLog); }
public Boolean SetReplicaSourceLogSync(Replica replica,ReplicaLog oreplicaLog) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); return sqlDatabaseAccess.SetReplicaLogSync(oreplicaLog); }
public List<ReplicaLog> GetReplicaLogsTerminalUnsynchronized(Replica replica) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrTerminalUser, replica.StrTerminalPassword, replica.StrTerminalIPAddress, replica.IntTerminalPort.ToString(), replica.StrTerminalDatabase); return sqlDatabaseAccess.GetReplicaLogsUnsynchronized(replica.StrSourceTable); }
public List<Insert> GetConfigValues(Replica replica, Table table) { SqlDatabaseDA sqlDatabaseAccess = new SqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); return sqlDatabaseAccess.GetCurrentRows(table); }
public Boolean Insert(Replica newReplica) { string strQuery = string.Empty; Boolean result = false; try { this.OpenConnection(); strQuery = "InsertReplica"; SqlCommand cmdComando = new SqlCommand(strQuery, this._oConnection); cmdComando.CommandType = CommandType.StoredProcedure; cmdComando.Parameters.AddWithValue("@intIdSourceEngine", newReplica.IntIdSourceEngine); cmdComando.Parameters.AddWithValue("@strSourceIPAddress", newReplica.StrSourceIPAddress); cmdComando.Parameters.AddWithValue("@intSourcePort", newReplica.IntSourcePort); cmdComando.Parameters.AddWithValue("@strSourceUser", newReplica.StrSourceUser); cmdComando.Parameters.AddWithValue("@strSourcePassword", newReplica.StrSourcePassword); cmdComando.Parameters.AddWithValue("@strSourceDatabase", newReplica.StrSourceDatabase); cmdComando.Parameters.AddWithValue("@strSourceTable", newReplica.StrSourceTable); cmdComando.Parameters.AddWithValue("@intIdTerminalEngine", newReplica.IntIdTerminalEngine); cmdComando.Parameters.AddWithValue("@strTerminalIPAddress", newReplica.StrTerminalIPAddress); cmdComando.Parameters.AddWithValue("@intTerminalPort", newReplica.IntTerminalPort); cmdComando.Parameters.AddWithValue("@strTerminalUser", newReplica.StrTerminalUser); cmdComando.Parameters.AddWithValue("@strTerminalPassword", newReplica.StrTerminalPassword); cmdComando.Parameters.AddWithValue("@strTerminalDatabase", newReplica.StrTerminalDatabase); cmdComando.Parameters.Add("@intResult", SqlDbType.Int).Direction = ParameterDirection.Output; cmdComando.ExecuteScalar(); int intResultado = Int32.Parse(cmdComando.Parameters["@intResult"].Value.ToString()); if (intResultado == 0) result = true; } catch (Exception ex) { this._oLogErrors.GuardarLog(IConstantes.TIPOCAPA.ACCESODATOS, this.GetType().ToString(), MethodInfo.GetCurrentMethod().Name, ex.Message, strQuery); } finally { this.CloseConnection(); } return result; }
/// <summary> /// This is the DA for accessing the Replica table /// Date: 9/4/2014 /// Created By: Juan Pablo Arias Mora /// </summary> /// <returns>A list of all the Replicas on the table, List<Replica></returns> public List<Replica> GetAllReplicas() { Replica oReplica = new Replica(); List<Replica> listResult = new List<Replica>(); string strQuery = string.Empty; SqlDataReader dtrResult = null; DataTable dtResult = new DataTable(); try { this.OpenConnection(); strQuery = "GetAllReplicas"; SqlCommand cmdComando = new SqlCommand(strQuery, this._oConnection); cmdComando.CommandType = CommandType.StoredProcedure; cmdComando.Parameters.Add("@intResult", SqlDbType.Int).Direction = ParameterDirection.Output; dtrResult = cmdComando.ExecuteReader(); //Load the Results on the DataTable dtResult.Load(dtrResult); foreach (DataRow dtrFila in dtResult.Rows) { oReplica = new Replica(); oReplica.IntIdReplica = Convert.ToInt32(dtrFila["idReplica"].ToString()); oReplica.StrSourceEngine = dtrFila["SourceEngine"].ToString(); oReplica.IntIdSourceEngine = Convert.ToInt32(dtrFila["IdSourceEngine"].ToString()); oReplica.StrTerminalEngine = dtrFila["TerminalEngine"].ToString(); oReplica.IntIdTerminalEngine = Convert.ToInt32(dtrFila["IdTerminalEngine"].ToString()); oReplica.StrSourceIPAddress = dtrFila["SourceIPAddress"].ToString(); oReplica.IntSourcePort = Convert.ToInt32(dtrFila["SourcePort"].ToString()); oReplica.StrSourceUser = dtrFila["SourceUser"].ToString(); oReplica.StrSourcePassword = dtrFila["SourcePassword"].ToString(); oReplica.StrSourceDatabase = dtrFila["SourceDatabase"].ToString(); oReplica.StrSourceTable = dtrFila["SourceTable"].ToString(); oReplica.StrTerminalIPAddress = dtrFila["TerminalIPAddress"].ToString(); oReplica.IntTerminalPort = Convert.ToInt32(dtrFila["TerminalPort"].ToString()); oReplica.StrTerminalUser = dtrFila["TerminalUser"].ToString(); oReplica.StrTerminalPassword = dtrFila["TerminalPassword"].ToString(); oReplica.StrTerminalDatabase = dtrFila["TerminalDatabase"].ToString(); oReplica.BoolEnable = Convert.ToBoolean(dtrFila["Enable"].ToString()); oReplica.StrCreated = dtrFila["Created"].ToString(); object value = dtrFila["LastCheckOnSource"]; if (value != DBNull.Value) { oReplica.StrLastCheckOnSource = dtrFila["LastCheckOnSource"].ToString(); } value = dtrFila["LastCheckOnTerminal"]; if (value != DBNull.Value) { oReplica.StrLastCheckOnSource = dtrFila["LastCheckOnTerminal"].ToString(); } listResult.Add(oReplica); } } catch (Exception ex) { this._oLogErrors.GuardarLog(IConstantes.TIPOCAPA.ACCESODATOS, this.GetType().ToString(), MethodInfo.GetCurrentMethod().Name, ex.Message, strQuery); } finally{ this.CloseConnection(); } return listResult; }
public Boolean TableSyncSource(Replica replica, ReplicaLog replicaLog) { MysqlDatabaseDA sqlDatabaseAccess = new MysqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); return sqlDatabaseAccess.TableSync(replica.StrSourceTable, replicaLog.StrReplicaTransaction); }
public List<ReplicaLog> GetReplicaLogsSourceUnsynchronized(Replica replica) { MysqlDatabaseDA sqlDatabaseAccess = new MysqlDatabaseDA(replica.StrSourceUser, replica.StrSourcePassword, replica.StrSourceIPAddress, replica.IntSourcePort.ToString(), replica.StrSourceDatabase); return sqlDatabaseAccess.GetReplicaLogsUnsynchronized(replica.StrSourceTable); }
public void CheckChangesReplica(Replica replica) { List<ReplicaLog> replicaLogSource = new List<ReplicaLog>(); List<ReplicaLog> replicaLogTerminal = new List<ReplicaLog>(); SqlDatabaseBL sqlDatabaseBL = new SqlDatabaseBL(); MysqlDatabaseBL mysqlDatabaseBL = new MysqlDatabaseBL(); if (replica.StrSourceEngine.Contains("SQL Server")) { replicaLogSource = sqlDatabaseBL.GetReplicaLogsSourceUnsynchronized(replica); } if (replica.StrSourceEngine.Contains("MySQL")) { replicaLogSource = mysqlDatabaseBL.GetReplicaLogsSourceUnsynchronized(replica); } if (replica.StrTerminalEngine.Contains("SQL Server")) { replicaLogTerminal = sqlDatabaseBL.GetReplicaLogsTerminalUnsynchronized(replica); } if (replica.StrTerminalEngine.Contains("MySQL")) { replicaLogTerminal = mysqlDatabaseBL.GetReplicaLogsTerminalUnsynchronized(replica); } if (replicaLogSource.Count() > 0) { //Sync Terminal foreach (ReplicaLog replicaLog in replicaLogSource) { if (replica.StrTerminalEngine.Contains("SQL Server")) { sqlDatabaseBL.TableSyncTerminal(replica, replicaLog); } if (replica.StrTerminalEngine.Contains("MySQL")) { mysqlDatabaseBL.TableSyncTerminal(replica,replicaLog); } if (replica.StrSourceEngine.Contains("SQL Server")) { sqlDatabaseBL.SetReplicaSourceLogSync(replica, replicaLog); } if (replica.StrSourceEngine.Contains("MySQL")) { //mysqlDatabaseBL.TableSyncTerminal(replica,replicaLog); mysqlDatabaseBL.SetReplicaSourceLogSync(replica, replicaLog); } } } if (replicaLogTerminal.Count() > 0) { //Sync Terminal foreach (ReplicaLog replicaLog in replicaLogTerminal) { if (replica.StrSourceEngine.Contains("SQL Server")) { sqlDatabaseBL.TableSyncSource(replica, replicaLog); //sqlDatabaseBL.SetReplicaTerminalLogSync(replica, replicaLog); } if (replica.StrSourceEngine.Contains("MySQL")) { mysqlDatabaseBL.TableSyncSource(replica, replicaLog); //sqlDatabaseBL.SetReplicaTerminalLogSync(replica, replicaLog); } if (replica.StrTerminalEngine.Contains("SQL Server")) { sqlDatabaseBL.SetReplicaTerminalLogSync(replica, replicaLog); } if (replica.StrTerminalEngine.Contains("MySQL")) { //mysqlDatabaseBL.TableSyncTerminal(replica,replicaLog); mysqlDatabaseBL.SetReplicaTerminalLogSync(replica, replicaLog); } } } }
/// <summary> /// This method insert on ReplicaManager Database /// </summary> /// <param name="replica"></param> public void InsertReplica(Replica replica) { ReplicaDA replicaDA = new ReplicaDA(); replicaDA.Insert(replica); }
/// <summary> /// This will configure the Initial Replica requirements on the client /// </summary> /// <param name="replica"></param> public void InitialReplicaClientConfig(Replica replica) { //Source Config Table table = new Table(); SqlDatabaseBL sqlDatabaseBL = new SqlDatabaseBL(); MysqlDatabaseBL mysqlDatabaseBL = new MysqlDatabaseBL(); List<Insert> valuesToInsert = new List<Insert>(); if (replica.StrSourceEngine.Contains("SQL Server")) { table = sqlDatabaseBL.ConfigSource(replica); valuesToInsert = sqlDatabaseBL.GetConfigValues(replica, table); } if (replica.StrSourceEngine.Contains("MySQL")) { table = mysqlDatabaseBL.ConfigSource(replica); valuesToInsert = mysqlDatabaseBL.GetConfigValues(replica, table); } //Terminal Config if (replica.StrTerminalEngine.Contains("SQL Server")) { sqlDatabaseBL.ConfigTerminal(replica, table, valuesToInsert); } if (replica.StrTerminalEngine.Contains("MySQL")) { mysqlDatabaseBL.ConfigTerminal(replica, table, valuesToInsert); } }