protected void Page_Load(object sender, EventArgs e) { try { SlkUtilities.RetryOnDeadlock(delegate() { m_helper = new ChangeActivityHelper(Request, Response); m_helper.ProcessPageLoad(TryGetSessionView, TryGetAttemptId, TryGetActivityId, RegisterError, GetErrorInfo, GetMessage); m_pageLoadSuccessful = (!HasError); }); } catch (Exception e2) { // Unexpected exceptions are not shown to user SlkStore.LogError(FramesetResources.FRM_UnknownExceptionMsg, e2.ToString()); RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle), ResHelper.GetMessage(SlkFrameset.FRM_UnexpectedExceptionMsg), false); m_pageLoadSuccessful = false; // Clear the response in case something has been written Response.Clear(); } }
/// <summary> /// Write the html for the table of contents to the response. /// </summary> /// <returns></returns> public void WriteToc() { SlkUtilities.RetryOnDeadlock(delegate() { // This accesses the database to get the list of nodes m_tocHelper.TocElementsHtml(Request, AssignmentView.Grading.ToString()); }); }
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] // all exceptions caught and written to server event log protected void Page_Load(object sender, EventArgs e) { try { CheckPlayAssignment(); SlkUtilities.RetryOnDeadlock(delegate() { Response.Clear(); ClearError(); m_framesetHelper = new FramesetHelper(); m_framesetHelper.ProcessPageLoad(SlkStore.PackageStore, TryGetSessionView, TryGetAttemptId, ProcessViewRequest); // If this is not e-learning content, then we have to write the content directly to response. if (!HasError && !m_isELearning) { SendNonElearningContent(); Response.End(); } }); } catch (ThreadAbortException) { // response ended. Do nothing. return; } catch (FileNotFoundException) { Response.StatusCode = 404; Response.StatusDescription = "Not Found"; RegisterError(SlkFrameset.FRM_DocumentNotFoundTitleHtml, SlkFrameset.FRM_DocumentNotFound, false); } catch (UserNotFoundException) { Response.StatusCode = 500; Response.StatusDescription = "Internal Server Error"; // This probably indicates the site allows anonymous access and the user is not signed in. RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_SignInRequiredMsgHtml, false); } catch (HttpException ex) { // Do not set response codes SlkStore.LogException(ex); RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_AssignmentNotAvailableMsgHtml, false); } catch (Exception ex) { Response.StatusCode = 500; Response.StatusDescription = "Internal Server Error"; SlkStore.LogException(ex); RegisterError(SlkFrameset.FRM_AssignmentNotAvailableTitle, SlkFrameset.FRM_AssignmentNotAvailableMsgHtml, false); } }
protected void Page_Load(object sender, EventArgs e) { try { SlkUtilities.RetryOnDeadlock(delegate() { // Clear data that may need to be reset on retry Response.Clear(); ClearError(); m_tocHelper = new TocHelper(); string submitText = ""; SessionView view; if (TryGetSessionView(false, out view)) { if (view == SessionView.Execute) { submitText = SlkFrameset.TOC_SubmitAssignment; } else { submitText = SlkFrameset.TOC_SubmitGrading; } } m_tocHelper.ProcessPageLoad(Response, SlkStore.PackageStore, TryGetSessionView, TryGetAttemptId, ProcessViewRequest, RegisterError, submitText); }); } catch (Exception ex) { // Unexpected exceptions are not shown to user SlkStore.LogError(FramesetResources.FRM_UnknownExceptionMsg, ex.ToString()); RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle), ResHelper.GetMessage(SlkFrameset.FRM_UnexpectedExceptionMsg), false); } }
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] // all exceptions caught and written to event log rather than getting aspx error page protected void Page_Load(object sender, EventArgs e) { try { bool isPosted = false; if (String.CompareOrdinal(Request.HttpMethod, "POST") == 0) { isPosted = true; } // Get the path to the content. This may be part of the url (if we are running without // an http module) or a URL parameter (with http module). We run in both modes because // VS.NET does not parse URLs of the form: /.../Content.aspx/0/1/foo.gif correctly without // the assistance of the module. m_contentPath = GetContentPath(); SPSecurity.CatchAccessDeniedException = true; SlkUtilities.RetryOnDeadlock(delegate() { // Initialize data that may get set on a first try, but must be reset for retry Response.Clear(); ClearError(); learnerAssignment = null; m_contentHelper = new ContentHelper(Request, Response, SlkEmbeddedUIPath); m_contentHelper.ProcessPageLoad(SlkStore.PackageStore, String.IsNullOrEmpty(m_contentPath), isPosted, TryGetViewInfo, TryGetAttemptInfo, TryGetActivityInfo, GetResourcePath, AppendContentFrameDetails, UpdateRenderContext, ProcessPostedData, ProcessViewRequest, ProcessPostedDataComplete, RegisterError, GetErrorInfo, GetMessage); }); } catch (ThreadAbortException) { // response ended. Do nothing. return; } catch (UnauthorizedAccessException uae) { SlkStore.LogError(FramesetResources.FRM_UnknownExceptionMsg, uae.ToString()); RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle), ResHelper.GetMessage(SlkFrameset.FRM_UnexpectedExceptionMsg), false); // Clear the response in case something has been written Response.Clear(); } catch (Exception e2) { // Unexpected exceptions are not shown to user SlkStore.LogError(FramesetResources.FRM_UnknownExceptionMsg, e2.ToString()); RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle), ResHelper.GetMessage(SlkFrameset.FRM_UnexpectedExceptionMsg), false); // Clear the response in case something has been written Response.Clear(); } }
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] // exceptions caught, added to event log protected void Page_Load(object sender, EventArgs e) { try { SlkUtilities.RetryOnDeadlock(delegate() { //Initialize data that may need to be reset on retry Response.Clear(); ClearError(); m_sessionEnded = false; m_hiddenHelper = new HiddenHelper(Request, Response, SlkEmbeddedUIPath); m_hiddenHelper.ProcessPageLoad(SlkStore.PackageStore, GetSessionTitle, TryGetSessionView, TryGetAttemptId, AppendContentFrameDetails, RegisterError, GetErrorInfo, ProcessSessionEnd, ProcessViewRequest, GetMessage, IsPostBack); // Send assignment information to client. If the session has ended, then force a reload of the current // assignment properties. Otherwise, the cached value will have required info so no need to re-query database. LearnerAssignmentProperties la = GetLearnerAssignment(SessionEnded); // Add assignment information to the hidden controls HiddenControlInfo hiddenCtrlInfo = new HiddenControlInfo(); hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.LearnerAssignmentId); hiddenCtrlInfo.Value = new PlainTextString(FramesetUtil.GetStringInvariant(la.LearnerAssignmentId.GetKey())); hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(ResHelper.Format("slkMgr.LearnerAssignmentId = document.getElementById({0}).value;", JScriptString.QuoteString(HiddenFieldNames.LearnerAssignmentId, false))); m_hiddenHelper.HiddenControls.Add(hiddenCtrlInfo); // Learner assignment status ('not started', 'in progress', etc) hiddenCtrlInfo = new HiddenControlInfo(); hiddenCtrlInfo.Id = new PlainTextString(HiddenFieldNames.LearnerAssignmentStatus); hiddenCtrlInfo.Value = new PlainTextString(SlkUtilities.GetLearnerAssignmentState(la.Status)); hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(ResHelper.Format("slkMgr.Status = document.getElementById({0}).value;", JScriptString.QuoteString(HiddenFieldNames.LearnerAssignmentStatus, false))); m_hiddenHelper.HiddenControls.Add(hiddenCtrlInfo); hiddenCtrlInfo = new HiddenControlInfo(); if (la.FinalPoints != null) { // finalPoints is passed in invariant culture, as a float hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(ResHelper.Format("slkMgr.FinalPoints = {0};", Convert.ToString(la.FinalPoints, CultureInfo.InvariantCulture.NumberFormat))); } else { hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString("slkMgr.FinalPoints = null;"); } m_hiddenHelper.HiddenControls.Add(hiddenCtrlInfo); // Send information about total points (ie, computed points on the client). This is called 'graded score' in // grading page. LearningSession session = m_hiddenHelper.Session; if (session != null) { hiddenCtrlInfo = new HiddenControlInfo(); if (session.TotalPoints != null) { // TotalPoints is passed in current culture, as a string JScriptString totalPointsValue = JScriptString.QuoteString(Convert.ToString(session.TotalPoints, CultureInfo.CurrentCulture.NumberFormat), false); hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(ResHelper.Format("slkMgr.ComputedPoints = {0};", totalPointsValue)); } else { hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString("slkMgr.ComputedPoints = \"\";"); } m_hiddenHelper.HiddenControls.Add(hiddenCtrlInfo); if (session.SuccessStatus != SuccessStatus.Unknown) { hiddenCtrlInfo = new HiddenControlInfo(); hiddenCtrlInfo.FrameManagerInitializationScript = new JScriptString(ResHelper.Format("slkMgr.PassFail = {0};\r\n", JScriptString.QuoteString(((session.SuccessStatus == SuccessStatus.Passed) ? "passed" : "failed"), false))); m_hiddenHelper.HiddenControls.Add(hiddenCtrlInfo); } } }); } catch (Exception ex) { ClearError(); // Unexpected exceptions are not shown to user SlkStore.LogError(FramesetResources.FRM_UnknownExceptionMsg, ex.ToString()); RegisterError(ResHelper.GetMessage(FramesetResources.FRM_UnknownExceptionTitle), ResHelper.GetMessage(SlkFrameset.FRM_UnexpectedExceptionMsg), false); } }