/// <summary> /// /// </summary> /// <param name="reportId"></param> /// <returns></returns> public async Task <StiReport> GetReportAsStiReportAsync(Guid reportId, ReportParameterViewModel viewModel) { var report = await FindByIdAsync(reportId); var stiReport = new StiReport(); var encoding = Encoding.UTF8; var docAsBytes = encoding.GetBytes(report.Content); stiReport.Load(docAsBytes); foreach (StiDatabase db in stiReport.Dictionary.Databases) { ((StiSqlDatabase)db).ConnectionString = _configurationManager.ConnectionString; } foreach (var item in viewModel.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { if (item.GetValue(viewModel) == null) { continue; } if (item.FieldType == typeof(DateTime?)) { var value = ((DateTime)item.GetValue(viewModel)).ToString("yyyy-MM-dd"); stiReport.Dictionary.Variables.Add(item.Name.GetNameViewModel(), value); } else { stiReport.Dictionary.Variables.Add(item.Name.GetNameViewModel(), item.GetValue(viewModel)); } } return(stiReport); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual async Task <ActionResult> Detail(Guid?id, ReportParameterViewModel viewModel = null) { TempData[id.ToString()] = viewModel; var options = new StiMvcViewerOptions(); return(View(MVC.Report.Views.Detail, viewModel)); }
public ActionResult SpeedReport(ReportViewModel reportModel) { reportModel.Results = new List <ReportResultViewModel>(); reportModel = new ReportData().GetSpeedReport(reportModel); ReportParameterViewModel model = new ReportParameterViewModel(); model.DeviceList = new List <SelectListItem>(); var CurrentUser = Session["UserData"] as Admin; // Get list of devices DataTable dt = Data.GetData(DataBase.Api, CommandType.StoredProcedure, "Api_GetDeviceList", new List <SqlParameter>() { new SqlParameter("UserId", Guid.Parse(CurrentUser.UserId.ToString())) }.ToArray()); if (dt != null || dt.Rows.Count > 0) { model.DeviceList = dt.AsEnumerable().Select(m => new SelectListItem() { Value = Convert.ToString(m["DeviceId"]), Text = Convert.ToString(m["DeviceId"]) }).ToList(); } reportModel.Parameter = model; return(View(reportModel)); }
public ActionResult GenerateReportPopup(int days, string time, string courseName) { ReportParameterViewModel model = new ReportParameterViewModel(); model.Time = time; model.Days = days; model.CourseName = courseName; return(PartialView("~/Views/Report/GenerateReportPopup.cshtml", model)); }
public async Task <IActionResult> GetHistoricalData(ReportParameterViewModel data) { var historical = await _reportManager.GetReportByMiuteData(data.meter, data.parameter, data.StartDate, data.EndDate, data.interval); var mappedData = _mapper.Map <List <EmsMaster>, List <EMSMasterViewModel> >(historical); var serializeObject = JsonConvert.SerializeObject(mappedData); return(Ok(serializeObject)); }
//protected async Task HandleValidSubmit() //{ //} //protected async Task HandleInvalidSubmit() //{ //} protected override async Task OnInitializedAsync() { try { UserName = await _sessionStorageService.GetItemAsync <string>("UserName"); CompanyId = await _sessionStorageService.GetItemAsync <string>("CompanyId"); //CompanyId = "ASRC"; DataLoaded = false; ErrorMessage = string.Empty; //companyId = "ASRC"; // var sqlcommand = $"exec ASRCReportsDtls '{companyId.Replace("'", "''")}'"; // var sqlcommand = $"exec ASRCReportsDtls '{companyId.Replace("'", "''")}'"; var param = new Dapper.DynamicParameters(); param.Add("companyId", CompanyId, System.Data.DbType.String); reportParameterViewModel = new ReportParameterViewModel(); reportParameterViewModel.dateFrom = DateTime.Parse("01/01/" + DateTime.Today.Year.ToString()); reportParameterViewModel.dateTo = DateTime.Today; //reportParameterViewModel.ReferenceVM = await dapperManager.GetAllAsync<ReferenceViewModal>("ASRCReportsDtls", param); if (CompanyId == "ASRC") { reportParameterViewModel.ReferenceVM = dapperManager.GetAll <ReferenceViewModal>("ASRCReportsDtls", param); } if (CompanyId == "ADBCA") { reportParameterViewModel.ReferenceVM = dapperManager.GetAll <ReferenceViewModal>("ADBCAReportsDtls", param); } if (CompanyId == "APMI") { reportParameterViewModel.ReferenceVM = dapperManager.GetAll <ReferenceViewModal>("APMIReportsDtls", param); } //dapperManager.GetAllAsync<ReferenceViewModal>("ASRCReportsDtls", param); //reportParameterViewModel.ReferenceVM = await // dapperManager.GetAllAsync<ReferenceViewModal>("ASRCReportsDtls", param); } catch (Exception ex) { ErrorMessage = ex.Message; } finally { IsDataLoaded = true; } IsDataLoaded = true; }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="viewModel"></param> /// <returns></returns> public virtual async Task <ActionResult> DetailReport(Guid?id, ReportParameterViewModel viewModel) { if (id == null) { throw new ArgumentNullException(nameof(id)); } viewModel = (ReportParameterViewModel)TempData[id.ToString()]; var report = await _reportService.GetReportAsStiReportAsync(id.Value, viewModel); return(StiMvcViewer.GetReportSnapshotResult(report)); }
public async Task <ReportParameterViewModel> PrepareReportParameter(Guid id) { var viewModel = new ReportParameterViewModel { DoctorList = await _doctorService.GetDoctorAsSelectItemListAsync(), PresenterList = await _presenterService.GetPresenterAsSelectListItem(), Id = id }; return(viewModel); }
public IHttpActionResult GetReportStudentList(ReportParameterViewModel model) { SqlParameter[] parameter = { new SqlParameter("@Time", model.Time), new SqlParameter("@Days", model.Days), new SqlParameter("@CourseName", model.CourseName), }; var totalOrders = db.Database.SqlQuery <ReportListViewModel>("spGetReport @Time, @Days,@CourseName", parameter).ToList(); return(Ok(totalOrders)); }
public async Task <IActionResult> GetDashboardDataByMonth(ReportParameterViewModel data) { data.StartDate = DateTime.Now.AddDays(-30); data.EndDate = DateTime.Now; data.interval = "Month"; var historical = await _reportManager.GetReportByMiuteData(data.meter, data.parameter, data.StartDate, data.EndDate, data.interval); var mappedData = _mapper.Map <List <EmsMaster>, List <EMSMasterViewModel> >(historical); var serializeObject = JsonConvert.SerializeObject(mappedData); return(Ok(serializeObject)); }