Deepthi 的个人资料Win with Win Mobile照片日志列表更多 ![]() | 帮助 |
|
|
1月16日 Approaches to data synchronization on windows mobile-Using Web Synchroniazation over sql server merge replicaiton
In part 1 of this post, I discussed about using the Disconnected Service Agent application block for data synchronization. This entry discusses the second method, which is web synchronization using merge replication.
Web Synchronization over Sql Server Merge Replication
This approach makes use of the merge replication features provided by Sql Server 2005 and Sql Server Mobile, extending it over http using IIS.
Some concepts related to merge replication: Publisher The Publisher is a database instance that makes data available to other locations through replication.
Distributor The Distributor is a database instance that acts as a store for replication specific data associated with one or more Publishers. Each Publisher is associated with a single database (known as a distribution database) at the Distributor.
Subscribers A Subscriber is a database instance that receives replicated data. A Subscriber can receive data from multiple Publishers and publications.
Publication A publication is a collection of one or more articles from one database.
Subscription A subscription is a request for a copy of a publication to be delivered to a Subscriber. The subscription defines what publication will be received, where, and when.
Web synchronization for merge replication provides the ability to replicate data using the HTTPS protocol and is well suited to the following scenarios:
Web synchronization is designed for synchronizing data with laptops, handheld devices, and other clients. It is not intended for high volume server to server applications.
To use Web synchronization for replication, you must perform the following steps.
Thus we can see that we can use the web synchronization feature of Sql Server when we need to synchronize between a sql server 2005 mobile and sql server 2005. For a more platform–neutral approach, we can use the disconnected web services approach using the Disconnected Services Agent. 12月22日 Managed Wrapper for Installing MSMQ on Pocket PCMsmq component is bundled with the OS. We need to install it as a separate cab file from the following link :
In my blog post titled 'Message Queues in .net CF' ,I mentioned the steps that need to be followed to install the msmq cab file manually.
Here's a wrapper class that will do the same through code. What I have done is call the processes that are required to be called to install,register,start and stop msmq. Also we can enable srmp and binary protocols through this wrapper.
using System;using System.Diagnostics;using System.IO;using System.Runtime.InteropServices;namespace MessagingQueueWrapper { public class MessagingQueueWrapperClass { [ DllImport("CoreDll.dll")] private extern static Int32 GetLastError();[ DllImport("CoreDll.dll")] private extern static Int32 CloseHandle(IntPtr hProcess);[ DllImport("CoreDll.dll")] private extern static IntPtr ActivateDevice( string lpszDevKey, Int32 dwClientInfo); //Execute commands on the MSMQAdm.exe utility public static bool ExecuteMSMQAdm(String CmdLine){ Process prc = Process.Start(@"\windows\msmqadm.exe", CmdLine); if (prc == null) throw new ApplicationException("Process already running");prc.WaitForExit(); if (prc.ExitCode != 0) return false; else return true;} //This is the MSMQAdm.exe utility we’ll be using private const String MSMQ_ADM = @"\windows\msmqadm.exe"; private const String MSMQ_DRIVER_REG = @"Drivers\BuiltIn\MSMQD"; private const string MsmqLogFilePath = @"\windows\MsmqLogFile"; public enum MsmqErrorCodes{ Success, RegisterInstallFailed, RegisterFailed, EnableBinaryFailed, EnableSrmpFailed, StartFailed, StatusFailed }; public static MsmqErrorCodes StartMSMQ() { //Check status of MSMQ (is it installed and running yet? if (!(ExecuteMSMQAdm("status"))){ //Deletes the MSMQ registry key and store directory. //All messages are lost.ExecuteMSMQAdm( "register cleanup"); //Installs MSMQ as device drivers. if (!ExecuteMSMQAdm("register install")){ return MsmqErrorCodes.RegisterInstallFailed;} //Creates the MSMQ Configuration in Registry if (!ExecuteMSMQAdm("register")){ return MsmqErrorCodes.RegisterFailed;} //Enables the native MSMQ protocol if (!ExecuteMSMQAdm("enable binary")){ return MsmqErrorCodes.EnableBinaryFailed;} //Starts the MSMQ service if (!ExecuteMSMQAdm("start")){ //This is one additional step that is needed for PocketPCs //The Device Drivers have to be loaded before the service //can be started //ActivateDevice will load the device drivers IntPtr handle = ActivateDevice(MSMQ_DRIVER_REG, 0);CloseHandle(handle); //Let us check if MSMQ is running if (!ExecuteMSMQAdm("status")){ return MsmqErrorCodes.StatusFailed;} return MsmqErrorCodes.StartFailed;} return MsmqErrorCodes.Success;} else return MsmqErrorCodes.Success;} public static MsmqErrorCodes EnableSrmp(){ //Check status of MSMQ (is it installed and running yet? if (!(ExecuteMSMQAdm("status"))){ MessagingQueueWrapper. MessagingQueueWrapperClass.StartMSMQ();} //Starts the MSMQ serviceExecuteMSMQAdm( "stop"); //Enables the native MSMQ protocol if (!ExecuteMSMQAdm("enable srmp")){ return MsmqErrorCodes.EnableSrmpFailed;} if (!ExecuteMSMQAdm("start")){ return MsmqErrorCodes.StartFailed;} else return MsmqErrorCodes.Success;} } }
How to use : Create a class library and copy-paste this code in that, build it and add a reference to this dll (MessageQueueWrapper) in ur project. In the FormLoad method, you can call the install and enable methods like this: if (MessagingQueueWrapper.MessagingQueueWrapperClass.StartMSMQ() == MessagingQueueWrapper.MessagingQueueWrapperClass.MsmqErrorCodes.Success) MessageBox.Show("Success in installing"); if (MessagingQueueWrapper.MessagingQueueWrapperClass.EnableSrmp() == MessagingQueueWrapper.MessagingQueueWrapperClass.MsmqErrorCodes.Success) MessageBox.Show("Success in enabling srmp");And lo ! MSMQ is installed on ur device ! Hope that helps :)..I spent quite a few days trying to figure out how to enable srmp manually...this should save us all the trouble :).
12月7日 MSMQ over HTTPThe coolest features of MSMQ 3.0 is the ability to send messages over HTTP - right through firewalls. For this to be possible, we need to have the MSMQ over HTTP component installed. (under Add/Remove Programs->Windows Components->Application Server->Message Queueing->).
If you have it installed, you will see an IIS application with the name 'msmq', and it will have nothing in it.
SOAP Reliable Messaging Protocol (SRMP), an XML-based messaging protocol, has been developed for delivering high Quality of Service (QoS) messages. The direct, public, and private format names of administration and response queues can be included in messages sent over HTTP transport. Similarly, the names of administration and response queues in HTTP format can be included in messages sent over ordinary (non-HTTP) transport.
Destination queues for HTTP messages are opened using direct format names that include the URL address of the target computer, the virtual directory name, and the queue name separated by slashes. The default virtual directory name is msmq, but Message Queuing can be configured by IIS to use a different virtual directory. A direct format name containing HTTPS as the protocol name invokes a secure HTTP transport through a Secure Sockets Layer (SSL) connection.
Now to send my message over MSMQ using http, what I did was create a message queue with the following direct format name :
@"FormatName:DIRECT=http://172.30.189.xxx/msmq/Private$/myqueue" with my machine's ip address. That does the trick :)..more on msmq over http in .net cf in the next post. cya !
12月6日 Message Queues in .net CFI have been researching on message queues in .net cf, and its cool stuff :) !
MSMQ is a Microsoft message queueing technology that allows disparate applications, not necessarily running in the same machine, to send messages to one another.Message Queuing provides built-in enhanced security, transaction support, and other features.
MSMQ is useful when custom applications need to communicate reliably across potentially unreliable or occasionally connected networks. MSMQ is also useful as a persistent storage mechanism for a list of items. For example, a server-based application could use MSMQ to store queued orders that would be submitted as a batch to an order-processing system at the end of the day. Now what I did not know was that MSMQ is also the underpinning infrastructure for reliable messaging in Windows Communication Foundation, first available in Windows Vista, the next version of the client operating system. Now how do I use MSMQ in my CF code ? Go to Microsoft Mobile Development Center and follow the link "Redistributable Server Components for Windows Mobile 5.0" to download the package. We need the msmq.ARM.CAB file in the package.
But just doing the above will not install the cab file (and the associated msmq isntallables) on the device/emulator. To do that, we manually have to install the cab file on the device /emulator. THis is howI did it on the emulator: 1.Place the msmq.ARM.CAB file in a folder 2.Open the File->'Configure'->Shared Folders-> Add the folder which contains the msmq.ARM.CAB file. 3.In the emulator Navigate to Start->Programs->File Explorer (Select the My Device option from the drop down on the top here ) -> StorageCard->YourFolderName->msmq.arm. Click on install-and bingo ! MSMQ is installed on your device/emulator now ! I spent a couple of exceptional (PUN INTENDED) hours trying to figure why MSMQ was not getting installed on my emulator, inspite of having the cab files added to my project. Once we are done with the above steps, we are ready to use MSMQ ! Now to write code to send and receive messages frm using MSMQ, you can check out the following link (the one i referred to myself :) ) : http://netcf2.blogspot.com/2006/01/msmq-message-queueing-in-compact.html More on MSMQ in the next post..till then-Keep Messaging ! :) |
|
|