Example #1
0
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        if (QueryHelper.ValidateHash("hash", "UILang"))
        {
            // Get report name
            string reportName = QueryHelper.GetString("reportName", null);

            // Check permissions
            bool isEcommerceReport = ReportInfoProvider.IsEcommerceReport(reportName);
            CMSEcommerceReportsPage.CheckPermissions(isEcommerceReport);

            SetCulture();

            ReportInfo report = ReportInfoProvider.GetReportInfo(reportName);
            if (report != null)
            {
                // Get report parameters
                string      parameters       = QueryHelper.GetString("parameters", String.Empty);
                CultureInfo currentCulture   = CultureHelper.GetCultureInfo(Thread.CurrentThread.CurrentUICulture.IetfLanguageTag);
                DataRow     reportParameters = ReportHelper.GetReportParameters(report, parameters, null, CultureHelper.EnglishCulture, currentCulture);

                // Init report
                if (reportParameters != null)
                {
                    DisplayReport1.LoadFormParameters = false;
                    DisplayReport1.ReportParameters   = reportParameters;
                }

                DisplayReport1.ReportName    = reportName;
                DisplayReport1.DisplayFilter = false;

                Page.Title = GetString("report_print.lblprintreport") + " " + HTMLHelper.HTMLEncode(report.ReportDisplayName);
            }
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // If data are valid
        if (bfParameters.ValidateData())
        {
            // Fill BasicForm with user data
            bfParameters.SaveData(null);
            if (bfParameters.DataRow != null)
            {
                int        reportID = QueryHelper.GetInteger("ReportID", 0);
                ReportInfo ri       = ReportInfoProvider.GetReportInfo(reportID);
                if (ri == null)
                {
                    return;
                }

                FormInfo fi         = new FormInfo(ri.ReportParameters);
                DataRow  defaultRow = fi.GetDataRow(false);
                fi.LoadDefaultValues(defaultRow, true);

                // Load default parameters to items ,where displayed in edit form not checked
                List <IDataDefinitionItem> items = fi.ItemsList;
                foreach (IDataDefinitionItem item in items)
                {
                    FormFieldInfo ffi = item as FormFieldInfo;
                    if ((ffi != null) && (!ffi.Visible))
                    {
                        bfParameters.DataRow[ffi.Name] = defaultRow[ffi.Name];
                    }
                }

                WindowHelper.Add(hdnGuid.Value, bfParameters.DataRow.Table.DataSet);
            }
            // Refreshh opener update panel script
            ltlScript.Text = ScriptHelper.GetScript("wopener.refresh (); CloseDialog()");
        }
    }
Example #3
0
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        if (QueryHelper.ValidateHash("hash", "UILang"))
        {
            // Check security
            CheckSecurity();

            // Set cultures
            SetCulture();
            CultureInfo currentCulture = CultureHelper.GetCultureInfo(Thread.CurrentThread.CurrentUICulture.IetfLanguageTag);

            // Get report info
            string     reportName = QueryHelper.GetString("reportname", String.Empty);
            ReportInfo report     = ReportInfoProvider.GetReportInfo(reportName);

            if (report != null)
            {
                // Get report parameters
                string  parameters       = QueryHelper.GetString("parameters", String.Empty);
                DataRow reportParameters = ReportHelper.GetReportParameters(report, parameters, AnalyticsHelper.PARAM_SEMICOLON, CultureHelper.EnglishCulture, currentCulture);

                // Init report
                if (reportParameters != null)
                {
                    displayReport.LoadFormParameters = false;
                    displayReport.ReportParameters   = reportParameters;
                }

                displayReport.ReportName    = report.ReportName;
                displayReport.DisplayFilter = false;

                Page.Title = GetString("Report_Print.lblPrintReport") + " " + HTMLHelper.HTMLEncode(report.ReportDisplayName);
            }
        }
    }
    /// <summary>
    /// Returns report graph.
    /// </summary>
    private void GetReportGraph(ReportGraphInfo reportGraph)
    {
        // Check whether report graph is defined
        if (reportGraph == null)
        {
            return;
        }

        report = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID);
        //check graph security settings
        if (report.ReportAccess != ReportAccessEnum.All)
        {
            if (!CMSContext.CurrentUser.IsAuthenticated())
            {
                Visible = false;
                return;
            }
        }

        EnableSubscription = (EnableSubscription && ValidationHelper.GetBoolean(ReportGraphInfo.GraphSettings["SubscriptionEnabled"], true) && report.ReportEnableSubscription);
        if (EmailMode && !EnableSubscription)
        {
            this.Visible = false;
            return;
        }

        //Set default parametrs directly if not set
        if (ReportParameters == null)
        {
            //Load ReportInfo
            if (report != null)
            {
                FormInfo fi = new FormInfo(report.ReportParameters);
                // Get datarow with required columns
                ReportParameters = fi.GetDataRow(false);
                fi.LoadDefaultValues(ReportParameters, true);
            }
        }

        // Only use base parameters in case of stored procedure
        if (QueryIsStoredProcedure)
        {
            AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null);
        }

        // Indicaates whether exception was throw during data loading
        errorOccurred = false;

        // Create graph data
        try
        {
            ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild();
            //Resolve parameters in query
            resolver.SourceParameters = AllParameters.ToArray();

            // Resolve dynamic data macros
            if (DynamicMacros != null)
            {
                for (int i = 0; i <= DynamicMacros.GetUpperBound(0); i++)
                {
                    resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]);
                }
            }

            //Prepare query attributes
            QueryText = resolver.ResolveMacros(reportGraph.GraphQuery);
            QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure;

            // Load data
            DataSource = LoadData();

            if (DataHelper.DataSourceIsEmpty(DataSource) && EmailMode && SendOnlyNonEmptyDataSource)
            {
                Visible = false;
                return;
            }
        }
        catch (Exception ex)
        {
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent("Get report graph", "E", ex);
            lblError.Text    = ex.Message;
            lblError.Visible = true;
            errorOccurred    = true;
        }
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        // Load value info object
        ReportValueInfo rvi = ValueInfo;

        if (rvi == null)
        {
            return;
        }

        ri = ReportInfoProvider.GetReportInfo(rvi.ValueReportID);
        if (ri == null)
        {
            return;
        }

        // Check security settings
        if (!(CheckReportAccess(ri) && CheckEmailModeSubscription(ri, ValidationHelper.GetBoolean(ValueInfo.ValueSettings["SubscriptionEnabled"], true))))
        {
            Visible = false;
            return;
        }

        // Prepare query attributes
        QueryIsStoredProcedure = rvi.ValueQueryIsStoredProcedure;
        QueryText = rvi.ValueQuery;

        // Init parameters
        InitParameters(ri.ReportParameters);

        // Init macro resolver
        InitResolver();

        DataSet ds = null;

        // Ensure report item name for caching
        if (String.IsNullOrEmpty(ReportItemName))
        {
            ReportItemName = String.Format("{0};{1}", ri.ReportName, rvi.ValueName);
        }

        try
        {
            // Load data
            ds = LoadData();
        }
        catch (Exception ex)
        {
            // Display error message, if data load fail
            lblError.Visible = true;
            lblError.Text    = "Error loading the data: " + ex.Message;
            EventLogProvider.LogException("Report value", "E", ex);
        }

        string value;

        // If data source or result is empty, send an empty dataset
        if (DataHelper.DataSourceIsEmpty(ds) || string.IsNullOrEmpty(value = GetReportValue(ds, rvi)))
        {
            if (EmailMode && SendOnlyNonEmptyDataSource)
            {
                Visible = false;
            }

            return;
        }

        if (EmailMode)
        {
            ltlEmail.Text    = HTMLHelper.HTMLEncode(ResolveMacros(value));
            ltlEmail.Visible = true;
            menuCont.Visible = false;
        }
        else
        {
            lblValue.Text = HTMLHelper.HTMLEncode(ResolveMacros(value));
        }
    }
Example #6
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        // Check 'Modify' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.reporting", "Modify"))
        {
            RedirectToAccessDenied("cms.reporting", "Modify");
        }
        string errorMessage = new Validator().NotEmpty(txtReportDisplayName.Text.Trim(), rfvReportDisplayName.ErrorMessage).NotEmpty(txtReportName.Text.Trim(), rfvReportName.ErrorMessage).Result;

        if ((errorMessage == "") && (!ValidationHelper.IsCodeName(txtReportName.Text.Trim())))
        {
            errorMessage = GetString("general.invalidcodename");
        }

        ReportAccessEnum reportAccess = ReportAccessEnum.All;

        if (!chkReportAccess.Checked)
        {
            reportAccess = ReportAccessEnum.Authenticated;
        }

        if (errorMessage == "")
        {
            ReportInfo reportInfo = ReportInfoProvider.GetReportInfo(reportId);
            ReportInfo nri        = ReportInfoProvider.GetReportInfo(txtReportName.Text.Trim());

            // If report with given name already exists show error message
            if ((nri != null) && (nri.ReportID != reportInfo.ReportID))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Report_New.ReportAlreadyExists");
                return;
            }

            if (reportInfo != null)
            {
                reportInfo.ReportLayout = htmlTemplateBody.ResolvedValue;

                // If there was a change in report code name change codenames in layout
                if (reportInfo.ReportName != txtReportName.Text.Trim())
                {
                    // part of old macro
                    string oldValue = "?" + reportInfo.ReportName + ".";
                    string newValue = "?" + txtReportName.Text.Trim() + ".";

                    reportInfo.ReportLayout = reportInfo.ReportLayout.Replace(oldValue, newValue);

                    // Set updated text back to HTML editor
                    htmlTemplateBody.ResolvedValue = reportInfo.ReportLayout;
                }
                int categoryID = ValidationHelper.GetInteger(selectCategory.Value, reportInfo.ReportCategoryID);

                // If there was a change in display name refresh category tree
                if ((reportInfo.ReportDisplayName != txtReportDisplayName.Text.Trim()) || (reportInfo.ReportCategoryID != categoryID))
                {
                    ltlScript.Text += ScriptHelper.GetScript(@"if ((parent != null) && (parent.Refresh != null)) {parent.Refresh();}");
                }

                reportInfo.ReportDisplayName = txtReportDisplayName.Text.Trim();
                reportInfo.ReportName        = txtReportName.Text.Trim();
                reportInfo.ReportAccess      = reportAccess;
                reportInfo.ReportCategoryID  = categoryID;

                ReportInfoProvider.SetReportInfo(reportInfo);

                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");

                // Reload header if changes were saved
                ScriptHelper.RefreshTabHeader(Page, GetString("general.general"));
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
Example #7
0
    /// <summary>
    /// Returns report graph.
    /// </summary>
    private void GetReportGraph(ReportGraphInfo reportGraph)
    {
        Visible         = true;
        ucChart.Visible = true;

        int correctWidth = 0;

        if (ComputedWidth != 0)
        {
            correctWidth = GetGraphWidth();
        }

        if (Width != String.Empty)
        {
            int graphWidth = ValidationHelper.GetInteger(Width, 0);
            if (graphWidth != 0)
            {
                reportGraph.GraphWidth = graphWidth;
            }
        }

        if (Height != 0)
        {
            reportGraph.GraphHeight = Height;
        }

        ReportGraph graph = new ReportGraph()
        {
            Colors = Colors
        };

        graph.ChartControl = ucChart;

        mReport = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID);
        if (mReport == null)
        {
            return;
        }

        // Check graph security settings
        if (!(CheckReportAccess(mReport) && CheckEmailModeSubscription(mReport, ValidationHelper.GetBoolean(ReportGraphInfo.GraphSettings["SubscriptionEnabled"], true))))
        {
            Visible = false;
            return;
        }

        // Prepare query attributes
        QueryText = reportGraph.GraphQuery;
        QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure;

        // Init parameters
        InitParameters(mReport.ReportParameters);

        // Init macro resolver
        InitResolver();

        mErrorOccurred = false;
        DataSet dsGraphData = null;

        // Create graph image
        try
        {
            // LoadData
            dsGraphData = LoadData();
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Get report graph", "E", ex);
            graph.CorrectWidth = correctWidth;
            graph.CreateInvalidDataGraph(reportGraph, "Reporting.Graph.InvalidDataGraph", false);
            mErrorOccurred = true;
        }

        // Test if dataset is empty
        if (DataHelper.DataSourceIsEmpty(dsGraphData))
        {
            if (EmailMode && SendOnlyNonEmptyDataSource)
            {
                // Empty dataset, and flag not send empty dataset is set
                Visible = false;
                return;
            }

            string noRecordText = ResolveMacros(ValidationHelper.GetString(reportGraph.GraphSettings["QueryNoRecordText"], String.Empty));
            if (noRecordText != String.Empty)
            {
                ltlEmail.Text   = noRecordText;
                lblInfo.Text    = noRecordText;
                ucChart.Visible = false;
                menuCont.MenuID = String.Empty;
                EnableExport    = false;
                lblInfo.Visible = true;
            }
            else
            {
                Visible = false;
            }
        }
        else
        {
            // Create chart
            graph.CorrectWidth = correctWidth;
            if (EmailMode)
            {
                byte[] data = graph.CreateChart(reportGraph, dsGraphData, ContextResolver, true);
                ltlEmail.Text = "##InlineImage##" + reportGraph.GraphName + "##InlineImage##";
                ReportSubscriptionSender.AddToRequest(mReport.ReportName, "g" + reportGraph.GraphName, data);
            }
            else
            {
                graph.CreateChart(reportGraph, dsGraphData, ContextResolver);
            }
        }
    }
Example #8
0
    /// <summary>
    /// Returns report graph.
    /// </summary>
    private void GetReportGraph(ReportGraphInfo reportGraph)
    {
        Visible         = true;
        ucChart.Visible = true;

        int correctWidth = 0;

        if (ComputedWidth != 0)
        {
            correctWidth = ModifyGraphInfo();
        }

        if (Width != String.Empty)
        {
            int graphWidth = ValidationHelper.GetInteger(Width, 0);
            if (graphWidth != 0)
            {
                reportGraph.GraphWidth = graphWidth;
            }
        }

        if (Height != 0)
        {
            reportGraph.GraphHeight = Height;
        }

        ReportGraph graph = new ReportGraph();

        graph.ChartControl = ucChart;

        ReportInfo report = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID);

        if (report == null)
        {
            return;
        }

        // Check graph security settings
        if (report.ReportAccess != ReportAccessEnum.All)
        {
            if (!CMSContext.CurrentUser.IsAuthenticated())
            {
                Visible = false;
                return;
            }
        }

        // Set default parametrs directly if not set
        if (ReportParameters == null)
        {
            // Load ReportInfo
            if (report != null)
            {
                FormInfo fi = new FormInfo(report.ReportParameters);
                // Get datarow with required columns
                ReportParameters = fi.GetDataRow();
                fi.LoadDefaultValues(ReportParameters, true);
            }
        }

        // If used via widget - this function ensure showing specific interval from actual time (f.e. last 6 weeks)
        ApplyTimeParameters();

        // Only use base parameters in case of stored procedure
        if (QueryIsStoredProcedure)
        {
            AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null);
        }

        ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild();

        // Indicaates whether exception was throw during data loading
        bool errorOccurred = false;

        // Create graph image
        try
        {
            // Resolve parameters in query
            resolver.SourceParameters = AllParameters.ToArray();

            // Resolve dynamic data macros
            if (DynamicMacros != null)
            {
                for (int i = 0; i <= DynamicMacros.GetUpperBound(0); i++)
                {
                    resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]);
                }
            }

            // Prepare query attributes
            QueryText = resolver.ResolveMacros(reportGraph.GraphQuery);
            QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure;

            // LoadData
            DataSet dsGraphData = LoadData();

            // Test if dataset is empty
            if (DataHelper.DataSourceIsEmpty(dsGraphData))
            {
                string noRecordText = ValidationHelper.GetString(reportGraph.GraphSettings["QueryNoRecordText"], String.Empty);
                if (noRecordText != String.Empty)
                {
                    lblInfo.Text    = noRecordText;
                    lblInfo.Visible = true;
                    ucChart.Visible = false;
                    menuCont.MenuID = String.Empty;
                    return;
                }
                Visible = false;
            }
            else
            {
                // Create Chart
                graph.CorrectWidth = correctWidth;
                graph.CreateChart(reportGraph, dsGraphData, resolver);
            }
        }
        catch (Exception ex)
        {
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent("Get report graph", "E", ex);
            graph.CorrectWidth = correctWidth;
            graph.CreateInvalidDataGraph(reportGraph, "Reporting.Graph.InvalidDataGraph", false);
            errorOccurred = true;
        }

        // Export data
        if ((report != null) && (!errorOccurred))
        {
            ProcessExport(ValidationHelper.GetCodeName(report.ReportDisplayName));
        }
    }
    /// <summary>
    /// OnInit.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        ScriptHelper.RegisterWOpenerScript(Page);
        PageTitle.TitleText = ResHelper.GetString("rep.webparts.reportparameterstitle");
        // Load data for this form
        int reportID = QueryHelper.GetInteger("ReportID", 0);

        hdnGuid.Value = QueryHelper.GetString("GUID", String.Empty);
        ReportInfo ri = ReportInfoProvider.GetReportInfo(reportID);

        if (ri == null)
        {
            return;
        }

        FormInfo fi = new FormInfo(ri.ReportParameters);

        bfParameters.FormInformation      = fi;
        bfParameters.SubmitButton.Visible = false;
        bfParameters.Mode = FormModeEnum.Update;

        // Get dataset from cache
        DataSet ds = (DataSet)WindowHelper.GetItem(hdnGuid.Value);
        DataRow dr = fi.GetDataRow(false);

        fi.LoadDefaultValues(dr, true);

        if (ds == null)
        {
            if (dr.ItemArray.Length > 0)
            {
                // Set up grid
                bfParameters.DataRow = RequestHelper.IsPostBack() ? fi.GetDataRow(false) : dr;
            }
        }


        // Set data set given from cache
        if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
        {
            //Merge with default data from report
            MergeDefaultValuesWithData(dr, ds.Tables[0].Rows[0]);
            //Set row to basic form
            bfParameters.DataRow = dr;
        }

        // Test if there is any item visible in report parameters
        bool          itemVisible = false;
        List <IField> items       = fi.ItemsList;

        foreach (IField item in items)
        {
            FormFieldInfo ffi = item as FormFieldInfo;
            if (ffi != null && ffi.Visible)
            {
                itemVisible = true;
                break;
            }
        }

        if (!itemVisible)
        {
            ShowInformation(GetString("rep.parameters.noparameters"));
        }

        base.OnInit(e);
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Test permission for query
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries"))
        {
            txtQueryQuery.Enabled = false;
        }
        else
        {
            txtQueryQuery.Enabled = true;
        }

        versionList.OnAfterRollback += new EventHandler(versionList_onAfterRollback);

        // Own javascript tab change handling -> because tab control raises changetab after prerender - too late
        // Own selected tab change handling
        RegisterTabScript(hdnSelectedTab.ClientID, tabControlElem);

        // Register script for resize and rolback
        RegisterResizeAndRollbackScript(divFooter.ClientID, divScrolable.ClientID);

        string[,] tabs = new string[4, 4];
        tabs[0, 0]     = GetString("general.general");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'report_htmlgraph_properties')";
        tabs[1, 0]     = GetString("general.preview");
        tabs[1, 1]     = "SetHelpTopic('helpTopic', 'report_htmlgraph_properties');";

        tabControlElem.Tabs        = tabs;
        tabControlElem.UsePostback = true;

        CurrentMaster.Title.TitleCssClass = "PageTitleHeader";
        CurrentMaster.Title.HelpTopicName = "report_htmlgraph_properties";
        CurrentMaster.Title.HelpName      = "helpTopic";
        Title = "ReportGraph Edit";

        btnOk.Text     = GetString("General.OK");
        btnCancel.Text = GetString("General.Cancel");
        btnApply.Text  = GetString("General.apply");

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        int  reportId  = QueryHelper.GetInteger("reportid", 0);
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        // If preview by URL -> select preview tab
        if (isPreview && !RequestHelper.IsPostBack())
        {
            SelectedTab = 1;
        }

        if (reportId > 0)
        {
            reportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        if (PersistentEditedObject == null)
        {
            if (reportInfo != null) //must be valid reportid parameter
            {
                string graphName = QueryHelper.GetString("itemname", "");

                // try to load graphname from hidden field (adding new graph & preview)
                if (graphName == String.Empty)
                {
                    graphName = txtNewGraphHidden.Value;
                }

                if (ValidationHelper.IsIdentifier(graphName))
                {
                    PersistentEditedObject = ReportGraphInfoProvider.GetReportGraphInfo(reportInfo.ReportName + "." + graphName);
                    graphInfo = PersistentEditedObject as ReportGraphInfo;
                }
            }
        }
        else
        {
            graphInfo = PersistentEditedObject as ReportGraphInfo;
        }


        if (graphInfo != null)
        {
            CurrentMaster.Title.TitleText  = GetString("Reporting_ReportGraph_EditHTML.TitleText");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportGraph/object.png");

            graphId = graphInfo.GraphID;

            if (ObjectVersionManager.DisplayVersionsTab(graphInfo))
            {
                tabs[2, 0]             = GetString("objectversioning.tabtitle");
                tabs[2, 1]             = "SetHelpTopic('helpTopic', 'objectversioning_general');";
                versionList.Object     = graphInfo;
                versionList.IsLiveSite = false;
            }
        }
        else
        {
            CurrentMaster.Title.TitleText  = GetString("Reporting_ReportGraph_EditHTML.NewItemTitleText");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportGraph/new.png");

            newReport = true;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Load default data for new report
            if (newReport)
            {
                txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                txtItemValueFormat.Text   = "{%yval%}";
                txtSeriesItemTooltip.Text = "{%ser%}";
                chkExportEnable.Checked   = true;
            }
            // Otherwise load saved data
            else
            {
                LoadData();
            }
        }
    }
Example #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.RegisterExportScript();

        //// Images
        imgNewCategory.ImageUrl  = GetImageUrl("Objects/CMS_WebPartCategory/add.png");
        imgNewReport.ImageUrl    = GetImageUrl("Objects/Reporting_report/add.png");
        imgDeleteItem.ImageUrl   = GetImageUrl("Objects/CMS_WebPart/delete.png");
        imgExportObject.ImageUrl = GetImageUrl("Objects/CMS_WebPart/export.png");
        imgCloneReport.ImageUrl  = GetImageUrl("CMSModules/CMS_WebParts/clone.png");

        // Resource strings
        lnkDeleteItem.Text   = GetString("Development-Report_Tree.DeleteSelected");
        lnkNewCategory.Text  = GetString("Development-Report_Tree.NewCategory");
        lnkNewReport.Text    = GetString("Development-Report_Tree.NewReport");
        lnkExportObject.Text = GetString("Development-Report_Tree.ExportObject");
        lnkCloneReport.Text  = GetString("Development-Report_Tree.CloneReport");

        // Setup menu action scripts
        lnkNewReport.Attributes.Add("onclick", "NewItem('report');");
        lnkNewCategory.Attributes.Add("onclick", "NewItem('reportcategory');");
        lnkDeleteItem.Attributes.Add("onclick", "DeleteItem();");
        lnkExportObject.Attributes.Add("onclick", "ExportObject();");
        lnkCloneReport.Attributes.Add("onclick", "CloneReport();");

        // Widgets
        lnkDeleteItem.ToolTip   = GetString("Development-Report_Tree.DeleteSelected");
        lnkNewCategory.ToolTip  = GetString("Development-Report_Tree.NewCategory");
        lnkNewReport.ToolTip    = GetString("Development-Report_Tree.NewReport");
        lnkExportObject.ToolTip = GetString("Development-Report_Tree.ExportObject");
        lnkCloneReport.ToolTip  = GetString("Development-Report_Tree.CloneReport");

        pnlSubBox.CssClass = BrowserHelper.GetBrowserClass();

        //// URLs for menu actions
        string script = "var categoryURL = '" + ResolveUrl("ReportCategory_Edit_Frameset.aspx") + "';\n";

        script += "var reportURL = '" + ResolveUrl("Report_Edit.aspx") + "';\n";
        script += "var doNotReloadContent = false;\n";

        // Script for deleting widget or category
        string delPostback  = ControlsHelper.GetPostBackEventReference(this.Page, "##");
        string deleteScript = "function DeleteItem() { \n" +
                              " if ((selectedItemId > 0) && (selectedItemParent > 0) && " +
                              " confirm('" + GetString("general.deleteconfirmation") + "')) {\n " +
                              delPostback.Replace("'##'", "selectedItemType+';'+selectedItemId+';'+selectedItemParent") + ";\n" +
                              "}\n" +
                              "}\n";

        script += deleteScript;

        // Preselect tree item
        if (!RequestHelper.IsPostBack())
        {
            int  categoryId = QueryHelper.GetInteger("categoryid", 0);
            int  reportID   = QueryHelper.GetInteger("reportid", 0);
            bool reload     = QueryHelper.GetBoolean("reload", false);

            // Select category
            if (categoryId > 0)
            {
                ReportCategoryInfo rci = ReportCategoryInfoProvider.GetReportCategoryInfo(categoryId);
                if (rci != null)
                {
                    // If not set explicitly stop reloading of right frame
                    if (!reload)
                    {
                        script += "doNotReloadContent = true;";
                    }
                    script += SelectAtferLoad(rci.CategoryPath, categoryId, "reportcategory", rci.CategoryParentID, true);
                }
            }
            // Select report
            else if (reportID > 0)
            {
                ReportInfo ri = ReportInfoProvider.GetReportInfo(reportID);
                if (ri != null)
                {
                    ReportCategoryInfo rci = ReportCategoryInfoProvider.GetReportCategoryInfo(ri.ReportCategoryID);
                    if (rci != null)
                    {
                        // If not set explicitly stop reloading of right frame
                        if (!reload)
                        {
                            script += "doNotReloadContent = true;";
                        }
                        string path = rci.CategoryPath + "/" + ri.ReportName;
                        script += SelectAtferLoad(path, reportID, "report", ri.ReportCategoryID, true);
                    }
                }
            }
            // Select root by default
            else
            {
                ReportCategoryInfo rci = ReportCategoryInfoProvider.GetReportCategoryInfo("/");
                if (rci != null)
                {
                    script += SelectAtferLoad("/", rci.CategoryID, "reportcategory", 0, true);
                }

                // Directly dispatch an action, if set by URL
                if (QueryHelper.GetString("action", null) == "newcategory")
                {
                    script += "NewItem('reportcategory');";
                }
            }
        }

        ltlScript.Text += ScriptHelper.GetScript(script);
    }
    protected override void OnInit(EventArgs e)
    {
        UseCMSDeskAccessDeniedPage = !IsLiveSite;
        CurrentUserInfo cui        = CMSContext.CurrentUser;
        bool            haveModify = cui.IsAuthorizedPerResource("cms.reporting", "modify");

        if (!(cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || haveModify))
        {
            RedirectToAccessDenied("cms.reporting", "Subscribe");
        }

        pnlBasic.GroupingText      = GetString("reportsubscription.settings");
        pnlParameters.GroupingText = GetString("reportsubscription.parameters.title");

        // Init validator
        rfvEmail.Text   = GetString("om.contact.enteremail");
        rfvSubject.Text = GetString("bizformgeneral.emptyemailsubject");

        rsi = ReportSubscriptionInfoProvider.GetReportSubscriptionInfo(QueryHelper.GetInteger("SubscriptionID", 0));

        int    reportID   = QueryHelper.GetInteger("ReportID", 0);
        String reportName = QueryHelper.GetString("reportName", String.Empty);

        if (reportID != 0)
        {
            ri = ReportInfoProvider.GetReportInfo(reportID);
        }
        else if (!String.IsNullOrEmpty(reportName))
        {
            ri = ReportInfoProvider.GetReportInfo(reportName);
        }
        else
        {
            if (rsi != null)
            {
                // If no report specified, get it from subscription
                ri = ReportInfoProvider.GetReportInfo(rsi.ReportSubscriptionReportID);
            }
        }

        if ((rsi != null) && !haveModify && !SimpleMode)
        {
            if (rsi.ReportSubscriptionUserID != cui.UserID)
            {
                RedirectToAccessDenied(GetString("reportsubscription.onlymodifyusersallowed"));
            }
        }

        if (ri == null)
        {
            return;
        }

        // Set interval control for subscription mode
        ucInterval.DisplayStartTime = false;
        ucInterval.DisplayOnce      = false;
        ucInterval.DisplaySecond    = false;

        if (!RequestHelper.IsPostBack())
        {
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.hours"), "hour"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.days"), "day"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.weeks"), "week"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.months"), "month"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.years"), "year"));
        }

        if (SimpleMode)
        {
            LoadAdHoc();
        }
        else
        {
            LoadData();
        }

        // Show save changes after new object created
        if (!RequestHelper.IsPostBack() && (QueryHelper.GetBoolean("saved", false) == true))
        {
            ShowChangesSaved();
        }

        base.OnInit(e);
    }
Example #13
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        try
        {
            // Load value info object
            ReportValueInfo rvi = ValueInfo;

            if (rvi != null)
            {
                //Test security
                ReportInfo ri = ReportInfoProvider.GetReportInfo(rvi.ValueReportID);
                if (ri.ReportAccess != ReportAccessEnum.All)
                {
                    if (!CMSContext.CurrentUser.IsAuthenticated())
                    {
                        this.Visible = false;
                        return;
                    }
                }

                ContextResolver resolver = CMSContext.CurrentResolver;
                // Resolve dynamic data macros
                if (DynamicMacros != null)
                {
                    for (int i = 0; i <= this.DynamicMacros.GetUpperBound(0); i++)
                    {
                        resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]);
                    }
                }

                this.QueryIsStoredProcedure = rvi.ValueQueryIsStoredProcedure;
                this.QueryText = resolver.ResolveMacros(rvi.ValueQuery);

                //Set default parametrs directly if not set
                if (this.ReportParameters == null)
                {
                    if (ri != null)
                    {
                        FormInfo fi = new FormInfo(ri.ReportParameters);
                        // Get datarow with required columns
                        this.ReportParameters = fi.GetDataRow();
                        fi.LoadDefaultValues(this.ReportParameters, true);
                    }
                }
            }

            // Only use base parameters in case of stored procedure
            if (this.QueryIsStoredProcedure)
            {
                this.AllParameters = SpecialFunctions.ConvertDataRowToParams(this.ReportParameters, null);
            }

            // Load data
            DataSet ds = this.LoadData();

            // If datasource is emptry, create empty dataset
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Set literal text
                string value = rvi.ValueFormatString;
                if ((value == null) || (value == ""))
                {
                    value = ValidationHelper.GetString(ds.Tables[0].Rows[0][0], "");
                }
                else
                {
                    value = string.Format(value, ds.Tables[0].Rows[0].ItemArray);
                }

                lblValue.Text = HTMLHelper.HTMLEncode(ResolveMacros(value));
            }
        }
        catch (Exception ex)
        {
            // Display error message, if data load fail
            lblError.Visible = true;
            lblError.Text    = "[ReportValue.ascx] Error loading the data: " + ex.Message;
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent("Report value", "E", ex);
        }
    }
Example #14
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if ((GraphImageWidth != 0) && (ComputedWidth == 0))
        {
            // Graph width is computed no need to create graph
            return;
        }

        this.Visible = true;

        // Indicaates whether exception was throw during data loading
        bool       errorOccurred = false;
        ReportInfo ri            = null;

        try
        {
            this.ReportTableName = this.Parameter;

            this.EnsureTableInfo();
            this.EnsureChildControls();

            //Test security
            if (TableInfo != null)
            {
                ri = ReportInfoProvider.GetReportInfo(TableInfo.TableReportID);
                if (ri != null)
                {
                    if (ri.ReportAccess != ReportAccessEnum.All)
                    {
                        if (!CMSContext.CurrentUser.IsAuthenticated())
                        {
                            this.Visible = false;
                            return;
                        }
                    }

                    //Set default parametrs directly if not set
                    if (this.ReportParameters == null)
                    {
                        FormInfo fi = new FormInfo(ri.ReportParameters);
                        // Get datarow with required columns
                        this.ReportParameters = fi.GetDataRow();
                        fi.LoadDefaultValues(this.ReportParameters, true);
                    }

                    ApplyTimeParameters();
                }
            }

            // Only use base parameters in case of stored procedure
            if (this.QueryIsStoredProcedure)
            {
                this.AllParameters = SpecialFunctions.ConvertDataRowToParams(this.ReportParameters, null);
            }

            // Load data
            DataSet ds = this.LoadData();

            // If no data load, set empty dataset
            if (DataHelper.DataSourceIsEmpty(ds))
            {
                string noRecordText = ValidationHelper.GetString(TableInfo.TableSettings["QueryNoRecordText"], String.Empty);
                if (noRecordText != String.Empty)
                {
                    GridViewObject.Visible = false;
                    lblInfo.Text           = noRecordText;
                    lblInfo.Visible        = true;
                    return;
                }

                this.Visible = false;
            }
            else
            {
                GridViewObject.Visible = true;
                // Resolve macros in column names
                int i = 0;
                foreach (DataColumn dc in ds.Tables[0].Columns)
                {
                    if (dc.ColumnName == "Column" + ((int)(i + 1)).ToString())
                    {
                        dc.ColumnName = ResolveMacros(ds.Tables[0].Rows[0][i].ToString());
                    }
                    else
                    {
                        dc.ColumnName = ResolveMacros(dc.ColumnName);
                    }
                    i++;
                }

                // Resolve macros in dataset
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    foreach (DataColumn dc in ds.Tables[0].Columns)
                    {
                        if (dc.DataType.FullName.ToLower() == "system.string")
                        {
                            dr[dc.ColumnName] = ResolveMacros(ValidationHelper.GetString(dr[dc.ColumnName], ""));
                        }
                    }
                }
            }

            ApplyStyles();

            // Databind to gridview control
            GridViewObject.DataSource = ds;
            this.EnsurePageIndex();
            GridViewObject.DataBind();

            if ((TableFirstColumnWidth != Unit.Empty) && (GridViewObject.Rows.Count > 0))
            {
                GridViewObject.Rows[0].Cells[0].Width = TableFirstColumnWidth;
            }
        }
        catch (Exception ex)
        {
            // Display error message, if data load fail
            lblError.Visible = true;
            lblError.Text    = "[ReportTable.ascx] Error loading the data: " + ex.Message;
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent("Report table", "E", ex);
            errorOccurred = true;
        }

        // Export data
        if ((ri != null) && (!errorOccurred))
        {
            ProcessExport(ValidationHelper.GetCodeName(ri.ReportDisplayName));
        }
    }
Example #15
0
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        // Check site availability
        if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Reporting", CMSContext.CurrentSiteName))
        {
            RedirectToResourceNotAvailableOnSite("CMS.Reporting");
        }

        CurrentUserInfo user = CMSContext.CurrentUser;

        // Check 'Read' permission
        if (!user.IsAuthorizedPerResource("CMS.Reporting", "Read"))
        {
            RedirectToAccessDenied("CMS.Reporting", "Read");
        }

        IFormatProvider culture        = DateTimeHelper.DefaultIFormatProvider;
        IFormatProvider currentCulture = new System.Globalization.CultureInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.IetfLanguageTag);

        // Get report name from querystring
        reportName = QueryHelper.GetString("reportname", String.Empty);
        // Get ReportInfo object
        ReportInfo ri = ReportInfoProvider.GetReportInfo(reportName);

        if (ri != null)
        {
            // Get parameters from querystring
            string[] httpParameters = QueryHelper.GetString("parameters", String.Empty).Split(";".ToCharArray());

            if (httpParameters.Length > 1)
            {
                string[] parameters = new string[httpParameters.Length / 2];

                DataTable dtp = new DataTable();

                // Create correct columns and put values in it
                for (int i = 0; i < httpParameters.Length; i = i + 2)
                {
                    if (ValidationHelper.GetDateTime(httpParameters[i + 1], DataHelper.DATETIME_NOT_SELECTED, culture) == DataHelper.DATETIME_NOT_SELECTED)
                    {
                        dtp.Columns.Add(httpParameters[i]);
                        parameters[i / 2] = httpParameters[i + 1].Replace(AnalyticsHelper.PARAM_SEMICOLON, ";");
                    }
                    else
                    {
                        dtp.Columns.Add(httpParameters[i], typeof(DateTime));
                        parameters[i / 2] = Convert.ToDateTime(httpParameters[i + 1], culture).ToString(currentCulture);
                    }
                }


                dtp.Rows.Add(parameters);
                dtp.AcceptChanges();

                DisplayReport1.LoadFormParameters = false;
                DisplayReport1.ReportName         = ri.ReportName;
                DisplayReport1.DisplayFilter      = false;
                DisplayReport1.ReportParameters   = dtp.Rows[0];
            }
            else
            {
                DisplayReport1.ReportName    = ri.ReportName;
                DisplayReport1.DisplayFilter = false;
            }
            Page.Title = GetString("Report_Print.lblPrintReport") + " " + HTMLHelper.HTMLEncode(ri.ReportDisplayName);
        }
    }
Example #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int siteId    = 0;
        int processId = QueryHelper.GetInteger("processid", 0);

        // Handle site selectors visibility
        if (IsSiteManager)
        {
            CurrentMaster.DisplaySiteSelectorPanel = true;
            siteOrGlobalSelector.Visible           = false;
            siteId = siteSelector.SiteID;
        }
        else
        {
            // Init site filter when user is authorized for global and site contacts
            if (AuthorizedForGlobalContacts && AuthorizedForSiteContacts)
            {
                CurrentMaster.DisplaySiteSelectorPanel = true;
                siteSelector.Visible = false;
                siteId = siteOrGlobalSelector.SiteID;
            }
            else if (AuthorizedForSiteContacts)
            {
                // User is authorized only for site contacts so set current site id
                siteId = SiteID;
            }
            else if (AuthorizedForGlobalContacts)
            {
                // User can read only global contacts
                siteId = UniSelector.US_GLOBAL_RECORD;
            }
            else
            {
                // User has no permissions
                RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ReadContacts");
            }
        }

        // Set report parameters
        ReportInfo report = ReportInfoProvider.GetReportInfo("Number_of_contacts_in_steps");

        if (report != null)
        {
            ucReport.ReportName            = report.ReportName;
            reportHeader.ReportName        = report.ReportName;
            reportHeader.DisplayManageData = false;

            ucReport.DisplayFilter      = false;
            ucReport.LoadFormParameters = false;

            string  parameterString = String.Format("AutomationProcessID;{0};SiteID;{1}", processId, siteId);
            DataRow parameters      = ReportHelper.GetReportParameters(report, parameterString, null, DateTimeHelper.DefaultIFormatProvider, CultureHelper.PreferredUICultureInfo);
            ucReport.ReportParameters     = parameters;
            reportHeader.ReportParameters = parameters;

            reportHeader.ActionPerformed += reportHeader_ActionPerformed;
        }

        // Create refresh action
        rightHeaderActions.AddAction(new HeaderAction()
        {
            Text        = GetString("general.refresh"),
            ImageUrl    = GetImageUrl("Objects/MA_AutomationState/refresh.png"),
            RedirectUrl = AddSiteQuery("Tab_Report.aspx?processid=" + processId, siteId)
        });
    }
Example #17
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if ((TableInfo == null) || ((GraphImageWidth != 0) && (ComputedWidth == 0)))
        {
            // Graph width is computed no need to create graph
            return;
        }

        Visible = true;

        EnsureChildControls();

        LoadTable();

        mReportInfo = ReportInfoProvider.GetReportInfo(TableInfo.TableReportID);
        if (mReportInfo == null)
        {
            return;
        }

        // Check security settings
        if (!(CheckReportAccess(mReportInfo) && CheckEmailModeSubscription(mReportInfo, ValidationHelper.GetBoolean(TableInfo.TableSettings["SubscriptionEnabled"], true))))
        {
            Visible = false;
            return;
        }

        // Prepare query attributes
        QueryIsStoredProcedure = TableInfo.TableQueryIsStoredProcedure;
        QueryText = TableInfo.TableQuery;

        // Init parameters
        InitParameters(mReportInfo.ReportParameters);

        // Init macro resolver
        InitResolver();

        mErrorOccurred = false;
        DataSet ds = null;

        // Ensure report item name for caching
        if (String.IsNullOrEmpty(ReportItemName))
        {
            ReportItemName = String.Format("{0};{1}", mReportInfo.ReportName, TableInfo.TableName);
        }

        try
        {
            // Load data
            ds = LoadData();
        }
        catch (Exception ex)
        {
            // Display error message, if data load fail
            lblError.Visible = true;
            lblError.Text    = "Error loading the data: " + ex.Message;
            EventLogProvider.LogException("Report table", "E", ex);
            mErrorOccurred = true;
        }

        // If no data load, set empty dataset
        if (DataHelper.DataSourceIsEmpty(ds))
        {
            if (EmailMode && SendOnlyNonEmptyDataSource)
            {
                Visible = false;
                return;
            }

            string noRecordText = ValidationHelper.GetString(TableInfo.TableSettings["QueryNoRecordText"], String.Empty);
            if (!String.IsNullOrEmpty(noRecordText))
            {
                UIGridViewObject.Visible = false;
                lblInfo.Text             = ResolveMacros(noRecordText);
                lblInfo.Visible          = true;
                EnableExport             = false;
                return;
            }

            if (!EmailMode)
            {
                Visible = false;
                return;
            }
        }
        else
        {
            UIGridViewObject.Visible = true;
            // Resolve macros in column names
            int i = 0;
            foreach (DataColumn dc in ds.Tables[0].Columns)
            {
                if (dc.ColumnName == "Column" + (i + 1))
                {
                    dc.ColumnName = ResolveMacros(ds.Tables[0].Rows[0][i].ToString());
                }
                else
                {
                    dc.ColumnName = ResolveMacros(dc.ColumnName);
                }
                i++;
            }

            // Resolve macros in dataset
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                foreach (DataColumn dc in ds.Tables[0].Columns)
                {
                    if (dc.DataType.FullName.Equals("system.string", StringComparison.CurrentCultureIgnoreCase))
                    {
                        dr[dc.ColumnName] = ResolveMacros(ValidationHelper.GetString(dr[dc.ColumnName], String.Empty));
                    }
                }
            }

            if (EmailMode)
            {
                // For some email formats, export data in csv format
                EmailFormatEnum format = EmailHelper.GetEmailFormat(ReportSubscriptionSiteID);

                if ((format == EmailFormatEnum.Both) || (format == EmailFormatEnum.PlainText))
                {
                    using (var ms = new SystemIO.MemoryStream())
                    {
                        DataExportHelper deh  = new DataExportHelper(ds);
                        byte[]           data = deh.ExportToCSV(ds, 0, ms, true);
                        ReportSubscriptionSender.AddToRequest(mReportInfo.ReportName, "t" + TableInfo.TableName, data);
                    }
                }

                // For plain text email show table only as attachment
                if (format == EmailFormatEnum.PlainText)
                {
                    menuCont.Visible = false;
                    ltlEmail.Visible = true;
                    ltlEmail.Text    = String.Format(GetString("reportsubscription.attachment"), TableInfo.TableName);
                    return;
                }

                GenerateTableForEmail(ds);
                menuCont.Visible = false;
                return;
            }
        }

        // Databind to gridview control
        UIGridViewObject.DataSource = ds;
        EnsurePageIndex();
        UIGridViewObject.DataBind();

        if ((TableFirstColumnWidth != Unit.Empty) && (UIGridViewObject.Rows.Count > 0))
        {
            UIGridViewObject.Rows[0].Cells[0].Width = TableFirstColumnWidth;
        }
    }
Example #18
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if ((GraphImageWidth != 0) && (ComputedWidth == 0))
        {
            // Graph width is computed no need to create graph
            return;
        }

        Visible = true;

        errorOccurred = false;

        try
        {
            ReportTableName = Parameter;

            EnsureTableInfo();
            EnsureChildControls();

            //Test security
            if (TableInfo != null)
            {
                ri = ReportInfoProvider.GetReportInfo(TableInfo.TableReportID);
                if (ri != null)
                {
                    if (ri.ReportAccess != ReportAccessEnum.All)
                    {
                        if (!CMSContext.CurrentUser.IsAuthenticated())
                        {
                            Visible = false;
                            return;
                        }
                    }

                    EnableSubscription = EnableSubscription && (ValidationHelper.GetBoolean(TableInfo.TableSettings["SubscriptionEnabled"], true) && ri.ReportEnableSubscription);
                    if (EmailMode && !EnableSubscription)
                    {
                        this.Visible = false;
                        return;
                    }

                    //Set default parametrs directly if not set
                    if (ReportParameters == null)
                    {
                        FormInfo fi = new FormInfo(ri.ReportParameters);
                        // Get datarow with required columns
                        ReportParameters = fi.GetDataRow(false);
                        fi.LoadDefaultValues(ReportParameters, true);
                    }

                    ApplyTimeParameters();
                }
            }

            // Only use base parameters in case of stored procedure
            if (QueryIsStoredProcedure)
            {
                AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null);
            }

            // Load data
            DataSet ds = LoadData();

            // If no data load, set empty dataset
            if (DataHelper.DataSourceIsEmpty(ds))
            {
                if (EmailMode && SendOnlyNonEmptyDataSource)
                {
                    Visible = false;
                    return;
                }

                string noRecordText = ValidationHelper.GetString(TableInfo.TableSettings["QueryNoRecordText"], String.Empty);
                if (noRecordText != String.Empty)
                {
                    GridViewObject.Visible = false;
                    lblInfo.Text           = CMSContext.ResolveMacros(noRecordText);
                    plcInfo.Visible        = true;
                    EnableExport           = false;
                    return;
                }

                if (!EmailMode)
                {
                    Visible = false;
                }
            }
            else
            {
                GridViewObject.Visible = true;
                // Resolve macros in column names
                int i = 0;
                foreach (DataColumn dc in ds.Tables[0].Columns)
                {
                    if (dc.ColumnName == "Column" + ((int)(i + 1)).ToString())
                    {
                        dc.ColumnName = ResolveMacros(ds.Tables[0].Rows[0][i].ToString());
                    }
                    else
                    {
                        dc.ColumnName = ResolveMacros(dc.ColumnName);
                    }
                    i++;
                }

                // Resolve macros in dataset
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    foreach (DataColumn dc in ds.Tables[0].Columns)
                    {
                        if (dc.DataType.FullName.ToLowerCSafe() == "system.string")
                        {
                            dr[dc.ColumnName] = ResolveMacros(ValidationHelper.GetString(dr[dc.ColumnName], ""));
                        }
                    }
                }

                if (EmailMode)
                {
                    // For some email formats, export data in csv format
                    EmailFormatEnum format = EmailHelper.GetEmailFormat(ReportSubscriptionSiteID);

                    if ((format == EmailFormatEnum.Both) || (format == EmailFormatEnum.PlainText))
                    {
                        using (MemoryStream ms = MemoryStream.New())
                        {
                            DataExportHelper deh  = new DataExportHelper(ds);
                            byte[]           data = deh.ExportToCSV(ds, 0, ms, true);
                            ReportSubscriptionSender.AddToRequest(ri.ReportName, "t" + TableInfo.TableName, data);
                        }
                    }

                    // For plain text email show table only as attachment
                    if (format == EmailFormatEnum.PlainText)
                    {
                        menuCont.Visible = false;
                        ltlEmail.Visible = true;
                        ltlEmail.Text    = String.Format(GetString("reportsubscription.attachment"), TableInfo.TableName);
                        return;
                    }

                    GenerateTableForEmail(ds);
                    menuCont.Visible = false;
                    return;
                }
            }

            ApplyStyles();

            // Databind to gridview control
            GridViewObject.DataSource = ds;
            EnsurePageIndex();
            GridViewObject.DataBind();

            if ((TableFirstColumnWidth != Unit.Empty) && (GridViewObject.Rows.Count > 0))
            {
                GridViewObject.Rows[0].Cells[0].Width = TableFirstColumnWidth;
            }
        }
        catch (Exception ex)
        {
            // Display error message, if data load fail
            lblError.Visible = true;
            lblError.Text    = "[ReportTable.ascx] Error loading the data: " + ex.Message;
            EventLogProvider ev = new EventLogProvider();
            ev.LogEvent("Report table", "E", ex);
            errorOccurred = true;
        }
    }
Example #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        usReports.OnSelectionChanged += usReports_OnSelectionChanged;
        string [,] specialFields      = new string [1, 2];

        pnlReports.Attributes.Add("style", "margin-bottom:3px");

        string     reportName = ValidationHelper.GetString(usReports.Value, String.Empty);
        ReportInfo ri         = ReportInfoProvider.GetReportInfo(reportName);

        if (ri != null)
        {
            usItems.Enabled = true;
            //test if there is any item visible in report parameters
            FormInfo fi = new FormInfo(ri.ReportParameters);

            //Get dataset from cache
            DataSet ds = (DataSet)WindowHelper.GetItem(hdnGuid.Value);
            DataRow dr = fi.GetDataRow();
            fi.LoadDefaultValues(dr);
            bool            itemVisible = false;
            List <FormItem> items       = fi.ItemsList;
            foreach (FormItem item in items)
            {
                FormFieldInfo ffi = item as FormFieldInfo;
                if (ffi != null)
                {
                    if (ffi.Visible)
                    {
                        itemVisible = true;
                        break;
                    }
                }
            }

            ReportID = ri.ReportID;

            if (!itemVisible)
            {
                plcParametersButtons.Visible = false;
            }
            else
            {
                plcParametersButtons.Visible = true;
            }
        }
        else
        {
            plcParametersButtons.Visible = false;
            usItems.Enabled = false;
        }

        ltlScript.Text = ScriptHelper.GetScript("function refresh () {" + ControlsHelper.GetPostBackEventReference(pnlUpdate, String.Empty) + "}");
        usReports.DropDownSingleSelect.AutoPostBack = true;

        if (!mDisplay)
        {
            pnlReports.Visible           = false;
            plcParametersButtons.Visible = false;
            usItems.Enabled = true;
        }

        if (!ShowItemSelector)
        {
            pnlItems.Visible = false;
        }

        usItems.IsLiveSite                 = IsLiveSite;
        usReports.IsLiveSite               = IsLiveSite;
        ugParameters.GridName              = "~/CMSModules/Reporting/FormControls/ReportParametersList.xml";
        ugParameters.ZeroRowsText          = String.Empty;
        ugParameters.PageSize              = "##ALL##";
        ugParameters.Pager.DefaultPageSize = -1;

        BuildConditions();

        // First item as "please select string" - not default "none"
        usItems.AllowEmpty      = false;
        usReports.AllowEmpty    = false;
        specialFields[0, 0]     = "(" + GetString("rep.pleaseselect") + ")";
        specialFields[0, 1]     = "0";
        usReports.SpecialFields = specialFields;

        if (ri == null)
        {
            string[,] itemSpecialFields = new string[1, 2];
            itemSpecialFields[0, 0]     = "(" + firstItemText + ")";
            itemSpecialFields[0, 1]     = "0";
            usItems.SpecialFields       = itemSpecialFields;
        }

        if (ShowItemSelector)
        {
            ReloadItems();
        }
    }
    protected override void OnPreRender(EventArgs e)
    {
        string reportName = ValidationHelper.GetString(usReports.Value, String.Empty);

        mReportInfo = ReportInfoProvider.GetReportInfo(reportName);
        if (mReportInfo != null)
        {
            ReportID = mReportInfo.ReportID;

            usItems.Enabled = true;

            // Test if there is any item visible in report parameters
            FormInfo fi = new FormInfo(mReportInfo.ReportParameters);

            // Hide if there are no visible parameters
            pnlParametersButtons.Visible = fi.GetFields(true, false).Any();
        }
        else
        {
            if (ReportID == 0)
            {
                pnlParametersButtons.Visible = false;
                usItems.Enabled = false;
            }
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "ReportItemSelector_Refresh", "function refresh () {" + ControlsHelper.GetPostBackEventReference(pnlUpdate, String.Empty) + "}", true);

        if (!mDisplay)
        {
            pnlReports.Visible           = false;
            pnlParametersButtons.Visible = false;
            usItems.Enabled = true;
        }

        if (!ShowItemSelector)
        {
            pnlItems.Visible = false;
        }

        BuildConditions();

        if (mReportInfo == null)
        {
            usItems.SpecialFields.Add(new SpecialField {
                Text = "(" + mFirstItemText + ")", Value = "0"
            });
        }

        if (ShowItemSelector)
        {
            ReloadItems();
        }

        var currentGuid = CurrentGuid();

        if (mSetValues)
        {
            WindowHelper.Add(currentGuid, CurrentDataSet);
            ScriptHelper.RegisterDialogScript(Page);
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "OpenModalWindowReportItem", ScriptHelper.GetScript("modalDialog('" + ResolveUrl("~/CMSModules/Reporting/Dialogs/ReportParametersSelector.aspx?ReportID=" + ReportID + "&guid=" + currentGuid) + "','ReportParametersDialog', 700, 500);"));
            mKeepDataInWindowsHelper = true;
        }

        // Apply reportid condition if report was selected via uniselector
        if (mReportInfo != null)
        {
            DataSet ds = CurrentDataSet;

            ViewState["ParametersXmlData"]   = null;
            ViewState["ParametersXmlSchema"] = null;

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                ViewState["ParametersXmlData"]   = ds.GetXml();
                ViewState["ParametersXmlSchema"] = ds.GetXmlSchema();
            }

            if (!mKeepDataInWindowsHelper)
            {
                WindowHelper.Remove(currentGuid);
            }

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                ds = DataHelper.DataSetPivot(ds, new [] { "ParameterName", "ParameterValue" });
                ugParameters.DataSource = ds;
                ugParameters.ReloadData();
                pnlParameters.Visible = true;
            }
            else
            {
                pnlParameters.Visible = false;
            }
        }
        else
        {
            pnlParameters.Visible = false;
        }

        if (pnlParameters.Visible || pnlParametersButtons.Visible)
        {
            pnlItems.AddCssClass("form-group");
        }
        else
        {
            pnlItems.RemoveCssClass("form-group");
        }

        base.OnPreRender(e);
    }
Example #21
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check 'Modify' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.reporting", "Modify"))
        {
            RedirectToAccessDenied("cms.reporting", "Modify");
        }


        string errorMessage = new Validator().NotEmpty(txtReportDisplayName.Text.Trim(), rfvReportDisplayName.ErrorMessage).NotEmpty(txtReportName.Text.Trim(), rfvReportName.ErrorMessage).Result;

        if ((errorMessage == "") && (!ValidationHelper.IsCodeName(txtReportName.Text.Trim())))
        {
            errorMessage = GetString("general.invalidcodename");
        }

        if (ReportCategoryInfoProvider.GetReportCategoryInfo(categoryId) == null)
        {
            errorMessage = GetString("Report_General.InvalidReportCategory");
        }

        ReportAccessEnum reportAccess = ReportAccessEnum.All;

        if (!chkReportAccess.Checked)
        {
            reportAccess = ReportAccessEnum.Authenticated;
        }

        if (errorMessage == "")
        {
            //if report with given name already exists show error message
            if (ReportInfoProvider.GetReportInfo(txtReportName.Text.Trim()) != null)
            {
                ShowError(GetString("Report_New.ReportAlreadyExists"));
                return;
            }

            ReportInfo ri = new ReportInfo();

            ri.ReportDisplayName        = txtReportDisplayName.Text.Trim();
            ri.ReportName               = txtReportName.Text.Trim();
            ri.ReportCategoryID         = categoryId;
            ri.ReportLayout             = "";
            ri.ReportParameters         = "";
            ri.ReportAccess             = reportAccess;
            ri.ReportEnableSubscription = chkEnableSubscription.Checked;

            ReportInfoProvider.SetReportInfo(ri);

            ltlScript.Text += "<script type=\"text/javascript\">";
            ltlScript.Text += @"if (parent.frames['reportcategorytree'])
                                {
                                    parent.frames['reportcategorytree'].location.href = 'ReportCategory_tree.aspx?reportid=" + ri.ReportID + @"';
                                }
                                if (parent.parent.frames['reportcategorytree'])
                                {
                                    parent.parent.frames['reportcategorytree'].location.href = 'ReportCategory_tree.aspx?reportid=" + ri.ReportID + @"';
                                }
                 this.location.href = 'Report_Edit.aspx?reportId=" + Convert.ToString(ri.ReportID) + @"&saved=1&categoryID=" + categoryId + @"'
                </script>";
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Example #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope               = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible        = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        if (mReportInfo != null) //must be valid reportid parameter
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;

            // If preview by URL -> select preview tab
            bool isPreview = QueryHelper.GetBoolean("preview", false);
            if (isPreview && !RequestHelper.IsPostBack())
            {
                tabControlElem.SelectedTab = 1;
            }

            if (PersistentEditedObject == null)
            {
                int id = QueryHelper.GetInteger("objectid", 0);
                if (id > 0)
                {
                    PersistentEditedObject = ReportValueInfoProvider.GetReportValueInfo(id);
                    mReportValueInfo       = PersistentEditedObject as ReportValueInfo;
                }
            }
            else
            {
                mReportValueInfo = PersistentEditedObject as ReportValueInfo;
            }

            if (mReportValueInfo != null)
            {
                PageTitle.TitleText = GetString("Reporting_ReportValue_Edit.TitleText");
                mValueId            = mReportValueInfo.ValueID;

                if (ObjectVersionManager.DisplayVersionsTab(mReportValueInfo))
                {
                    tabControlElem.TabItems.Add(new UITabItem
                    {
                        Text = GetString("objectversioning.tabtitle")
                    });

                    versionList.Object     = mReportValueInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else //new item
            {
                PageTitle.TitleText     = GetString("Reporting_ReportValue_Edit.NewItemTitleText");
                chkSubscription.Checked = true;

                if (!RequestHelper.IsPostBack())
                {
                    ucSelectString.Value = String.Empty;
                }
            }

            if (!RequestHelper.IsPostBack())
            {
                LoadData();
            }
        }
        else
        {
            ShowError(GetString("Reporting_ReportValue_Edit.InvalidReportId"));
        }

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        if (preview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
Example #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope               = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible        = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        // Register common resize and refresh scripts
        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        // If preview by URL -> select preview tab
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        if (isPreview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
        }

        if (PersistentEditedObject == null)
        {
            if (mReportInfo != null) // Must be valid reportid parameter
            {
                int id = QueryHelper.GetInteger("objectid", 0);

                // Try to load tableName from hidden field (adding new graph & preview)
                if (id == 0)
                {
                    id = ValidationHelper.GetInteger(txtNewTableHidden.Value, 0);
                }

                if (id > 0)
                {
                    PersistentEditedObject = ReportTableInfoProvider.GetReportTableInfo(id);
                    mReportTableInfo       = PersistentEditedObject as ReportTableInfo;
                }
            }
        }
        else
        {
            mReportTableInfo = PersistentEditedObject as ReportTableInfo;
        }

        if (mReportInfo != null)
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;

            // Control text initializations
            if (mReportTableInfo != null)
            {
                PageTitle.TitleText = GetString("Reporting_ReportTable_Edit.TitleText");
                mTableId            = mReportTableInfo.TableID;

                if (ObjectVersionManager.DisplayVersionsTab(mReportTableInfo))
                {
                    tabControlElem.TabItems.Add(new UITabItem
                    {
                        Text = GetString("objectversioning.tabtitle")
                    });

                    versionList.Object     = mReportTableInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else // New item
            {
                PageTitle.TitleText = GetString("Reporting_ReportTable_Edit.NewItemTitleText");
                if (!RequestHelper.IsPostBack())
                {
                    ucSelectString.Value      = String.Empty;
                    txtPageSize.Text          = "15";
                    txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                    chkExportEnable.Checked   = true;
                    chkSubscription.Checked   = true;
                }
            }

            if (!RequestHelper.IsPostBack())
            {
                ControlsHelper.FillListControlWithEnum <PagerButtons>(drpPageMode, "PagerButtons");
                // Preselect page numbers paging
                drpPageMode.SelectedValue = ((int)PagerButtons.Numeric).ToString();

                LoadData();
            }
        }

        if ((preview) && (!RequestHelper.IsPostBack()))
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        // In case of preview paging without saving table
        if (RequestHelper.IsPostBack() && tabControlElem.SelectedTab == 1)
        {
            // Reload default parameters
            FormInfo fi = new FormInfo(mReportInfo.ReportParameters);

            // Get datarow with required columns
            ctrlReportTable.ReportParameters = fi.GetDataRow(false);
            fi.LoadDefaultValues(ctrlReportTable.ReportParameters, true);

            // Collect data and put them in table info
            SetData();
            ctrlReportTable.TableInfo = mReportTableInfo;
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope                    = ReportInfo.OBJECT_TYPE;
        ConnectionStringRow.Visible             = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        txtQueryQuery.FullScreenParentElementID = pnlWebPartForm_Properties.ClientID;

        // Test permission for query
        txtQueryQuery.Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries");

        versionList.OnAfterRollback += versionList_onAfterRollback;

        // Register script for resize and rollback
        RegisterResizeAndRollbackScript("divFooter", divScrolable.ClientID);

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.general")
        });

        tabControlElem.TabItems.Add(new UITabItem
        {
            Text = GetString("general.preview")
        });

        tabControlElem.UsePostback = true;

        Title = "ReportGraph Edit";
        PageTitle.HelpTopicName = HELP_TOPIC_LINK;

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        Save += (s, ea) =>
        {
            if (SetData(true))
            {
                ltlScript.Text += ScriptHelper.GetScript("window.RefreshContent();CloseDialog();");
            }
        };

        int  reportId  = QueryHelper.GetInteger("reportid", 0);
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        // If preview by URL -> select preview tab
        if (isPreview && !RequestHelper.IsPostBack())
        {
            tabControlElem.SelectedTab = 1;
        }

        if (reportId > 0)
        {
            mReportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        if (PersistentEditedObject == null)
        {
            if (mReportInfo != null) //must be valid reportid parameter
            {
                int id = QueryHelper.GetInteger("objectid", 0);

                // Try to load graph name from hidden field (adding new graph & preview)
                if (id == 0)
                {
                    id = ValidationHelper.GetInteger(txtNewGraphHidden.Value, 0);
                }

                if (id > 0)
                {
                    PersistentEditedObject = ReportGraphInfoProvider.GetReportGraphInfo(id);
                    mReportGraphInfo       = PersistentEditedObject as ReportGraphInfo;
                }
            }
        }
        else
        {
            mReportGraphInfo = PersistentEditedObject as ReportGraphInfo;
        }

        if (mReportInfo != null)
        {
            ucSelectString.DefaultConnectionString = mReportInfo.ReportConnectionString;
        }

        if (mReportGraphInfo != null)
        {
            PageTitle.TitleText = GetString("Reporting_ReportGraph_EditHTML.TitleText");
            mGraphId            = mReportGraphInfo.GraphID;

            if (ObjectVersionManager.DisplayVersionsTab(mReportGraphInfo))
            {
                tabControlElem.TabItems.Add(new UITabItem
                {
                    Text = GetString("objectversioning.tabtitle")
                });

                versionList.Object     = mReportGraphInfo;
                versionList.IsLiveSite = false;
            }
        }
        else
        {
            PageTitle.TitleText = GetString("Reporting_ReportGraph_EditHTML.NewItemTitleText");
            mNewReport          = true;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Load default data for new report
            if (mNewReport)
            {
                ucSelectString.Value      = String.Empty;
                txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                txtItemValueFormat.Text   = "{%yval%}";
                txtSeriesItemTooltip.Text = "{%ser%}";
                chkExportEnable.Checked   = true;
                chkSubscription.Checked   = true;
            }
            // Otherwise load saved data
            else
            {
                LoadData();
            }
        }

        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");
        CurrentMaster.PanelContent.RemoveCssClass("ModalDialogContent");
    }
Example #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "Report General";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReloadPage", ScriptHelper.GetScript("function ReloadPage() { \n" + Page.ClientScript.GetPostBackEventReference(btnHdnReload, null) + "}"));

        reportId = ValidationHelper.GetInteger(Request.QueryString["reportId"], 0);

        // control initializations
        rfvReportDisplayName.ErrorMessage = GetString("Report_New.EmptyDisplayName");
        rfvReportName.ErrorMessage        = GetString("Report_New.EmptyCodeName");

        lblReportDisplayName.Text = GetString("Report_New.DisplayNameLabel");
        lblReportName.Text        = GetString("Report_New.NameLabel");
        lblReportCategory.Text    = GetString("Report_General.CategoryLabel");
        lblLayout.Text            = GetString("Report_General.LayoutLabel");
        lblGraphs.Text            = GetString("Report_General.GraphsLabel") + ":";
        lblHtmlGraphs.Text        = GetString("Report_General.HtmlGraphsLabel") + ":";
        lblTables.Text            = GetString("Report_General.TablesLabel") + ":";
        lblValues.Text            = GetString("Report_General.TablesValues") + ":";
        lblReportAccess.Text      = GetString("Report_General.ReportAccessLabel");

        ScriptHelper.RegisterSaveShortcut(lnkSave, null, false);

        imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        mSave            = GetString("general.save");

        AttachmentTitle.TitleText = GetString("general.attachments");

        attachmentList.AllowPasteAttachments = true;
        attachmentList.ObjectID   = reportId;
        attachmentList.ObjectType = ReportingObjectType.REPORT;
        attachmentList.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_LAYOUT;

        // Get report info
        ri = ReportInfoProvider.GetReportInfo(reportId);

        if (!RequestHelper.IsPostBack())
        {
            LoadData();
        }

        htmlTemplateBody.AutoDetectLanguage = false;
        htmlTemplateBody.DefaultLanguage    = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
        htmlTemplateBody.EditorAreaCSS      = "";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReportingHTML", ScriptHelper.GetScript(" var reporting_htmlTemplateBody = '" + htmlTemplateBody.ClientID + "'"));

        // initialize item list controls
        ilGraphs.Report     = ri;
        ilTables.Report     = ri;
        ilValues.Report     = ri;
        ilHtmlGraphs.Report = ri;

        ilGraphs.EditUrl     = "ReportGraph_Edit.aspx";
        ilTables.EditUrl     = "ReportTable_Edit.aspx";
        ilValues.EditUrl     = "ReportValue_Edit.aspx";
        ilHtmlGraphs.EditUrl = "ReportHtmlGraph_Edit.aspx";

        ilGraphs.ItemType     = ReportItemType.Graph;
        ilTables.ItemType     = ReportItemType.Table;
        ilValues.ItemType     = ReportItemType.Value;
        ilHtmlGraphs.ItemType = ReportItemType.HtmlGraph;
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void SaveReport()
    {
        // Check 'Modify' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "Modify"))
        {
            RedirectToAccessDenied("cms.reporting", "Modify");
        }
        string errorMessage = new Validator().NotEmpty(txtReportDisplayName.Text.Trim(), rfvReportDisplayName.ErrorMessage).NotEmpty(txtReportName.Text.Trim(), rfvReportName.ErrorMessage).Result;

        if (String.IsNullOrEmpty(errorMessage) && (!ValidationHelper.IsCodeName(txtReportName.Text.Trim())))
        {
            errorMessage = GetString("general.invalidcodename");
        }

        ReportAccessEnum reportAccess = ReportAccessEnum.All;

        if (!chkReportAccess.Checked)
        {
            reportAccess = ReportAccessEnum.Authenticated;
        }

        if (String.IsNullOrEmpty(errorMessage))
        {
            ReportInfo reportInfo = ReportInfoProvider.GetReportInfo(reportId);
            ReportInfo nri        = ReportInfoProvider.GetReportInfo(txtReportName.Text.Trim());

            // If report with given name already exists show error message
            if ((nri != null) && (nri.ReportID != reportInfo.ReportID))
            {
                ShowError(GetString("Report_New.ReportAlreadyExists"));
                return;
            }

            if (reportInfo != null)
            {
                reportInfo.ReportLayout = htmlTemplateBody.ResolvedValue;

                // If there was a change in report code name change codenames in layout
                if (reportInfo.ReportName != txtReportName.Text.Trim())
                {
                    // part of old macro
                    string oldValue = "?" + reportInfo.ReportName + ".";
                    string newValue = "?" + txtReportName.Text.Trim() + ".";

                    reportInfo.ReportLayout = reportInfo.ReportLayout.Replace(oldValue, newValue);

                    // Set updated text back to HTML editor
                    htmlTemplateBody.ResolvedValue = reportInfo.ReportLayout;
                }
                int categoryID = ValidationHelper.GetInteger(selectCategory.Value, reportInfo.ReportCategoryID);

                // If there was a change in display name refresh category tree
                if ((reportInfo.ReportDisplayName != txtReportDisplayName.Text.Trim()) || (reportInfo.ReportCategoryID != categoryID))
                {
                    ltlScript.Text += ScriptHelper.GetScript(@"if ((parent != null) && (parent.Refresh != null)) {parent.Refresh();}");
                }

                reportInfo.ReportDisplayName        = txtReportDisplayName.Text.Trim();
                reportInfo.ReportName               = txtReportName.Text.Trim();
                reportInfo.ReportAccess             = reportAccess;
                reportInfo.ReportCategoryID         = categoryID;
                reportInfo.ReportEnableSubscription = chkEnableSubscription.Checked;
                reportInfo.ReportConnectionString   = ValidationHelper.GetString(ucSelectString.Value, String.Empty);

                ReportInfoProvider.SetReportInfo(reportInfo);

                ShowChangesSaved();

                // Reload header if changes were saved
                ScriptHelper.RefreshTabHeader(Page, reportInfo.ReportDisplayName);
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Example #27
0
    protected override void OnInit(EventArgs e)
    {
        // Security check
        UseCMSDeskAccessDeniedPage = !IsLiveSite;
        var  cui        = MembershipContext.AuthenticatedUser;
        bool haveModify = cui.IsAuthorizedPerResource("cms.reporting", "modify");

        if (!(cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || haveModify))
        {
            RedirectToAccessDenied("cms.reporting", "Subscribe");
        }

        // Init validators
        rfvEmail.Text   = GetString("om.contact.enteremail");
        rfvSubject.Text = GetString("bizformgeneral.emptyemailsubject");

        var subscriptionId = QueryHelper.GetInteger("SubscriptionID", 0);

        mReportSubscriptionInfo = subscriptionId > 0
            ? ReportSubscriptionInfoProvider.GetReportSubscriptionInfo(QueryHelper.GetInteger("SubscriptionID", 0))
            : new ReportSubscriptionInfo();

        // Set edited object
        EditedObject = mReportSubscriptionInfo;

        int    reportID   = QueryHelper.GetInteger("ReportID", 0);
        string reportName = QueryHelper.GetString("reportName", String.Empty);

        if (reportID != 0)
        {
            Report = ReportInfoProvider.GetReportInfo(reportID);
        }
        else if (!String.IsNullOrEmpty(reportName))
        {
            Report = ReportInfoProvider.GetReportInfo(reportName);
        }
        else
        {
            if (mReportSubscriptionInfo.ReportSubscriptionID > 0)
            {
                // If no report specified, get it from subscription
                Report = ReportInfoProvider.GetReportInfo(mReportSubscriptionInfo.ReportSubscriptionReportID);
            }
        }

        if ((mReportSubscriptionInfo.ReportSubscriptionID > 0) && !haveModify && !SimpleMode)
        {
            if (mReportSubscriptionInfo.ReportSubscriptionUserID != cui.UserID)
            {
                RedirectToAccessDenied(GetString("reportsubscription.onlymodifyusersallowed"));
            }
        }

        if (Report == null)
        {
            return;
        }

        // Set interval control for subscription mode
        ucInterval.DisplayStartTime = false;
        ucInterval.DisplayOnce      = false;
        ucInterval.DisplaySecond    = false;

        if (!RequestHelper.IsPostBack())
        {
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.hours"), "hour"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.days"), "day"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.weeks"), "week"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.months"), "month"));
            drpLast.Items.Add(new ListItem(GetString("reportsubscription.years"), "year"));
        }

        if (SimpleMode)
        {
            LoadAdHoc();
        }
        else
        {
            LoadData();
        }

        // Show save changes after new object created
        if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
        {
            ShowChangesSaved();
        }

        base.OnInit(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ucSelectString.Scope        = ReportInfo.OBJECT_TYPE;
        pnlConnectionString.Visible = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString");
        Title = "Report General";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReloadPage", ScriptHelper.GetScript("function ReloadPage() { \n" + Page.ClientScript.GetPostBackEventReference(btnHdnReload, null) + "}"));

        reportId = QueryHelper.GetInteger("reportId", 0);

        // control initializations
        rfvReportDisplayName.ErrorMessage = GetString("Report_New.EmptyDisplayName");
        rfvReportName.ErrorMessage        = GetString("Report_New.EmptyCodeName");

        lblReportDisplayName.Text = GetString("Report_New.DisplayNameLabel");
        lblReportName.Text        = GetString("Report_New.NameLabel");
        lblReportCategory.Text    = GetString("Report_General.CategoryLabel");
        lblLayout.Text            = GetString("Report_General.LayoutLabel");
        lblGraphs.Text            = GetString("Report_General.GraphsLabel") + ":";
        lblHtmlGraphs.Text        = GetString("Report_General.HtmlGraphsLabel") + ":";
        lblTables.Text            = GetString("Report_General.TablesLabel") + ":";
        lblValues.Text            = GetString("Report_General.TablesValues") + ":";
        lblReportAccess.Text      = GetString("Report_General.ReportAccessLabel");

        actionsElem.ActionsList.Add(new SaveAction(Page));
        actionsElem.ActionPerformed += actionsElem_ActionPerformed;

        AttachmentTitle.TitleText = GetString("general.attachments");

        attachmentList.AllowPasteAttachments = true;
        attachmentList.ObjectID   = reportId;
        attachmentList.ObjectType = ReportInfo.OBJECT_TYPE;
        attachmentList.Category   = ObjectAttachmentsCategories.LAYOUT;

        // Get report info
        ri = ReportInfoProvider.GetReportInfo(reportId);

        if (!RequestHelper.IsPostBack())
        {
            LoadData();
        }

        htmlTemplateBody.AutoDetectLanguage = false;
        htmlTemplateBody.DefaultLanguage    = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
        htmlTemplateBody.EditorAreaCSS      = "";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReportingHTML", ScriptHelper.GetScript(" var reporting_htmlTemplateBody = '" + htmlTemplateBody.ClientID + "'"));

        // initialize item list controls
        ilGraphs.Report     = ri;
        ilTables.Report     = ri;
        ilValues.Report     = ri;
        ilHtmlGraphs.Report = ri;

        ilGraphs.EditUrl     = "ReportGraph_Edit.aspx";
        ilTables.EditUrl     = "ReportTable_Edit.aspx";
        ilValues.EditUrl     = "ReportValue_Edit.aspx";
        ilHtmlGraphs.EditUrl = "ReportHtmlGraph_Edit.aspx";

        ilGraphs.ItemType     = ReportItemType.Graph;
        ilTables.ItemType     = ReportItemType.Table;
        ilValues.ItemType     = ReportItemType.Value;
        ilHtmlGraphs.ItemType = ReportItemType.HtmlGraph;

        // Refresh script
        string script = "function RefreshWOpener(w) { if (w.refreshPageOnClose){ " + ControlsHelper.GetPostBackEventReference(this, "arg") + " }}";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReportingRefresh", ScriptHelper.GetScript(script));
    }
Example #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Test permission for query
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Reporting", "EditSQLQueries"))
        {
            txtQuery.Enabled = false;
        }
        else
        {
            txtQuery.Enabled = true;
        }

        versionList.OnAfterRollback += new EventHandler(versionList_onAfterRollback);

        // Own javascript tab change handling -> because tab control raises changetab after prerender - too late
        // Own selected tab change handling
        RegisterTabScript(hdnSelectedTab.ClientID, tabControlElem);

        // Register common resize and refresh scripts
        RegisterResizeAndRollbackScript(divFooter.ClientID, divScrolable.ClientID);

        string[,] tabs = new string[4, 4];
        tabs[0, 0]     = GetString("general.general");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'report_table_properties')";
        tabs[1, 0]     = GetString("general.preview");
        tabs[0, 1]     = "SetHelpTopic('helpTopic', 'report_table_properties')";

        tabControlElem.Tabs               = tabs;
        tabControlElem.UsePostback        = true;
        CurrentMaster.Title.HelpName      = "helpTopic";
        CurrentMaster.Title.HelpTopicName = "report_table_properties";
        CurrentMaster.Title.TitleCssClass = "PageTitleHeader";

        rfvCodeName.ErrorMessage    = GetString("general.requirescodename");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        btnApply.Text  = GetString("General.apply");
        btnOk.Text     = GetString("General.OK");
        btnCancel.Text = GetString("General.Cancel");

        int  reportId = QueryHelper.GetInteger("reportid", 0);
        bool preview  = QueryHelper.GetBoolean("preview", false);

        if (reportId > 0)
        {
            reportInfo = ReportInfoProvider.GetReportInfo(reportId);
        }

        // If preview by URL -> select preview tab
        bool isPreview = QueryHelper.GetBoolean("preview", false);

        if (isPreview && !RequestHelper.IsPostBack())
        {
            SelectedTab = 1;
        }

        if (PersistentEditedObject == null)
        {
            if (reportInfo != null) // Must be valid reportid parameter
            {
                string tableName = ValidationHelper.GetString(Request.QueryString["itemname"], "");

                // Try to load tableName from hidden field (adding new graph & preview)
                if (tableName == String.Empty)
                {
                    tableName = txtNewTableHidden.Value;
                }

                if (ValidationHelper.IsIdentifier(tableName))
                {
                    PersistentEditedObject = ReportTableInfoProvider.GetReportTableInfo(reportInfo.ReportName + "." + tableName);
                    tableInfo = PersistentEditedObject as ReportTableInfo;
                }
            }
        }
        else
        {
            tableInfo = PersistentEditedObject as ReportTableInfo;
        }

        if (reportInfo != null)
        {
            // Control text initializations
            if (tableInfo != null)
            {
                CurrentMaster.Title.TitleText  = GetString("Reporting_ReportTable_Edit.TitleText");
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportTable/object.png");

                tableId = tableInfo.TableID;

                if (ObjectVersionManager.DisplayVersionsTab(tableInfo))
                {
                    tabs[2, 0] = GetString("objectversioning.tabtitle");
                    tabs[2, 1] = "SetHelpTopic('helpTopic', 'objectversioning_general');";

                    versionList.Object     = tableInfo;
                    versionList.IsLiveSite = false;
                }
            }
            else // New item
            {
                CurrentMaster.Title.TitleText  = GetString("Reporting_ReportTable_Edit.NewItemTitleText");
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Reporting_ReportTable/new.png");

                if (!RequestHelper.IsPostBack())
                {
                    txtPageSize.Text          = "15";
                    txtQueryNoRecordText.Text = GetString("attachmentswebpart.nodatafound");
                    chkExportEnable.Checked   = true;
                }

                newTable = true;
            }

            // Set help key
            CurrentMaster.Title.HelpTopicName = "report_table_properties";

            if (!RequestHelper.IsPostBack())
            {
                DataHelper.FillListControlWithEnum(typeof(PagerButtons), drpPageMode, "PagerButtons.", null);
                // Preselect page numbers paging
                drpPageMode.SelectedValue = ((int)PagerButtons.Numeric).ToString();

                LoadData();
            }
        }

        if ((preview) && (!RequestHelper.IsPostBack()))
        {
            tabControlElem.SelectedTab = 1;
            ShowPreview();
        }

        // In case of preview paging without saving table
        if (RequestHelper.IsPostBack() && tabControlElem.SelectedTab == 1)
        {
            // Reload deafult parameters
            FormInfo fi = new FormInfo(reportInfo.ReportParameters);
            // Get datarow with required columns
            ctrlReportTable.ReportParameters = fi.GetDataRow();
            fi.LoadDefaultValues(ctrlReportTable.ReportParameters, true);

            // Colect data and put them in talbe info
            Save(false);
            ctrlReportTable.TableInfo = tableInfo;
        }
    }
Example #30
0
    protected override void OnPreRender(EventArgs e)
    {
        pnlReports.Attributes.Add("style", "margin-bottom:3px");

        string reportName = ValidationHelper.GetString(usReports.Value, String.Empty);

        ri = ReportInfoProvider.GetReportInfo(reportName);
        if (ri != null)
        {
            usItems.Enabled = true;

            // Test if there is any item visible in report parameters
            FormInfo fi = new FormInfo(ri.ReportParameters);

            // Get dataset from cache
            DataSet ds = (DataSet)WindowHelper.GetItem(CurrentGuid());
            DataRow dr = fi.GetDataRow();
            fi.LoadDefaultValues(dr);
            bool             itemVisible = false;
            List <IFormItem> items       = fi.ItemsList;
            foreach (IFormItem item in items)
            {
                FormFieldInfo ffi = item as FormFieldInfo;
                if (ffi != null)
                {
                    if (ffi.Visible)
                    {
                        itemVisible = true;
                        break;
                    }
                }
            }

            ReportID = ri.ReportID;

            if (!itemVisible)
            {
                plcParametersButtons.Visible = false;
            }
            else
            {
                plcParametersButtons.Visible = true;
            }
        }
        else
        {
            if (ReportID == 0)
            {
                plcParametersButtons.Visible = false;
                usItems.Enabled = false;
            }
        }

        ltlScript.Text = ScriptHelper.GetScript("function refresh () {" + ControlsHelper.GetPostBackEventReference(pnlUpdate, String.Empty) + "}");
        usReports.DropDownSingleSelect.AutoPostBack = true;

        if (!mDisplay)
        {
            pnlReports.Visible           = false;
            plcParametersButtons.Visible = false;
            usItems.Enabled = true;
        }

        if (!ShowItemSelector)
        {
            pnlItems.Visible = false;
        }

        usItems.IsLiveSite                 = IsLiveSite;
        usReports.IsLiveSite               = IsLiveSite;
        ugParameters.GridName              = "~/CMSModules/Reporting/FormControls/ReportParametersList.xml";
        ugParameters.ZeroRowsText          = String.Empty;
        ugParameters.PageSize              = "##ALL##";
        ugParameters.Pager.DefaultPageSize = -1;

        BuildConditions();

        if (ri == null)
        {
            string[,] itemSpecialFields = new string[1, 2];
            itemSpecialFields[0, 0]     = "(" + firstItemText + ")";
            itemSpecialFields[0, 1]     = "0";
            usItems.SpecialFields       = itemSpecialFields;
        }

        if (ShowItemSelector)
        {
            ReloadItems();
        }

        if (setValues)
        {
            WindowHelper.Add(CurrentGuid(), CurrentDataSet);
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "OpenModalWindowReportItem", ScriptHelper.GetScript("modalDialog('" + ResolveUrl("~/CMSModules/Reporting/Dialogs/ReportParametersSelector.aspx?ReportID=" + ReportID + "&guid=" + CurrentGuid().ToString()) + "','ReportParametersDialog', 700, 500);"));
            keepDataInWindowsHelper = true;
        }

        // Apply reportid condition if report was selected via uniselector
        if (ri != null)
        {
            FormInfo fi = new FormInfo(ri.ReportParameters);
            DataRow  dr = fi.GetDataRow();
            DataSet  ds = CurrentDataSet;

            ViewState["ParametersXmlData"]   = null;
            ViewState["ParametersXmlSchema"] = null;

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                ViewState["ParametersXmlData"]   = ds.GetXml();
                ViewState["ParametersXmlSchema"] = ds.GetXmlSchema();
            }

            if (!keepDataInWindowsHelper)
            {
                WindowHelper.Remove(CurrentGuid().ToString());
            }

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                ds = DataHelper.DataSetPivot(ds, new string[] { "ParameterName", "ParameterValue" });
                ugParameters.DataSource = ds;
                ugParameters.ReloadData();
                pnlParameters.Visible = true;
            }
            else
            {
                pnlParameters.Visible = false;
            }
        }
        else
        {
            pnlParameters.Visible = false;
        }

        base.OnPreRender(e);
    }