SaveCardRequest.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / SaveCardRequest.cs / 1 / SaveCardRequest.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace Microsoft.InfoCards
{ 
    using System;
    using System.Collections; 
    using System.IO; 
    using System.Runtime.InteropServices;
    using System.Collections.Generic; 

    class SaveCardRequest : UIAgentRequest
    {
        InfoCard m_card; 

        public SaveCardRequest( IntPtr rpcHandle, Stream inArgs, Stream outArgs, ClientUIRequest parent ) 
            : base( rpcHandle, inArgs, outArgs, parent ) 
        {
        } 

        protected override void OnInitializeAsSystem()
        {
            base.OnInitializeAsSystem(); 
        }
 
        protected override void OnMarshalInArgs() 
        {
            Stream stream = InArgs; 

            m_card = new InfoCard( stream );
            m_card.GetExtendedInformation().Deserialize( stream );
            m_card.GetRPIdentityRequirement().Deserialize( stream ); 
            m_card.GetClaims().Deserialize( stream );
 
        } 

        protected override void OnProcess() 
        {
            if( null != m_card )
            {
                StoreConnection connection = StoreConnection.GetConnection(); 
                try
                { 
 
                    connection.BeginTransaction();
 
                    try
                    {
                        //
                        // Set the last update time 
                        //
                        m_card.LastUpdate = DateTime.UtcNow; 
 
                        m_card.Save( connection );
                        connection.CommitTransaction(); 
                        if( m_card.IsSelfIssued )
                        {
                            AuditLog.AuditCardWritten();
                        } 
                        else
                        { 
                            AuditLog.AuditCardImport(); 
                        }
                    } 
                    catch
                    {
                        connection.RollbackTransaction();
                        throw; 
                    }
                } 
                finally 
                {
                    connection.Close(); 
                }

            }
        } 

        protected override void OnMarshalOutArgs() 
        { 
            Stream stream = OutArgs;
            StoreConnection connection = StoreConnection.GetConnection(); 
            try
            {
                m_card.AgentSerialize(
                            stream, 
                            ( ParentRequest is GetTokenRequest ),
                            GetPolicy(), 
                            connection, 
                            new System.Globalization.CultureInfo( ParentRequest.UserLanguage ) );
            } 
            finally
            {
                connection.Close();
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK