Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Azure

Local Application for Updates : JupiterMotorsERP local application

7/31/2011 9:25:42 AM
With our web service and worker roles in place, it's time to develop the application our drivers will use in order to confirm that the customer has accepted his/her vehicle. What we're about to do can be accomplished by any technology capable of calling a web service, but we'll use a simple Windows application to build on our strengths in .NET development. Our aim here is to cover some basics of Windows forms development, and one way to connect Windows Forms to Azure.

Brief overview of the application

Our application has two purposes. The first purpose is to show the current status of an order. This is handled by selecting an order from the listbox and clicking a link to update a label with the selected order's status. This is done using our WCF web services by passing the OrderHeaderID to the web service and accepting the order status produced as output. The application will then update the label with the returned string.

The second purpose is to be able to update status for an order by selecting the order from the listbox, selecting the new order status for the order, and clicking a button to update the order. When the button is clicked, the OrderHeaderID for the selected order and the OrderStatusID for the selected status is sent via the web service and added to the queue for processing by our worker role.


JupiterMotorsERP local application

Adding our local application to the solution is very simple. Right-click on our solution, and choose Add | New Project....

Under the project type Windows, select Windows Forms Application. Name the project as JupiterMotorsERP and click OK.

This will create a Form1.vb file and an app.config file. The Form1.vb will be our form design and code, whereas the app.config will hold any settings we wound need for the application.

As the first step toward setting up our local application, we're going to build the design of our form. We need the following:

  • Two listboxes named lbOrdersNotComplete and lbOrderStatuses

  • A label named lCurrentStatus and another named lMessage

  • A link button called lnkUpdateCurrentStatus

  • A button called btnUpdateOrderStatus

Our sample application form now looks like the following screenshot:

It's going to be a little tough for us to code our Windows Forms application to use our web services, as we haven't yet told the project where we're going to call the services. This is done by right-clicking on the project and choosing Add Service Reference....

This is where Visual Studio does some great things. We can click the Discover button, and it will search the solution for available web services; we can also manually type in the URL of the service that we want to integrate with. For developing our application now, we're going to click the Discover button and let it find our web service in our WCF web role. Finally, name the service reference as ERPServiceReference and click OK. This will add the necessary code to app.config. We are now ready to run the application!

Adding App.config code

This code was inserted into the app.config file once the service reference was set up. We are good with using the code generated for us, but should any changes need to be made to the service reference (such as changing the endpoint from a local address to a production address), this is where you would make them:

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IERPService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurity Context="true" />
</security>
JupiterMotorsERP local applicationApp.config code, adding</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1587/ERPService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IERPService" contract="ERPServiceReference.IERPService"
name="WSHttpBinding_IERPService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>



Now, if we double-click somewhere in the form, it will open up the code for our application. This is where we will add the following code to handle the web service calls, listbox, data bindings, and the events for the link and button clicks.

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim _client As New ERPServiceReference.ERPServiceClient
Dim _resultsSet As New DataSet
_resultsSet = _client.LoadStartupData()
lbOrdersNotComplete.SelectedItem() = Nothing
lbOrdersNotComplete.DataSource = _resultsSet. Tables("OrdersNotComplete").DefaultView
lbOrdersNotComplete.DisplayMember = "CustomerPO"
lbOrdersNotComplete.ValueMember = "OrderHeaderID"
lbOrdersNotComplete.SelectedItem() = Nothing
lbOrderStatuses.DataSource = _resultsSet. Tables("OrderStatuses").DefaultView
lbOrderStatuses.DisplayMember = "Description"
lbOrderStatuses.ValueMember = "OrderStatusID"
lbOrderStatuses.SelectedItem() = Nothing
Catch ex As Exception
JupiterMotorsERP local applicationApp.config code, addinglMessage.Text = ex.Message()
End Try
End Sub
Private Sub btnUpdateOrderStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateOrderStatus.Click
Dim _client As New ERPServiceReference.ERPServiceClient
_client.AddOrderStatusUpdateToQueue(lbOrdersNotComplete. SelectedValue, lbOrderStatuses.SelectedValue)
End Sub

Private Sub lnkUpdateCurrentStatus_LinkClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkUpdateCurrentStatus.LinkClicked
Dim _client As New ERPServiceReference.ERPServiceClient
lCurrentStatus.Text = _client.GetOrderStatusForOrder( lbOrdersNotComplete.SelectedValue)
End Sub
End Class

Testing our application

To test our application, we need to run the entire solution in debug mode. We can easily do this in Visual Studio by pressing the F5 button. The web role, worker role, and WCF web role should all start up in the development fabric once the solution is built, except our local application. Once all the web and worker roles have started, we can start an instance of our local application by right-clicking on the project and selecting Debug | Start new instance.

Our application will start up, bind the listboxes using the data returned from the web services, and allow us to now check the order statuses for any order not yet complete in the database. We can also change the status of any of these orders in the listbox. Note that the order status changes do not occur immediately. The changes are placed in the queue for processing and our worker role has a sleep timer on it. Once the worker role picks up the message, it is updated and can be checked by clicking the link and updating the label.

Other -----------------
- Collaborating on Spreadsheets : Exploring Web-Based Spreadsheets (part 3)
- Collaborating on Spreadsheets : Exploring Web-Based Spreadsheets (part 2)
- Collaborating on Spreadsheets : Exploring Web-Based Spreadsheets (part 1) - Google Spreadsheets
- Integrating DataMarket Data with a Visual Web Part : Create a WCF Service to Retrieve DATA.gov Crime Data (part 2)
- Integrating DataMarket Data with a Visual Web Part : Create a WCF Service to Retrieve DATA.gov Crime Data (part 1)
- Integrating DataMarket Data with Excel and SharePoint - Consume Windows Azure Data in Excel 2010
- Using Cloud Services : Collaborating on Word Processing (part 2)
- Using Cloud Services : Collaborating on Word Processing (part 1)
- Using Cloud Services : Collaborating on Project Management
- Windows Azure Marketplace DataMarket (part 2)
- Windows Azure Marketplace DataMarket (part 1) - WCF Data Services and Publicly Consumable Data Feeds
- Accessing the Surveys Application : Content Delivery Network
- Accessing the Surveys Application : Authentication and Authorization
- Working with Data in the Surveys Application : Using SQL Azure
- Using Cloud Services : Collaborating on Contact Management - Exploring Contact Management and CRM Applications
- Using Cloud Services : Collaborating on Event Management - Exploring Event Management Applications
- Working with Data in the Surveys Application : Displaying Data (part 3) - Displaying Questions & Displaying the Summary Statistics
- Working with Data in the Surveys Application : Displaying Data (part 2) - Session Data Storage
- Working with Data in the Surveys Application : Displaying Data (part 1) - Paging through Survey Results
- Microsoft Azure: Enterprise Application Development - Queue Storage
 
 
Most view of day
- Windows Server 2012 Administration : Managing Printers with the Print Management Console (part 2) - Adding New Printers as Network Shared Resources
- Installing and Configuring the Basics of Exchange Server 2013 for a Brand-New Environment (part 7)
- Microsoft Dynamics AX 2009 : Form Customization (part 1) - Learning Form Fundamentals
- Adobe Photoshop CS5 : Fixing Backlit Photos by Adding Fill Light
- Preparing Windows PE : Working with Windows PE (part 2)
- Microsoft Lync Server 2010 : Planning for Voice Deployment - Voice Routing
- Microsoft Dynamic GP 2010 : Sales Order Processing (part 2)
- Microsoft Dynamic AX 2009 : .NET Business Connector - Inside .NET Business Connector
- Microsoft Visio 2010 : Creating and Using Shape Data Fields (part 3) - Saving Sets of Shape Data Fields
- Microsoft Project 2010 : Tracking Progress on Tasks (part 1) - Saving a Project Baseline
Top 10
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 3) - Creating IPv4 DHCP Scopes
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 2) - Installing DHCP Server and Server Tools
- Windows Server 2012 : DHCP,IPv6 and IPAM - Exploring DHCP (part 1)
- Windows Server 2012 : DHCP,IPv6 and IPAM - Understanding the Components of an Enterprise Network
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 3) - Translating Text with the Mini Translator
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 2) - Translating a Word or Phrase with the Research Pane
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 1) - Setting Options for the Research Task Pane, Searching with the Research Task Pane
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 2) - Ending a Linked Notes Session, Viewing Linked Notes
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 1) - Beginning a Linked Notes Session
- Microsoft OneNote 2010 : Doing Research with Side Notes (part 3) - Moving Side Notes to Your Existing Notes
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro