public IActionResult Create() { var model = new CreateReportModel() { CreateProject = _timeTrackingService.GetAllProjects() }; return(View(model)); }
public JsonResult Create(CreateReportModel model) { IReportTemplate template = _templateFactory.Create(new DescriptionMetadata() { Name = model.Name, Author = model.CreatedBy }); template.DataSources.Set(new DataSource("", new StaticDataProvider().Set("test", 4711).Set("switch", true))); // Un-comment this to add a data provider which returns a DataSet with data filled by a custom script written in C#. //template.DataSources.Set(new DataSource("scr1", new ScriptDataProvider() //{ // ScriptTypeKey = "cs", // ScriptText = @"DataSet result = new DataSet(""Created from code""); result.Tables.Add(""Hello world""); return result;" //})); IReportTemplateSection section = template.Sections.GetSection(SectionType.Detail); ICompositionElement rootElement = new VerticalContainerElement(); rootElement.Set("data-source", ""); rootElement.AddChild(new StaticLabelElement() { Value = "Hello, world!" }); rootElement.AddChild(new TableElement() { DataSource = "ours" }); section.RootElement = rootElement; string definition = null; using (StreamReader reader = new StreamReader(_templateFactory.Save(template))) { definition = reader.ReadToEnd(); } ReportData rd = new ReportData() { Name = model.Name, Guid = Guid.NewGuid(), CreatedAt = DateTimeOffset.Now, CreatedBy = model.CreatedBy, Definition = definition }; using (IDataRepository repository = GetRepository()) { repository.Add(rd); } return(Json(new { success = true, name = rd.Name, guid = rd.Guid }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Create([FromBody] CreateReportModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var report = Mapper.Map <Report>(model); var newReport = await _reportService.CreateAsync(report); if (newReport == null) { return(BadRequest()); } return(Ok(newReport)); }
public async Task <IActionResult> Reporting([FromBody] CreateReportModel model) { var currentUserId = int.Parse(User.Identity.Name); var report = _mapper.Map <Report>(model); report.CustomerId = _customerService.GetCustomerId(currentUserId); try { var _report = await _customerService.CreateReport(report); //signalR var _reportModel = _mapper.Map <ReportModel>(_report); await _signalrHub.Clients.Group("Group Admins").SendReportToAdmins(_reportModel); return(Ok(new { message = "Report have been sended" })); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public bool PostReport(int id, [FromBody] CreateReportModel model) => queries.CreateReport(id, model.ReportType, WebHelper.GetRealHost(Request), model.Reason).created;
public IActionResult Show(CreateReportModel model) { if (!ModelState.IsValid) { if (String.IsNullOrEmpty(model.ReportName)) { return(Error("Ошибка создания отчета!", "Название отчета должно быть не нулевым!")); } if (model.ReportName?.Length > 100) { return(Error("Ошибка создания отчета!", "Название отчета должно быть не длиннее 100 символов!")); } if (model.IssueFilter?.Length > 1000) { return(Error("Ошибка создания отчета!", "Фильтр должен быть не длиннее 1000 символов!")); } return(Error("Ошибка создания отчета!")); } RequestResult <bool> isContains = _storage.ContainsReport(model.ReportName); if (!isContains.IsSuccess) { return(Error("Ошибка обращения к БД!", isContains.Error.Message)); } if (isContains.Result) { return(Error("Ошибка создания отчета!", "Отчет с таким именем уже существует!")); } // Get issues var issues = _timeTrackingService.GetIssues(model.ProjectName, model.IssueFilter); if (issues == null) { issues = new List <Issue>(); } // Save report var report = new Report(model.ReportName, model.ProjectName, model.IssueFilter, issues); _storage.SaveReport(report); // Get saved report with id var reportResult = _storage.GetReport(report.Name); if (!reportResult.IsSuccess) { return(Error("Ошибка обращения к БД!", reportResult.Error.Message)); } // Filter issues var issuesToShow = issues .Where(i => i.SpentTime.HasValue && i.EstimatedTime.HasValue) .ToList(); // Get and fill charts var charts = _chartService.GetAllCharts(); foreach (var chart in charts.Values) { chart.SetData(issuesToShow, 5); } return(View(new ChartModel(reportResult.Result.ReportId, charts.Values.ToList()))); }
/// <summary> /// Create report /// </summary> /// <param name="model">Create report model</param> public void CreateReport(CreateReportModel model) { var ssrs = this.ssrsWrapperProvider.GetReportingServiceWrapper(); Warning[] warnings; Report report = new Report(); report.Description = model.ReportDescription; report.Page.PageWidth = new ReportSize(280, SizeTypes.Mm); report.Page.PageHeight = new ReportSize(210, SizeTypes.Mm); report.Width = new ReportSize(297, SizeTypes.Mm); report.Body.Height = new ReportSize(210, SizeTypes.Mm); DataSource dataSource = new DataSource { Name = "DataSource", DataSourceReference = ConfigurationManager.AppSettings["SharedSsrsDataSourceName"] }; report.DataSources.Add(dataSource); report.DataSets.Add(new DataSet() { Name = "DataSet1", Fields = this.ssrsProvider.GetFieldsFromQuery(model.DatabaseName, model.Query), Query = new Query() { CommandType = CommandTypes.Text, CommandText = string.Format("USE {0}; {1}", model.DatabaseName, model.Query), Timeout = 30, DataSourceName = report.DataSources[0].Name } }); //report.ReportParameters.Add(new ReportParameter() // { // DataType = DataTypes.String, // UsedInQuery = UsedInQueryTypes.False, // MultiValue = false, // Prompt = "?", // Name = "TestParameter", // AllowBlank = true // }); Tablix tablix = new Tablix() { Name = "tablix1", Width = new ReportSize("250mm"), Left = new ReportSize("3mm") }; tablix.DataSetName = report.DataSets[0].Name; var colHeirarcy = new TablixHierarchy(); var rowHeirarcy = new TablixHierarchy(); foreach (var field in report.DataSets[0].Fields) { tablix.TablixBody.TablixColumns.Add(new TablixColumn() { Width = new ReportSize(50, SizeTypes.Mm) }); } TablixRow header = new TablixRow() { Height = new ReportSize(8, SizeTypes.Mm) }; foreach (var field in report.DataSets[0].Fields) { TablixCell cell = new TablixCell(); Textbox tbx = new Textbox(); tbx.Name = tablix.Name + "_Header_txt" + field.Name.Replace(" ", string.Empty); tbx.Paragraphs[0].TextRuns[0].Value = field.Name; tbx.Paragraphs[0].TextRuns[0].Style = new Style() { FontWeight = new ReportExpression <FontWeights>(FontWeights.Bold), FontSize = new ReportExpression <ReportSize>("10pt"), }; cell.CellContents = new CellContents() { ReportItem = tbx }; header.TablixCells.Add(cell); colHeirarcy.TablixMembers.Add(new TablixMember()); } tablix.TablixBody.TablixRows.Add(header); TablixRow row = new TablixRow() { Height = new ReportSize(5, SizeTypes.Mm) }; foreach (var field in report.DataSets[0].Fields) { TablixCell cell = new TablixCell(); Textbox tbx = new Textbox(); tbx.Name = "txt" + field.Name.Replace(" ", string.Empty); tbx.Paragraphs[0].TextRuns[0].Value = "=Fields!" + field.Name + ".Value"; tbx.Paragraphs[0].TextRuns[0].Style = new Style() { FontSize = new ReportExpression <ReportSize>("8pt") }; cell.CellContents = new CellContents() { ReportItem = tbx }; row.TablixCells.Add(cell); } tablix.TablixBody.TablixRows.Add(row); var mem = new TablixMember() { KeepTogether = true }; var mem2 = new TablixMember() { Group = new Group { Name = "Details" } }; rowHeirarcy.TablixMembers.Add(mem); rowHeirarcy.TablixMembers.Add(mem2); tablix.TablixColumnHierarchy = colHeirarcy; tablix.TablixRowHierarchy = rowHeirarcy; tablix.Style = new Style() { Border = new Border() }; report.Body.ReportItems.Add(tablix); RdlSerializer serializer = new RdlSerializer(); using (MemoryStream ms = new MemoryStream()) { serializer.Serialize(ms, report); ssrs.CreateCatalogItem("Report", model.ReportName, "/", false, ms.ToArray(), null, out warnings); } }
public async virtual Task <IHttpActionResult> CreateReport(string userName, string token, [FromBody] CreateReportModel createReportModel) { base.AuthUser(); var tenantId = createReportModel.TenantId; var homeOwerId = createReportModel.HomeOwerId; var communityId = createReportModel.CommunityId; var title = createReportModel.Title; var content = createReportModel.Content; var files = createReportModel.Files; var community = await _communityManager.CommunityRepository.GetAsync(createReportModel.CommunityId); var building = await _buildingManager.BuildingRepository.GetAsync(createReportModel.BuildingId); var flatNo = await _flatNoManager.FlatNumberRepository.GetAsync(createReportModel.FlatNoId); using (CurrentUnitOfWork.SetTenantId(tenantId)) { var report = new Report(tenantId, title, content, files, createReportModel.CommunityId, createReportModel.BuildingId, createReportModel.FlatNoId, createReportModel.HomeOwerId, community.Name, building.BuildingName, flatNo.FlatNo); await _reportManager.CreateAsync(report); return(Ok()); } }
public async Task <ActionResult> CreateReport(CreateReportModel model) { var result = await _reportService.UpsertDailyReportAsync(model.CustomerId, model.ReportDate); return(Ok(result)); }