Pro Sync Framework pdf

354 5.8K 3
Pro Sync Framework pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for content only—size & color not accurate spine = 0.82" 352 page count Books for professionals By professionals ® Pro Sync Framework Dear Reader, The Microsoft Sync Framework is a new technology for creating software that can synchronize data smoothly between applications, data stores, and devices without having to agree on any data characteristics being synchronized in advance. This flexible approach is a major step forward from previous synchroni- zation solutions that regularly struggled to deal with unexpected events such as storage and application errors, network failures, or unexpected conflicts between applications. In such circumstances the synchronization system often failed, leaving users without reliable access to their data. The Sync Framework provides a robust solution to these problems, along with additional benefits such as the ability to take an application offline and then reconnect seamlessly, and the opportunity to reduce networking costs through improvements in data transfer efficiency and communication. Pro Sync Framework covers the Sync Framework from the ground up. It begins with detailed instructions that outline how to install the Sync Framework and to configure it correctly before moving on to a detailed treatment of how the Sync Framework operates and the providers that are available. Finally, the book provides a comprehensive explanation of how to create and customize purpose-built synchronization providers. We’re confident that after you have read this book you will have a firm grasp of how the Sync Framework operates and that you will be ready to develop your own applications to take advantage of it. We hope you have as much fun reading this book as we did writing it! Rituraj Singh and Joydip Kanjilal US $49.99 Shelve in Microsoft/.NET User level: Intermediate–Advanced Singh, Kanjilal Pro Sync Framework The eXperT’s Voice ® in synchronizaTion Pro Sync Framework cyan MaGenTa yelloW Black panTone 123 c Rituraj Singh and Joydip Kanjilal Companion eBook Available THE APRESS ROADMAP Pro ASP.NET 3.5 in C# 2008 Pro C# 2008 and the .NET3.5 Platform Pro Sync Framework Expert Service- Oriented Architecture, Second Edition www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-1005-4 9 781430 210054 5 4 9 9 9 Rituraj Singh Joydip Kanjilal www.it-ebooks.info www.it-ebooks.info Pro Sync Framework ■■■ Rituraj Singh and Joydip Kanjilal Kanjilal_1005-4FRONT.fm Page i Thursday, October 30, 2008 8:16 AM www.it-ebooks.info Pro Sync Framework Copyright © 2009 by Rituraj Singh and Joydip Kanjilal All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1005-4 ISBN-13 (electronic): 978-1-4302-1006-1 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Ewan Buckingham Technical Reviewer: Todd Meister Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Beth Christmas Copy Editor: Nancy Sixsmith Associate Production Director: Kari Brooks-Copony Production Editor: Ellie Fountain Compositor: Susan Glinert Proofreader: Nancy Bell Indexer: Brenda Miller Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http:// www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. Kanjilal_1005-4FRONT.fm Page ii Thursday, October 30, 2008 8:16 AM www.it-ebooks.info I would like to dedicate this book to two special ladies in my life, my mom (Radhika Singh) and my wife (Priya Singh). Thanks for all your support and patience over the years and the years to come. Writing a book requires lot of time and thanks for allowing me to steal a large part of your time to write my first book. Thank you for all your sacrifices. —Rituraj Singh Dedicated to my parents and family. —Joydip Kanjilal Kanjilal_1005-4FRONT.fm Page iii Thursday, October 30, 2008 8:16 AM www.it-ebooks.info Kanjilal_1005-4FRONT.fm Page iv Thursday, October 30, 2008 8:16 AM www.it-ebooks.info v Contents at a Glance Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi ■CHAPTER 1 Introduction to the Microsoft Sync Framework . . . . . . . . . . . . . . . . . 1 ■CHAPTER 2 Microsoft Sync Framework Metadata . . . . . . . . . . . . . . . . . . . . . . . . . 19 ■CHAPTER 3 Working with Synchronization Providers: Part 1 . . . . . . . . . . . . . . . 33 ■CHAPTER 4 Working with Synchronization Providers: Part 2 . . . . . . . . . . . . . . . 91 ■CHAPTER 5 Working with File Synchronization Providers . . . . . . . . . . . . . . . . . 119 ■CHAPTER 6 Microsoft Sync Framework Metadata Storage Service . . . . . . . . 141 ■CHAPTER 7 Working with RSS Sync Feed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 ■CHAPTER 8 Sync Services for ADO.NET 2.0: Offline Scenarios . . . . . . . . . . . . . 191 ■CHAPTER 9 Synchronization Services for ADO.NET 2.0: Peer-to-Peer Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 ■APPENDIX Sync Framework Library Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 295 ■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Kanjilal_1005-4FRONT.fm Page v Thursday, October 30, 2008 8:16 AM www.it-ebooks.info Kanjilal_1005-4FRONT.fm Page vi Thursday, October 30, 2008 8:16 AM www.it-ebooks.info vii Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi ■CHAPTER 1 Introduction to the Microsoft Sync Framework . . . . . . . . . . . 1 Benefits of Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Life Before Sync Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Why the Microsoft Sync Framework? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Installing Microsoft Sync Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Core Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Synchronization Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Sync Framework Participants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Synchronization Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Synchronizing Two Replicas Using Built-in Providers . . . . . . . . . . . . . . . 11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 ■CHAPTER 2 Microsoft Sync Framework Metadata . . . . . . . . . . . . . . . . . . . . 19 What Is Sync Metadata? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Metadata Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Components of Sync Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Example of Sync Metadata Use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Sync Metadata Requirement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 ■CHAPTER 3 Working with Synchronization Providers: Part 1 . . . . . . . . 33 What Is a Sync Provider? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Synchronizing Two Replicas Using Built-in Providers . . . . . . . . . . . . . . . 35 Creating a Synchronization Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Contents Kanjilal_1005-4FRONT.fm Page vii Thursday, October 30, 2008 8:16 AM www.it-ebooks.info viii ■CONTENTS Provider Writer Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Change Tracking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Change Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Conflict Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Conflict Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Resolving Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Saving the Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Sample Synchronization Provider for Synchronizing SQL Server Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 MySyncProvider.cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Overriding Provider Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Creating New Customer Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Synchronizing Replicas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Running the Sample Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Synchronizing New Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Detecting and Handling Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Synchronize Deleted Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Finishing Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 ■CHAPTER 4 Working with Synchronization Providers: Part 2 . . . . . . . . 91 Change Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Creating Sync Providers with Change Units. . . . . . . . . . . . . . . . . . . . 94 Creating Providers That Use Asynchronous Change Tracking . . . . . . . . . 94 MySyncProvider.cs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Changing the Customer.cs Class . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Changes in the Synchronizing Application. . . . . . . . . . . . . . . . . . . . 104 Creating a Generic Sync Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 BaseSyncProvider. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Extending the Generic Sync Provider Class . . . . . . . . . . . . . . . . . . . 109 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 ■CHAPTER 5 Working with File Synchronization Providers . . . . . . . . . . . 119 Sync Framework Core Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 File Sync Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 File Sync Provider Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Kanjilal_1005-4FRONT.fm Page viii Thursday, October 30, 2008 8:16 AM www.it-ebooks.info [...]... the sync agent The sync agent is responsible for establishing and managing the sync session Sync providers can receive and apply changes to the replicas There are two sync providers on the top of the Sync Framework runtime: the source sync provider and destination sync provider, respectively After being invoked by a sync agent, the destination sync provider sends its knowledge to the source sync provider... F T SYNC F RAME WO RK Figure 1-6 Synchronization flow Synchronizing Two Replicas Using Built-in Providers This section shows you how to synchronize two replicas using the built-in sync provider The Sync Framework ships with the following three out-of-the-box synchronization providers: • Synchronization provider for ADO.NET-enabled data sources • Synchronization provider for files and folders • Synchronization... three types of processors: • AMD64 • IA64 • X86 You can download the appropriate version from the Microsoft download page For example, if you want to download the Sync Framework for the X86 processor in English, select SyncSetup_es.x86.zip Before installing the Sync Framework SDK, you must uninstall all previous versions of Microsoft Sync Framework and sync services for ADO.NET 2.0 The Sync Framework is... T H E MI CRO SO F T SYNC F RAME WO RK • Microsoft Sync Framework runtime: This SDK allows developers to use the built-in sync providers and create their own sync providers • Metadata services: Provide the necessary infrastructure to store the sync metadata Sync metadata is used by the Sync Framework runtime during the synchronization The Sync Framework ships with the built-in Microsoft SQL Server Compact... one sync provider for each replica for the replica to synchronize its data with other replicas A replica synchronizes its data with another replica by establishing a sync session As shown in Figure 1-6, synchronization providers communicate with each other using a sync session The two sync providers are attached to the sync agent, and the sync application initiates the communication between the two providers... understand the basics of the Microsoft Sync Framework Chapter 1 explains the need for synchronization and how the Sync Framework eliminates some of the common problems You will also get detailed information about the architecture and components of the Sync Framework Chapter 2 dives into the details of the Sync Framework metadata model The Sync Framework enables you to synchronize any type of data between... using any protocol over any network.” In this chapter you will learn the following: • The features and benefits of using the Microsoft Sync Framework and how it can resolve common problems of synchronization • How to install the Sync Framework • Different components of the Sync Framework Benefits of Synchronization Before we dig into the Sync Framework, it’s important to understand what synchronization... metadata • Built-in providers: The Sync Framework ships with the following three built-in providers: • Synchronization services for ADO.NET provide offline and collaboration support for ADO.NET enabled data stores • Synchronization services for SSEs are the built-in providers for synchronizing RSS and Atom feeds • Synchronization services for file systems are the built-in providers for synchronizing files... session contains a sync agent and two sync providers One of the providers is a source provider that sends the changes; the other is a destination provider that receives and applies the changes Of course, the sync agent controls this flow The sync providers shown in Figure 1-6 illustrate a scenario in which the metadata is stored in the built-in metadata store provided by the Sync Framework, which is... unmanaged code Installing Microsoft Sync Framework At the time of writing, Microsoft Sync Framework 1.0 was the latest release You can get a copy of the Microsoft Sync Framework software development kit (SDK) in three ways: • Sync Framework ships with Microsoft SQL Server 2008 • Sync Framework ships with Microsoft Visual Studio 2008 Service Pack 1 • You can download the Sync Framework from the Microsoft download . for professionals By professionals ® Pro Sync Framework Dear Reader, The Microsoft Sync Framework is a new technology for creating software that can synchronize. level: Intermediate–Advanced Singh, Kanjilal Pro Sync Framework The eXperT’s Voice ® in synchronizaTion Pro Sync Framework cyan MaGenTa yelloW Black

Ngày đăng: 16/03/2014, 20:20

Từ khóa liên quan

Mục lục

  • Prelims

  • Contents at a Glance

  • Contents

  • Foreword

  • About the Authors

  • About the Technical Reviewer

  • Acknowledgments

  • Introduction

    • Overview

    • Source Code for This Book

    • Introduction to the Microsoft Sync Framework

      • Benefits of Synchronization

      • Life Before Sync Framework

      • Why the Microsoft Sync Framework?

      • Installing Microsoft Sync Framework

        • Core Components

        • Synchronization Providers

        • Sync Framework Participants

        • Synchronization Flow

        • Synchronizing Two Replicas Using Built-in Providers

        • Summary

        • Microsoft Sync Framework Metadata

          • What Is Sync Metadata?

            • Metadata Store

            • Components of Sync Metadata

              • Version

Tài liệu cùng người dùng

Tài liệu liên quan