Beispiel #1
0
        public bool SaveFile(bool saveAs)
        {
            // update report's script
            Report.ScriptText = Script;

            while (true)
            {
                OpenSaveDialogEventArgs e = new OpenSaveDialogEventArgs(Designer);
                string fileName           = Report.FileName;

                // show save dialog in case of untitled report or "save as"
                if (saveAs || String.IsNullOrEmpty(fileName))
                {
                    if (String.IsNullOrEmpty(fileName))
                    {
                        fileName = Res.Get("Designer,Untitled");
                    }
                    e.FileName = fileName;
                    Config.DesignerSettings.OnCustomSaveDialog(Designer, e);
                    if (e.Cancel)
                    {
                        return(false);
                    }

                    fileName = e.FileName;
                }

                OpenSaveReportEventArgs e1 = new OpenSaveReportEventArgs(Report, fileName, e.Data, e.IsPlugin);

                try
                {
                    Config.DesignerSettings.OnCustomSaveReport(Designer, e1);
                    // don't change the report name if plugin was used
                    if (e.IsPlugin)
                    {
                        fileName = Report.FileName;
                    }
                    Report.FileName = fileName;
                    FModified       = false;
                    Designer.UpdatePlugins(null);
                    if (!e.IsPlugin)
                    {
                        Designer.cmdRecentFiles.Update(fileName);
                    }
                    UpdateCaption();
                    return(true);
                }
                catch
                {
                    // something goes wrong, suggest to save to another place
                    FRMessageBox.Error(Res.Get("Messages,CantSaveReport"));
                    saveAs = true;
                }
            }
        }
Beispiel #2
0
        public bool LoadFile(string fileName)
        {
            OpenSaveDialogEventArgs e = new OpenSaveDialogEventArgs(Designer);

            // empty fileName: user pressed "Open" button, show open dialog.
            // non-empty fileName: user choosed a report from recent file list, just load the specified report.
            if (String.IsNullOrEmpty(fileName))
            {
                Config.DesignerSettings.OnCustomOpenDialog(Designer, e);
                if (e.Cancel)
                {
                    return(false);
                }
                fileName = e.FileName;
            }

            bool result = SaveCurrentFile();

            if (result)
            {
                try
                {
                    Designer.Lock();
                    OpenSaveReportEventArgs e1 = new OpenSaveReportEventArgs(Report, fileName, e.Data, false);
                    Config.DesignerSettings.OnCustomOpenReport(Designer, e1);
                    Report.FileName = fileName;
                    Designer.cmdRecentFiles.Update(fileName);
                    Config.DesignerSettings.OnReportLoaded(this, new ReportLoadedEventArgs(Report));
                    result = true;
                }
#if !DEBUG
                catch (Exception ex)
                {
                    EmptyReport(false);
                    FRMessageBox.Error(String.Format(Res.Get("Messages,CantLoadReport") + "\r\n" + ex.Message, fileName));
                    result = false;
                }
#endif
                finally
                {
                    InitReport();
                    Designer.Unlock();
                }
            }

            return(result);
        }
Beispiel #3
0
 internal void OnCustomSaveReport(object sender, OpenSaveReportEventArgs e)
 {
     if (CustomSaveReport != null)
     {
         CustomSaveReport(sender, e);
     }
     else
     {
         // standard save report
         if (e.Data == null)
         {
             e.Report.Save(e.FileName);
         }
         else
         {
             e.Report.GenerateReportAssembly(e.FileName);
         }
     }
 }
Beispiel #4
0
 internal void OnCustomOpenReport(object sender, OpenSaveReportEventArgs e)
 {
     if (CustomOpenReport != null)
     {
         CustomOpenReport(sender, e);
     }
     else
     {
         // standard open report
         if (e.Data == null)
         {
             e.Report.Load(e.FileName);
         }
         else
         {
             (e.Data as ImportPlugin).LoadReport(e.Report, e.FileName);
         }
     }
     OnReportLoaded(sender, new ReportLoadedEventArgs(e.Report));
 }