/// <summary> /// Returns Extension (with comma) from Report Resource Type. /// </summary> /// <param name="type"></param> /// <returns></returns> public static string GetFileExtensionFromReportResource(ReportResource type) { switch (type) { case ReportResource.Component: return(".rdc"); case ReportResource.DataSource: return(".rds"); case ReportResource.Model: return(".rdm"); case ReportResource.LinkedReport: return(".rdr"); case ReportResource.Report: return(".rdl"); case ReportResource.Resource: return(".rdx"); case ReportResource.DataSet: return(".rsd"); default: return(""); } }
/// <summary> /// Returns the report type name. /// </summary> /// <param name="type"></param> /// <returns></returns> public static string GetReportResourceName(ReportResource type) { switch (type) { case ReportResource.Component: return("Component"); case ReportResource.DataSource: return("DataSource"); case ReportResource.Model: return("Model"); case ReportResource.LinkedReport: return("LinkedReport"); case ReportResource.Report: return("Report"); case ReportResource.Resource: return("Resource"); case ReportResource.DataSet: return("DataSet"); default: return("Resource"); } }
public async Task <IActionResult> AddReport([FromBody] ReportResource reportResource) { var currentEmail = HttpContext.GetUserEmail(); User user = await _userService.GetUser(currentEmail); return(new OkObjectResult(await _reportService.AddReport(reportResource, user))); }
public IReportsStore Register(Assembly assembly, string reportResourcePath) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } if (string.IsNullOrWhiteSpace(reportResourcePath)) { return(this); } var reportResource = new ReportResource(assembly, reportResourcePath); _pathIndex[reportResource.Path] = reportResource; _nameIndex[reportResource.Name] = reportResource; return(this); }
public async Task <ReportResource> GetReport(int id) { Report report = await _reportRepository.GetReport(id); ReportResource reportResource = new ReportResource { Id = report.Id, Description = report.Description, ReportStatus = report.ReportStatus.Name, ReportPhoto = Convert.ToBase64String(report.ReportPhoto.Photo), ReportType = report.ReportType, Latitude = report.Latitude, Longitude = report.Longitude }; return(reportResource); }
public async Task <Report> AddReport(ReportResource report, User user) { var status = await _reportRepository.GetReportStatus(1); // 1 - в обработке byte[] photo = Convert.FromBase64String(report.ReportPhoto); ReportPhoto newReportPhoto = new ReportPhoto { Photo = photo }; Report newReport = new Report { Description = report.Description, Latitude = report.Latitude, Longitude = report.Longitude, RegionName = await GetLocationRegion(report.Latitude, report.Longitude), User = user, ReportStatus = status, ReportType = report.ReportType }; await _reportRepository.AddReport(newReport, newReportPhoto); return(newReport); }
// Method will be called from Report Viewer client to get the image src for Image report item. public object GetResource(ReportResource resource) { return(ReportHelper.GetResource(resource, this, this._cache)); }
/// <summary> /// Upload the specified file to this folder /// </summary> /// <param name="sourceFile"></param> /// <param name="relativeTo"></param> /// <param name="type"></param> public async System.Threading.Tasks.Task UploadFileInThisFolder(FileInfo sourceFile, DirectoryInfo relativeTo, ReportResource type) { byte[] data = System.IO.File.ReadAllBytes(sourceFile.FullName); await _service.CreateCatalogItem(Report.GetReportResourceName(type), sourceFile, relativeTo, _catalogitem.Path, data); }
public object GetResource(ReportResource resource) { return(Syncfusion.EJ.ReportViewer.ReportHelper.GetResource(resource, this, _cache)); }
public HttpResponseMessage PutReport([FromBody] ReportRequest request) { DateTime requestDate; DateTime.TryParse(request.Date, out requestDate); if (request == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new HttpError("Wrong content"))); } User currentUser = GetUser(request.User); if (currentUser == null) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new HttpError("Cannot identify user"))); } Question question = GetQuestion(requestDate); if (question == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, new HttpError("Cannot find question for the date"))); } Report existingReport = GetReport(currentUser, question.Date); if (existingReport != null) { return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, new HttpError("Report for these user and date already exists"))); } IRepository <Report> reportList = RepositoryFactory.Default.GetRepository <Report>() as ReportRepository; Report report = reportList.AddItem(new Report { User = currentUser, Question = question, Created = DateTime.Now }); List <AnswerResource> answers = new List <AnswerResource>(); IRepository <Question> questionList = RepositoryFactory.Default.GetRepository <Question>() as QuestionRepository; foreach (var answer in questionList.Data.FirstOrDefault(q => q.Id == question.Id).Answers) { answers.Add(new AnswerResource { Id = answer.Id, IsCorrect = answer.IsCorrect, Text = answer.Text }); } ReportResource responseResource = new ReportResource { Id = report.Id, Created = report.Created, Question = new QuestionResource { Text = report.Question.Text, Date = report.Question.Date, Explanation = report.Question.Explanation }, Answers = answers }; var jsonResponse = JsonConvert.SerializeObject(responseResource); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(jsonResponse.ToString(), Encoding.UTF8, "application/json"); return(response); }
public static string CreateAnchorName(ReportResource reportResource) => ReportVisualService.CreateAnchorName(reportResource);
public IReportResource Resolve(string name, Stream stream, string title = null, string description = null) { var theme = this.ResolveTheme(stream); if (theme == null) { return(null); } var resource = new ReportResource(string.IsNullOrEmpty(name) ? "Unnamed" : name, this.Name, title, null, description); StringBuilder builder = null; if (theme.Colors != null) { if (builder == null) { builder = new StringBuilder(); } builder.Append($"{nameof(IThemeInfo.Dark1)}:{theme.Colors.Dark1};"); builder.Append($"{nameof(IThemeInfo.Dark2)}:{theme.Colors.Dark2};"); builder.Append($"{nameof(IThemeInfo.Light1)}:{theme.Colors.Light1};"); builder.Append($"{nameof(IThemeInfo.Light2)}:{theme.Colors.Light2};"); builder.Append($"{nameof(IThemeInfo.Accent1)}:{theme.Colors.Accent1};"); builder.Append($"{nameof(IThemeInfo.Accent2)}:{theme.Colors.Accent2};"); builder.Append($"{nameof(IThemeInfo.Accent3)}:{theme.Colors.Accent3};"); builder.Append($"{nameof(IThemeInfo.Accent4)}:{theme.Colors.Accent4};"); builder.Append($"{nameof(IThemeInfo.Accent5)}:{theme.Colors.Accent5};"); builder.Append($"{nameof(IThemeInfo.Accent6)}:{theme.Colors.Accent6};"); if (resource.Dictionary == null) { resource.Dictionary = new Dictionary <string, ReportResourceEntry>(StringComparer.OrdinalIgnoreCase); } resource.Dictionary.Add(ThemeMapper.COLORS_DARK1_KEY, new ReportResourceEntry(ThemeMapper.COLORS_DARK1_KEY, null, theme.Colors.Dark1)); resource.Dictionary.Add(ThemeMapper.COLORS_DARK2_KEY, new ReportResourceEntry(ThemeMapper.COLORS_DARK2_KEY, null, theme.Colors.Dark2)); resource.Dictionary.Add(ThemeMapper.COLORS_LIGHT1_KEY, new ReportResourceEntry(ThemeMapper.COLORS_LIGHT1_KEY, null, theme.Colors.Light1)); resource.Dictionary.Add(ThemeMapper.COLORS_LIGHT2_KEY, new ReportResourceEntry(ThemeMapper.COLORS_LIGHT2_KEY, null, theme.Colors.Light2)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT1_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT1_KEY, null, theme.Colors.Accent1)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT2_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT2_KEY, null, theme.Colors.Accent2)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT3_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT3_KEY, null, theme.Colors.Accent3)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT4_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT4_KEY, null, theme.Colors.Accent4)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT5_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT5_KEY, null, theme.Colors.Accent5)); resource.Dictionary.Add(ThemeMapper.COLORS_ACCENT6_KEY, new ReportResourceEntry(ThemeMapper.COLORS_ACCENT6_KEY, null, theme.Colors.Accent6)); resource.Dictionary.Add(ThemeMapper.COLORS_HYPERLINK_KEY, new ReportResourceEntry(ThemeMapper.COLORS_HYPERLINK_KEY, null, theme.Colors.Hyperlink)); resource.Dictionary.Add(ThemeMapper.COLORS_HYPERLINKFOLLOWED_KEY, new ReportResourceEntry(ThemeMapper.COLORS_HYPERLINKFOLLOWED_KEY, null, theme.Colors.HyperlinkFollowed)); } if (theme.Fonts != null && (theme.Fonts.MajorFont != null || theme.Fonts.MinorFont != null)) { if (builder == null) { builder = new StringBuilder(); } if (theme.Fonts.MajorFont != null) { builder.Append($"{nameof(IThemeInfo.MajorFontFamily)}:{theme.Fonts.MajorFont.Family};"); } if (theme.Fonts.MinorFont != null) { builder.Append($"{nameof(IThemeInfo.MinorFontFamily)}:{theme.Fonts.MinorFont.Family};"); } if (resource.Dictionary == null) { resource.Dictionary = new Dictionary <string, ReportResourceEntry>(StringComparer.OrdinalIgnoreCase); } resource.Dictionary.Add(ThemeMapper.FONTS_MAJOR_KEY, new ReportResourceEntry(ThemeMapper.FONTS_MAJOR_KEY, null, GetFontText(theme.Fonts.MajorFont))); resource.Dictionary.Add(ThemeMapper.FONTS_MINOR_KEY, new ReportResourceEntry(ThemeMapper.FONTS_MINOR_KEY, null, GetFontText(theme.Fonts.MinorFont))); } if (builder != null) { resource.Extra = builder.ToString(); } if (theme.Images != null && theme.Images.Length > 0) { if (resource.Dictionary == null) { resource.Dictionary = new Dictionary <string, ReportResourceEntry>(StringComparer.OrdinalIgnoreCase); } for (int i = 0; i < theme.Images.Length; i++) { var image = theme.Images[i]; if (image == null || string.IsNullOrEmpty(image.ImageData)) { continue; } var entry = new ReportResourceEntry( "Images:" + image.Name, image.MIMEType?.Replace('\\', '/'), Convert.FromBase64String(image.ImageData)); resource.Dictionary.Add(entry.Name, entry); } } if (theme.Constants != null && theme.Constants.Length > 0) { if (resource.Dictionary == null) { resource.Dictionary = new Dictionary <string, ReportResourceEntry>(StringComparer.OrdinalIgnoreCase); } for (int i = 0; i < theme.Constants.Length; i++) { var constant = theme.Constants[i]; if (constant == null || string.IsNullOrEmpty(constant.Value)) { continue; } var entry = new ReportResourceEntry("Constants:" + constant.Key, null, constant.Value); resource.Dictionary.Add(entry.Name, entry); } }