/// <summary> /// The event called when a login has been submitted. The event will /// default the user interface of the form and deactivate the /// buttons. Updates will take place on another thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { // Ignore the click if we have an empty user name or password if (0 == txtUsername.TextLength) { txtUsername.Focus(); return; } if (0 == txtPassword.TextLength) { txtPassword.Focus(); return; } //reset error text box and size of the form txtErrors.Text = ""; txtErrors.Visible = false; this.Size = new System.Drawing.Size(300, 194); // Disable the buttons while we're processing btnSubmit.Enabled = false; btnCancel.Enabled = false; // Also show the progress bar pbLogin.Visible = true; m_state = new OSBLEState(txtUsername.Text, txtPassword.Text); m_state.RefreshAsync(this.LoginAttemptCompleted_CT); }
/// <summary> /// The function called when the login button is clicked. The event will show the /// login form and update mState with its return value. The value of mState will /// then be used to update the ribbon user interface. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, RibbonControlEventArgs e) { //display login form and retrieve OSBLE state frmOSBLELogin loginForm = new frmOSBLELogin(); mState = loginForm.DoPrompt(); }
/// <summary> /// Logs out a user and updates the ribbon user interface to prevent /// the option of submitting documents to courses. The drop down menu /// is emptied. /// </summary> private void logoutActions() { //set state to null mState = null; //hide OSBLE options and switch login and logout visibility grpOSBLEOptions.Visible = false; btnLogin.Visible = true;; btnLogout.Visible = false; //reset last save label lblLastSave.Label = "Last Save: "; //clear drop down course menu dropDownCourse.Items.Clear(); RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem(); item.Label = "No Courses Found"; item.Tag = null; dropDownCourse.Items.Add(item); //clear drop down assignment menu dropDownAssignment.Items.Clear(); item.Label = "No Assignments Found"; item.Tag = null; dropDownAssignment.Items.Add(item); }
/// <summary> /// Saves the active word document and zips the file in the local directory. /// </summary> /// <param name="state"></param> /// <param name="course"></param> /// <param name="assignment"></param> /// <param name="doc"></param> /// <returns></returns> public static SaveResult Save(OSBLEState state, int courseId, int assignmentId, Document doc) { //if the document doesn't exist or contains changes then request the user to save if (!File.Exists(doc.FullName) || !doc.Saved) { return(new SaveResult(false, "Please save the current document before submitting.")); } string zipPath = null; byte[] zipData = null; //zip document try { zipPath = SaveFileToZip(state.FullName, doc); zipData = File.ReadAllBytes(zipPath); } catch (Exception e) { return(new SaveResult(true, "Failed to package document before sending to the server.")); } //package assignment information var submitevent = new SubmitEvent(); submitevent.AssignmentId = assignmentId; submitevent.CourseId = courseId; submitevent.SolutionData = zipData; HttpResponseMessage response = null; //call asynchronous web api helper function try { response = AsyncServiceClient.SubmitAssignment(submitevent, state.AuthToken).Result; } catch (Exception e) { return(new SaveResult(false, "Failed to submit document to the server.")); } if (response.IsSuccessStatusCode) { return(new SaveResult(true, null)); } else { return(new SaveResult(false, "The server failed to process the submission.")); } }
public OSBLEStateEventArgs(bool success, string message, OSBLEState state) { m_message = message; m_success = success; m_state = state; }