New Posts New Posts RSS Feed: EntityManager.DefaultManager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityManager.DefaultManager

 Post Reply Post Reply
Author
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Topic: EntityManager.DefaultManager
    Posted: 18-Apr-2011 at 12:39pm
Hi danjal;

I looked at your solution and it seems that you're using IEntityLoginManager. You have to use AspAuthenticatingLoginManager instead since you're using ASP.NET. 

Back to Top
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Posted: 16-Apr-2011 at 3:22am

Hi smi-mark,

 

Do I have to do something special to use ASP.NET authentication with DevForce? A setting or something?

 

Thanks for helping.

                                                                           

Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 15-Apr-2011 at 6:03pm
Are you using asp.net authentication with DevForce? If so, the context sample should definitely work. I'll take a look at your sample project later, but it should work.
Back to Top
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Posted: 15-Apr-2011 at 4:20am

uploads/946/PivotWithLoginManager.zip

 
Hi,

 

I have made a little sample project where I try to get the logged in user thru the HttpContext – but it is empty .

 

I read the documentation from Ideablade on this issue, but I am missing something. Can someone look at the sample and help me?

 

1.       The sample application takes a username and password. These are passed into the LoginAsync method of the entitymanager. (MainPage.xaml.cs)

 

2.       These are then transferred to the Login method of a loginmanager that implements the IEntityLoginManager. (LoginManager.cs)

3.       The loginmanager validates the username and password against a database.

 

4.       When this process is done and successful, the user can load a collection to the pivotviewer. (ViewImageLibrary.xaml.cs)

 

5.       When doing this a http request is sent to the server where some httphelpers handle the request. (CxmlHandler.ProcessRequest in HttpHandlers.cs)

6.       The problem here is that the HttpContext.User is empty.

 

7.       Then the collection is created and sent back to the PivotViewer. (RNImageCollection.cs)

 

In my webconfig I have set these settings:

....

<serverSettings loginManagerRequired="true" />

....

<serverSettings useAspNetSecurityServices="true" />

....

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

....

<authentication mode="Forms" />

....

 

 



Edited by danjal - 15-Apr-2011 at 4:22am
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 29-Mar-2011 at 5:56pm
Hi danjal;

I've read that previous thread and if I understand correctly, you want to handle a request that comes in using your custom HttpHandler.

Using smi-mark's sample, we can now do this inside the ProcessRequest method.

    public void ProcessRequest(HttpContext context) {
      context.Response.ContentType = "text/plain";
      context.Response.Write("Logged in as: ");
      context.Response.Write(context.User.Identity.Name);

     if (!AuthenticateUser(context.User)) {
        throw new Exception("No access!");
     }

     //Else you can query
      var mgr = new EntityManager();
      var query = new EntityQuery<Customer>();
      query.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);
      try {
        var images = mgr.ExecuteQuery<Customer>(query);
        var count = images.Count();
      } catch (Exception e) {
        var msg = e.Message;
      }
    }

Back to Top
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Posted: 29-Mar-2011 at 7:26am

Because we use a login manager, and it does not allow us to run this code:

 

var m_entityManager = new C2NetDomainModelEntityManager();

 

var query = new EntityQuery<EntImage>();

query.QueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);

 

var images = m_entityManager.ExecuteQuery<EntImage>(query);

 

It worked before the upgrade, with help from the the DefaultManager.



Edited by danjal - 29-Mar-2011 at 7:28am
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 28-Mar-2011 at 12:06pm
Hi danjal;

Could you elaborate on why you need to pass the DefaultManager to create another EntityManager?
Back to Top
danjal View Drop Down
Groupie
Groupie


Joined: 20-Sep-2010
Posts: 43
Post Options Post Options   Quote danjal Quote  Post ReplyReply Direct Link To This Post Posted: 25-Mar-2011 at 3:04am

Hi,

 

We upgraded our DevForce to 6.0.9 Silverlight.

With the new version we encounter a show stopper – EntityManager.DefaultManger is going to be obsolete.

 

We use a PivotViewer control in our application that use a collection that is generated server-side by some HttpHelpers. We have been discussing this before on this thread:

http://www.ideablade.com/forum/forum_posts.asp?TID=2525&KW=defaultmanager&PID=10054&title=entitymanager-server-side#10054

 

When querying for data we use this code to get an EntityManager:

var m_entityManager = new C2NetDomainModelEntityManager(EntityManager.DefaultManager);

 

But this code does not work anymore.

 

What is the right way to use DevForce when working with a control like PivotViewer (dynamically generating a collection with HttpHelpers)?

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down