Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
-
- Posts: 16
- Joined: Mon Oct 11, 2010 9:43 am
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
That seems to have remedied the problem, and I'm grateful, but in testing to ensure this solution worked I came across another problem. When I create a new document, it ALWAYS treats saving as a new save, even if I've already saved it. How can I tell it in the override that it's no longer a new save?
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
Hello,
Please modify your code on
Thank you.
Please modify your code on
Code: Select all
Public Sub SaveWithoutDialog(ByVal sender As Object, ByVal e As Stimulsoft.Report.Design.StiSavingObjectEventArgs)
' Your code for saving
...
Dim Report As StiReport = DirectCast(sender, StiDesignerControl).Report
Report.IsModified = False
e.Processed = True
End Sub
-
- Posts: 16
- Joined: Mon Oct 11, 2010 9:43 am
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
That doesn't seem to work. Testing with this new code in doesn't seem to change anything- I'm noticing in debugging however that every time I choose to save on a "New" designer file it always has the e.SaveAs set to True, even after I've saved it once and it is not a SaveAs but a regular save. SaveAs is readonly so I can't just directly change it and I use saveas in existing files to differentiate between save and SaveAs so I need to find a way for this to get properly reset when it is a new report that has already been saved.
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
Hello,
Please check the following code. it works without problems.
Thank you.
Please check the following code. it works without problems.
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Report As Stimulsoft.Report.StiReport = New Stimulsoft.Report.StiReport
Report.ScriptLanguage = Stimulsoft.Report.StiReportLanguageType.VB
Report.IsModified = False
AddHandler Stimulsoft.Report.Design.StiDesigner.SavingReport, AddressOf Me.SaveWithoutDialog
Report.Design()
RemoveHandler Stimulsoft.Report.Design.StiDesigner.SavingReport, AddressOf Me.SaveWithoutDialog
End Sub
Public Sub SaveWithoutDialog(ByVal sender As Object, ByVal e As Stimulsoft.Report.Design.StiSavingObjectEventArgs)
MessageBox.Show("!!!")
Dim Report As StiReport = DirectCast(sender, StiDesignerControl).Report
Report.IsModified = False
e.Processed = True
End Sub
-
- Posts: 16
- Joined: Mon Oct 11, 2010 9:43 am
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
This doesn't seem to have any effect, but I'm wondering if this is because both SavewithoutDialog and SavetoDatabase are both within a class that inherits stireport? I actually just call clsQPReports instead of StiReport which is why you can see in my original code it actually calls MyBase.Save- but I didn't think this would matter. I'm not sure what this line of code is expected to do
I've tried modifying my code so that I would call
This, however, has no effect. Is it because these are all taking place within the object that inherits stireport? Here is a more accurate picture of my code as it stands now.
clsQPReports:
Does this provide any new insight into why every time I create a new file, every save is a save as?
Code: Select all
Dim Report As StiReport = DirectCast(sender, StiDesignerControl).Report
Code: Select all
Dim report As clsQPReports = DirectCast(sender, Stimulsoft.Report.Design.StiDesignerControl).Report
Code: Select all
public sub DesignReport (byval strFileName as String)
Dim Report As clsQPReports = New clsQPReports
Report.ScriptLanguage = Stimulsoft.Report.StiReportLanguageType.VB
Report.RegData("DataSet", grdPreviewResults.DataSource)
Report.Load(strFileName)
RemoveHandler Stimulsoft.Report.Design.StiDesigner.SavingReport, AddressOf Report.SaveWithoutDialog
Report.IsModified = False
AddHandler Stimulsoft.Report.Design.StiDesigner.SavingReport, AddressOf clsQPReports.SaveWithoutDialog
Report.Design()
Report.Dispose()
End Sub
Code: Select all
Public Class clsQPReports
Inherits Stimulsoft.Report.StiReport
Public Sub SaveWithoutDialog(byVal sender as Object, ByVal e as Stimulsoft.Report.Design.StiSavingObjectEventArgs)
'Check if this is initial save or save as option
If LastPathSaved Is Nothing Or e.SaveAs = True Then
Dim strTempSave As String = System.IO.Path.GetTempPath & "Report" & Now().ToString("MM_dd_yyyy HH_mm_ss") & ".mrt"
Dim service As New Stimulsoft.Report.SaveLoad.StiXmlReportSLService()
MyBase.Save(service, strTempSave)
[b]Call SaveToDataBase(True, strTempSave)[/b]
Else
'If it is just a save, sometimes saving too frequently causes it to error out since it is still looking at the file
Dim boolSaveWorked As Boolean = False
Try
MyBase.Save(LastPathSaved)
boolSaveWorked = True
Catch ex As Exception
End Try
'If so, perform a new save and use the new file as reference from now on, ignoring the old
If boolSaveWorked = False Then
Dim strTempSave As String = System.IO.Path.GetTempPath & "Report" & Now().ToString("MM_dd_yyyy HH_mm_ss") & ".mrt"
Dim service As New Stimulsoft.Report.SaveLoad.StiXmlReportSLService()
MyBase.Save(service, strTempSave)
End If
[b]Call SaveToDataBase(False, LastPathSaved)[/b]
End If
Dim Report As clsQPReports = DirectCast(sender, Stimulsoft.Report.Design.StiDesignerControl).Report
Report.IsModified = False
e.Processed = True
End Sub
Public Sub SaveToDataBase(ByVal createNew As Boolean, ByVal filePath As String)
'This call will save a serialized copy of the temporary saved .mrt file from the temp folder into the Database
Dim designer As New QP.ReportDesignerFile()
Dim dt As DataTable = designer.RetrieveReportDesignerFile(DesignerID)
Dim reportName As String = Me.ReportName
Dim strDesignerFile As String = filePath
Dim strComments As String = ""
'Distinguish between creating a new
If dt.Rows.Count > 0 And createNew = False Then
reportName = dt.Rows(0).Item(2).ToString
strComments = dt.Rows(0).Item(3).ToString
DesignerID = designer.SaveReportDesignerFile(DesignerID, reportName, strDesignerFile, strComments)
Else
Dim frmNewDesigner As New pfrmNewDesigner(reportName)
Dim formResult As DialogResult
formResult = frmNewDesigner.ShowDialog()
reportName = frmNewDesigner.txtReportName.Text
strComments = frmNewDesigner.txtComments.Text
If reportName = "" Or formResult = DialogResult.Cancel Then
Exit Sub
End If
DesignerID = 0
DesignerID = designer.SaveReportDesignerFile(DesignerID, reportName, strDesignerFile, strComments)
If ReportID 0 Then
Dim tblTemp As DataTable = designer.ReportRelationships(ReportID)
Dim boolDefault As Boolean = tblTemp.Rows.Count <= 0
designer.SaveReportRelationship(ReportID, DesignerID, boolDefault)
End If
End If
LastPathSaved = filePath
End Sub
Overriding the StiDesigner.SavingReport event occurs twice in Ribbon GUI
Hello,
Please send us a sample project which reproduces the problem.
Thank you.
Please send us a sample project which reproduces the problem.
Thank you.