コード例 #1
0
        private void AuthForLoadCompleted(object sender, ValidateUserCompletedEventArgs e)
        {
            object[] args = e.UserState as object[];
            AuthenticationServiceClient authClient = args[0] as AuthenticationServiceClient;

            // If we failed then there's not much we can do
            if (null != e.Error || e.Cancelled)
            {
                m_gettingFiles = false;

                // Invoke the completion delegate
                (args[1] as EventHandler)(this, new RelevantAssignmentEventArgs(m_files));

                return;
            }

            string authToken = e.Result;

            m_lastAuthToken = authToken;

            // The last thing we do with the authentication client is get the active user
            authClient.GetActiveUserCompleted += new EventHandler <GetActiveUserCompletedEventArgs>(AuthClient_GetActiveUserCompleted);
            authClient.GetActiveUserAsync(authToken, authClient);

            OsbleServiceClient osc = new OsbleServiceClient();

            // What we query for depends on the assignment type
            args[0] = osc;
            if (AssignmentTypes.CriticalReview == m_a.Type)
            {
                // We need to use "GetReviewItems"
                osc.GetReviewItemsCompleted += new EventHandler <GetReviewItemsCompletedEventArgs>(GetReviewItemsCompleted);
                try
                {
                    osc.GetReviewItemsAsync(m_a.ID, authToken, args);
                }
                catch (Exception)
                { }
            }
            else if (AssignmentTypes.CriticalReviewDiscussion == m_a.Type)
            {
                // We need to use "GetMergedReviewDocument"
                osc.GetMergedReviewDocumentCompleted += new EventHandler <GetMergedReviewDocumentCompletedEventArgs>(GetMergedReviewDocumentCompleted);
                try
                {
                    osc.GetMergedReviewDocumentAsync(m_a.ID, authToken, args);
                }
                catch (Exception)
                { }
            }
            else
            {
                // We need to use "GetAssignmentSubmission"
                osc.GetAssignmentSubmissionCompleted += new EventHandler <GetAssignmentSubmissionCompletedEventArgs>(GetAssignmentSubmissionCompleted);
                try
                {
                    osc.GetAssignmentSubmissionAsync(m_a.ID, authToken, args);
                }
                catch (Exception) { }
            }
        }