/// <summary> /// Gets custom sql command /// </summary> /// <returns>custom sql command</returns> public string GetCustomCommand() { string result = ""; switch (DbCommand) { case IsagCustomProperties.DbCommandType.Merge: result = SqlCreator.GetSqlMerge(this, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS, true); break; case IsagCustomProperties.DbCommandType.Merge2005: result = SqlCreator.GetSqlMerge2005(this, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS, true); break; case IsagCustomProperties.DbCommandType.UpdateTblInsertRow: break; case IsagCustomProperties.DbCommandType.UpdateRowInsertRow: break; case IsagCustomProperties.DbCommandType.BulkInsert: break; case IsagCustomProperties.DbCommandType.BulkInsertRowLock: break; case IsagCustomProperties.DbCommandType.Insert: result = SqlCreator.GetSqlInsert(this, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS, true); break; default: break; } return(result); }
/// <summary> /// Gets sql command with placeholders for tables, columns, etc. /// </summary> /// <param name="eventType">event type</param> /// <param name="sqlTemplate">sql command template</param> public void GetDbCommandDefinition(out IsagEvents.IsagEventType eventType, out string[] sqlTemplate) { switch (_IsagCustomProperties.DbCommand) { case IsagCustomProperties.DbCommandType.Merge: eventType = IsagEvents.IsagEventType.MergeBegin; sqlTemplate = new string[] { GetExecuteStatementFromTemplate(SqlCreator.GetSqlMerge(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS)) }; break; case IsagCustomProperties.DbCommandType.Merge2005: eventType = IsagEvents.IsagEventType.Merge2005Begin; sqlTemplate = new string[] { GetExecuteStatementFromTemplate(SqlCreator.GetSqlMerge2005(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS)) }; break; case IsagCustomProperties.DbCommandType.UpdateTblInsertRow: eventType = IsagEvents.IsagEventType.UpdateTblInsertRowBegin; string spInsertName = "[#" + Constants.SP_INSERT_BY_CURSOR + "_" + Guid.NewGuid().ToString() + "]"; string sqlSpInsert = SqlCreator.GetSqlInsertSP(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS).Replace("<SPName>", spInsertName); string sqlUpdate = SqlCreator.GetSqlUpdate(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS); string sqlExecSp = "EXEC " + spInsertName; string sqlDropSpInsert = "DROP PROCEDURE " + spInsertName; sqlTemplate = new string[] { sqlSpInsert, sqlUpdate, sqlExecSp }; break; case IsagCustomProperties.DbCommandType.UpdateRowInsertRow: eventType = IsagEvents.IsagEventType.UpdateRowInsertRowBegin; string spInsertName1 = "[#" + Constants.SP_INSERT_BY_CURSOR + "_" + _componentMetaData.Name + "_" + Guid.NewGuid().ToString() + "]"; string spUpdateName1 = "[#" + Constants.SP_UPDATE_BY_CURSOR + "_" + _componentMetaData.Name + "_" + Guid.NewGuid().ToString() + "]"; string sqlSpInsert1 = SqlCreator.GetSqlInsertSP(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS).Replace("<SPName>", spInsertName1); string sqlSpUpdate1 = SqlCreator.GetSqlUpdateSP(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS).Replace("<SPName>", spUpdateName1); string sqlExecInsertSp = "EXEC " + spInsertName1; string sqlExecUpdateSp = "EXEC " + spUpdateName1; string sqlDropSpInsert1 = "DROP PROCEDURE " + spInsertName1; string sqlDropSpUpdate = "DROP PROCEDURE " + spUpdateName1; sqlTemplate = new string[] { sqlSpInsert1, sqlSpUpdate1, sqlExecUpdateSp, sqlExecInsertSp }; break; case IsagCustomProperties.DbCommandType.Insert: eventType = IsagEvents.IsagEventType.InsertBegin; sqlTemplate = new string[] { GetExecuteStatementFromTemplate(SqlCreator.GetSqlInsert(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS)) }; break; case IsagCustomProperties.DbCommandType.BulkInsert: eventType = IsagEvents.IsagEventType.BulkInsert; sqlTemplate = null; break; case IsagCustomProperties.DbCommandType.BulkInsertRowLock: eventType = IsagEvents.IsagEventType.BulkInsert; sqlTemplate = null; break; default: _events.FireError(new string[] { "Choosen DBCommand is invalid." }); throw new Exception("Choosen DBCommand is invalid."); } }