private bool NotificationForcesUpdate(TriggerUpdateNotification updateNotification) { // Only update the trigger list if the trigger is for an unknown user or if the user's triggers have been // updated since the last pull from the trigger repository. This reduces repository load if a users makes quick, // successive updates to their trigger list. return(!_lastUpdated.ContainsKey(updateNotification.UserId) || updateNotification.UpdatedAt >= _lastUpdated[updateNotification.UserId]); }
private void UpdateUserTriggers(TriggerUpdateNotification updateNotification) { if (updateNotification.TriggerType == TriggerType.Buy) { Log.DebugFormat(CultureInfo.InvariantCulture, "Updating buy triggers for user with Id={0}.", updateNotification.UserId); UpdateBuyTriggersForUser(updateNotification.UserId, updateNotification.UserDbId); } else { Log.DebugFormat(CultureInfo.InvariantCulture, "Updating sell triggers for user with Id={0}.", updateNotification.UserId); UpdateSellTriggersForUser(updateNotification.UserId, updateNotification.UserDbId); } }
private void HandleTriggerNotification(TriggerUpdateNotification updateNotification) { if (updateNotification == null) { Log.WarnFormat(CultureInfo.InvariantCulture, "Worker {0} received a null TriggerUpdateNotification.", InstanceId); return; } if (!NotificationForcesUpdate(updateNotification)) { Log.DebugFormat(CultureInfo.InvariantCulture, "Skipping trigger update for User={0}, TransactionId={1}. No update required.", updateNotification.UserId, updateNotification.TransactionId); return; } UpdateUserTriggers(updateNotification); }