Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        l10nManager = ObjectFactory.GetLocalizationManager(contAPI.RequestInformationRef);
        IsExcelExport = Request.QueryString["out"] == "xls";
        IncludeFolderPath = Request.QueryString.AllKeys.Contains("fp") ?
            (Request.QueryString["fp"] == "1") : IsExcelExport;

        NameValueCollection filters = HttpUtility.ParseQueryString(Request.QueryString["f"]);
        foreach (string f in filters.Keys)
            SetFilterValue(f, filters[f]);

        ReportingCriteria criteria2 = new ReportingCriteria();
        criteria2.FolderRecursive = true;
        criteria2.AddFilter(ReportingProperty.FolderId, CriteriaFilterOperator.EqualTo, FilterFolderId < 0 ? 0 : FilterFolderId);
        if (!string.IsNullOrEmpty(FilterTitle))
            criteria2.AddFilter(ReportingProperty.Title, CriteriaFilterOperator.Contains, FilterTitle.Replace("&", "&amp;").Replace("'", "&#39;"));

        if (FilterLocale > 0)
        {
            if (!FilterLocaleNotIn)
                criteria2.AddFilter(ReportingProperty.Locale, CriteriaFilterOperator.Contains, "," + FilterLocale.ToString() + ",");
            else
                criteria2.AddFilter(ReportingProperty.Locale, CriteriaFilterOperator.DoesNotContain, "," + FilterLocale.ToString() + ",");
        }
        else if (FilterLocale == -1)
        {
            criteria2.AddFilter(ReportingProperty.Locale, CriteriaFilterOperator.EqualTo, string.Format(",{0},", CurrentLanguageId));
        }
        if (FilterLocStatus != Ektron.Cms.Localization.LocalizationState.Undefined)
            criteria2.AddFilter(ReportingProperty.TranslationStatus, CriteriaFilterOperator.EqualTo, (byte)FilterLocStatus);
        if (!string.IsNullOrEmpty(FilterContentStatus))
            criteria2.AddFilter(ReportingProperty.ContentStatus, CriteriaFilterOperator.EqualTo, FilterContentStatus);
        if (FilterLastModifiedStart != DateTime.MinValue)
            criteria2.AddFilter(ReportingProperty.LastModified, CriteriaFilterOperator.GreaterThanOrEqualTo, FilterLastModifiedStart);
        if (FilterLastModifiedEnd != DateTime.MinValue)
            criteria2.AddFilter(ReportingProperty.LastModified, CriteriaFilterOperator.LessThanOrEqualTo, FilterLastModifiedEnd);
        if (FilterDateCreatedStart != DateTime.MinValue)
            criteria2.AddFilter(ReportingProperty.DateCreated, CriteriaFilterOperator.GreaterThanOrEqualTo, FilterDateCreatedStart);
        if (FilterDateCreatedEnd != DateTime.MinValue)
            criteria2.AddFilter(ReportingProperty.DateCreated, CriteriaFilterOperator.LessThanOrEqualTo, FilterDateCreatedEnd);
        if (FilterContentId > 0)
            criteria2.AddFilter(ReportingProperty.ContentId, CriteriaFilterOperator.EqualTo, FilterContentId);
        if (FilterAuthorId > 0)
            criteria2.AddFilter(ReportingProperty.AuthorId, CriteriaFilterOperator.EqualTo, FilterAuthorId);
        if (FilterLanguageId > 0)
            criteria2.AddFilter(ReportingProperty.LanguageId, CriteriaFilterOperator.EqualTo, FilterLanguageId);

        criteria2.GetMetadata = true;
        criteria2.PagingInfo.CurrentPage = 0;
        criteria2.PagingInfo.RecordsPerPage = int.MaxValue;
        Pair sort = GetSort(Request.QueryString["s"]);
        criteria2.OrderByField = (ReportingProperty)sort.First;
        criteria2.OrderByDirection = (EkEnumeration.OrderByDirection)sort.Second;

        List<ReportingData> contentlist2 = l10nManager.GetReport(criteria2);

        int pageCount = 0;
        int totalCount = criteria2.PagingInfo.TotalRecords;
        int totalPages = criteria2.PagingInfo.TotalPages;
        int currentPage = criteria2.PagingInfo.CurrentPage;

        if (IsExcelExport)
        {
            pnlPrint.Visible = false;
            pnlExcel.Visible = true;
            rptExcel.DataSource = contentlist2;
            rptExcel.DataBind();

            Response.Clear();
            Response.ContentType = "application/ms-excel";
            Response.AppendHeader("content-disposition", "attachment; filename=LocReport_" + DateTime.Now.Ticks.ToString() + ".xls");
            Response.Write(RenderControl(plcExcel));
            Response.End();
        }
        else
        {
            pnlPrint.Visible = true;
            pnlExcel.Visible = false;
            rptPrint.DataSource = contentlist2;
            rptPrint.DataBind();

            lResultCount.Text = totalCount.ToString() + " row" + (totalCount == 1 ? string.Empty : "s");
        }
    }