开发者

USB sync of local database to WP7

开发者 https://www.devze.com 2023-03-09 10:04 出处:网络
I have a requirement where data on SQL server needs to be synced to WP7 devices through USB. I initially thought of writing a WCF Lib., but it\'ll go online & sync even if device is connected to U

I have a requirement where data on SQL server needs to be synced to WP7 devices through USB. I initially thought of writing a WCF Lib., but it'll go online & sync even if device is connected to USB in local network (Where it's easy & cheaper to get data over local network rather than go to internet & get it).

I have coded isolated storage to save the data synced, but i need an efficient way of getting data from local network, while it's connected to local network.

My questions are:

  1. Is there a way to request data from local network when connected to local network in WCF?
  2. Does someone have a C# code i can use to write synchronization routines to usb over local network? (I would love to have the code, if anyone has this)
  3. Is there a better way of achieving what I'm trying to do?

I'm hoping for some quick answers开发者_C百科 for this problem, any help is greatly appreciated.

Thanks.


My recommendation would be for your WCF API to have an DNS name pointing to an internal IP address, which is not available outside of the local network and in the routing it will get resolved through USB and another DNS name pointing to an external IP Address which is only available outside of the local network. Your application would try to connect using the local IP address first, which should go through the local network and if it fails it should retry the with external option.


You can use NetworkInterface.NetworkInterfaceType to detect a connection of type Ethernet.

Implementing a full sync protocol is complicated and not something I would recommend attempting unless you really have to.
If you do go down this route I'd recommend using item based message queues and then syncing the queues (and replaying as necessary) rather than trying to sync database tables. It'll depend on the requirements of your application and nature of the data though.


Further to both Murven and Matt's answers, I'd recommend looking into the Microsoft Sync Framework, which supports WP7 as a client, commonly uses WCF on the server, and has great support for a wide range of edge cases.

You can then, as per Matt's answer, watch for connectivity changes and, on USB connection, start a sync to a local IP.

When it comes to targeting mango, you can implement it as a ResourceIntensiveTask and it will run when USB is connected, even if the app isn't running.

0

精彩评论

暂无评论...
验证码 换一张
取 消