Problem with StiConfig

Stimulsoft Reports.NET discussion
Post Reply
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Problem with StiConfig

Post by mietzekotze »

Hello again,

I have following problem:

I have a program, which i want to control mainly via command line. The parameters for the command line, are "template" (which is the mrt-file), "report" (which is the disered target file) and "autosave" which indicates, if the programm shall save the file automatically or wait for the user to do it. The parameter "report" shall contains the desired type of file, like 'report="c:\test.pdf"', or 'report="c:\test.docx"', and so on.So if autosave is false, the programm shall disable all export-formats, except for the one in the report-parameter.
This is the code for this part of my program:

Code: Select all

Dim services As Stimulsoft.Base.Services.StiServiceContainer = Stimulsoft.Report.StiConfig.Services.GetServices(GetType(StiExportService))
            Dim service As StiService

            StiConfig.Load()
            If ext = ".pdf" Then

                For Each service In services
                    If TypeOf service Is StiPdfExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next

            ElseIf ext = ".docx" Then

                For Each service In services
                    If TypeOf service Is StiWord2007ExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next

            ElseIf ext = ".xls" Then

                For Each service In services
                    If TypeOf service Is StiExcel2007ExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next
            ElseIf ext = ".csv" Then

                For Each service In services
                    If TypeOf service Is StiCsvExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next
            ElseIf ext = ".png" Then

                For Each service In services
                    If TypeOf service Is StiPngExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next
            ElseIf ext = ".rtf" Then

                For Each service In services
                    If TypeOf service Is StiRtfExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next
            ElseIf ext = ".odt" Then

                For Each service In services
                    If TypeOf service Is StiOdtExportService Then
                        service.ServiceEnabled = True
                    Else
                        service.ServiceEnabled = False
                    End If
                Next
            End If
            StiConfig.Save()
The problem is, that if i start the program twice, everytime with different export-formats, at the second time there are no export-formats left. First i tried to put StiConfig.Restore() in front of StiConfig.Load(), but it didn't work, because all the export-formats appeared again, everytime i ran the program.

Is there a way to store the StiConfig-settings only for one Session of the Program?

I hope you understood my problem.

Regards.
Stephan1
Posts: 122
Joined: Fri Aug 31, 2007 7:22 am
Location: Germany

Problem with StiConfig

Post by Stephan1 »

Hi Mietzekotze,

easy one :-)

You have to set back the original settings of the Services.

At Top of you Code try this:

StiConfig.Restore()

Thx.

Stephan
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Problem with StiConfig

Post by mietzekotze »

Stephan1 wrote:Hi Mietzekotze,

easy one :-)

You have to set back the original settings of the Services.

At Top of you Code try this:

StiConfig.Restore()

Thx.

Stephan
Nope, it's not that easy. It's exactly what i already tried, but the problem here is, following:

At the first call of the program, i want the output-file to be, lets say a Exelsheet (-report="C:\test.xls"), that works.
Second call i want it to be a Word-document (-report="C:\test.docx"), but if i click on the save button in the viewer, theres still only the Exel-export button.
When i start the program a third time (still -report="C:\test.docx"), then it works. But it's not really userfriendly, if you have to start a program two times, before it works properly. ;-)

Attached my sourcecode, for further analysis.
Attachments
1537.ReportViewer.zip
(96.76 KiB) Downloaded 190 times
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Problem with StiConfig

Post by mietzekotze »

Can nobody help me with this? :\
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Problem with StiConfig

Post by Alex K. »

Hello,

Editing config is needed to be done before initializing a component.
As a way, you can remove viwer from form and create StiViewerControl at runtime in FuncShowReport(...)

Code: Select all

...
Dim StiViewerControl1 As Stimulsoft.Report.Viewer.StiViewerControl = New Stimulsoft.Report.Viewer.StiViewerControl()
StiViewerControl1.Dock = DockStyle.Fill
Me.Controls.Add(StiViewerControl1)

StiViewerControl1.Report = Report
StiViewerControl1.FirstPage()
Thank you.
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Problem with StiConfig

Post by mietzekotze »

Aleksey wrote:Thank you.
I have to thank. Worked great.
:)
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Problem with StiConfig

Post by Andrew »

Hello,

Perfect!

Thank you.
Post Reply