Пример #1
0
    /// <summary>
    /// Gets and bulk updates report values. Called when the "Get and bulk update values" button is pressed.
    /// Expects the CreateReportValue method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateReportValues()
    {
        // Prepare the parameters
        string where = "ValueName LIKE N'MyNewValue%'";

        // Get the data
        DataSet values = ReportValueInfoProvider.GetValues(where, null);

        if (!DataHelper.DataSourceIsEmpty(values))
        {
            // Loop through the individual items
            foreach (DataRow valueDr in values.Tables[0].Rows)
            {
                // Create object from DataRow
                ReportValueInfo modifyValue = new ReportValueInfo(valueDr);

                // Update the properties
                modifyValue.ValueDisplayName = modifyValue.ValueDisplayName.ToUpper();

                // Save the changes
                ReportValueInfoProvider.SetReportValueInfo(modifyValue);
            }

            return(true);
        }

        return(false);
    }
Пример #2
0
    /// <summary>
    /// Fill items dropdown
    /// </summary>
    private void FillItems()
    {
        drpItems.Items.Add(new ListItem(GetString("reportsubscription.wholereport"), "all"));

        // Fill graphs
        DataSet ds = ReportGraphInfoProvider.GetGraphs("GraphReportID=" + Report.ReportID, String.Empty);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                String displayName = ValidationHelper.GetString(dr["GraphDisplayName"], String.Empty);
                String id          = ValidationHelper.GetString(dr["GraphID"], String.Empty);
                drpItems.Items.Add(new ListItem(String.Format("{0} ({1})", displayName, GetString("reporting.graph")), "g" + id));
            }
        }

        // Fill tables
        ds = ReportTableInfoProvider.GetTables("TableReportID=" + Report.ReportID, String.Empty);
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                String displayName = ValidationHelper.GetString(dr["TableDisplayName"], String.Empty);
                String id          = ValidationHelper.GetString(dr["TableID"], String.Empty);
                drpItems.Items.Add(new ListItem(String.Format("{0} ({1})", displayName, GetString("reporting.table")), "t" + id));
            }
        }

        // Fill values
        ds = ReportValueInfoProvider.GetValues("ValueReportID=" + Report.ReportID, String.Empty);
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                String displayName = ValidationHelper.GetString(dr["ValueDisplayName"], String.Empty);
                String id          = ValidationHelper.GetString(dr["ValueID"], String.Empty);
                drpItems.Items.Add(new ListItem(String.Format("{0} ({1})", displayName, GetString("reporting.value")), "v" + id));
            }
        }

        // Select value in dropdown based on non empty key in object
        if (mReportSubscriptionInfo.ReportSubscriptionID > 0)
        {
            if (mReportSubscriptionInfo.ReportSubscriptionGraphID != 0)
            {
                drpItems.SelectedValue = "g" + mReportSubscriptionInfo.ReportSubscriptionGraphID;
            }

            if (mReportSubscriptionInfo.ReportSubscriptionTableID != 0)
            {
                drpItems.SelectedValue = "t" + mReportSubscriptionInfo.ReportSubscriptionTableID;
            }

            if (mReportSubscriptionInfo.ReportSubscriptionValueID != 0)
            {
                drpItems.SelectedValue = "v" + mReportSubscriptionInfo.ReportSubscriptionValueID;
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Clones the given report (including attachment files).
    /// </summary>
    /// <param name="reportId">Report id</param>
    protected void Clone(int reportId)
    {
        // Check 'Modify' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.reporting", "Modify"))
        {
            RedirectToAccessDenied("cms.reporting", "Modify");
        }

        // Try to get report info
        ReportInfo oldri = ReportInfoProvider.GetReportInfo(reportId);

        if (oldri == null)
        {
            return;
        }

        DataSet graph_ds = ReportGraphInfoProvider.GetGraphs(reportId);
        DataSet table_ds = ReportTableInfoProvider.GetTables(reportId);
        DataSet value_ds = ReportValueInfoProvider.GetValues(reportId);

        // Duplicate report info object
        ReportInfo ri = new ReportInfo(oldri, false);

        ri.ReportID   = 0;
        ri.ReportGUID = Guid.NewGuid();

        // Duplicate report info
        string reportName    = ri.ReportName;
        string oldReportName = ri.ReportName;

        string reportDispName = ri.ReportDisplayName;

        while (ReportInfoProvider.GetReportInfo(reportName) != null)
        {
            reportName     = Increment(reportName, "_", "", 100);
            reportDispName = Increment(reportDispName, "(", ")", 450);
        }

        ri.ReportName        = reportName;
        ri.ReportDisplayName = reportDispName;

        // Used to eliminate version from create object task
        using (CMSActionContext context = new CMSActionContext())
        {
            context.CreateVersion = false;
            ReportInfoProvider.SetReportInfo(ri);
        }

        string name;

        // Duplicate graph data
        if (!DataHelper.DataSourceIsEmpty(graph_ds))
        {
            foreach (DataRow dr in graph_ds.Tables[0].Rows)
            {
                // Duplicate the graph
                ReportGraphInfo rgi = new ReportGraphInfo(dr);
                rgi.GraphID       = 0;
                rgi.GraphGUID     = Guid.NewGuid();
                rgi.GraphReportID = ri.ReportID;
                name = rgi.GraphName;

                // Replace layout based on HTML or regular graph type
                ri.ReportLayout = ReplaceMacro(ri.ReportLayout, rgi.GraphIsHtml ? REP_HTMLGRAPH_MACRO : REP_GRAPH_MACRO, rgi.GraphName, name, oldReportName, reportName);
                rgi.GraphName   = name;

                ReportGraphInfoProvider.SetReportGraphInfo(rgi);
            }
        }

        // Duplicate table data
        if (!DataHelper.DataSourceIsEmpty(table_ds))
        {
            foreach (DataRow dr in table_ds.Tables[0].Rows)
            {
                // Duplicate the table
                ReportTableInfo rti = new ReportTableInfo(dr);
                rti.TableID       = 0;
                rti.TableGUID     = Guid.NewGuid();
                rti.TableReportID = ri.ReportID;
                name = rti.TableName;

                ri.ReportLayout = ReplaceMacro(ri.ReportLayout, REP_TABLE_MACRO, rti.TableName, name, oldReportName, reportName);
                rti.TableName   = name;

                ReportTableInfoProvider.SetReportTableInfo(rti);
            }
        }

        // Duplicate value data
        if (!DataHelper.DataSourceIsEmpty(value_ds))
        {
            foreach (DataRow dr in value_ds.Tables[0].Rows)
            {
                // Duplicate the value
                ReportValueInfo rvi = new ReportValueInfo(dr);
                rvi.ValueID       = 0;
                rvi.ValueGUID     = Guid.NewGuid();
                rvi.ValueReportID = ri.ReportID;
                name = rvi.ValueName;

                ri.ReportLayout = ReplaceMacro(ri.ReportLayout, REP_VALUE_MACRO, rvi.ValueName, name, oldReportName, reportName);
                rvi.ValueName   = name;

                ReportValueInfoProvider.SetReportValueInfo(rvi);
            }
        }

        List <Guid> convTable = new List <Guid>();

        try
        {
            MetaFileInfoProvider.CopyMetaFiles(reportId, ri.ReportID, ReportingObjectType.REPORT, MetaFileInfoProvider.OBJECT_CATEGORY_LAYOUT, convTable);
        }
        catch (Exception e)
        {
            lblError.Visible = true;
            lblError.Text    = e.Message;
            ReportInfoProvider.DeleteReportInfo(ri);
            return;
        }

        for (int i = 0; i < convTable.Count; i += 2)
        {
            Guid oldGuid = convTable[i];
            Guid newGuid = convTable[i + 1];
            ri.ReportLayout = ri.ReportLayout.Replace(oldGuid.ToString(), newGuid.ToString());
        }

        ReportInfoProvider.SetReportInfo(ri);

        // Refresh tree
        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>";
    }