public ActivityLogger(IBaseMessage msg) { _activityInfo = new AtomicScope.ActivityInfo(); }
}//Business Layer public void UpdateActivity(ActivityInfo activityInfo) { SqlConnection sqlConnection = new SqlConnection("Data Source=BT360DEV34\\MSSQLSERVER1;Initial Catalog=AtomicScope;Integrated Security=SSPI"); StringBuilder commandString = new StringBuilder("UPDATE [dbo].[AtomicScope_ActivityLog] SET"); //TODO : change this to cleaner approach if (activityInfo.MessageId != null) { commandString.Append(" MessageId = @messageId,"); } if (activityInfo.BatchId != null) { commandString.Append(" BatchId = @batchId,"); } if (activityInfo.MessageType != null) { commandString.Append(" MessageType = @messageType, "); } if (activityInfo.SenderId != null) { commandString.Append(" SenderId = @senderId, "); } if (activityInfo.ReceiverId != null) { commandString.Append(" ReceiverId = @receiverId, "); } commandString.Append(" EndTime = @endDateTime"); commandString.Append(" Where EventId= @EventId"); SqlCommand command = new SqlCommand(commandString.ToString(), sqlConnection); command.Parameters.Add("@EventId", SqlDbType.UniqueIdentifier).Value = Guid.Parse(activityInfo.EventId); if (activityInfo.MessageId != null) { command.Parameters.Add("@messageId", SqlDbType.VarChar).Value = activityInfo.MessageId; } if (activityInfo.BatchId != null) { command.Parameters.Add("@batchId", SqlDbType.VarChar).Value = activityInfo.BatchId; } if (activityInfo.MessageType != null) { command.Parameters.Add("@messageType", SqlDbType.VarChar).Value = activityInfo.MessageType; } if (activityInfo.SenderId != null) { command.Parameters.Add("@senderId", SqlDbType.VarChar).Value = activityInfo.SenderId; } if (activityInfo.ReceiverId != null) { command.Parameters.Add("@receiverId", SqlDbType.VarChar).Value = activityInfo.ReceiverId; } command.Parameters.Add("@endDateTime", SqlDbType.DateTime).Value = DateTime.UtcNow; sqlConnection.Open(); command.ExecuteNonQuery(); sqlConnection.Close(); }//DataLayer