public IActionResult CreateScheduledReport( [FromForm] CreateScheduledReportViewModel createScheduledReportViewModel) { try { var tableauReportViewModel = createScheduledReportViewModel.ReportViewModel; var createPdfOptions = new CreatePdfOptions(tableauReportViewModel.WorkbookName, tableauReportViewModel.ViewName, tableauReportViewModel.WorksheetName); var cronString = createScheduledReportViewModel.RecurrenceSettings.ConvertToCronString(); var recurringJobId = RecurringJobManager.Add(Hangfire.Common.Job.FromExpression <ITenantJobs>(x => x.ScheduleTableauPdfDownload(createPdfOptions)), cronString); var campaignName = "Scheduled Report: " + tableauReportViewModel.ViewName; var communication = new Communication { CampaignName = campaignName.ToTitleFriendlyString(), CommunicationTitle = tableauReportViewModel.ViewName.ToTitleFriendlyString(), CommunicationSettings = new CommunicationSettings { Recurrence = createScheduledReportViewModel.RecurrenceSettings, RecurringJobId = recurringJobId, ReportId = createScheduledReportViewModel.ReportViewModel.Id.ToString(), ReportName = tableauReportViewModel.ViewName } }; Rdb.Communications.Add(communication); Rdb.SaveChanges(); return(RedirectToAction(ActionNames.ScheduledReports)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public IActionResult CreateScheduledReport(string id, string anchorName) { try { var tableauReportViewModel = GetReportViewModel(id); if (tableauReportViewModel == null) { return(RedirectToAction(ActionNames.Index)); } var scheduleReportViewModel = new CreateScheduledReportViewModel(tableauReportViewModel, new RecurrenceSettings()); return(View(scheduleReportViewModel)); } catch (Exception e) { Trace.WriteLine(e); throw; } }