public string GetAccessId(string reportId) { IUniqueIdentifier reportUid = reportId.AsUniqueIdentifierGuid(); if (reportUid == null) { throw new ApiException( "Invalid unique identifier."); } ExpressReport.ExpressReport expressReport = null; try { expressReport = _reportManager.GetExpressReport(reportUid); } catch (ArgumentNullException) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } return(_fileAccessService.GetAccessId(reportId)); }
private Dictionary <ExpressReportParameter, object> GetParameters(ExpressReport.ExpressReport expressReport, string parametersString, IEntity entity) { var parameters = expressReport.FakeReportEntity.GetParametersValues(); if (!parametersString.IsNullOrEmpty() && entity != null) { var paramsPairs = parametersString.Split(';'); foreach (var paramPair in paramsPairs) { var pair = paramPair.Split(':'); if (pair.Length == 2) { string paramName = pair[0]; string paramValue = pair[1].Replace("<colon>", ":").Replace("<semicolon>", ";"); if (paramValue.IsNullOrEmpty()) { continue; } Expression paramExpression = _expressionParsing.Parse(paramValue); if (paramExpression == null || paramExpression == Expression.Empty) { continue; } string errorMessage; parameters[parameters.FirstOrDefault(p => p.Key.Key == paramName).Key] = _expressionEvaluator.Evaluate(paramExpression, entity, out errorMessage); } } } return(parameters); }
private XtraReport GetXtraReport(string reportId, string parameters = null, string entityId = null, string accessId = null) { if (accessId != null) { string accessedReportId = _fileAccessService.GetAccessObject(reportId, accessId); if (accessedReportId.IsNullOrEmpty()) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } } // идентификатор отчета доступен -> ищем сам отчет IUniqueIdentifier reportUid = reportId.AsUniqueIdentifierGuid(); if (reportUid == null) { throw new ApiException( "Invalid unique identifier."); } var xtraReport = new XtraReport(); ExpressReport.ExpressReport expressReport = null; try { expressReport = _reportManager.GetExpressReport(reportUid); } catch (ArgumentNullException) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } IEntity entity = null; if (!entityId.IsNullOrEmpty()) { entity = _entityManager.GetEntity(entityId.AsUniqueIdentifierGuid()); } // Получаем параметры: var expressParameters = GetParameters(expressReport, parameters, entity); // Определяем имя документа var documentName = _reportManager.GetReportFileName(expressReport); // Получаем имя файла по умолчанию, удалив недопустимые символы: var invalidFileNameChars = new HashSet <char>(Path.GetInvalidFileNameChars()); var defaultFileName = new string(documentName.Where(c => !invalidFileNameChars.Contains(c)).ToArray()); try { xtraReport = _dxReportCreator.CreateReport(expressReport, expressParameters, false); xtraReport.PrintingSystem.ExportOptions.PrintPreview.DefaultFileName = defaultFileName; return(xtraReport); } catch (OutOfMemoryException) { } return(xtraReport); }