.NET Compact Framework 3.5 Data-Driven Applications - Tan Edmund - E-Book

.NET Compact Framework 3.5 Data-Driven Applications E-Book

Tan Edmund

0,0
26,26 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

In Detail

The new .NET CF 3.5 framework provides enterprise application developers with a whole arsenal of possibilities at their disposal, but without proper guidance on developing performance-critical enterprise applications, it is easy to make the wrong design and technology decisions.

This book guides you to build each part of a robust enterprise application by illustrating the .NET CF 3.5 framework with the help of real-world business applications. It will not only help you to master basic .NET CF skills, but also outlines the best methods, techniques, and tools available to create high-impact and performance-critical data-driven enterprise mobile applications. It provides a solid set of guidelines to aid .NET CF developers to understand how best to apply the features of the .NET CF 3.5 framework.

The bulk of the book illustrates the basic concepts of .NET Compact 3.5 Framework programming by walking the reader through 3 different kinds of mobile applications:

  • A thick-client mobile sales-force application
  • A thin-client mobile dashboard and reporting application
  • A customer support case management application

Both the SQL Server Lite and Oracle Lite mobile databases are covered in detail, from data access to data synchronization. The book explains how device features such as Bluetooth, SMS, telephony, Infrared, and Windows Contacts can be accessed via .NET CF in a real-world example, namely the mobile sales-force application. It also explains.NET CF's GDI+ features that can be used to create rich charts and reports. You learn to synchronize the mobile application with remote datasources and communicate via web services and WCF services. The book outlines performance optimization and memory management techniques on the mobile platform. It also outlines the tools and techniques available for testing, performance-tuning, deploying and debugging .NET CF enterprise applications (including Power Toys for .NET Compact Framework 3.5 from Microsoft).

This book will teach you to build robust, feature-rich enterprise applications using the .NET Compact Framework 3.5, with the help of an end-to-end real-world example of a mobile sales force application.

Approach

The book walks you through three different real-world mobile applications from head to toe to provide a practical, hands-on experience on how to use .NET CF. It provides you with code snippets (in both VB.NET and C#) from real-world business scenarios. A summary at the end of each chapter explains how these code snippets work together as a part of the larger whole. It also makes use of diagrams to explain core concepts and helps you decide on which design patterns to use in different enterprise application scenarios.

Who this book is for

This book is written for developers who are acquainted with the basics of .NET Compact Framework and want to create enterprise-level mobile applications. It is for developers who have worked with the .NET CF Framework before but would like to learn how to utilize its advanced features and deploy leaner and faster business applications.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 417

Veröffentlichungsjahr: 2010

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

.NET Compact Framework 3.5 Data-Driven Applications
Credits
About the Author
About the Reviewer
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. CRMLive.NET: An Overview
Tomorrow Inc.
The mobile sales force application
The mobile dashboard application
The mobile support case application
Data flow in CRMLive.NET
Deciding on the type of mobile application
Thin clients
Thick clients
Smart clients
Messaging
A brief summary
Defining the mobile sales force application
Capturing lead, opportunity, and customer information
Mobile screen design
Creating reusable controls
Maintaining global lists
Data retrieval and manipulation on the mobile device
Data transfer between multiple mobile devices
Task management
Full-text search functionality
Integrating with Windows Mobile and the hardware
Detect incoming phone calls and SMS
Integrating with the Windows Mobile Calendar and Contacts book
Data exchange using Bluetooth and IrDA
Capturing handwritten input
Data synchronization
Dual database support
Application maintenance and upgrades
Defining the mobile dashboard application
Using stateless web services as a data source
Rendering the dashboard
Road show revenue
Total monthly sales
Sales for last three months
Defining the mobile support case application
Building a messaging backbone with MSMQ
Summary
2. Building the Data Tier
Designing the data tier
SQL Server CE 3.5 versus Oracle Lite 10g
Connecting the Windows Mobile emulator to ActiveSync
Setting up SQL Server Compact 3.5
Installing SQL Server CE on the development machine
Installing SQL Server CE on the Pocket PC device.
Setting up Oracle Lite 10g
Installing Oracle Lite 10g on the development machine
Installing Oracle Lite 10g on the Pocket PC device
Building the data tier
Building the CRMLiveFramework project
Defining the IDataLibPlugin interface
Building the Plugin Manager UI
An overview
Implementing the PluginCollection class
Implementing the PluginManager class
Creating the SalesForceApp project
Building the ConfigurePlugin form
Building the PluginsSetup form
Testing what you've built so far
Building the database plugins
Implementing the SQL Server CE Plugin
Storing DDL in the resource file
Building the plugin class
Connecting to SQL Server CE
Programmatically creating the SQL Server CE database
Testing what you've done so far
Browsing the SQL Server CE database with Query Analyzer
Retrieving data from SQL Server CE
Data manipulation in SQL Server CE
Dealing with GUID values in SQL Server CE
Implementing the Oracle Lite plugin
Storing DDL in the resource file
Building the plugin class
Connecting to Oracle Lite
Programmatically creating the Oracle Lite database
Browsing the Oracle Lite database with Msql
Retrieving data from Oracle Lite
Data manipulation in Oracle Lite
Dealing with GUID values in Oracle Lite
Summary
3. Building the Mobile Sales Force Module
A brief walkthrough of what you will be building
Building a form navigation class
Building the main menu
Using Main() as the startup object
Creating the business objects to encapsulate your DataSets
Validating data in your business objects
Building the AccountViewer form
Data binding .NET controls to your business objects
Launching the AccountViewer form
Testing the AccountViewer form
Building the Tasks list
Populating the Tasks Datagrid control
Building the TaskDetailViewer form
Launching the TaskDetailViewer form
Testing the tasks list
Handling file attachments
Building a file manager class
Building the FileUpload user control
Building the FileDetailViewer form
Testing file upload functionality
Custom formatting and display in list controls
Building a collection sorter using the IComparer interface
Custom formatting and display in the list control
Using the History list control
Testing the History list control
Building the ProductList control
Using XML DOM to store and retrieve product selection
Using the ProductList control
Testing the ProductList control
Building a paged listing of accounts
Paging in SQL Server CE
Paging in Oracle Lite
Building a paging user control
Creating a context menu for the paging user control
Launching the accounts listing page
Testing the accounts listing page
Summary
4. Building Search Functionality
A brief walk-through of parameterized search
Building the parameterized search feature
Creating the parameterized search query in SQL Server CE
Creating the parameterized search query in Oracle Lite
Encapsulating the retrieved Dataset using business objects
Building the parameterized search forms
Building the search form
Building the search results listing form
Trying out your code
A brief walk-through of full-text search
Building the full-text search feature
Creating the Keyword Extractor classes
A sample keyword extractor—the HTML Keyword Extractor
Indexing the file
Creating the full-text search query for SQL Server CE
Creating the full-text search query for Oracle Lite
Encapsulating the retrieved dataset using business objects
Creating the full-text search forms
Trying out the full-text search
Improving the full-text search engine
Summary
5. Building Integrated Services
Sending SMS and e-mail from your application
Sending SMS and e-mail directly through code
Delegating to the default Windows Mobile Compose UI
Intercepting incoming SMS
Intercepting an SMS message
Placing phone calls from your application
Detecting incoming phone calls
Populating the History tab in the sales force application
Creating the data tier functions to insert historical records
Encapsulating SMS functionality
Encapsulating phone functionality
Intercepting incoming SMS messages and phone calls in the background
Handling outgoing SMS messages and phone calls
Testing your code
Synchronizing with Windows Mobile Contacts
Synchronizing with Windows Mobile Tasks
Sharing an account between two devices
Sharing an account between two devices using Infrared (IrDA)
Sharing an account between two devices using Bluetooth
Capturing handwritten input using the Smart Device Framework
Summary
6. Data Synchronization
Overview of the different data synchronization methods available for Microsoft SQL Server CE
SQL Remote Data Access (SQLRDA)
Merge replication
Microsoft Synchronization Services
Overview of the different data synchronization methods available for Oracle Lite
Oracle Mobile Server
A quick comparison between the various Synchronization frameworks
Using Microsoft Synchronization Services
Setting up Microsoft SQL Server and Microsoft Synchronization Services
Creating the CRMLive server tables
Creating the WCF service
Configuring the WCF service library
Setting filters for the Sync
Configuring the client project
Writing the sync code
Conflict resolution
Using Oracle Mobile Server
Installing Oracle Database Enterprise 11g and Oracle Mobile Server
Creating an Oracle Mobile repository
Creating the CRMLive server tables
Creating a new publication using the Mobile Database Workbench
Creating a new mobile project
Adding publication items to your project
Adding sequence items to your project
Adding a publication to your project
Publishing the mobile application to the mobile server
Setting up application users using the WebToGo portal
Registering the mobile device with the mobile server
Synchronizing with the mobile server
Synchronizing files with the server
Creating network-aware synchronization modules
Summary
7. Optimizing for Performance
Measuring performance
Measuring .NET CF code performance
Capturing application performance statistics
Optimizing database performance
Data caching
Using database indexes to boost search performance
Other database optimization tips
Optimizing data transfer performance
Managing better code
Managing better strings
Managing better Winforms
Using BeginUpdate and EndUpdate
Using SuspendLayout and ResumeLayout
Load and cache forms in the background
Managing better XML
Using XMLTextReader and XMLTextWriter
XML serialization and deserialization thesis
Managing better files
The .NET Compact Framework garbage collector
Summary
8. Securing the Application
Encrypting the database
Encrypting the SQL Server CE database
Encrypting the Oracle Lite database
Authenticating the sales force application
Performing one-way encryption using SHA256
Writing the code for authentication
Loading the login form
Encrypting data for inter-device transmission using AES
Summary
9. Globalization
Supporting double-byte languages
Supporting Japanese character input in Windows Mobile
Supporting Unicode at the application level
Designing culture-sensitive forms
Retrieving culture information
Summary
10. Building the Dashboard
An overview of the dashboard
Creating the web service
Creating the dashboard smart client
Connecting to the web service
Creating the line chart
Creating the round gauge
Creating the bar chart
Summary
11. Building the Support Case System
Introduction to MSMQ and the support case system
Setting up MSMQ on your mobile device
Writing your first MSMQ application
Setting up MSMQ on your server
Creating a queue on the server manually using the computer management panel
Sending a message from the server to a remote mobile device
Sending data to a remote queue
Creating the server-side application
Creating the client-side application
Sending a message from the mobile device to the server
Writing the client-side code
Writing the server-side code
Summary
12. Testing and Debugging
Overview of Power Toys for .NET CF 3.5
Installing Power Toys for .NET CF 3.5
Using the Remote Performance Monitor and GC Heap Viewer tool
Memory leaks and their causes
A sample application with memory leak
Using the Remote Performance Monitor tool to view application statistics in real time
Using PerfMon to graphically view runtime performance statistics
Using the GC Heap Viewer tool to detect memory leaks
Resolving the memory leak
Using the CLR Profiler tool
A sample application with bad performance
Launching the application with the CLR Profiler tool
Inspecting the Histogram view
Inspecting the Allocation Graph
Inspecting the Time Line view
Inspecting the Call Tree view
Using the App Configuration tool
Using the ServiceModel Metadata tool
Using the Remote Logging Configuration tool
Using the Network Log Viewer tool
Summary
13. Packaging and Deployment
Deploying your solution as a CAB file
Adding the SalesForce application files to your CAB project
Configuring other miscellaneous settings
Deploying your solution as an MSI file
Creating an INI file
Creating the custom action DLL
Creating the MSI installer project
Creating an automated update service
Creating the server-side web service
Creating the client-side updater tool
Summary
Index

.NET Compact Framework 3.5 Data-Driven Applications

Edmund Tan

.NET Compact Framework 3.5 Data-Driven Applications

Copyright © 2010 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2010

Production Reference: 1220410

Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.

ISBN 978-1-849690-10-2

www.packtpub.com

Cover Image by Vinayak Chittar (<[email protected]>)

Credits

Author

Edmund Tan

Reviewer

Greg Yap

Acquisition Editor

David Barnes

Development Editor

Rakesh Shejwal

Technical Editors

Neha Damle

Rukhsana Khambatta

Copy Editor

Sanchari Mukherjee

Indexer

Monica Ajmera Mehta

Editorial Team Leader

Gagandeep Singh

Project Team Leader

Lata Basantani

Project Coordinator

Srimoyee Ghoshal

Proofreader

Sandra Hopper

Graphics

Geetanjali Sawant

Production Coordinator

Shantanu Zagade

Cover Work

Shantanu Zagade

About the Author

Edmund Tan is the CTO and co-founder of a leading e-forms and workflow solution vendor based in Singapore. He holds more than eight years of experience building performance-critical .NET e-forms and workflow solutions for smart devices on top of Oracle and Microsoft SQL Server databases for large companies and governmental institutions located in Singapore and Malaysia. Edmund is also a regular public speaker at various conferences held in Singapore and Malaysia on the topic of on-the-go BPM (Business Process Management) hosted on smart device technologies. During his free time, Edmund works on trying to create machines capable of emulating human thought.

My first and heartfelt word of thanks goes out to David Barnes without whom this book would not have been possible at all. I also thank James Lumsden for giving my e-mail a chance, Rakesh Shejwal and Greg, my long-time collaborator, for their always insightful edits, Srimoyee Ghoshal for keeping me on schedule, Lata Basantani, as well as everyone else involved in this book at Packt.

I extend my gratitude to my parents, Laumee and Obagi, for their undying love and support, my aunt Laumar for instilling the bookworm in me, my wife Shen for keeping the beverages flowing, my kid Sophie simply for being the pride of my life, and, last but not least, my brother Edwin for his jokes during the really, really late hours of the night.

About the Reviewer

Greg Yap is a tech-savvy person who's always interested in the latest technology. He has worked on .NET since its first release. He has experience in developing software for small, medium, and enterprise-sized companies around the world and has worked on Microsoft technologies for a variety of platforms including the .NET Compact Framework. He is also well versed in the C# and VB.NET programming languages.

I would like to thank my family, especially my understanding wife Jennie who's given me all the support and time I needed to review this great book. To my two kids—thank you! I'm glad that both of you have shown the patience I knew you would. My thanks also go out to my friend Edmund for having considered me as the technical reviewer for this book—I owe you a coffee! Last but not the least, I would like to thank Srimoyee Ghoshal for always being there to keep me on time and the remaining Packt Publishing team for giving me the opportunity to review this book.

Preface

As business systems become increasingly distributed, the mobile device becomes an increasingly important tool on the enterprise stage. The large amount of processing power available to mobile devices nowadays bring to it a whole new range of possibilities as a mobile extension to traditional server-based enterprise systems.

Harnessing this power is the .NET Compact Framework, which has seen tremendous improvements over the last few versions. The .NET Compact Framework provides a rich set of managed classes that does away with a big chunk of the menial labor required to perform common tasks, leaving the developer to focus on building business logic instead.

This book is not intended to be a complete reference tome of the .NET Compact Framework. There are numerous books and documentation online that serve this purpose. Rather, it will show you how to apply the .NET Compact Framework in interesting ways to solve real-world business problems. We will explore commonly encountered design decisions and technology comparisons along the way and ultimately build clean solutions that keep to best practices such as the three-tier design and the Model View Controller (MVC) model.

Using a sales force application as the central example and theme in this book, you will have a clear step-by-step guide on building one of the most popular types of business applications in the market today from ground up. Through these pages, you will learn how to create robust data-driven mobile applications that work seamlessly with other mobile devices and database servers. You will get to explore the little nuances of .NET Compact Framework programming, and how to get around them using its advanced features. You will also get a firsthand look at how you can use third-party libraries such as the open source Smart Device Framework to add a host of rich functionality to your applications.

Towards the end of this book, you will have accumulated enough understanding of the capabilities and limitations of the .NET Compact Framework and its tools to confidently tackle an enterprise mobile application of any size or complexity.

I hope in the process of getting there you will have as much fun reading this book and trying out the samples as I had writing it.

What this book covers

Chapter 1, CRMLive.NET: An Overview, provides a technical and scope overview of CRMLive.NET, a mobile customer relationship management suite comprising three individual applications (a mobile sales force, mobile dashboard, and mobile support case application).Chapter 1 also outlines the four different mobile client models and a comparison of their strengths and weaknesses.

Chapter 2, Building the Data Tier, shows how a plugin-based data tier based on both the Microsoft SQL Server Compact and Oracle Lite databases can be created using ADO.NET.

Chapter 3, Building the Mobile Sales Force Module, walks the reader through building the logic and presentation tiers of the mobile sales force application, illustrating various concepts along the way such as UI object reusability, validation, paging, record navigation, sorting, and grouping.

Chapter 4, Building Search Functionality, illustrates how full-text search and parameterized-search functionality can be added to the mobile sales force application.

Chapter 5, Building Integrated Services, illustrates how the sales force application can make use of the .NET Compact Framework and P/Invoke calls to access underlying Windows Mobile operating system and mobile device functionality such as the Bluetooth, Infrared, Calendar, and Telephony services.

Chapter 6, Data Synchronization, covers one of the most important topics in the book—the process of data synchronization between the mobile device and the remote database. In this chapter, we will look at how the sales force application can perform bidirectional synchronization using Microsoft SQL Server Compact's SQL RDA and Oracle Lite's mSync technologies.

Chapter 7, Optimizing for Performance, illustrates how the sales force application's performance can be measured and improved using various techniques such as data caching and data compression.

Chapter 8, Securing the Application, covers the various ways to secure locally stored data on the mobile device. It also covers the various authentication mechanisms available during data synchronization with the remote database.

Chapter 9, Globalization, illustrates how the reader can globalize the sales force application to intrinsically support double-byte (Unicode) languages.

Chapter 10, Building the Dashboard, walks the reader through the building of the second application in CRMLive.NET—the mobile dashboard. It will cover the use of stateless asynchronous web service calls to retrieve XML-based data from a remote server.

Chapter 11, Building the Support Case System, walks the reader through the building of the third application in CRMLive.NET—the mobile support case application. It will cover how a messaging backbone based on Microsoft Messaging Queue (MSMQ) technology can be built to support disconnected-state messaging between two remote applications.

Chapter 12, Testing and Debugging, looks at how the tools provided in the PowerToys for .NET CF 3.5 suite can assist in the testing and debugging process of the CRMLive.NET application.

Chapter 13, Packaging and Deployment, walks through the packaging and deployment process of the CRMLive.NET application and how a network-aware, automated update service can be created to assist in the deployment of application upgrades.

What you need for this book

This book provides all source code in both VB.NET and C#. To run most of the code samples in this book, you will need the following basic tools:

A suitable development workstation with Microsoft Visual Studio 2008 Windows Mobile 6 SDK (includes an emulator for you to test your .NET CF applications) Microsoft ActiveSync 4.5 (for Windows XP machines) or Microsoft Mobile Device Center (for Windows Vista machines) The .NET Compact Framework 3.5 redistributable The Microsoft SQL Server Compact 3.5 database

Throughout the book, we will also encounter certain technologies and products when we build our application. The following lists the other products used in the book:

In Chapter 2, we will show how the data tier can also be built to support the Oracle Lite database. To run the Oracle Lite code samples, you will need to download and install Oracle Lite 10g. In Chapters 5 and 10, we make use of the Smart Device Framework to handle specific requirements in the CRMLive.NET application. To run the code samples in these chapters, you will need to install the Community Edition of the Smart Device Framework v. 2.3.0.39 (at the time of writing). In Chapter 11, we will be building a messaging backbone on top of the Microsoft Messaging Queue service. You will need to install the MSMQ service on the mobile device. In Chapter 12, we will cover the tools provided in the PowerToys for .NET CF 3.5 suite (provided by Microsoft) to test and debug the CRMLive.NET application. You will need to install this product to try out the samples in this chapter.

Who this book is for

This book is primarily targeted at developers who are new to the .NET Compact Framework and wish to embark on data-driven mobile application development in an enterprise scenario. All code samples included in this book are in VB.NET and C#.

This book assumes you are familiar with either the Visual Basic.NET or C# language. It does not require you to have any prerequisite experience or knowledge of the .NET Compact Framework.

This book is also targeted at:

Developers who are already familiar with the .NET Compact Framework, but want to learn about how it can be effectively used to tackle commonly faced problems in real-life business scenarios Developers who want to learn how to use the .NET Compact Framework to access core Windows Mobile 6.0 and device functionality

Most of the samples in this book are targeted at the Windows Mobile operating system. Some basic knowledge of the Windows Mobile operating system would be beneficial, but not necessary.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an e-mail to <[email protected]>, and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email <[email protected]>.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for the book

Visit https://www.packtpub.com//sites/default/files/downloads/0102_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. CRMLive.NET: An Overview

Mobile device programming by itself can be a serious test of software engineering skill, where coders are usually forced to work with a fraction of the resources available compared to the full .NET Framework. Screen area, processor speed, memory, and disk space available stand at a fraction of what one would generally get with a desktop computer. In fact, the .NET Compact Framework implements only thirty percent of the full .NET Framework, doing away with a large subset of the classes deemed to be unsuitable for the small footprint required of a mobile application.

In such a resource-tight environment, the wrong design decisions can often lead to an underperforming application, a clunky interface that irritates users, or worse—grinds to a halt when deployed in an enterprise scenario where hundreds of instances of the application need to exchange and sync data in synchrony.

As you progress through this book, you will find that the three-tier model recurs throughout all chapters. In each approach, you will learn how to think a few steps ahead and adopt designs that allow the various components you are building to fit in together elegantly.

We start this first chapter by exploring an overview of game developer Tomorrow Inc. and CRMLive.NET, a mobile customer relationship management suite that we will be building for this company. By the end of this chapter, you will obtain:

A first-hand look at how the end product you are developing will lookA general overview of the functional scope of CRMLive.NETA look at the various designs undertaken in CRMLive.NET and why they work best in each scenarioAn understanding of the various classes in CRMLive.NET and their interactionsAn overview of the various .NET Compact Framework technologies you are going to use along the way

Tomorrow Inc.

Tomorrow Inc. is a cutting edge gaming company of about 5,000 employees based in New York with branches around the world. They have recently developed a technology that immerses the gamer in a virtual world and are planning to launch their first MMIG (Massively Multiplayer Immersive Game), titled 'Rabbits from Hell' at a road show in New York and Tokyo at the same time.

The products include a virtual reality chair, simply known as 'The Chair,' which is basically an interface to the game that allows full unrestricted physical motion from the player. Used together in conjunction with a set of Virtual Reality goggles, it brings gaming realism to a whole new level by immersing the player completely in the game. The Chair is about the size of an armchair and after purchase, a visit will be typically arranged by Tomorrow Inc. technicians to deliver and install the product in the customer's home.

The road show is the biggest ever launch in the history of Tomorrow Inc., stationing about 100 salespersons at the event itself and another 50 on the streets for a total duration of three weeks. Tomorrow Inc. needs a suite of mobile applications: CRMLive.NET to cater to the needs of three different levels of staff—the salesperson, the boss, and the technician.

The mobile sales force application

Tomorrow Inc. needs a mobile sales force application that will allow its salespersons to capture and manage leads, opportunities, and customers at the event. Before we proceed with the technical requirements, let's explore Tomorrow Inc.'s business a little further in detail.

A 'lead' is a sales term that applies to someone who shows an interest in the product, but how genuine he or she is about buying it has not yet been ascertained. It is usually the intention of the salesperson to convert a lead (a curious prospect) into an 'opportunity' (a serious potential buyer) and eventually into a buying customer.

At any one time during and after the launch of the game, there will be a mix of people from all three categories. There are the curious onlookers at the road show who casually enquire about the game. These people fall under the leads category. Then there are those who have been hounded by salespersons for weeks. They have the money and do show a genuine interest to buy, but need a little more coaxing. These are 'opportunities'. Finally, there are the frenzied young kids who have camped outside the road show hall since 2 a.m., having saved up their entire life savings anticipating the game release. These are undoubtedly buying customers.

Tomorrow Inc. is forecasting a huge flood of visitors to its road show, and has placed a strong emphasis on a lean UI design that can streamline quick data capture and access. The following list highlights the core requirements of this application in brief:

Capable of lead, opportunity, customer, and task managementMust have quick and responsive UIMust support offline access to stored information (when a network connection is unavailable)Must support strong personalization featuresMust be highly secure—Tomorrow Inc. is anticipating the possibility of lost mobile devices and wishes to protect locally stored informationMust be capable of fast full-text search (searching within file attachment content and the entire database)Salespersons may decide to share leads at any point in time. The application must be able to transfer leads from a mobile device to another easilyMust have dual database support—due to incredibly poor IT budget management, half of Tomorrow Inc.'s servers are hosted on Oracle, with the other half hosted on Microsoft SQL Server Enterprise. Extending this to the mobile device, this means that Oracle Lite Edition and Microsoft SQL Server Compact Edition support will be necessaryAuthentication must make use of Tomorrow Inc.'s existing ActiveDirectory setupMust provide Japanese-language support for users at the road show in Tokyo

The mobile dashboard application

The boss of Tomorrow Inc. travels across country frequently by train; his trips usually take him through areas with little or no Internet connectivity. His requirements are primarily centered on a mobile dashboard application that allows real-time monitoring of sales figures and Key Performance Indices (KPIs). His requirements include:

Must provide customizable dashboard viewsMust have real-time access to the latest data from the serverMust be able to display information visually in the form of interactive charts and gauges

The mobile support case application

After the customer purchases a game account, the Tomorrow Inc. technician will need to make a visit to the customer's residence to install and deploy The Chair. Before that can happen, the following series of actions will first take place:

A data entry clerk at the Tomorrow Inc. office will create a job at the server.Once a job is created, it will be broadcast to all technicians on the field over the Internet.The technicians can then choose to accept a job via the mobile application. The accepted job is subsequently removed from the list of jobs at the server.

The core requirements for this application include the following:

Must be able to broadcast/push new jobs to individual mobile devices over the Internet even if these devices are offlineMust be able to propagate the technician's actions back to the server

Data flow in CRMLive.NET

Based on the requirements outlined in the previous section, we can roughly summarize the data flow of CRMLive.NET in the succeeding diagram. CRMLive.NET comprises three separate and distinct applications that tap into the same central data source.

The sales force application is the key application that provides data to fuel the rest of the system. You will notice from the diagram that mobile devices running the sales force application can also share data directly with each other. This is because salespersons at the event may decide to transfer their leads and opportunities to their colleagues. At the end of the day, all data entered through the sales force application is eventually synced up to the central database.

The support case system will make use of information captured from new customers, such as their residential addresses and phone numbers, to generate new jobs for the technicians.

The mobile dashboard on the other hand will periodically retrieve sales-related data (keyed in when new customers are created) directly from this central database every minute. This sales data is converted into visual charts for display on the mobile dashboard.

Each of these three applications access data in a different way. In all three scenarios, the central database can be accessed over the Internet as well as over an Intranet. We will also explore the different ways to protect data transmission and access throughout CRMLive.NET in the later chapters of this book.

Deciding on the type of mobile application

There are four different ways to deploy a mobile application, each with their own benefits and downsides. Before you decide on the type of model to use in your applications, let's take a look at them in further detail.

Thin clients

Applications deployed on a thin client model are accessed through browsers on the mobile device, called mobile browsers or alternatively, mini browsers, or wireless Internet browsers. They are essentially scaled-down versions of a full-blown browser. For instance, the default preinstalled browser that comes with the Windows Mobile operating system, Internet Explorer Mobile, is a mobile browser.

In the thin client model, application code and data are not stored on the mobile device. Just like traditional web-based applications, all the work is done at the server, and each page is served up on-demand as they are accessed from the mobile device. Thin-client applications, therefore do not require the installation of any additional software other than the mobile browser.

Thick clients

Thick clients run entirely on the mobile device and store both code and data locally. It must be installed on the mobile device prior to usage. Thick clients typically utilize a mobile database installed on the same mobile device such as Microsoft SQL Server Compact or Oracle Lite. It is common for thick clients to transfer its data from the local database to a remote and central database periodically so that it can be shared with other units. This process is called data synchronization.

The basic set of features you would find common across thick clients include:

A responsive and interactive UIAbility to store data locally in a mobile databaseAbility to synchronize data with a database on a remote server

Smart clients

A smart client, sometimes known as a rich client lies somewhere between a thin client and a thick client. Code is still stored locally on the mobile device, but data is stored on a remote server. Data (commonly in the form of XML) is retrieved from or updated to the server in an on-demand fashion whenever needed. There are various ways over which this data exchange can take place, the most common being web service calls, made over the SOAP (Simple Object Access Protocol) interface.

As smart clients still render the UI of the application locally, it has the benefit of a responsive and rich interface. However, smart clients do not have to worry about data synchronization as all data manipulation is done in real time (via web service calls). Smart clients are suitable for projects where:

There are lists of frequently changing information, such as global pricelists that need to be frequently updated on the mobile device.Developers need the flexibility of a customizable and responsive UI together with real-time data transactions.

Messaging

Lastly, messaging-based mobile applications make use of services such as SMS (Short Messaging Service) and e-mail to drive the interaction between the user and the application. Like the thin client model, it does not require installation of any specific software other than the messaging application itself.

For example, a stock price enquiry service may involve the following actions:

A mobile user sends an SMS containing the stock symbol of the desired stock to a special numberThis incoming SMS is processed by the server-side application, which then queries the database and retrieves the corresponding stock price for the symbol.The stock price is then sent back to the user via SMS

A brief summary

The following table summarizes the various strengths and shortcomings of each type of mobile application:

Feature

Thick client

Thin client

Smart client

Messaging

Requires installation/stores code locally on the mobile device

Y

N

Y

N

Requires live network connection to the application server

N

Y

N

N

Stores data locally and requires database on the mobile device

Y

N

N

N

Allows application to access low level device functions

Y

N

Y

N

Middleware requirements on the mobile device

.NET CF,

Mobile Database

Mobile Browser

.NET CF

Messaging application

UI responsiveness

High

Low

Medium

High

UI richness/interactivity

High

Low

High

Low

Ease of development

Low

Medium

Medium

High

Security

High

Medium

Medium

Low

Ease of application update and maintenance

Low

High

Low

High

Ideal for high transactional volume

Y

N

N

Y

Ideal for data transactions that are large in size (example : file attachments)

Y

N

N

N

Ideal for complex input data (example : forms involving multiple field input)

Y

Y

Y

N

Ideal for complex data input methods (example : digital signatures, barcode scanning)

Y

N

Y

N

Application data latency

Non real-time

Real-time

Real-time

Real-time

Support for different operating systems/devices

Low

High

Low

High

Defining the mobile sales force application

We will first take a look at the mobile sales force application and try to decide on a suitable client model. Looking at the earlier chart, a thick client model would best fit the requirements of this application due to the two key requirements of a responsive UI and offline access support.

You may have also considered the smart client model for this task, but there is no requirement for real-time data transactions in this application. A local database works better in this case because it eliminates network latency that would otherwise be present on the smart client (due to remote database access). Furthermore, a smart client model would not work well in areas without a network connection.

In the following sections, we walk through the main functionality of the application and outline the various .NET Compact Framework technologies that will be used in the process.

Capturing lead, opportunity, and customer information

Tomorrow Inc. is anticipating a very large turnout at the road show; your users will need 'at a glance' access to key information as well as easy navigation across the various data entry windows.

Mobile screen design

To cite an example of a screen design that is the product of objective thought, consider the following Lead Details form:

You might be used to the idea that phone numbers, street addresses, and e-mail addresses are related and should all go together under a single Contact Details tab. Thinking objectively though, the salesperson would likely spend more time trying to follow up on a lead making phone calls rather than holding face to face meetings at the lead's address. In this case, it makes for a better design to have the phone number and not the address on the first screen.

When we build this application later on in the book, you will encounter other similar examples and learn how you can minimize the need to switch between tabs by placing the most commonly used fields in a single screen.

We will also extend the idea of objective design to the toolbars and menus in the application, covering best practices and how efficient use of these controls can help reduce on-screen clutter.

Creating reusable controls

You may have also noticed from the previous screenshots that we have placed various icons next to the phone number fields. They allow the user to initiate a phone call or send an SMS directly using the number in the adjacent text box. This control, called the PhoneNumber control (shown in the following screenshot), is one of the various Usercontrols that we will build and reuse throughout this application.

Maintaining global lists

You will also learn how to implement a simple checklist such as the Interested product(s) checklist shown in the succeeding screenshot using the .NET Compact Framework's Listview control.

To make things interesting, we will also feature a dynamic product list that can change any time at the remote server end. We will explore how a sync in the opposite direction (from server to mobile device) can be used to update global lists like this in your application.

Data retrieval and manipulation on the mobile device

As this is the first section dealing with data retrieval and manipulation, we will also get a first-hand look at the ADO.NET libraries and how we can make full use of the library to execute SQL queries against the local database to retrieve and manipulate sales force data.

We will cover data access and ADO.NET in full detail when we build a generic data layer in Chapter 2 ,Building the Data Tier.

Data transfer between multiple mobile devices

Transferring data between one mobile device and another is a common requirement in most enterprise scenarios and our sales force application is no exception. At any point in time, a salesperson may decide to hand over a lead to another colleague, possibly because he or she is not interested in following up on that lead.

Passing the lead to another person means that the receiving party needs to have the lead details and all other relevant data transferred to his mobile device. There are a few different approaches to data transfer, which we will cover in detail when the time comes, but for this application we will concentrate on using both Infrared and Bluetooth technology to transfer a lead record (in compressed XML format) directly from one device to another.

Task management

One of the reasons for building a task management module in this application is to allow the salesperson to manage tasks that are lead and opportunity specific. We will choose to implement the task listing using the .NET Compact Framework's DataGrid control due to its rich set of data formatting and data binding capabilities.

You will also learn the basics of using the DataGrid control in this section and how to get around its limitations. We will also cover the following subtopics:

How to data bind an ADO.NET data source to the DataGrid controlHow to implement data paging at the SQL levelHow to create columns with multiple sortingHow to handle data and cell formatting in the DataGrid control

Full-text search functionality

Being able to search within the content of a file and entire databases via an incredibly simple UI comprising a text box and a button is indeed very attractive to any mobile user.

We will build a similar search engine for the sales force application. It will be capable of searching within file content, file names, and database records all at one go.

Microsoft SQL Server Compact and Oracle Lite needs to operate with a small footprint and, unfortunately, does not provide any full-text search feature. We will take it upon ourselves to create a simplified version of the full-text search service of our own. You will learn how to do the following from this exercise:

How to index the contents of a file for full-text searchHow to handle wildcard and binary searches (the ability to combine multiple search phrases with AND and OR conditions)How to create column indices in Microsoft SQL Server Compact and Oracle Lite to improve the performance of full-text search queries

The following screenshot shows what the search results listing will finally look like in your application:

Integrating with Windows Mobile and the hardware

The mobile device is usually packed with useful hardware and operating system features like telephony, GPS, SMS, and Bluetooth, just to name a few. You can use the libraries in the .NET Compact Framework and the open source Smart Device Framework to access a large range of such functionality from your application.

Looking at an example of how this can work with your sales force application, consider phone number displays in your application. As you saw earlier, you will be creating a reusable PhoneNumber usercontrol that allows users to easily place a phone call or send an SMS message.

You will learn how you can call the Windows Mobile classes in the .NET Compact Framework libraries to achieve this. Most of what follows in this section refers to application features discussed earlier.

Detect incoming phone calls and SMS

We will in fact extend this functionality further using the .NET Compact Framework Message Intercept classes to detect incoming phone calls and SMS. You will see how you can use these events to automatically generate historical log entries for every lead. This allows the salesperson to see a comprehensive history of all correspondence with a particular lead.

Integrating with the Windows Mobile Calendar and Contacts book

If you recall, we had to implement a lead and opportunity-specific task list in this application. What is also unique about this task list is that a copy of the tasks will be automatically pushed to the Windows Mobile Calendar. This allows you to tap into the reminder services in Windows Mobile to remind the user of an impending task. You will learn how to integrate with the Windows Mobile Calendar and Contacts services using the .NET Compact Framework libraries to achieve this functionality.

The benefits are twofold. In addition to not having to reinvent the wheel, this sort of integration opens up a host of functionality behind the scenes. For instance, by placing a copy of the lead- and opportunity-specific tasks in the Windows Mobile Calendar, the user will be able to eventually sync them to Microsoft Outlook on his desktop PC via ActiveSync. This feature is immediately available to your users without having to write any additional line of code!

Data exchange using Bluetooth and IrDA

We will also explore how we can transfer the lead details from one device to another directly using both the device's Bluetooth and IrDA (Infrared) capabilities. You will learn how you can efficiently package and compress XML-based data for transmission across these channels.

Capturing handwritten input

When new buyers sign up for a subscription to the game, Tomorrow Inc. needs their signature for record purposes. We can implement signature-capturing functionality using the Smart Device Framework's signature control. The signature will be captured as an image and saved together with the customer record in the database.

Note

In Chapters 3 and 6, we will cover more ground on file attachments and how they can be alternatively stored outside the database in the local filesystem. You will also learn of the different options available to the developer to sync files to a remote server.

Data synchronization

Data synchronization for the sales force application is a mix of bidirectional (between mobile device and server) and unidirectional synchronization (mobile device to server only). The synchronization process is closely tied to the database systems that we are deploying for the application. For instance, Oracle Lite uses mSync technology while Microsoft SQL Server Compact uses the Microsoft Sync Framework.

In Chapter 6, Data Synchronization, you will learn how to set up a mobile device and a server for data sync on these two databases. We will also go through the various approaches available to handle data concurrency and integrity during the sync process.

Dual database support

As part of Tomorrow Inc.'s requirements, we will ensure that our sales force application can support both the Oracle Lite 10g and Microsoft SQL Server Compact mobile databases. These two databases differ considerably in terms of their data types, SQL syntax, and synchronization processes.

Application maintenance and upgrades

As we've covered earlier on in this chapter, one of the biggest disadvantages of a thick client is the deployment process. Any subsequent updates to the application need to be redeployed to all devices.

We will mitigate this drawback by building and integrating a network-aware Auto Update service into our sales force application. You will learn how to create a service that can periodically check and download the latest updates from a remote site on its own without the need to cradle the device.

Defining the mobile dashboard application

Our second application, the mobile dashboard, will be used by executive-level decision makers in Tomorrow Inc. on the move. The mobile dashboard will need to pull real-time data off the server over an Internet connection, which is then collated and presented on the dashboard in the form of a graphical chart. New data is periodically pulled down from the server every minute to refresh the chart displays.