c# - WPF, WCF and Code First - Disconnected mode -
some architecture dilemma: i'm using wpf client-side, ef code first info access layer, , wcf connect between those. probelm hou reupdate ui after did changes db, example:
user insert new "person" on ui (id=0) user save "person" db (id=10, example)when talking 1 user it's simple - can homecoming id , update ui (so next alter person considered "update"), adding more 1 user @ once, or updating other properties calculated on server? should homecoming whole graph? not mention hard remap on client side.
before codefirst utilize ste, has it's own problems. knows known codefirst approach?
would happy hear voice. thanks!
you can send request wcf service datetime of lastly update in client-side. in server-side take persons
updated/added after datetime , homecoming result. in way modified/added person
s server-side.
so add together lastupdate collumn entity person
.
edit 1
if want server update info in client not client inquire news server.
you can utilize way works in web programming
.
(1)the client-side
asks server-side
- "hey, lastly update @ 20:00 10.02.2013", server looks db - "is news after 20:00 10.02.2013?" if yes:
a) returns news client
if no news in db:
b) dont returns null, thread.sleep(somevalue). sleeps repeats query db , asks "there news in db". it's repeats untill news in db apear. after news in db appears homecoming list<data>
in updated after datetime. after client gets info goes point - (1).
so dont create lot of requests server making 1 request , wait news server.
notice 2 things:
1) if client waits long server side throw exception(dont remember error code it's not of import now), have grab exception on client-side
, create new request server-side
. have configure on server-side
long can wait time, minimize amount of requests client.
2) have run data-updater
in new thread not in main, application runs.
how looks code(it may not work, want show logic):
server side:
public list<somedata> updater(datetime clientsidelastupdate) { list<somedata> news = new list<somedata>(); while(true) { list<somedata> news = dbcontext.somedata.where(e=>e.updatedatetime > clientsidelastupdate).tolist(); if(news.count()>0) { homecoming news; } } }
client-side:
public static void updater() { seek { var news = someservicereference.updater(datetime clientsidelastupdate); renewdatainforms(news); updater(); } catch(serverdiesorwhatelseexcepption) { updater() } }
and somewhere in code run updater in new thread
thread updaterthread = new thread(updater()); updaterthread.start();
edit 2
if want update 1 request entities not somedata
have add together dto object contain list of every entities want updatable. server-side
finish , homecoming dto object.
hope helps.
c# .net wpf wcf ef-code-first
No comments:
Post a Comment