Print Page | Close Window

Web

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1282
Printed Date: 23-Apr-2025 at 9:04pm


Topic: Web
Posted By: orcities
Subject: Web
Date 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?
 
 



Replies:
Posted By: orcities
Date 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;

                }

            }

           

           

        }



Posted By: orcities
Date 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


Posted By: orcities
Date 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.


Posted By: kimj
Date 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. 


Posted By: orcities
Date Posted: 27-May-2009 at 12:46pm

tx




Print Page | Close Window