Synchronizing SQL table via WCF service -


i have 1 table on ms sql db. (2008 r2) table name: messages fields: message_id, message, is_synced

on mobile smart phone need develop application sync table records , update table when application synced each record. need support min numbers of calls wcf must not generate call each record.

if there n records in table, dont call wcf n times, want call 1 time, records, sync , return using wcf synced results. right way go? can suggest better implementation?

you can duplex communication send data smart phones out service when things changed.

http://www.codeproject.com/articles/491844/a-beginners-guide-to-duplex-wcf

http://msdn.microsoft.com/en-us/library/ms731064.aspx

however answer current question given current implementation poll service list of messages @ start or on timer

on server can have in simple collection:

[servicecontract(namespace = "contracts.idatabaseresponder")] public interface idatabaseresponder {     //you use object rather string have mark object     [operationcontract]     list<string> getmessages();     [operationcontract]     void syncmessagesback(list<string> messages);  }    [servicebehavior(instancecontextmode = instancecontextmode.percall, concurrencymode = concurrencymode.multiple)] public class databaseresponder : idatabaseresponder {     list<string> _databasemessagelist;      public list<string> getmessages()     {         //code here go sql , grab of needed messages         //..           return _databasemessagelist;     }      public void syncmessagesback(list<string> messages)     {         //code here go sql , update messages want update         //..       }  } 

then on client side work:

    //can use plain old list or observablecollection     private ilist<string> _databasemessagesitems = new observablecollection<string>();     private databaseresponderclient _proxy;     dispatchertimer dispatchertimer;     list<string> locallistofmessages;      public constructor()     {            _proxy = new databaseresponderclient();           _proxy.innerchannel.faulted += new eventhandler(innerchannel_faulted);          try        {                 _databasemessagesitems = _proxy.getmessages();        }        catch (exception ex)        {                 messagebox.show(ex.message);                  throw;        }         dispatchertimer = new dispatchertimer();        dispatchertimer.tick += new eventhandler(dispatchertimertick);        dispatchertimer.interval = new timespan(0, 0, 60);        dispatchertimer.start();         dispatchertimertick();     }       private void dispatchertimertick(object sender, eventargs e)     {          try         {              //push service new or changed list of messages need push              _proxy.syncmessagesback(locallistofmessages);         }         catch (exception ex)         {             //handel error         }     }     //code keep track of new messages add them etc    //... 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -