New Posts New Posts RSS Feed: Switch IsDistrubuted based on if DB found
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Switch IsDistrubuted based on if DB found

 Post Reply Post Reply
Author
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Topic: Switch IsDistrubuted based on if DB found
    Posted: 10-Nov-2010 at 10:38am
Is there a way to switch the IsDistrubted state if the database connection is not found using the connectionstring? At run time.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 10-Nov-2010 at 2:07pm
There's nothing intrinsic within DevForce, but you can still do this.  Before creating an EntityManager you can look at the ConnectionStrings; you can use IdeaBladeConfig.Instance.ConnectionStrings if you'd like.  After you've determined whether to go distributed or not, then set the isDistributed flag:
    IdeaBladeConfig.Instance.ObjectServer.ClientSettings.IsDistributed = x
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 11-Nov-2010 at 12:46pm
So, what I have attempted to do was login. If it fails I then change the IsDistributed to true. In theory that should switch to the object server and run fine. But it still fails. The error is connection string is empty. If I make the change in the config file to distributed = true it passes on the first try. It just seems to not take the new setting into account.
 
This is just testing:
 

try

{

LoginClientCore.Instance.Login(mEntityManager, "guest", string.Empty, string.Empty);

}

catch (System.Exception e)

{

IdeaBlade.Core.IdeaBladeConfig.Instance.ObjectServer.ClientSettings.IsDistributed = true;

LoginClientCore.Instance.Login(mEntityManager, "guest", string.Empty, string.Empty);

}

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 11-Nov-2010 at 2:07pm
This won't work because once you've created an EntityManager it uses whatever configuration information was provided to it at its construction.  Your second login on the same EntityManager uses exactly the same configuration and communication setup as before, and ignores the change in the IsDistributed flag.
 
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 17-Nov-2010 at 9:41am
I basically have it working but I have a question.
 
If I set the object server information in the app.config to point to the desired bos but have distributed set to false. Does it connect only using my Connection strings.
 
Connection speeds seem to be slower and it sometimes crosses between the two. I see the difference because I had it pointing to the live BOS and connection strings to the dev db.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 17-Nov-2010 at 10:48am
A connection string is used to connect to a database; the IsDistributed flag on the <clientSettings> is used to connect to a BOS, when the flag is false the client does not connect to a BOS.  Generally, when you are using a BOS all database connections are made from the BOS; likewise when not using a BOS all database connections are made from the local application.  So, if IsDistributed is false, you are not using a BOS and any database connections are made using the connection strings in your client app.config.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down