SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Library Project, Phase 1<br />Introduction:<br />This project required us to build a Windows Forms application to automate the principal day-to-day operations of a lending library.  The application had to support the four (4) principal library functions: adding adult & juvenile members and checking items in & out.<br />For this project, we were given DLLs containing the Entity and Data Access layers.  These interfaced with the back-end database, running on SQL Server.  Our task was to build a front-end for the application using Windows Forms and a business layer to isolate the front-end from the Data Access layer.<br />Audience:<br />.NET Project managers, .NET Developers<br />Project Goals:<br />The project goals were:<br />,[object Object]
The application must validate user input to make sure data is entered for valid fields and all input meets business rules.
Items already checked-out cannot be checked-out by someone else until they have been checked back in.
Regular expressions were to be used to verify that all input met formatting requirements.Sample Screen Shots & Code<br />The Main Page<br />The application used a tabbed interface to keep all fields and buttons for each function grouped together.  The main page contains fields for checking out an item.  This is a three step process:<br />,[object Object]
Find the Item the member wishes to check-out. The librarian enters the ISBN & Copy Number of the Item the member wishes to borrow, then clicks on the “Search” button next to the Copy No. field.
Check-out the item.  This is done by clicking on the “Check-Out” button.In the example shown above, the member’s membership has expired.  As a result, they are not allowed to check-out any items until their membership is renewed.<br />Here is the front-end code used to search the database for a particular member.<br />/// <summary><br />/// Handles the Search button on the Check-Out tab in the 1. Find a Member <br />/// Groupbox.<br />/// </summary><br />/// <param name=quot;
senderquot;
>The object that sent the message.  Ignored.</param><br />/// <param name=quot;
equot;
>The arguments for the event.  Ignored</param><br />private void searchMemberButton_Click( object sender, EventArgs e ) {<br />    // Set our private field so the Validating methods know how to validate<br />    validateControls = ValidateCtrls.Member;<br />    // Validate the fields on the form<br />    if ( !this.ValidateChildren( ValidationConstraints.Enabled |<br />                                 ValidationConstraints.Visible ) ) {<br />        // If we get here, at least one field does not validate.  <br />        // Tell the user there's a problem<br />        DisplayStatus( statusLabel.Text + <br />            quot;
 Please fix the errors before trying to search again.quot;
 );<br />        // Exit now<br />        return;<br />    }<br />    // The form validates OK.  Get the member ID from the memberIdTextBox<br />    short memberID = short.Parse( memberIdTextBox.Text );<br />    // We need a try-catch block<br />    try {<br />        // Try to find the member with the given member ID from the database<br />        CurMember = BusinessLayer.GetMember( memberID );<br />    } catch ( ArgumentOutOfRangeException ) {<br />        // . . . <br />    } catch ( LibraryException ex ) {<br />        // If we get here, the GetMember operation failed.  <br />        // Construct an error message<br />        string errMsg = string.Format( <br />            quot;
Unable to find a Member with ID {0} because {1}.quot;
, memberID, <br />            BusinessLayer.GetReason( ex ) );<br />        // Display the error message in the statusLabel control<br />        DisplayStatus( errMsg );<br />        // Put the same error message in the errorProvider<br />        errorProvider.SetError( memberIdTextBox, errMsg );<br />        // Make sure CurMember is null<br />        CurMember = null;<br />    } catch ( Exception ex ) {<br />        // . . .<br />    }<br />}<br />Checking Out an Item<br />The figure above shows the main screen after an Item has been successfully checked out for the member.  The Check-In button shown in this figure is enabled only when the Item shown is already checked-out.  This button is on the screen because sometimes, in a real library, people returning books that are late put them on the shelves directly, in order to avoid paying a late fee.  As a result, the next member to check-out the book finds it is already checked-in.  This button is a convenience feature that allows the librarian to check the book back in before checking it out for the member without having to change screens.<br />Here is the front-end code for checking-out an Item.<br />/// <summary><br />/// Called when the user clicks the quot;
Check-Outquot;
 button.  Displays<br />/// the Check-Out Form using a pop-up window.<br />/// </summary><br />/// <param name=quot;
senderquot;
>The object that sent the message.  Ignored.</param><br />/// <param name=quot;
equot;
>The arguments for the event.  Ignored</param><br />private void checkOutButton_Click( object sender, EventArgs e ) {<br />    // Build a string with the information on the member & book <br />    // we are going to check in<br />    string bookInfo = string.Format( quot;
Title: {0}, ISBN {1}, Copy {2}quot;
,<br />            CheckOutItem.Title, CheckOutItem.ISBN, CheckOutItem.CopyNumber );<br />    // We need to use a try-catch block for our check-in attempt<br />    try {<br />        // Try to check-in the current Item in the business layer<br />        BusinessLayer.CheckOut( CurMember, CheckOutItem );<br />    } catch ( ArgumentOutOfRangeException ex ) {<br />. . .<br />        <br />    } catch ( Exception ex ) {<br />        // There was an error in the business layer.  Construct a message<br />        string msg = string.Format( <br />quot;
An unexpected error occurred while checking out {0}: {1}.quot;
,<br />bookInfo, ex.Message );<br />        // Display the error message<br />        DisplayStatus( msg );<br />        // Exit now<br />        return;<br />    }<br />    // Display a success message in the statusLabel<br />    DisplayStatus( string.Format( quot;
{0} was successfully checked out by {1}quot;
,<br />                   bookInfo, BusinessLayer.GetMemberName( CurMember ) ) );<br />    // Reload the CurMember property<br />    CurMember = CurMember;<br />    // Reload the CheckOutItem property<br />    CheckOutItem = GetItem( CheckOutItem.ISBN, CheckOutItem.CopyNumber );<br />}<br />Library Project, Phase 2<br />Introduction:<br />This project required us to build new entity and data access layers for the library application we built in phase 1.  We were also required to build our own stored procedures for the data access layer to call using ADO.NET objects in order to implement all of the required functionality.  In addition to supporting the four operations (add adult & juvenile members, check in & out items), we were required to make sure an item being checked-out was marked as loanable in the database.<br />There were also a number of extra-credit tasks for this project.  These included:<br />,[object Object]
Convert a juvenile member to an adult member if the date is after their 18th birthday.
Allow a librarian to add a new item to the database.Audience:<br />.NET Project managers, .NET Developers<br />Project Goals:<br />The project goals were:<br />,[object Object]
Use transactions in the stored procedures where required.
Write test scripts for each of the stored procedures
Use ADO.NET objects to call the stored procedures & read the data returned into the entity objects.
The data access layer had to be stateless, meaning it could not remember any information between calls.Check-Out Item Stored Procedure<br />The Check-Out Item stored procedure, shown below, follows a standard sequence of events:<br />,[object Object]
If all arguments are valid, the stored procedure then performs whatever steps are necessary to implement the required functionality.In addition to checking the validity of its arguments, the Check-Out stored procedure must also verify that the member’s membership hasn’t expired and that the Item that the member wishes to check-out is not already checked out.  If so, an error is raised.  But if the member is in good standing & the item is not checked out, it must update two tables to complete the checkout.  In this case, a transaction is started & if either operation fails, the entire operation is rolled-back.<br />CREATE PROCEDURE [dbo].[CheckOutItem]<br />    -- Add the parameters for the stored procedure here<br />    @ISBN            int,<br />    @CopyNo            smallint,<br />    @MemberID        smallint,<br />    @OtherMemberID    smallint OUTPUT<br />AS<br />BEGIN<br />. . .<br />    -- Try to get the tile number for the Item out of the Copy table<br />    DECLARE @TitleNo int;<br />    SELECT @TitleNo = title_no FROM copy <br />    WHERE isbn = @ISBN AND copy_no = @CopyNo;<br />    <br />    -- Declare an error message string<br />    DECLARE @error varchar;<br />    <br />    -- Everything is OK.  Check out the Item. Begin a transaction<br />    BEGIN TRANSACTION;<br />        -- Trap any errors<br />        BEGIN TRY<br />            -- Create a row in the Loan table for this loan<br />            INSERT INTO loan<br />                ( isbn, copy_no, member_no, title_no, out_date, due_date )<br />            VALUES<br />                ( @ISBN, @CopyNo, @MemberID, @TitleNo, GETDATE(), <br />DATEADD( dd, 14, GETDATE() ) )<br />        END TRY<br />        BEGIN CATCH<br />            -- The insert into the Loan table failed.  Rollback<br />            ROLLBACK TRANSACTION<br />, , ,<br />            -- Raise an error (send a SqlException to C#)<br />            RAISERROR( @error, 11, 12 );<br />        END CATCH<br />        <br />        -- The Item is now in the Loan table.  Set the on_loan field to 'Y'<br />        BEGIN TRY<br />            -- Update the Copy table<br />            UPDATE Copy<br />                SET on_loan = 'Y'<br />              WHERE isbn = @ISBN AND copy_no = @CopyNo;<br />        END TRY<br />        BEGIN CATCH<br />            -- The Copy table Update failed.  Rollback the transaction<br />            ROLLBACK TRANSACTION<br />. . .<br />            -- Raise an error (send a SqlException to C#)<br />            RAISERROR( @error, 11, 13 );<br />        END CATCH<br />    COMMIT TRANSACTION;<br />    <br />    -- Return 1 to show it worked<br />    RETURN 1;<br />END<br />Check-Out Item Data Access Layer Method<br />The Check-Out Item method in the Data Access Layer uses ADO.NET object to obtain a connection to the database server and then execute it.  It throws a custom LibraryException if any expected errors occur in the stored procedures.  It re-throws the original exception if an unexpected error occurs.<br />public void CheckOutItem( short memberNumber, int ISBN, short copyNumber ) {<br />    // Trap any errors that occur in this routine.<br />    try {<br />        // Get a connection to the database<br />        using ( SqlConnection connection = new SqlConnection( <br /> ConnectionString ) ) {<br />            // Create a Command that uses the AddAdultMember stored procedure<br />            using ( SqlCommand command = new SqlCommand( quot;
CheckOutItemquot;
,<br />   connection ) ) {<br />                // Open the connection now<br />                connection.Open();<br />                // Tell the Command it's a stored procedure<br />                command.CommandType = CommandType.StoredProcedure;<br />                // Create our parameters for the stored procedure<br />                command.Parameters.AddWithValue( quot;
@ISBNquot;
, ISBN );<br />                command.Parameters.AddWithValue( quot;
@CopyNoquot;
, copyNumber );<br />                command.Parameters.AddWithValue( quot;
@MemberIDquot;
, memberNumber );<br />                // Need an output parameter for the OtherMemberID<br />                SqlParameter omi = new SqlParameter( quot;
@OtherMemberIDquot;
,<br />     DbType.Int16 );<br />                omi.Direction = ParameterDirection.Output;<br />                // Need a parameter for the return value<br />                SqlParameter rv = new SqlParameter();<br />                rv.ParameterName = quot;
@Returnquot;
;<br />                rv.Direction = ParameterDirection.ReturnValue;<br />                // Add the two parameters we created outside this try block<br />                command.Parameters.Add( omi );<br />                command.Parameters.Add( rv );<br />                // Execute the Stored Procedure.<br />                command.ExecuteNonQuery();<br />                // Is the return value 0 or is it 1?<br />                if ( ( (int) rv.Value ) == 0 )<br />                    // The Item was already on loan.<br />                    throw new LibraryException( (short) omi.Value, <br />quot;
The Item is already on loan to another Member.quot;
 );<br />                }<br />            }<br />        } catch ( SqlException ex ) {<br />            // Determine which ErrorCode to return<br />            switch ( ex.State ) {<br />                case 1:         // ISBN is null<br />                    throw new ArgumentNullException( quot;
ISBNquot;
,<br />                              quot;
The ISBN is NULL.quot;
 );<br />                case 2:         // ISBN is invalid<br />                    throw new ArgumentOutOfRangeException( quot;
ISBNquot;
, ISBN, <br />                              quot;
The ISBN is out of the allowed range.quot;
 );<br />                case 3:         // The ISBN does not exist<br />                case 7:         // The Copy Number does not exist<br />                    throw new LibraryException( ErrorCode.ItemNotFound,<br />ex.Message );<br />. . .<br />            }<br />        }<br />    }<br />Check-In Item Stored Procedure<br />The Check-In Item stored procedure, shown below, is like the check-out stored procedure in that it performs the usual argument checks.  In addition to checking the validity of its arguments, the Check-In stored procedure must also verify that the Item is already checked out.  If so, the Item is checked in by copying the row in the Loan table into the LoanHistory table and then deleting the row from the Loan table.<br />CREATE PROCEDURE [dbo].[CheckInItem]<br />    -- Add the parameters for the stored procedure here<br />    @ISBN   int, @CopyNo smallint<br />AS<br />BEGIN<br />    -- Declare an error message string<br />    DECLARE @error varchar;<br />. . .<br />    -- The Copy is on loan.  Begin a transaction<br />    BEGIN TRANSACTION;<br />        -- Trap any errors<br />        BEGIN TRY<br />            -- Create a row in the LoanHist table for this loan<br />            INSERT INTO loanhist<br />                ( isbn, copy_no, out_date, title_no, member_no, due_date,<br />in_date )<br />            SELECT isbn, copy_no, out_date, title_no, member_no, due_date, <br /> GETDATE()<br />            FROM loan<br />            WHERE isbn = @ISBN AND copy_no = @CopyNo;<br />        END TRY<br />        BEGIN CATCH<br />            -- The insert into the Loan table failed.<br />            ROLLBACK TRANSACTION<br />. . .<br />            -- Raise an error (send a SqlException to C#)<br />            RAISERROR( @error, 11, 8 );<br />        END CATCH<br />        <br />        -- We have to set the on_loan field in the Copy table to 'N'<br />        BEGIN TRY<br />            -- Update the Copy table<br />            UPDATE Copy SET on_loan = 'N'<br />              WHERE isbn = @ISBN AND copy_no = @CopyNo;<br />        END TRY<br />        BEGIN CATCH<br />. . .<br />        END CATCH<br />        <br />        -- Delete the row from the Loan table<br />        BEGIN TRY<br />            DELETE FROM loan<br />             WHERE isbn = @ISBN AND copy_no = @CopyNo;<br />        END TRY<br />        BEGIN CATCH<br />. . .<br />        END CATCH<br />    -- If we get here, everything worked.  Commit the transaction<br />    COMMIT TRANSACTION;<br />    <br />    -- Return 1 to show it worked<br />    RETURN 1;<br />END<br />Get Items Data Access Layer Method<br />The requirements called for the display of all Items a member has on loan when they are looked-up and displayed.  To find all of the Items a member has on loan, a stored procedure was written.  Then, a strongly typed DataSet called ItemsDataSet was created that connected to the stored procedure.  The code shown below is the Data Access Layer method that queries the database using the stored procedure and returns an ItemsDataSet to the caller with all of the Items that member has on loan.<br />public ItemsDataSet GetItems( short memberNumber ) {<br />    // Declare an ItemsDataSet object to return to the caller<br />    ItemsDataSet dataSet = new ItemsDataSet();<br />    // Create a try-catch block<br />    try {<br />        // Get a TableAdapter<br />        using ( ItemsTableAdapter adapter = new ItemsTableAdapter() ) {<br />            // Load the table with the data<br />            adapter.Fill( dataSet.Items, memberNumber );<br />        }<br />    } catch ( SqlException ex ) {<br />        // The cause of the exception is in the exception's State property<br />        switch ( ex.State ) {<br />            case 1:         // The MemberID is null<br />                throw new ArgumentNullException( quot;
memberNumberquot;
, <br />quot;
The Member Number is NULL.quot;
 );<br />            case 2:         // The MemberID is invalid<br />                throw new ArgumentOutOfRangeException( quot;
memberNumberquot;
, <br />memberNumber, <br />quot;
The Member Number is out of the allowed range.quot;
 );<br />            default:<br />                // An unexpected error occurred.  Throw a LibraryException<br />                throw new LibraryException( ErrorCode.GenericException, <br />quot;
A database error occurredquot;
, ex );<br />        }<br />    }<br />    return dataSet;<br />}<br />Overdue Items Report<br />One of the extra-credit requirements we had was to implement a report that retrieved a list of all overdue Items using Linq to SQL.  My implementation consisted of the following parts:<br />,[object Object]
A method in the Data Access Layer that returned the ItemOnLoanContext object created by the .dbml file.
A method in the Business Layer that performed a Linq query against the ItemOnLoadContext returned by the DataAccessLayer & returned the results of that query.
The front end consisted of a tab page for the report that contained a DataGridView control.  The Business Layer method is called when the tab is displayed and its return value is data bound to the DataGridView control.Below is the Data Access layer method:<br />public ItemsOnLoanDataContext GetItemsOnLoan() {<br />    // Declare a DataContext that we will return<br />    ItemsOnLoanDataContext context = null;<br />    // Start a try-catch block<br />    try {<br />        // Create the DataContext<br />        context = new ItemsOnLoanDataContext( ConnectionString );<br />    } catch ( SqlException ex ) {<br />        // An unxpected SQL error occurred.  Throw a LibraryException<br />        throw new LibraryException( . . . );<br />    }<br />    // Return the DataContext to the caller<br />    return context;<br />}<br />And here is the Business Layer method:<br />public static IEnumerable<ItemOnLoan> GetOverDueItems() {<br />    // Create Get a LibraryDataAccess instance<br />    LibraryDataAccess lda = new LibraryDataAccess();<br />    // Get a DataContext for our BooksOnLoan database view<br />    ItemsOnLoanDataContext context = lda.GetItemsOnLoan();<br />    // Get all of the over due items<br />    var overDueItems = from  item in context.ItemsOnLoan<br />                       where item.due_date < DateTime.Now<br />                       orderby item.due_date descending<br />                       select item;<br />    return overDueItems;<br />}<br />Library Project, Phase 3<br />Introduction:<br />This project required us to replace the Windows front end which we had built & refined in Phases 1 & 2 with an ASP.NET front end.  In addition, new functionality had to be implemented.<br />Audience:<br />.NET Project managers, .NET Developers<br />Project Goals:<br />The project goals were:<br />,[object Object]
The previous Entities, Business & Data Access Layers were used.
Flag adults whose memberships have expired when looking them up and give the librarian the option to renew their memberships.
Detect when a juvenile member’s 18th birthday has passed and automatically promote them into adult members.  The librarian must be notified when this promotion is done.
Overdue items displayed on any page must be highlighted
The librarian must be able to enter new Items into the database
The Member look-up page had to use an AJAX UpdatePanel and an Update Progress control.  The user has to be able to select books that the member has checked-out and check them in from the Member Look-up page.  The Update Progress control must be displayed as the check-ins are done & the page must refresh showing all Items the member still has on loan.
Hyperlinks must be used to navigate between pages.
The application has to use form-based authentication and authorization.  Only users with a Librarian role are allowed to use any of the library functionality.Member Look-up Page<br />The Member Look-up page allows the librarian to look-up a member who wants to borrow or return books from the database.  The librarian enters their Member ID number into the field for it and clicks the “Search” button.  The database is searched for the Member Number.  If the member is not found, or if the member number is not valid, an error message is displayed in the message area at the bottom of the screen.  If the member is found, their information, including the list of all items they have on loan, is retrieved & displayed.<br />In the above figure, you will notice the member’s membership has expired & is displayed in red.  Further, the member has four (4) Items on loan, which is the maximum.  All four books are also overdue, as their due dates are displayed in red.<br />The message area is displaying two error messages, one indicating that the member’s membership has expired, and the other that the member cannot check out any more Items.  This second message is displayed for 2 reasons:<br />,[object Object]
The member’s membership is expired.If the librarian clicks the “Renew Membership” button, the member’s membership expiration date is changed to one year from today & they are permitted to borrow books again, so long as they have less than four (4) items on loan.<br />The librarian can check off any or all of the books displayed in the Items Borrowed grid and click on the Check-In button.  At that time, the books that are checked-off will be checked in while the Update Progress control displays a graphic indicating it is processing.  Once all of the selected Items are checked-in, the grid is reloaded with the list of Items still on loan & the Update Progress control is no longer displayed.  As this is all done in an AJAX Update Panel control, the operation appears to happen without a round trip or postback to the server.<br />Once the member has been looked-up, the librarian can navigate to the Check-Out page and check out any items they wish to borrow, provided the member is allowed to do so.  The Check-Out page is shown below.<br />Member Look-up Page Mark-Up<br />Below is an excerpt of the Member Look-up page’s mark-up.  This code is automatically translated into HTML & downloaded to the user’s browser when they navigate to this page. This excerpt shows the Update Panel, Grid View, and the UpdateProgress controls.<br /><asp:UpdatePanel ID=quot;
ContentUpdatePanelquot;
 runat=quot;
serverquot;
><br />    <ContentTemplate><br />        <asp:GridView ID=quot;
LoansDataGridquot;
 runat=quot;
serverquot;
 <br />        AutoGenerateColumns=quot;
Falsequot;
 . . .<br />            EmptyDataText=quot;
This Member does not have any Items on loan.quot;
 <br />            onrowdatabound=quot;
LoansDataGrid_RowDataBoundquot;
><br />            <Columns><br />                <asp:TemplateField><br />                    <ItemTemplate><br />                        <asp:CheckBox ID=quot;
ItemSelectedCheckBoxquot;
<br />runat=quot;
serverquot;
 /><br />                    </ItemTemplate><br />                </asp:TemplateField><br />                <asp:BoundField DataField=quot;
out_datequot;
 HeaderText=quot;
Outquot;
 <br />                    DataFormatString=quot;
{0:d}quot;
 ReadOnly=quot;
Truequot;
 /><br />                <asp:BoundField DataField=quot;
due_datequot;
 HeaderText=quot;
Duequot;
 <br />                    DataFormatString=quot;
{0:d}quot;
 ReadOnly=quot;
Truequot;
 /><br />                <asp:BoundField DataField=quot;
isbnquot;
 HeaderText=quot;
ISBNquot;
 <br />                    ReadOnly=quot;
Truequot;
 /><br />                <asp:BoundField DataField=quot;
copy_noquot;
 HeaderText=quot;
Copyquot;
 <br />                    SortExpression=quot;
copy_noquot;
 ReadOnly=quot;
Truequot;
 /><br />                <asp:BoundField DataField=quot;
titlequot;
 HeaderText=quot;
Titlequot;
 <br />                    ReadOnly=quot;
Truequot;
 /><br />                <asp:BoundField DataField=quot;
authorquot;
 HeaderText=quot;
Authorquot;
 <br />                    ReadOnly=quot;
Truequot;
 /><br />            </Columns><br />            . . .<br />        </asp:GridView><br />        <div style=quot;
text-align: centerquot;
><br />            <br /><br />            <asp:Button ID=quot;
CheckInSelectedButtonquot;
 runat=quot;
serverquot;
 <br />Text=quot;
Check-Inquot;
 <br />                Enabled=quot;
Falsequot;
 onclick=quot;
CheckInSelectedButton_Clickquot;
 /><br />            <br /><br />            <asp:UpdateProgress ID=quot;
UpdateProgressquot;
 runat=quot;
serverquot;
 <br />DisplayAfter=quot;
250quot;
><br />                <ProgressTemplate><br />                    <asp:Image ID=quot;
ProgressImagequot;
 runat=quot;
serverquot;
<br />ImageUrl=quot;
~/images/ajax-loader.gifquot;
 /><br />                </ProgressTemplate><br />            </asp:UpdateProgress><br />        </div><br />    </ContentTemplate><br />    <Triggers><br />        <asp:AsyncPostBackTrigger ControlID=quot;
CheckInSelectedButtonquot;
 <br />EventName=quot;
Clickquot;
 /><br />    </Triggers><br /></asp:UpdatePanel><br />Check-In Selected Items Method<br />Once the librarian checks off Items in the Items Borrowed Grid View control and clicks the “Check-In” button, the code below is executed.<br />protected void CheckInSelectedButton_Click( object sender, EventArgs e ) {<br />    // Sleep for 1 seconds, to make the UpdateProgress control show<br />    Thread.Sleep( 1000 );<br />. . .<br />    // Loop through all of the rows in the LoansDataGrid<br />    for ( int r = 0; r < LoansDataGrid.Rows.Count; r++ ) {<br />        // Get a reference to this Row<br />        GridViewRow row = LoansDataGrid.Rows[ r ];<br />        // Get a reference to the CheckBox control on this row<br />        CheckBox cb = (CheckBox) row.FindControl( quot;
ItemSelectedCheckBoxquot;
 );<br />        // Is the checkbox checked?<br />        if ( cb.Checked ) {<br />            // Yes it is.  Get this Item's ISBN & Copy Number<br />            int   isbn =   int.Parse( row.Cells[ colISBN ].Text );<br />            short copy = short.Parse( row.Cells[ colCopy ].Text );<br />            // Try to Check-In this Item<br />            if ( helper.CheckIn( isbn, copy ) ) {<br />                // We checked it in.  Increment our counter<br />                checkedIn++;<br />. . .<br />                // Do we have a CheckInItem?<br />                if ( CheckInItem != null ) {<br />                    // Yes, we do.  Is this Item the current Check-In item?<br />                    if ( CheckInItem.ISBN == isbn && <br />                         CheckInItem.CopyNumber == copy ) {<br />                        // It is.  Reload it!<br />                        CheckInItem = helper.GetItem( isbn, copy );<br />                    }<br />                }<br />. . .<br />            }<br />        }<br />    }<br />    // Redisplay the Current Member<br />    CurMember = CurMember;<br />    // Reload the ItemsOnLoan and update the GridView<br />    ItemsOnLoan = helper.GetItemsOnLoan( CurMember );<br />    // Display a message indicating which Items have been checked-in<br />    helper.DisplayStatus( string.Format( quot;
Checked in {0} Items: {1}quot;
,<br />  checkedIn, items ) );<br />}<br />Library Project, Phase 4<br />Introduction:<br />This project required us to transform our ASP.NET applications into a WCF service back-end and a WCF client front-end application.<br />Audience:<br />.NET Project managers, .NET Developers<br />Project Goals:<br />The project goals were:<br />,[object Object]
Update the front-end so it calls the WCF service.
The service must support the following:
A WCF Service Library project calls the Business Layer methods.
The service runs as a WCF Service Website.
The service should use the WsHttpBinding.
Transport with Message Credential security.
Authentication using ASP.NET membership.

Weitere ähnliche Inhalte

Was ist angesagt?

Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentationshangbaby
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Rabble .
 
Maintaining sanity in a large redux app
Maintaining sanity in a large redux appMaintaining sanity in a large redux app
Maintaining sanity in a large redux appNitish Kumar
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
 
Validation using javascripts by karan chanana
Validation using javascripts by karan chananaValidation using javascripts by karan chanana
Validation using javascripts by karan chananakaran info
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionSALT Lab @ UBC
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsVincent Chien
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with ReactGreeceJS
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointmentsWindowsPhoneRocks
 
Ajax Fundamentals Web Applications
Ajax Fundamentals Web ApplicationsAjax Fundamentals Web Applications
Ajax Fundamentals Web Applicationsdominion
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesKen Wheeler
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiRaffaele Chiocca
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoHasnain Iqbal
 

Was ist angesagt? (17)

Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 
Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentation
 
AJAX
AJAXAJAX
AJAX
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007
 
Maintaining sanity in a large redux app
Maintaining sanity in a large redux appMaintaining sanity in a large redux app
Maintaining sanity in a large redux app
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
Validation using javascripts by karan chanana
Validation using javascripts by karan chananaValidation using javascripts by karan chanana
Validation using javascripts by karan chanana
 
Dompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code CompletionDompletion: DOM-Aware JavaScript Code Completion
Dompletion: DOM-Aware JavaScript Code Completion
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 forms
 
Taming forms with React
Taming forms with ReactTaming forms with React
Taming forms with React
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointments
 
Introduction to JQuery
Introduction to JQueryIntroduction to JQuery
Introduction to JQuery
 
Ajax Fundamentals Web Applications
Ajax Fundamentals Web ApplicationsAjax Fundamentals Web Applications
Ajax Fundamentals Web Applications
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
 
Validate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation apiValidate your entities with symfony validator and entity validation api
Validate your entities with symfony validator and entity validation api
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael PizzoADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
ADO.NET Entity Framework by Jose A. Blakeley and Michael Pizzo
 

Andere mochten auch

0.敏捷ppt v1
0.敏捷ppt v10.敏捷ppt v1
0.敏捷ppt v1Lanhui Ou
 
Karen visitation
Karen visitationKaren visitation
Karen visitationprosper50
 
Scrum e a Crise Mundial
Scrum e a Crise MundialScrum e a Crise Mundial
Scrum e a Crise MundialMarcos Garrido
 
Social media for business
Social media for businessSocial media for business
Social media for businesstjwheatcroft
 
Html表格制作
Html表格制作Html表格制作
Html表格制作Lanhui Ou
 
教育信息化
教育信息化教育信息化
教育信息化Lanhui Ou
 
Inntekter
InntekterInntekter
Inntektereli1957
 
Oral presentation
Oral presentationOral presentation
Oral presentationharderna
 
面向“对象”的编程模式
面向“对象”的编程模式面向“对象”的编程模式
面向“对象”的编程模式Lanhui Ou
 
Pepsi RefreshEverything Multitouch Grant Proposal
Pepsi RefreshEverything Multitouch Grant ProposalPepsi RefreshEverything Multitouch Grant Proposal
Pepsi RefreshEverything Multitouch Grant Proposalprosper50
 
Facilitation techniques for Effective ScrumMasters
Facilitation techniques for Effective ScrumMastersFacilitation techniques for Effective ScrumMasters
Facilitation techniques for Effective ScrumMastersMarcos Garrido
 
Saleem Malik Painting / Coating, Insulation and Fire proofing inspector
Saleem Malik Painting / Coating, Insulation and Fire proofing inspectorSaleem Malik Painting / Coating, Insulation and Fire proofing inspector
Saleem Malik Painting / Coating, Insulation and Fire proofing inspectorsalimmalic
 
思维的片段 有动画
思维的片段 有动画思维的片段 有动画
思维的片段 有动画Lanhui Ou
 

Andere mochten auch (17)

0.敏捷ppt v1
0.敏捷ppt v10.敏捷ppt v1
0.敏捷ppt v1
 
Karen visitation
Karen visitationKaren visitation
Karen visitation
 
Scrum e a Crise Mundial
Scrum e a Crise MundialScrum e a Crise Mundial
Scrum e a Crise Mundial
 
Social media for business
Social media for businessSocial media for business
Social media for business
 
Adda politiken
Adda politikenAdda politiken
Adda politiken
 
Nb的敏捷
Nb的敏捷Nb的敏捷
Nb的敏捷
 
Html表格制作
Html表格制作Html表格制作
Html表格制作
 
教育信息化
教育信息化教育信息化
教育信息化
 
Inntekter
InntekterInntekter
Inntekter
 
Adda politiken
Adda politikenAdda politiken
Adda politiken
 
Oral presentation
Oral presentationOral presentation
Oral presentation
 
TIC en la Educación
TIC en la EducaciónTIC en la Educación
TIC en la Educación
 
面向“对象”的编程模式
面向“对象”的编程模式面向“对象”的编程模式
面向“对象”的编程模式
 
Pepsi RefreshEverything Multitouch Grant Proposal
Pepsi RefreshEverything Multitouch Grant ProposalPepsi RefreshEverything Multitouch Grant Proposal
Pepsi RefreshEverything Multitouch Grant Proposal
 
Facilitation techniques for Effective ScrumMasters
Facilitation techniques for Effective ScrumMastersFacilitation techniques for Effective ScrumMasters
Facilitation techniques for Effective ScrumMasters
 
Saleem Malik Painting / Coating, Insulation and Fire proofing inspector
Saleem Malik Painting / Coating, Insulation and Fire proofing inspectorSaleem Malik Painting / Coating, Insulation and Fire proofing inspector
Saleem Malik Painting / Coating, Insulation and Fire proofing inspector
 
思维的片段 有动画
思维的片段 有动画思维的片段 有动画
思维的片段 有动画
 

Ähnlich wie Library Project Automation

My Portfolio
My PortfolioMy Portfolio
My Portfolioz02247
 
Library Project
Library ProjectLibrary Project
Library ProjectMauro_Sist
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzerwspreitzer
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark_Jackson
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universitylhkslkdh89009
 
My Portfolio
My PortfolioMy Portfolio
My Portfolioaemartin4
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentationapweir12
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEHitesh Mohapatra
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioRobert Tanenbaum
 
Library Website
Library WebsiteLibrary Website
Library Websitegholtron
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq Hasan
 
Library Management System - V1.0
Library Management System - V1.0Library Management System - V1.0
Library Management System - V1.0JamesMuturi
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and DashboardsAtlassian
 
Project: Call Center Management
Project: Call Center ManagementProject: Call Center Management
Project: Call Center Managementpritamkumar
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmerselliando dias
 
Testing ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyTesting ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyBen Hall
 
The program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdfThe program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdfivylinvaydak64229
 
]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3Klaus Hofeditz
 

Ähnlich wie Library Project Automation (20)

My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Library Project
Library ProjectLibrary Project
Library Project
 
Il 09 T3 William Spreitzer
Il 09 T3 William SpreitzerIl 09 T3 William Spreitzer
Il 09 T3 William Spreitzer
 
Mark Jackson\'s Portfoilo
Mark Jackson\'s PortfoiloMark Jackson\'s Portfoilo
Mark Jackson\'s Portfoilo
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry university
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentation
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 
R Tanenbaum .Net Portfolio
R Tanenbaum .Net PortfolioR Tanenbaum .Net Portfolio
R Tanenbaum .Net Portfolio
 
Library Website
Library WebsiteLibrary Website
Library Website
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
Library Management System - V1.0
Library Management System - V1.0Library Management System - V1.0
Library Management System - V1.0
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
Project: Call Center Management
Project: Call Center ManagementProject: Call Center Management
Project: Call Center Management
 
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmers
 
Testing ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyTesting ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using Ruby
 
C#Portfolio
C#PortfolioC#Portfolio
C#Portfolio
 
The program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdfThe program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdf
 
]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3
 

Library Project Automation

  • 1.
  • 2. The application must validate user input to make sure data is entered for valid fields and all input meets business rules.
  • 3. Items already checked-out cannot be checked-out by someone else until they have been checked back in.
  • 4.
  • 5. Find the Item the member wishes to check-out. The librarian enters the ISBN & Copy Number of the Item the member wishes to borrow, then clicks on the “Search” button next to the Copy No. field.
  • 6.
  • 7. Convert a juvenile member to an adult member if the date is after their 18th birthday.
  • 8.
  • 9. Use transactions in the stored procedures where required.
  • 10. Write test scripts for each of the stored procedures
  • 11. Use ADO.NET objects to call the stored procedures & read the data returned into the entity objects.
  • 12.
  • 13.
  • 14. A method in the Data Access Layer that returned the ItemOnLoanContext object created by the .dbml file.
  • 15. A method in the Business Layer that performed a Linq query against the ItemOnLoadContext returned by the DataAccessLayer & returned the results of that query.
  • 16.
  • 17. The previous Entities, Business & Data Access Layers were used.
  • 18. Flag adults whose memberships have expired when looking them up and give the librarian the option to renew their memberships.
  • 19. Detect when a juvenile member’s 18th birthday has passed and automatically promote them into adult members. The librarian must be notified when this promotion is done.
  • 20. Overdue items displayed on any page must be highlighted
  • 21. The librarian must be able to enter new Items into the database
  • 22. The Member look-up page had to use an AJAX UpdatePanel and an Update Progress control. The user has to be able to select books that the member has checked-out and check them in from the Member Look-up page. The Update Progress control must be displayed as the check-ins are done & the page must refresh showing all Items the member still has on loan.
  • 23. Hyperlinks must be used to navigate between pages.
  • 24.
  • 25.
  • 26. Update the front-end so it calls the WCF service.
  • 27. The service must support the following:
  • 28. A WCF Service Library project calls the Business Layer methods.
  • 29. The service runs as a WCF Service Website.
  • 30. The service should use the WsHttpBinding.
  • 31. Transport with Message Credential security.
  • 33. Authorization using ASP.NET roles, using the Principle Permission property to secure the service operations.
  • 34. Use DataContracts for the entities.
  • 35. Support all previous developed functionality.
  • 36.
  • 37. Code all error handling in the WCF Service Library so it passed strongly typed FaultException objects to the client when an unrecoverable error occurred.
  • 38. Host the WCF Service Library in a WCF Web Host website.
  • 39. Convert the front-end so it would work with the new WCF Web Service.
  • 40. Confirm all functionality works as designed.
  • 41. Host the web service in IIS.
  • 42. Configure security for the service as specified.
  • 43. Modify the client to pass the proper credentials to the service.
  • 44.
  • 45. The definition of the service behavior (in the <service> element). This specifies the fully-qualified name of the class that implements the service, and is the linkage between the Service.svc file and the configuration information.
  • 46. The definition of the endpoint for the service, which includes the service’s endpoint, binding and contract in the <endpoint> element.
  • 47. Additional information about the security configuration is included in the <behaviors> element of the web configuration file. Things defined here include:
  • 48. The type of service credentials to use, in this case user name credentials, and the name of the provider class to use to verify the user, in this case AspNetSqlmembershipProvider.
  • 49. The type of service authorization to use, in the <serviceAuthorizaton> tag. The tag has attributes that specify Principal Permission mode (UseAspNetRoles) and the role provider class name (AspNetSqlRoleProvider).
  • 50.
  • 51. Allow the user to create a new session of an existing course of study
  • 52. Allow the user to edit an existing session
  • 53. Allow the user to add new session types
  • 54. Allow the user to add or remove variables
  • 55.
  • 56. File: The variable contains the name of an XML file in the XML folder
  • 57.
  • 58. For variables known to contain at least one paragraph of text (as opposed to a couple of words), a multi-line Text Box is displayed.
  • 59. For variables of type Cost, a plain Text Box is used, but the value is formatted properly when the Text Changed event is fired.
  • 60. For variables of type File, a Drop Down List is displayed. The choices provided are a list of all of the XML files in the XML folder, minus the configuration file.
  • 61. For all other variables, a plain, single line, default sized Text Box is displayed.Below is the control’s Bind method, which is where the logic described above is implemented.<br />/// <summary><br />/// The user calls this method to have it display <br />/// </summary><br />/// <param name=quot; variablequot; >The Variable object to associate with this <br />/// control.</param><br />/// The list of values to bind the DropDownList's DataSource to<br />public void Bind( Variable variable, List<string> contracts ) {<br /> // Hide all of the child controls<br /> ddlFileValue.Visible = txtDateValue.Visible = <br /> txtTextValue.Visible = false;<br /> // Does this variable's name contain the word quot; Datequot; in it?<br /> if ( variable.Name.ToLower().Contains( quot; datequot; ) ) {<br /> // It does. Set the VariableType to Date<br /> VariableType = VariableTypes.Date;<br /> // Show the txtDateValue control<br /> txtDateValue.Visible = true;<br /> // The name doesn't have quot; Datequot; in it. Is it quot; templatequot; ?<br /> } else if ( variable.Name.ToLower() == quot; templatequot; ) {<br /> // It is. Set the VariableType to File<br /> VariableType = VariableTypes.File;<br /> // Show the ddlFileValue control<br /> ddlFileValue.Visible = true;<br /> } else {<br /> // It isn't template, either. Switch on the variable's Type<br /> switch ( variable.Type.ToLower() ) {<br /> case quot; costquot; :<br /> // Set the VariableType to Cost<br /> VariableType = VariableTypes.Cost;<br /> // Show the txtCostValue control<br /> txtTextValue.Visible = true;<br /> break;<br /> case quot; filequot; :<br /> // Set the VariableType to File<br /> VariableType = VariableTypes.File;<br /> // Show the ddlFileValue control<br /> ddlFileValue.Visible = true;<br /> break;<br /> default:<br /> // Set the VariableType to Text<br /> VariableType = VariableTypes.Text;<br /> // Does the variable's name contain quot; paragraphquot; ?<br /> if ( variable.Name.ToLower().Contains( quot; paragraphquot; ) ||<br /> variable.Name.ToLower() == quot; classtimesquot; ) {<br /> // It does. Make the txtTextValue control multiline<br /> txtTextValue.TextMode = TextBoxMode.MultiLine;<br /> txtTextValue.Rows = 5;<br /> txtTextValue.Columns = 35;<br /> }<br /> // Show the txtTextValue control<br /> txtTextValue.Visible = true;<br /> break;<br /> }<br /> }<br /> // Save the VariableType in the ViewState<br /> ViewState[ quot; VariableTypequot; ] = VariableType;<br /> // Is the list of contracts null or empty?<br /> if ( contracts != null && contracts.Count > 0 ) {<br /> // It is not. Set it up<br /> FileList = contracts;<br /> }<br /> // Now set the proper child control's Text or Value property<br /> Text = variable.Value;<br />}<br />Updating a Contract<br />One of the optional requirements we had was to provide a means for the users to update a contract. The issue is that the contracts are stored as XML files and are translated into PDF files by a custom program, called the Generator. The Generator is an ASP.NET application that is accessible over the web & is used by students to print a copy of the contract for the class they are going to take. They then sign & return the contract to SetFocus before the class starts.<br />We decided to implement this functionality by using an XML Stylesheet Transforms, or XSLTs. The page we designed to accomplish this task is shown below.<br />The user chooses one of the XML files in the XML folder from the drop down & clicks the “Download” button. At that time, the XML file is transformed into a Word 2007 format document and downloaded to the user’s PC. The user may then edit the document and make any changes required.<br />When the user is done editing the file, they return to the above page and click the “Browse” button. This displays a dialog showing all files & folders on their local hard drive. The user locates the file they have edited & select it. Next, the user clicks the “Upload” button. At that time, the file is uploaded back to the server & transformed back into XML.<br />Below is the code that transforms the original XML file into Word 2007 format.<br />public static string Transform( string XmlFile, string TransformXslt, <br /> string TemplateFile ) {<br /> // Is the XmlFileName parameter null or empty?<br /> if ( String.IsNullOrEmpty( XmlFile ) ) {<br /> // It is. Throw an ArgumentException<br /> throw new ArgumentException( <br /> quot; Must specify the fully-qualified XML file to transformquot; , <br /> quot; XmlFilequot; );<br /> }<br /> // Does the file specified by XmlFile really exist?<br /> FileInfo xmlFile = new FileInfo( XmlFile);<br /> if ( !xmlFile.Exists ) {<br /> // It does not. Throw a FileNotFoundException<br /> throw new FileNotFoundException( <br /> quot; Cannot find the XmlFile at the specified pathquot; , XmlFile );<br /> }<br /> // Is the TransformXslt parameter null or empty?<br /> if ( String.IsNullOrEmpty( TransformXslt ) ) {<br /> // It is. Throw an ArgumentException<br /> throw new ArgumentException( <br /> quot; Must specify a fully-qualified XML file for the transformquot; ,<br /> quot; TransformXsltquot; );<br /> }<br /> // Does the file specified by TransforXslt really exist?<br /> FileInfo transformXslt = new FileInfo( TransformXslt );<br /> if ( !transformXslt.Exists ) {<br /> // It does not. Throw a FileNotFoundException<br /> throw new FileNotFoundException( <br /> quot; Cannot find the XSLT file at the specified pathquot; , TransformXslt );<br /> }<br /> // Is the TemplateFile parameter null or empty?<br /> if ( String.IsNullOrEmpty( TemplateFile ) ) {<br /> // It is. Throw an ArgumentException<br /> throw new ArgumentException( <br /> quot; Must specify a fully-qualified Word Template for the transformquot; , <br /> quot; TemplateFilequot; );<br /> }<br /> // Does the file specified by TemplateFile really exist?<br /> FileInfo templateFile = new FileInfo( TemplateFile );<br /> if ( !templateFile.Exists ) {<br /> // It does not. Throw a FileNotFoundException<br /> throw new FileNotFoundException( <br /> quot; Cannot find the Word template file at the specified pathquot; , <br /> TemplateFile );<br /> }<br /> // Get a temporary file name to use for the output file<br /> string outputDocument = Path.GetTempFileName();<br /> outputDocument = Path.ChangeExtension( outputDocument, quot; docxquot; );<br /> <br /> // Create a writer for the output of the Xsl Transformation.<br /> StringWriter stringWriter = new StringWriter();<br /> XmlWriter xmlWriter = XmlWriter.Create( stringWriter );<br /> // Create the Xsl Transformation object.<br /> XslCompiledTransform transform = new XslCompiledTransform();<br /> transform.Load( TransformXslt );<br /> // Transform the xml data into Open XML 2.0 Wordprocessing format.<br /> transform.Transform( XmlFile, xmlWriter );<br /> // Create an Xml Document of the new content.<br /> XmlDocument newWordContent = new XmlDocument();<br /> newWordContent.LoadXml( stringWriter.ToString() );<br /> // Copy the Word 2007 template document to the output file.<br /> File.Copy( TemplateFile, outputDocument, true);<br /> // Use the Open XML SDK version 2.0 to open the output document in edit mode.<br /> using ( WordprocessingDocument output = <br />WordprocessingDocument.Open( outputDocument, true ) ) {<br /> // Using the body element within the new content XmlDocument, <br /> // create a new Open Xml Body object.<br /> Body updatedBodyContent = <br /> new Body( newWordContent.DocumentElement.InnerXml );<br /> // Replace the existing Document Body with the new content.<br /> output.MainDocumentPart.Document.Body = updatedBodyContent;<br /> // Save the updated output document.<br /> output.MainDocumentPart.Document.Save();<br /> }<br /> // Return the output file's name<br /> return outputDocument;<br />}<br />