Page 1 of 2

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Tue Aug 11, 2009 10:30 am
by johnham
My reports are stored in an SQL Database. To open a recent file from the "Recent Files" list I hook the StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner event handler. When I do this I end up with odd results in the dictionary. I either end up with my Data Connection being not connected (a big black "X" over it) or I end up with none of my data sources showing up.

In the first case I am Loading the Report using a function then assigning it to the Designer.Report property like so:

Code: Select all

private void GlobalEvents_OpenRecentFileInDesigner(object sender, StiOpenRecentFileObjectEventArgs e)
{
            ///////////
            //  Data
            ///////////
            #region Data
            StiDesignerControl Designer;            
            #endregion
		
            ///////////
            //  Code
            ///////////
            #region Code
            Designer = (StiDesignerControl)sender;

            if (Designer.Report != null)
            {
                //Destroy Currently Open Report if it Exists
                Designer.Report.Dispose();
                //Designer.Report = null;  //Setting the report to null causes an exception
            }

            Designer.Report = LoadReport(e.FileName);
}           
The code above causes a problem. With my data connection in my dictionary.

However if I do the following nothing is loaded into the dictionary.

Code: Select all

        private void GlobalEvents_OpenRecentFileInDesigner(object sender, StiOpenRecentFileObjectEventArgs e)
        {
            ///////////
            //  Data
            ///////////
            #region Data
            StiDesignerControl Designer;            
            #endregion
		
            ///////////
            //  Code
            ///////////
            #region Code
            Designer = (StiDesignerControl)sender;

            if (Designer.Report != null)
            {
                //Destroy Currently Open Report if it Exists
                Designer.Report.Dispose();
                //Designer.Report = null;  //Setting the report to null causes an exception
            }
            
            //Set Class Property
            ReportName = e.FileName;

            Designer.Report = new StiReport();
            
            Designer.Report.LoadFromString(LoadReportString());
            StiOptions.Designer.DesignerTitle = "POSitive Report Designer - " + ReportName;
            StiOptions.Designer.DesignerTitleText = "POSitive Report Designer - " + ReportName;
            
            //Add Variables to Dictiony
            MakeParameters(_ReportParams, Designer.Report);

            Designer.Refresh();            
                                               
            #endregion
		            

        }
The above code causes the dictionary to not have ANY dataconnections or datasources at all.

Keep in mind that at this point the designer was already open with a currently registered data connections etc. Also the report I am trying to load always has my registered data connections saved with it.

Also, a quick comment on both of these fragments. I am destroying any open reports first due to the possibility that someone will close the current report before opening a new one. In this case I will need to create a new report as Designer.Report will be null. To make my code more consistent I make sure Designer.Report always starts null before I begin loading a new report.

I am at a loss as how to proceed with this. If you guys could help me that would be great.

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Wed Aug 12, 2009 3:53 pm
by Jan
Hello John,

We use following code to open recent file:

Code: Select all

public void OpenFile(string name)
		{
			if (!File.Exists(name))MessageBox.Show(string.Format(StiLocalization.Get("Errors", "FileNotFound"), name));
			else
			{
				if (StiDesigner.CanDesignerChangeReportFileName)ReportFileName = name;

				if (Report == null)Report = new StiReport();

				TabControl.SelectedTabIndex = 0;
				Report.Load(name);
				Report.Pages.SortByPriority();

				AddRecentFile(name, null);
				UndoRedo.Clear();
				Report.Dictionary.Connect(false);

				#region Select first page
				report.CurrentPage = 0;
				report.ResetSelection();
				report.Pages[0].Select();			
				#endregion

				Builder.BuildReport();
				ToolboxType = StiToolboxType.None;
				InvokeBuidingToolbox();
				Builder.InvalidateRulers();
				
				ReportNeverSaved = false;
			}
		}
In your case you need use something like this:

Code: Select all

public void OpenReport(StiReport report)
        {
            this.Report = report;
            this.TabControl.SelectedTabIndex = 0;
            Report.Pages.SortByPriority();

            AddRecentFile(name, null);
            UndoRedo.Clear();
            Report.Dictionary.Connect(false);

            #region Select first page
            report.CurrentPage = 0;
            report.ResetSelection();
            report.Pages[0].Select();
            #endregion

            Builder.BuildReport();
            ToolboxType = StiToolboxType.None;
            InvokeBuidingToolbox();
            Builder.InvalidateRulers();

            ReportNeverSaved = false;
        }
We have added OpenReport method to StiDesignerControl. It will be available in next prerelease build.

Thank you.

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Tue Aug 18, 2009 12:42 pm
by johnham
Using the Aug 17 Pre-Release, I changed my code to the following code. When I open a document this way the dictionary comes up with my datasource connection having a big black "X" over it (see attached picture). This causes the report not to run and the datasource to be non-operational.

Code: Select all

private void GlobalEvents_OpenRecentFileInDesigner(object sender, StiOpenRecentFileObjectEventArgs e)
        {
            ///////////
            //  Data
            ///////////
            #region Data
            StiDesignerControl Designer;
            StiReport NewReport;
            #endregion
		
            ///////////
            //  Code
            ///////////
            #region Code
            Designer = (StiDesignerControl)sender;
            ReportName = e.FileName;
            NewReport = new StiReport();
            NewReport.LoadFromString(LoadReportString());
            Designer.OpenReport(NewReport);
            CheckMetaData(Designer.Report);
            StiOptions.Designer.DesignerTitle = "POSitive Report Designer - " + ReportName;
            StiOptions.Designer.DesignerTitleText = "POSitive Report Designer - " + ReportName;
            MakeParameters(_ReportParams, Designer.Report);
            //Designer.Report.RegData("POSitive Retail Manager", new SqlConnection(_ConnectString));
            //Designer.Report.RegReportDataSources();
            //Designer.Report.Dictionary.Synchronize();
            //Designer.Refresh();                       
            
            #endregion
		            

        }
Image

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Thu Aug 20, 2009 11:05 am
by johnham
:biggrin: bump :biggrin:

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Fri Aug 21, 2009 3:20 am
by Jan
Hello,

We analyse this problem now.

Thank you.

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Fri Aug 21, 2009 12:20 pm
by johnham
Sounds great Jan!

YOU THE MAN!!! :biggrin:

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Tue Aug 25, 2009 6:19 am
by Jan
Hello John,

We have rechecked OpenReport method of StiDesigner class. All work fine. All must work fine!. Most probably the problem is in the following line of code:

Code: Select all

//Designer.Report.RegData("POSitive Retail Manager", new SqlConnection(_ConnectString));
If you register connection not in report you need uncomment this line of code. In result you will receive something like this:

Code: Select all

            Designer = (StiDesignerControl)sender;
            ReportName = e.FileName;
            NewReport = new StiReport();
            NewReport.LoadFromString(LoadReportString());
            NewReport.RegData("POSitive Retail Manager", new SqlConnection(_ConnectString));
            Designer.OpenReport(NewReport);
            CheckMetaData(Designer.Report);
            StiOptions.Designer.DesignerTitle = "POSitive Report Designer - " + ReportName;
            StiOptions.Designer.DesignerTitleText = "POSitive Report Designer - " + ReportName;
            MakeParameters(_ReportParams, Designer.Report);
Thank you.

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Tue Aug 25, 2009 11:13 am
by johnham
That line of code is there because I have tried it both ways and it still does not work.

I will attempt to strip down my project and send it and an example SQL database to you guys. Where would I send this to?


Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Tue Aug 25, 2009 3:50 pm
by Jan
Hello John,

Please send it to support@stimulsoft.com.

Thank you.

Problems with StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner Event

Posted: Wed Sep 02, 2009 12:37 am
by johnham
Sent in project for testing to support@stimulsoft.com