Exemplo n.º 1
0
        /// <summary> Gets report result. </summary>
        /// <param name="request"> The request. </param>
        /// <returns> The report result. </returns>
        private async Task <ReportResult> GetReportResult(GetItemReport request)
        {
            ReportViewType         reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
            ReportBuilder          reportBuilder = new ReportBuilder(_libraryManager);
            QueryResult <BaseItem> queryResult   = await GetQueryResult(request).ConfigureAwait(false);

            ReportResult reportResult = reportBuilder.GetReportResult(queryResult.Items, reportRowType, request);

            reportResult.TotalRecordCount = queryResult.TotalRecordCount;

            return(reportResult);
        }
Exemplo n.º 2
0
        /// <summary> Gets the given request. </summary>
        /// <param name="request"> The request. </param>
        /// <returns> A Task&lt;object&gt; </returns>
        public async Task <object> Get(GetReportDownload request)
        {
            if (string.IsNullOrEmpty(request.IncludeItemTypes))
            {
                return(null);
            }

            var    headers       = new Dictionary <string, string>();
            string fileExtension = "csv";
            string contentType   = "text/plain;charset='utf-8'";

            switch (request.ExportType)
            {
            case ReportExportType.CSV:
                break;

            case ReportExportType.Excel:
                contentType   = "application/vnd.ms-excel";
                fileExtension = "xls";
                break;
            }

            var filename = "ReportExport." + fileExtension;

            headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
            headers["Content-Encoding"]    = "UTF-8";

            ReportViewType         reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
            ReportBuilder          reportBuilder = new ReportBuilder(_libraryManager);
            QueryResult <BaseItem> queryResult   = await GetQueryResult(request).ConfigureAwait(false);

            ReportResult reportResult = reportBuilder.GetReportResult(queryResult.Items, reportRowType, request);

            reportResult.TotalRecordCount = queryResult.TotalRecordCount;

            string result = string.Empty;

            switch (request.ExportType)
            {
            case ReportExportType.CSV:
                result = new ReportExport().ExportToCsv(reportResult);
                break;

            case ReportExportType.Excel:
                result = new ReportExport().ExportToExcel(reportResult);
                break;
            }

            object ro = ResultFactory.GetResult(result, contentType, headers);

            return(ro);
        }
Exemplo n.º 3
0
		/// <summary> Gets the given request. </summary>
		/// <param name="request"> The request. </param>
		/// <returns> A Task&lt;object&gt; </returns>
		public async Task<object> Get(GetReportDownload request)
		{
			if (string.IsNullOrEmpty(request.IncludeItemTypes))
				return null;

			var headers = new Dictionary<string, string>();
			string fileExtension = "csv";
			string contentType = "text/plain;charset='utf-8'";

			switch (request.ExportType)
			{
				case ReportExportType.CSV:
					break;
				case ReportExportType.Excel:
					contentType = "application/vnd.ms-excel";
					fileExtension = "xls";
					break;
			}

			var filename = "ReportExport." + fileExtension;
			headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
			headers["Content-Encoding"] = "UTF-8";

			ReportViewType reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
			ReportBuilder reportBuilder = new ReportBuilder(_libraryManager);
			QueryResult<BaseItem> queryResult = await GetQueryResult(request).ConfigureAwait(false);
			ReportResult reportResult = reportBuilder.GetReportResult(queryResult.Items, reportRowType, request);

			reportResult.TotalRecordCount = queryResult.TotalRecordCount;

			string result = string.Empty;
			switch (request.ExportType)
			{
				case ReportExportType.CSV:
					result = new ReportExport().ExportToCsv(reportResult);
					break;
				case ReportExportType.Excel:
					result = new ReportExport().ExportToExcel(reportResult);
					break;
			}

			object ro = ResultFactory.GetResult(result, contentType, headers);
			return ro;
		}
Exemplo n.º 4
0
		/// <summary> Gets report result. </summary>
		/// <param name="request"> The request. </param>
		/// <returns> The report result. </returns>
		private async Task<ReportResult> GetReportResult(GetItemReport request)
		{

			ReportViewType reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
			ReportBuilder reportBuilder = new ReportBuilder(_libraryManager);
			QueryResult<BaseItem> queryResult = await GetQueryResult(request).ConfigureAwait(false);
			ReportResult reportResult = reportBuilder.GetReportResult(queryResult.Items, reportRowType, request);
			reportResult.TotalRecordCount = queryResult.TotalRecordCount;

			return reportResult;
		}