New Posts New Posts RSS Feed: Web
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Web

 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: Web
    Posted: 26-May-2009 at 4:48pm
I have a web page that logs in to the Persistence server then loads some data. I have recently been running into an issue. After the login is successful it goes to run an query and gives an error that the user does not exist. I have verified that the PM is connected and logged in but it still throws the error. It only throws this error initially. If I close the browser then try again it will usually work the second time. It seems to be tied in with the session state time but I have overridden anything it should be the default.
 
What could be the issue?
 
 
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: 27-May-2009 at 10:11am

        protected void Page_Load(object sender, EventArgs e)

        {

            if (Request.Params[SERVER] != null)

            {

                if (!Page.IsPostBack)

                {

                    PerformLogin();

                }

                //Get query string information and set variables

                if (Request.Params[REPORTID] != null)

                    mReportId = Convert.ToInt64(Request.Params[REPORTID]);

 

                if (Request.Params[FILTERBY] != null)

                    mFilterByString = Request.Params[FILTERBY].ToString();

 

                if (Request.Params[FILTERFOR] != null)

                    mFilterForString = Request.Params[FILTERFOR].ToString();

 

                if (Request.Params[SHOWTOOLBAR] != null)

                    mShowToolBar = Convert.ToBoolean(Request.Params[SHOWTOOLBAR]);

 

 

                //mReportToolbar.Visible = mShowToolBar;

 

                //Build display report

                BuildReport();                   

             

            }

            else

            {

                mMessageLabel.Text = "Invalid Permissions to view report.";

                //mReportToolbar.Visible = false;

                mReportViewer.Visible = false;

            }

        }

 

        private void PerformLogin()

        {

            //Login as server for viewing rights

            LoginCredential credential = new LoginCredential(Request.Params[SERVER].ToString(), Request.Params[SERVER].ToString(), "");

           

            PersistenceManager.DefaultManager.Connect();

            PersistenceManager.DefaultManager.Login(credential);

           

        }

 

        /// <summary>

        /// Build report based on criteria and report

        /// </summary>

        private void BuildReport()

        {

            //Only run if report id exists

            if(mReportId != -1 && PersistenceManager.DefaultManager.IsLoggedIn)

            {

                try

                {

 

                    //Get the request report

                    LOC.CEMS.Web.Model.ReportAdapterManager mManager = new LOC.CEMS.Web.Model.ReportAdapterManager();

 

                    Report aReport = (Report)(mManager.GetSelectedEntity(mReportId)[0]);

 

                    System.IO.MemoryStream stream = new System.IO.MemoryStream();

                    stream = new System.IO.MemoryStream(aReport.Report);

 

                    //Add report stream to report viewer

                    mReportViewer.Report = (XtraReport)XtraReport.FromStream(stream, true);

 

                    //Get datasource

                    ReportDataSourceEngine engine = new ReportDataSourceEngine(aReport.Query.Query, aReport.PersistenceManager);

                    DataTable mResultsTable = engine.Run();

 

                    //Apply filter to DataTable

                    //Add DataSource to report

                    mReportViewer.Report.DataSource = SetFilters(mResultsTable);

                    //mReportToolbar.Visible = mShowToolBar;

 

 

                }

 

                catch (System.Exception ex)

                {                   

                    mMessageLabel.Text = "Error building report. " + ex.Message + "<br><br>Stack Trace:" + ex.StackTrace + "<br><br>Source:" + ex.Source;

                    mReportViewer.Visible = false;

                    //mReportToolbar.Visible = false;

                }

            }

           

           

        }

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: 27-May-2009 at 10:13am
Once again it successfully logs in but then when it gets to BuildReport it passes the PM.DefaultMan.IsLoggedIn and then fails on the call to mManager.GetSelectedEntity(mReportId). I am using the default code sent with the IdeaBlade.Web just as the example states
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: 27-May-2009 at 10:16am
The error is as follows:
Error building report. Unable to login

Stack Trace: at IdeaBlade.Persistence.PersistenceManager.HandlePersistenceServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation) at IdeaBlade.Persistence.PersistenceManager.CheckLogin(Boolean pShouldHandle) at IdeaBlade.Persistence.PersistenceManager.InitializeSchema(Type pEntityType) at IdeaBlade.Persistence.PersistenceManager.CreateTableAndInitialize(Type pEntityType) at IdeaBlade.Persistence.PersistenceManager.GetTable(Type pEntityType) at IdeaBlade.Persistence.PersistenceManager.FindEntity(PrimaryKey pPrimaryKey) at IdeaBlade.Persistence.PersistenceManager.GetEntity(PrimaryKey pPrimaryKey, QueryStrategy pQueryStrategy) at IdeaBlade.Persistence.PersistenceManager.GetEntity(PrimaryKey pPrimaryKey) at LOC.CEMS.Web.Model.EntityAdapterManager.GetSelectedEntity(Int64 id) at LOC.CEMS.Reporting.Web.ReportViewer.BuildReport()

Source:IdeaBlade.Persistence
 
Once again it has passed the check that it is logged in.
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: 27-May-2009 at 10:54am
Your mManager instance is not the PersistenceManager.DefaultManager, but instead a new disconnected, not logged in PM, and you likely have an IPersistenceLoginManager implementation which requires login credentials.
 
It's not a good idea to be using the PersistenceManager.DefaultManager in a multi-threaded application, since the PersistenceManager is not thread safe. 
 
If you need to login each user in order to do a BuildReport, then you should do the login call on the the mManager. 
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: 27-May-2009 at 12:46pm

tx

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down