public IReportContext InitializeContext(IReportRequest request) { var context = ResolveService<IReportContext>("", request); context.Log = context.Log ?? this.Logg; var report = request.PreparedReport ?? Storage.Get(request.Id); if (null == report) { throw new Exception("cannot find report " + request.Id); } if (null != request.User) { if (!string.IsNullOrWhiteSpace(report.Role)) { if (!Roles.IsInRole(request.User, report.Role)) { throw new Exception("not authorized access to report "+report.Id); } } } context.Report = report; foreach (var agentdef in report.Agents) { var agent = agentdef.Instance ?? ResolveService<IReportAgent>(agentdef.Name); if (null == agent) { throw new Exception("cannot find agent "+agentdef.Name); } agent.Initialize(agentdef); if (agent.IsMatch(context)) { context.Agents.Add(agent); } } return context; }
public async Task<IReportContext> Execute(IReportRequest request) { Logg.Debug(new {op="start",r=request}.stringify()); var context = InitializeContext(request); try { var scope = new Scope(); await ExecutePhase(context, ReportPhase.Init,scope); await ExecutePhase(context, ReportPhase.Data, scope); await ExecutePhase(context, ReportPhase.Prepare, scope); if (request.DataOnly) { if (null != context.Data) { context.SetHeader("Content-Type","application/json; charset=utf-8"); context.Write(context.Data.stringify()); } } else { await ExecutePhase(context, ReportPhase.Render, scope); } await ExecutePhase(context, ReportPhase.Finalize, scope); context.Finish(); } catch (Exception e) { Logg.Error(e); context.Error = e; if (!context.Request.NoFinalizeOnError) { context.Finish(e); } } finally { Logg.Trace(new { op = "success", r = request }.stringify()); } return context; }
public ReportContext(IReportRequest request) : this() { this.Request = request; Console = request.ConsoleContext; if (null != request.WebContext) { Response = request.WebContext.Response; } }
public override void Execute(IReportRequest request){ try{ innerExecute(request); } catch (ReportException){ throw; } catch (Exception ex){ throw new ReportException("Error occured while report processing", ex, request); } }
private IReportProduction generateProduction(IReportRequest request){ IReportProduction result = null; if (request is IMultiProductionReportRequest){ result = generateMultipleProduction((IMultiProductionReportRequest) request); } else{ var preProduction = generatePreProduction(request); result = generateProduction(request, preProduction); } result.ParentRequest = request; return result; }
public ActionResult GetExcel(string serviceName, string Paramas) { IReportService iReportService = ReportConfig.GetReportServiceByName(serviceName); IReportRequest reportRequest = Newtonsoft.Json.JsonConvert.DeserializeObject(Paramas, iReportService.RequetType) as IReportRequest; byte[] reportData = new Core.Report.ReportManagement().GetReportExcel( reportRequest, iReportService, System.Web.Hosting.HostingEnvironment.MapPath("~"), GetCurrentUserId() ); return(GetReportFileContent(reportData, reportRequest)); }
public byte[] GetReportExcel( IReportRequest reportRequest, IReportService reportService, string serverRootPath, int currentUserId ) { string reportFileName = string.Format(@"{0}\{1}_Fa.mrt", serverRootPath + "\\Areas\\sepehr", reportService.GetReportName(reportRequest) ); byte[] reportTemplate = Core.Cmn.FileHelper.ReadFile(reportFileName); List <ReportDataSource> reportData = reportService.GetReportData(reportRequest, currentUserId); return(GetExcelBytes(reportTemplate, reportData)); }
private FileContentResult GetReportFileContent( byte[] reportData, IReportRequest requestParams ) { return(File( reportData, MimeMapping.GetMimeMapping(requestParams.FileName),//System.Net.Mime.MediaTypeNames.Application.Octet, string.Format( /// ma bekhatere bug firefox majborim esme file ro bezarim to double quatation /// http://stackoverflow.com/questions/21442903/firefox-has-problems-when-downloading-with-a-space-in-filename "\"{0}-{1}{2}\"", Path.GetFileNameWithoutExtension(requestParams.FileName), DateTime.Now.ToString("HHmmss"), Path.GetExtension(requestParams.FileName) ) )); }
public async Task <IReportContext> Execute(IReportRequest request) { Logg.Debug(new { op = "start", r = request }.stringify()); var context = InitializeContext(request); try { var scope = new Scope(); await ExecutePhase(context, ReportPhase.Init, scope); await ExecutePhase(context, ReportPhase.Data, scope); await ExecutePhase(context, ReportPhase.Prepare, scope); if (request.DataOnly) { if (null != context.Data) { context.SetHeader("Content-Type", "application/json; charset=utf-8"); context.Write(context.Data.stringify()); } } else { await ExecutePhase(context, ReportPhase.Render, scope); } await ExecutePhase(context, ReportPhase.Finalize, scope); context.Finish(); } catch (Exception e) { Logg.Error(e); context.Error = e; if (!context.Request.NoFinalizeOnError) { context.Finish(e); } } finally { Logg.Trace(new { op = "success", r = request }.stringify()); } return(context); }
public IReportContext InitializeContext(IReportRequest request) { var context = ResolveService <IReportContext>("", request); context.Log = context.Log ?? this.Logg; var report = request.PreparedReport ?? Storage.Get(request.Id); if (null == report) { throw new Exception("cannot find report " + request.Id); } if (null != request.User) { if (!string.IsNullOrWhiteSpace(report.Role)) { if (!Roles.IsInRole(request.User, report.Role)) { throw new Exception("not authorized access to report " + report.Id); } } } context.Report = report; foreach (var agentdef in report.Agents) { var agent = agentdef.Instance ?? ResolveService <IReportAgent>(agentdef.Name); if (null == agent) { throw new Exception("cannot find agent " + agentdef.Name); } agent.Initialize(agentdef); if (agent.IsMatch(context)) { context.Agents.Add(agent); } } return(context); }
public abstract void Execute(IReportRequest request);
protected virtual void innerExecute(IReportRequest request){ checkReportSecurity(request); refactorRequest(request); var production = generateProduction(request); outputProduction(production); }
public ReportException(string message, Exception innerException, IReportRequest request) : base(message, innerException){ Request = request; }
public ReportException(IReportRequest request){ Request = request; }
protected abstract void refactorRequest(IReportRequest request);
public ICounterReportResponse GetReport(IReportRequest reportRequest) { return(GetReport(reportRequest as ReportRequest)); }
protected abstract IPreProduction generatePreProduction(IReportRequest request);
public ReportLoadException(string message, IReportRequest request) : base(message, request) {}
public ReportLoadException(string message, Exception innerException, IReportRequest request) : base(message, innerException, request) {}
protected abstract IReportProduction generateProduction(IReportRequest request, IPreProduction preProduction);
private IReportItem[] GetResponse(DateTime runDate, String reportName) { IReportRequest reportRequest = _client.GenerateReportRequest(runDate, reportName, _arguments, _releaseVersion); ICounterReportResponse response; try { response = _client.GetReport(reportRequest); } catch (FaultException exception) { throw new RepositoryConfigurationException(ConfigurationExceptionCategory.InvalidHost, this, String.Format(RepositoryExceptionMessage.UnrecognizedException, _arguments.Url), exception); } catch (EndpointNotFoundException exception) { throw new RepositoryIOException(IOExceptionCategory.NetworkUnavailable, RepositoryExceptionMessage.NetworkUnavailableWait, this, String.Format(RepositoryExceptionMessage.NetworkUnavailable_1, _arguments.Url), exception); } catch (TimeoutException exception) { throw new RepositoryIOException(IOExceptionCategory.TimedOut, RepositoryExceptionMessage.TimedOutWait, this, RepositoryExceptionMessage.Timeout, exception); } catch (ServerTooBusyException exception) { throw new RepositoryIOException(IOExceptionCategory.General, oneHour, this, "The server was too busy to handle the request", exception); } if (response.Exception == null || response.Exception.Length <= 0) { return(response.Report?[0].Customer?[0].ReportItems); } switch (response.Exception[0].Number) { case 1000: throw new RepositoryIOException(IOExceptionCategory.General, oneHour, this, "The service is not available."); case 1010: throw new RepositoryIOException(IOExceptionCategory.General, oneHour, this, "The server was too busy to handle the request."); case 1020: throw new RepositoryIOException(IOExceptionCategory.General, oneDay, this, "The client has made too many requests today."); case 2000: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.InvalidCredentials, this, "The Requestor ID was not recognized by the server."); case 2010: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.InvalidCredentials, this, "The Customer ID was not recognized by the server."); case 3000: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.NotSupported, this, $"The server does not support {reportRequest.ReportDefinition.Name}"); case 3010: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.NotSupported, this, $"The server does not support {reportRequest.ReportDefinition.Name} release version {reportRequest.ReportDefinition.Release}"); case 3030: case 10: return(null); case 3040: // Partial data returned? break; //Proquest case 20101: Console.WriteLine("ProQuest did not find any data for {0} release version {1}", reportRequest.ReportDefinition.Name, reportRequest.ReportDefinition.Release); return(null); //Lexis Nexis case 3001: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.NotSupported, this, "The Lexis Nexis does not support CR2 reports since it is not a consortium account"); case 11: throw new RepositoryConfigurationException(ConfigurationExceptionCategory.NotSupported, this, $"The Lexis Nexis does not support {reportRequest.ReportDefinition.Name}"); //Highwire case 1: Console.WriteLine("HighWire did not find any data for {0} release version {1}", reportRequest.ReportDefinition.Name, reportRequest.ReportDefinition.Release); return(null); default: throw new RepositoryImplementationException(ImplementationExceptionCategory.UnrecognizedException, this, RepositoryExceptionMessage.UnrecognizedError); } return(response.Report[0].Customer[0].ReportItems); }
public ReportException(SerializationInfo info, StreamingContext context, IReportRequest request) : base(info, context){ Request = request; }
public ReportLoadException(IReportRequest request) : base(request) {}
protected abstract void checkReportSecurity(IReportRequest request);
public ICounterReportResponse GetReport(IReportRequest reportRequest) { return(CounterRepositoryHelper.FixItemPlatformIssue(HandleNoData(GetReport(reportRequest as ReportRequest)), reportRequest.PlatformCorrections)); }
public ReportException(string message, IReportRequest request) : base(message){ Request = request; }