private void OnExecuteReport(ReportViewModelBase obj) { foreach (var report in Reports) report.Selected = false; obj.Selected = true; ActiveReport = obj; ActiveReport.RefreshReport(); }
public BasicReportModule(IRegionManager regionManager, BasicReportView basicReportView, IWorkPeriodService workPeriodService, IPrinterService printerService, IInventoryService inventoryService, IUserService userService, IApplicationState applicationState, IAutomationService automationService, ILogService logService) : base(regionManager, AppScreens.ReportView) { ReportContext.PrinterService = printerService; ReportContext.WorkPeriodService = workPeriodService; ReportContext.InventoryService = inventoryService; ReportContext.UserService = userService; ReportContext.ApplicationState = applicationState; ReportContext.LogService = logService; _userService = userService; _regionManager = regionManager; _basicReportView = basicReportView; SetNavigationCommand(Resources.Reports, Resources.Common, "Images/Ppt.png", 60); PermissionRegistry.RegisterPermission(PermissionNames.OpenReports, PermissionCategories.Navigation, Resources.CanDisplayReports); PermissionRegistry.RegisterPermission(PermissionNames.ChangeReportDate, PermissionCategories.Report, Resources.CanChangeReportFilter); automationService.RegisterActionType("SaveReportToFile", Resources.SaveReportToFile, new { ReportName = "", FileName = "" }); automationService.RegisterActionType(ActionNames.PrintReport, Resources.PrintReport, new { ReportName = "" }); automationService.RegisterParameterSoruce("ReportName", () => ReportContext.Reports.Select(x => x.Header)); EventServiceFactory.EventService.GetEvent <GenericEvent <ActionData> >().Subscribe(x => { if (x.Value.Action.ActionType == "SaveReportToFile") { var reportName = x.Value.GetAsString("ReportName"); var fileName = x.Value.GetAsString("FileName"); if (!string.IsNullOrEmpty(reportName)) { var report = ReportContext.Reports.FirstOrDefault(y => y.Header == reportName); if (report != null) { ReportContext.CurrentWorkPeriod = ReportContext.ApplicationState.CurrentWorkPeriod; var document = report.GetReportDocument(); ReportViewModelBase.SaveAsXps(fileName, document); } } } if (x.Value.Action.ActionType == ActionNames.PrintReport) { var reportName = x.Value.GetAsString("ReportName"); if (!string.IsNullOrEmpty(reportName)) { var report = ReportContext.Reports.FirstOrDefault(y => y.Header == reportName); if (report != null) { ReportContext.CurrentWorkPeriod = ReportContext.ApplicationState.CurrentWorkPeriod; var document = report.GetReportDocument(); ReportContext.PrinterService.PrintReport(document, ReportContext.ApplicationState.CurrentTerminal.ReportPrinter); } } } }); }
private void OnExecuteReport(ReportViewModelBase obj) { foreach (var report in Reports) { report.Selected = false; } obj.Selected = true; ActiveReport = obj; ActiveReport.RefreshReport(); }
public BasicReportModule(IRegionManager regionManager, BasicReportView basicReportView) { _regionManager = regionManager; _basicReportView = basicReportView; _navigateReportsCommand = new CategoryCommand <string>(Resources.Reports, Resources.Common, "Images/Ppt.png", OnNavigateReportModule, CanNavigateReportModule) { Order = 80 }; PermissionRegistry.RegisterPermission(PermissionNames.OpenReports, PermissionCategories.Navigation, Resources.CanDisplayReports); PermissionRegistry.RegisterPermission(PermissionNames.ChangeReportDate, PermissionCategories.Report, Resources.CanChangeReportFilter); RuleActionTypeRegistry.RegisterActionType("SaveReportToFile", Resources.SaveReportToFile, new { ReportName = "", FileName = "" }); RuleActionTypeRegistry.RegisterParameterSoruce("ReportName", () => ReportContext.Reports.Select(x => x.Header)); EventServiceFactory.EventService.GetEvent <GenericEvent <ActionData> >().Subscribe(x => { if (x.Value.Action.ActionType == "SaveReportToFile") { var reportName = x.Value.GetAsString("ReportName"); var fileName = x.Value.GetAsString("FileName"); if (!string.IsNullOrEmpty(reportName)) { var report = ReportContext.Reports.Where(y => y.Header == reportName).FirstOrDefault(); if (report != null) { ReportContext.CurrentWorkPeriod = AppServices.MainDataContext.CurrentWorkPeriod; var document = report.GetReportDocument(); try { ReportViewModelBase.SaveAsXps(fileName, document); } catch (Exception e) { AppServices.LogError(e); } } } } }); }