public void ProcessLogForInterventionSync(ActivityEvent log) { using (InterventionController intervention = new InterventionController()) { intervention.ProcessActivityEvent(log); } }
public void NotifyNewSuggestion(int userId, int courseId = 0, string authKey = "") { bool refreshSuggestion = false; if (!String.IsNullOrEmpty(authKey)) { InterventionController ic = new InterventionController(); refreshSuggestion = ic.RefreshInterventionsOnDashboard(authKey); } if (refreshSuggestion) { List <int> activeCourseIds = new List <int>(); //push notification to all active courses that have suggestions enabled for this user using (var sqlConnection = new SqlConnection(StringConstants.ConnectionString)) { sqlConnection.Open(); string query = "SELECT DISTINCT ac.ID FROM AbstractCourses ac " + "INNER JOIN CourseUsers cu " + "ON ac.ID = cu.AbstractCourseID " + "INNER JOIN OSBLEInterventionsCourses oic " + "ON ac.ID = oic.CourseId " + "WHERE cu.UserProfileID = @UserProfileId "; var result = sqlConnection.Query(query, new { UserProfileId = userId }); if (result != null) { foreach (var item in result) { activeCourseIds.Add(item.ID); } } sqlConnection.Close(); } if (activeCourseIds.Count == 0 && courseId > 0) { activeCourseIds.Add(courseId); } foreach (int id in activeCourseIds) //send to all 'active' courses with suggestions enabled { var connection = new HubConnection(StringConstants.WebClientRoot, "userID=" + userId + "&courseID=" + id + "&authKey=" + authKey, true); connection.Headers.Add("Host", (new Uri(StringConstants.WebClientRoot)).Host); connection.Headers.Add("Origin", StringConstants.WebClientRoot); IHubProxy hub = connection.CreateHubProxy("ActivityFeedHub"); connection.Start().Wait(); hub.Invoke("NotifyNewSuggestion"); //stop the connection after the message has been forwarded. connection.Stop(); } } }
private async void ProcessLogForIntervention(SubmissionRequest request) { using (InterventionController intervention = new InterventionController()) { intervention.ProcessActivityEvent( EventCollectionControllerHelper.GetActivityEvent( new EventPostRequest { AuthToken = request.AuthToken, SubmitEvent = request.SubmitEvent } )); } }