Exemplo n.º 1
0
 /// <summary>
 /// When dialog's preview export button is clicked.
 /// </summary>
 protected void btnPreview_Click(object sender, EventArgs e)
 {
     try
     {
         DataExportFormatEnum format = (DataExportFormatEnum)Enum.Parse(typeof(DataExportFormatEnum), drpExportTo.SelectedItem.Value);
         ExportData(format, 100);
     }
     catch (Exception ex)
     {
         AddAlert(GetString("general.erroroccurred") + " " + ex.Message);
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// When postback is invoked to perform direct export.
    /// </summary>
    protected void btnFullPostback_Click(object sender, EventArgs e)
    {
        // Parse format to export
        string parameter = ValidationHelper.GetString(hdnParameter.Value, string.Empty);

        try
        {
            DataExportFormatEnum format = (DataExportFormatEnum)Enum.Parse(typeof(DataExportFormatEnum), parameter);
            ExportData(format);
        }
        catch (Exception ex)
        {
            AddAlert(GetString("general.erroroccurred") + " " + ex.Message);
        }
    }
    /// <summary>
    /// Exports data based on given format.
    /// </summary>
    /// <param name="format">Format to export data in</param>
    /// <param name="forceMaxItems">Max items count (for preview export)</param>
    private void ExportData(DataExportFormatEnum format, int?forceMaxItems = null)
    {
        UniGridExportHelper.ExportRawData   = chkExportRawData.Checked && UserCanEditSql;
        UniGridExportHelper.CSVDelimiter    = CurrentDelimiter;
        UniGridExportHelper.GenerateHeader  = chkExportHeader.Checked;
        UniGridExportHelper.CurrentPageOnly = chkCurrentPageOnly.Checked;
        UniGridExportHelper.Records         = ValidationHelper.GetInteger(txtRecords.Text, -1);

        // Preview export
        if (forceMaxItems != null)
        {
            int limit;

            if (UniGridExportHelper.CurrentPageOnly)
            {
                limit = UniGrid.Pager.DisplayPager ? UniGrid.Pager.CurrentPageSize : 0;
            }
            else
            {
                limit = UniGridExportHelper.Records;
            }
            if ((limit >= forceMaxItems) || (limit <= 0))
            {
                UniGridExportHelper.Records         = forceMaxItems.Value;
                UniGridExportHelper.CurrentPageOnly = false;
            }
        }

        // Get order by clause from correct control
        if (!chkCurrentPageOnly.Checked)
        {
            UniGridExportHelper.OrderBy        = UserCanEditSql ? TrimExtendedTextAreaValue(txtOrderBy.Text) : ValidationHelper.GetString(orderByElem.Value, null);
            UniGridExportHelper.WhereCondition = UserCanEditSql ? TrimExtendedTextAreaValue(txtWhereCondition.Text) : String.Empty;
        }
        UniGridExportHelper.Columns = GetSelectedColumns();

        if (UIContext.SiteID > 0)
        {
            UniGridExportHelper.SiteName = SiteInfoProvider.GetSiteName(UIContext.SiteID);
        }
        else if (IsCMSDesk)
        {
            UniGridExportHelper.SiteName = SiteContext.CurrentSiteName;
        }

        UniGridExportHelper.ExportData(format, Page.Response);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Exports data based on given format.
    /// </summary>
    /// <param name="format">Format to export data in</param>
    /// <param name="forceMaxItems">Max items count (for preview export)</param>
    private void ExportData(DataExportFormatEnum format, int?forceMaxItems = null)
    {
        UniGridExportHelper.ExportRawData   = chkExportRawData.Checked;
        UniGridExportHelper.CSVDelimiter    = CurrentDelimiter;
        UniGridExportHelper.GenerateHeader  = chkExportHeader.Checked;
        UniGridExportHelper.CurrentPageOnly = chkCurrentPageOnly.Checked;
        UniGridExportHelper.Records         = ValidationHelper.GetInteger(txtRecords.Text, -1);

        // Preview export
        if (forceMaxItems != null)
        {
            int limit = 0;
            if (UniGridExportHelper.CurrentPageOnly)
            {
                limit = UniGrid.Pager.DisplayPager ? UniGrid.Pager.CurrentPageSize : 0;
            }
            else
            {
                limit = UniGridExportHelper.Records;
            }
            if ((limit >= forceMaxItems) || (limit <= 0))
            {
                UniGridExportHelper.Records         = forceMaxItems.Value;
                UniGridExportHelper.CurrentPageOnly = false;
            }
        }

        UniGridExportHelper.UseGridFilter = chkUseGridFilter.Checked;
        // Get order by clause from correct control
        if (MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
        {
            UniGridExportHelper.OrderBy = TrimExtendedTextAreaValue(txtOrderBy.Text);
        }
        else
        {
            UniGridExportHelper.OrderBy = ValidationHelper.GetString(orderByElem.Value, null);
        }
        UniGridExportHelper.WhereCondition = TrimExtendedTextAreaValue(txtWhereCondition.Text);
        UniGridExportHelper.Columns        = GetSelectedColumns();
        if (IsCMSDesk)
        {
            UniGridExportHelper.SiteName = SiteContext.CurrentSiteName;
        }
        UniGridExportHelper.ExportData(format, Page.Response);
    }
    /// <summary>
    /// Exports data based on given format.
    /// </summary>
    /// <param name="format">Format to export data in</param>
    /// <param name="forceMaxItems">Max items count (for preview export)</param>
    private void ExportData(DataExportFormatEnum format, int? forceMaxItems = null)
    {
        UniGridExportHelper.ExportRawData = chkExportRawData.Checked;
        UniGridExportHelper.CSVDelimiter = CurrentDelimiter;
        UniGridExportHelper.GenerateHeader = chkExportHeader.Checked;
        UniGridExportHelper.CurrentPageOnly = chkCurrentPageOnly.Checked;
        UniGridExportHelper.Records = ValidationHelper.GetInteger(txtRecords.Text, -1);

        // Preview export
        if (forceMaxItems != null)
        {
            int limit;

            if (UniGridExportHelper.CurrentPageOnly)
            {
                limit = UniGrid.Pager.DisplayPager ? UniGrid.Pager.CurrentPageSize : 0;
            }
            else
            {
                limit = UniGridExportHelper.Records;
            }
            if ((limit >= forceMaxItems) || (limit <= 0))
            {
                UniGridExportHelper.Records = forceMaxItems.Value;
                UniGridExportHelper.CurrentPageOnly = false;
            }
        }

        UniGridExportHelper.UseGridFilter = chkUseGridFilter.Checked;

        // Get order by clause from correct control
        UniGridExportHelper.OrderBy = MembershipContext.AuthenticatedUser.IsGlobalAdministrator ? TrimExtendedTextAreaValue(txtOrderBy.Text) : ValidationHelper.GetString(orderByElem.Value, null);
        UniGridExportHelper.WhereCondition = TrimExtendedTextAreaValue(txtWhereCondition.Text);
        UniGridExportHelper.Columns = GetSelectedColumns();

        if (IsCMSDesk)
        {
            UniGridExportHelper.SiteName = SiteContext.CurrentSiteName;
        }

        UniGridExportHelper.ExportData(format, Page.Response);
    }
 /// <summary>
 /// Exports data based on given format.
 /// </summary>
 /// <param name="format">Format to export data in</param>
 private void ExportData(DataExportFormatEnum format)
 {
     ExportData(format, null);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Exports data based on given format.
 /// </summary>
 /// <param name="format">Format to export data in</param>
 private void ExportData(DataExportFormatEnum format)
 {
     ExportData(format, null);
 }