Esempio n. 1
0
        public void SaveCurrentAssignmentAsync(byte[] assignmentData)
        {
            AuthenticationServiceClient authClient = new AuthenticationServiceClient();

            authClient.ValidateUserCompleted += this.ValidateForSaveCompleted;
            authClient.ValidateUserAsync(m_userName, m_password, new object[] { authClient, assignmentData });
        }
Esempio n. 2
0
        private void RefreshThreadProc(object parameter)
        {
            // The parameter is the event handler for completion
            //EventHandler onCompletion = parameter as EventHandler;

            AuthenticationServiceClient auth = new AuthenticationServiceClient();

            auth.ValidateUserCompleted += this.AuthForLoadCompleted;
            auth.ValidateUserAsync(m_userName, m_password, new object[] { auth, parameter });
        }
Esempio n. 3
0
        /// <summary>
        /// Thread procedure for saving an assignment. Compresses the workspace save data and then starts
        /// the save process by re-authenticating.
        /// </summary>
        private void SaveAsyncThreadProc(object o)
        {
            AssignmentStream stream         = (o as object[])[0] as AssignmentStream;
            Workspace        workspace      = (o as object[])[1] as Workspace;
            EventHandler     onSaveComplete = (o as object[])[2] as EventHandler;

            // Build the zip file here. Start by saving the workspace to a memory stream.
            MemoryStream ms = new MemoryStream();

            workspace.Save(ms);

            // Determine a file name and compress the file data. The contract (at the time of this writing)
            // is that the file name in the uploaded assignments must ALWAYS match the deliverable file
            // name. This is true for both reviews and basic assignments.
            string fileName = OSBLEState.GetDeliverableFileName(this);

            byte[] zipData = CreateZipFile(ms.ToArray(), fileName);

            // Dispose the memory stream, as we are done with it
            ms.Dispose();
            ms = null;

            // If it's null then we have a problem
            if (null == zipData)
            {
                onSaveComplete(this, new SaveEventArgs(false));
                return;
            }

#if DEBUG
            IList <string> fileNamesCheck = GetZipFileNames(zipData);
            if (1 != fileNamesCheck.Count)
            {
                throw new Exception("Workspace save data could not be correctly compressed");
            }
#endif

            //AuthenticationServiceClient auth = new AuthenticationServiceClient(
            //    m_bind, new System.ServiceModel.EndpointAddress(OSBLEState.AuthServiceLink));
            AuthenticationServiceClient auth = new AuthenticationServiceClient();
            auth.ValidateUserCompleted += new EventHandler <ValidateUserCompletedEventArgs>(AuthForSaveCompleted);

            // Build an array of parameters
            object[] args = new object[] { auth, onSaveComplete, zipData,
                                           (null == stream) ? -1 : stream.OriginalAuthorID };

            // Authenticate so that we can save to OSBLE
            auth.ValidateUserAsync(m_userName, m_password, args);
        }
Esempio n. 4
0
        public void RefreshAsync()
        {
            m_relevant.Clear();

            // Create the authentication client. We need this to get an authentication token which serves
            // as our "key" for getting lists of courses, assignments, etc.
            //AuthenticationServiceClient authClient = new AuthenticationServiceClient(m_bind,
            //    new EndpointAddress(AuthServiceLink));
            AuthenticationServiceClient authClient = new AuthenticationServiceClient();

            authClient.ValidateUserCompleted += new EventHandler <ValidateUserCompletedEventArgs>(AuthClient_ValidateUserCompleted);
            try
            {
                authClient.ValidateUserAsync(m_userName, m_password, authClient);
            }
            catch (Exception)
            {
                OnLoginFailure(this, new OSBLEStateEventArgs(false,
                                                             "Could not log in, please try again"));
                return;
            }
        }