Skip to main content Skip to footer

Linking ActiveReports Server and End User Designer

INTRODUCTION

The End User Designer has been a part of the professional edition of ActiveReports from a long time and is among its most popular features. This allows the End-Users to quickly create and preview reports without the need to install Visual Studio. Similarly ActiveReports Server is a scalable server-based platform that gives you a secure place to deploy reports that users can view in any browser. Administrators access the admin panel to manage reports and user permissions. The End-Users use their portal to view and query reports. With the release of the latter, we felt that an end user may want to Open or Save a report to the ActiveReports Server while working with the End User Designer. Wouldn't it be nice if we can directly perform this operation from the End User Designer itself? Well this blog post focuses on fulfilling this functionality and we will find out how exactly this works.

OVERVIEW

The End User Designer is a Winforms based application and on the other hand, the ActiveReports Server allows access over web browser. So our development team came up with two methods viz SaveReportToServer and OpenReportFromServer which allow End User Designer users to directly upload/save report from the ActiveReports Server. In the next section, we will learn the simple steps involved during the Save and Open operations, along with the screenshots.

SAVE/OPEN ACTION

  • Saving Report to Server

1. Both the Save and Open options have been added to the File menu of the designer. So we need to select the "Save To Server" option. This is how it looks: Save2. Once the "Save to Server" option is selected, a dialog box is presented. We need to enter the server URL and credentials to connect to it. In addition to this, user has the option to enter the report name and additional description about the upload. This is how it looks: Save_Server 3. Finally once we click the Save button, the report is saved to the server. The image below shows the above report uploaded to the server. Server

  • Opening Report From Server

1. Just like the "Save To Server" option, another option "Open From Server" is added to the File menu. Open2. Once the option is selected, a dialog opens listing the available reports on the server. Similar to the save dialog, we need to specify the server URL and credentials. Here is an image showing it. Open_Server 3. So we can select a report and it will be automatically loaded on to the End User Designer. That was simple isn't it?

CODE

This is a pretty simple implementation and all we need to do is to add two items to the File menu and then handle their click event to perform the required operation. So we are taking the default End User Designer sample which is shipped with ActiveReports 9 and updating it. Let' s see how the code looks like. First we have the CreateFileMenu function here which creates the File menu options:

        private void CreateFileMenu(ToolStripDropDownItem fileMenu)  
        {  
            fileMenu.DropDownItems.Clear();  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.NewText, Properties.Resources.CmdNewReport, new EventHandler(OnNew), (Keys.Control | Keys.N)));  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.OpenText, Properties.Resources.CmdOpen, new EventHandler(OnOpen), (Keys.Control | Keys.O)));  
    //Adding Load From Server option  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.LoadfrmServer, Properties.Resources.CmdOpenFromServer, new EventHandler(OnLoadFromServer)));  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.SaveText, Properties.Resources.CmdSave, new EventHandler(OnSave), (Keys.Control | Keys.S)));  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.SaveAsText, Properties.Resources.CmdSaveAs, new EventHandler(OnSaveAs)));  
    //Adding Save To Server option  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.SaveToServer, Properties.Resources.CmdSaveToServer, new EventHandler(OnSaveToServer)));  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.ExportText, GrapeCity.ActiveReports.Samples.EndUserDesigner.Properties.Resources.export, new EventHandler(OnExport), (Keys.Control | Keys.E)));  
            fileMenu.DropDownItems.Add(new ToolStripSeparator());  
            fileMenu.DropDownItems.Add(new ToolStripMenuItem(Properties.Resources.ExitText, null, new EventHandler(OnExit)));  
            fileMenu.DropDownItems[6].Enabled = false;  
        }

And this is how the event handlers for the LoadFromServer and SaveToServer file menu items looks like:

        //Click "Save to Server" to save a report with a name.  
        private void OnSaveToServer(object sender, EventArgs e)  
        {  
            reportDesigner.SaveReportToServer();  
        }  
        //Click "Open from Server" to open a report with a name.  
        private void OnLoadFromServer(object sender, EventArgs e)  
        {  
            var reportname = "";  
            reportDesigner.LoadReportFromServer(out reportname);  
        }

So that is all we require to do. Simple calls to built in methods do the trick. A full fledged sample can be download from the download link below.

MESCIUS inc.

comments powered by Disqus