コード例 #1
0
 public bool ValidateUser(string username, string password, string customCredential)
 {
     using (AuthenticationServiceClient proxy = new AuthenticationServiceClient())
     {
         return proxy.ValidateUser(username, password, customCredential);
     }
 }
コード例 #2
0
ファイル: OSBLEState.cs プロジェクト: WSU-HELPLAB/OSBLE
        private void RefreshProc()
        {
            // First login
            AuthenticationServiceClient authClient = new AuthenticationServiceClient();
            string authToken = null;

            try
            {
                authToken = authClient.ValidateUser(m_user, m_pass);
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                authClient.Close();
                m_onComplete(this, new OSBLEStateEventArgs(false,
                                                           "Could not connect to the OSBLE server. " +
                                                           "Please contact support if this problem persists."));
                return;
            }
            authClient.Close();
            authClient = null;

            if (string.IsNullOrEmpty(authToken))
            {
                m_onComplete(this, new OSBLEStateEventArgs(false,
                                                           "Could not log in to OSBLE. " +
                                                           "Please check your user name and password."));
                return;
            }

            // Now get a list of courses
            OsbleServiceClient osc = new OsbleServiceClient();

            m_courses = osc.GetCourses(authToken);

            // Make sure we got some courses
            if (null == m_courses || 0 == m_courses.Length)
            {
                m_onComplete(this, new OSBLEStateEventArgs(false,
                                                           "No courses were found for this user."));
                return;
            }

            // Go through the courses and find out this user's role
            List <Course> canBeGraded = new List <Course>();

            foreach (Course c in m_courses)
            {
                CourseRole cr = osc.GetCourseRole(c.ID, authToken);
                if (cr.CanGrade)
                {
                    canBeGraded.Add(c);
                }
            }
            m_courses = canBeGraded.ToArray();

            // Success if we made it this far
            m_onComplete(this, new OSBLEStateEventArgs(true, string.Empty));
        }
コード例 #3
0
ファイル: index.aspx.cs プロジェクト: calebespinoza/wcfepm
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            AuthenticationServiceClient au = new AuthenticationServiceClient();
            string user          = txtUsername.Text.Trim();
            string password      = txtPassword.Text.Trim();
            bool   autenticacion = au.ValidateUser(user, password);

            if (!autenticacion)
            {
                lblError.Visible = true;
                lblError.Text    = "ERROR: Username or Password incorrect";
                txtUsername.Text = "";
                txtPassword.Text = "";
                txtUsername.Focus();
                return;
            }
            Session["User"] = user;
            Response.Redirect("Readings.aspx");
        }
コード例 #4
0
ファイル: frmLogin.cs プロジェクト: calebespinoza/wcfepm
        private void btnAccept_Click(object sender, EventArgs e)
        {
            AuthenticationServiceClient au = new AuthenticationServiceClient();
            string usuario       = txtUserName.Text.Trim();
            string password      = txtPassword.Text.Trim();
            bool   autenticacion = au.ValidateUser(usuario, password);

            if (!autenticacion)
            {
                MessageBox.Show("Username or Password incorrect", "ERROR");
                txtUserName.Text = "";
                txtPassword.Text = "";
                txtUserName.Focus();
                return;
            }
            this.Hide();
            frmReadings formReadings = new frmReadings();

            formReadings.Show();
        }
コード例 #5
0
ファイル: CommonTestLibrary.cs プロジェクト: kielr/OsbleTest
        public static string OsbleLogin(string username, string password)
        {
            AuthenticationService authClient = new AuthenticationServiceClient();

            return authClient.ValidateUser(username, password);
        }
コード例 #6
0
        public static SaveResult Save(string userName, string password, int courseID,
                                      Workbook wb)
        {
            // What needs to be done here:
            // 1. "Export" each sheet in the workbook to a CSV
            // 2. Package all CSVs in a zip
            // 3. Upload this zip to OSBLE through the web service

            string tempSaveDir = Environment.GetFolderPath(
                Environment.SpecialFolder.LocalApplicationData);

            if (!tempSaveDir.EndsWith("\\") &&
                !tempSaveDir.EndsWith("/"))
            {
                tempSaveDir += "\\";
            }

            // For each non-empty worksheet in the workbook we need to make a CSV
            ZipFile zf         = new ZipFile();
            int     sheetCount = 0;

            foreach (Worksheet ws in wb.Worksheets)
            {
                // We only want gradebook worksheets.
                // Check for a "#" in cell A1 before making a CSV
                var currentWorkSheet = Convert.ToString(ws.Range["A1"].Value);

                if (currentWorkSheet == null) // Cell is empty
                {
                }
                else if (currentWorkSheet.Contains("#")) //Cell contains #, continue...
                {
                    // Make an in-memory CSV for the worksheet
                    string csvTemp = WorksheetToCSVString(ws);
                    if (string.IsNullOrEmpty(csvTemp))
                    {
                        continue;
                    }

                    sheetCount++;
                    zf.AddEntry(ws.Name + ".csv", Encoding.UTF8.GetBytes(csvTemp));
                }
            }

            // If we didn't get any data then we can't upload to OSBLE
            if (0 == sheetCount)
            {
                return(new SaveResult(false,
                                      string.Format(
                                          "Save attempt at {0} failed because no data could be obtained " +
                                          "from the workbook.\r\nPlease make sure you have at least 2x2 " +
                                          "cells worth of grade data in one or more worksheets.", DateTime.Now)));
            }

            // Save the zip to a memory stream
            MemoryStream ms = new MemoryStream();

            zf.Save(ms);
            zf.Dispose();
            zf = null;

            // Get the byte array from the memory stream
            byte[] data = ms.ToArray();

            AuthenticationServiceClient auth = new AuthenticationServiceClient();
            string authToken;

            try
            {
                authToken = auth.ValidateUser(userName, password);
            }
            catch (Exception)
            {
                return(new SaveResult(false,
                                      "Could not login to OSBLE. " +
                                      "You may need to reenter your user name and password."));
            }
            auth.Close();

            // Now we get the service client
            OSBLEServices.OsbleServiceClient osc = new OSBLEServices.OsbleServiceClient();
            int retVal = osc.UploadCourseGradebook(courseID, data, authToken);

            osc.Close();

            // The return value indicates the number of items in the zip that
            // FAILED to upload if >0 or generic upload failure if == -1. A
            // return value of 0 indicates success.
            if (retVal >= sheetCount || -1 == retVal)
            {
                return(new SaveResult(
                           false,
                           string.Format(
                               "Save attempt at {0} failed because the data failed to upload " +
                               "properly. This might occur because of a lapse in Internet " +
                               "connectivity, so it is recommended that you try again shortly. If " +
                               "the problem persists, please contact OSBLE support.", DateTime.Now)));
            }
            else if (retVal > 0)
            {
                // This means that some sheets failed but some succeeded. We'll still
                // issue an error message in this case.
                return(new SaveResult(
                           false,
                           string.Format(
                               "Save attempt at {0} only uploaded some of the worksheets in the " +
                               "workbook. It is recommended that you try again and/or check the " +
                               "gradebook status online at PLUS.OSBLE.org.", DateTime.Now)));
            }

            return(new SaveResult(true, null));
        }