Esempio n. 1
0
 public ReportStandardPagesMaker(ReportStandardGenerator OwnerGenerator)
 {
     this.OwnerGenerator      = OwnerGenerator;
     this.PageRemainingHeight = this.OwnerGenerator.WorkingPageContentHeight;
     this.IsAtPageStart       = true;
 }
Esempio n. 2
0
        public static void GeneratePdfXpsReport(CompositionEngine Engine)
        {
            if (Engine == null)
            {
                return;
            }

            if (!ProductDirector.ValidateEditionPermission(AppExec.LIC_EDITION_STANDARD, "Generate PDF/XPS Report"))
            {
                return;
            }

            if (Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration == null)
            {
                Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration = new ReportConfiguration();
            }

            if (!ReportingManager.EditReportConfiguration("PDF/XPS", Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration))
            {
                return;
            }

            var Generator = new ReportStandardGenerator(Engine.TargetComposition, Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration);

            var Title = "Report of " + Engine.TargetComposition.Name;

            ProgressiveThreadedExecutor <int> .Execute("Generating " + Title, Generator.Generate,
                                                       (opresult) =>
            {
                if (opresult.WasSuccessful && !File.Exists(Generator.GeneratedDocumentTempFilePath))
                {
                    opresult = OperationResult.Failure <int>("Cannot write temporal report file at: " + Generator.GeneratedDocumentTempFilePath);
                }

                if (!opresult.WasSuccessful)
                {
                    Display.DialogMessage("Report not completed!", opresult.Message, EMessageType.Warning);
                    return;
                }

                try
                {
                    var GeneratedDocument = Display.LoadDocumentFromXPS(Generator.GeneratedDocumentTempFilePath);
                    var Location          = new Uri(Generator.GeneratedDocumentTempFilePath, UriKind.Absolute);
                    var Package           = System.IO.Packaging.PackageStore.GetPackage(Location);

                    DocViewerControl = new PrintPreviewer(GeneratedDocument, Generator.GeneratedDocumentTempFilePath,
                                                          Engine.TargetComposition.Name);

                    Display.OpenContentDialogWindow(ref WinFlowDocViewer, Title, DocViewerControl);

                    Package.Close();        // Package remains open, so must closed!
                    //if you don't remove the package from the PackageStore, you won't be able to
                    //re-open the same file again later (due to System.IO.Packaging's Package store/caching
                    //rather than because of any file locks)
                    System.IO.Packaging.PackageStore.RemovePackage(Location);

                    if (File.Exists(Generator.GeneratedDocumentTempFilePath))
                    {
                        File.Delete(Generator.GeneratedDocumentTempFilePath);
                    }
                }
                catch (Exception Problem)
                {
                    Display.DialogMessage("Attention!", "Cannot show generated Report.\n"
                                          + (!Generator.GeneratedDocumentTempFilePath.IsAbsent() && File.Exists(Generator.GeneratedDocumentTempFilePath)
                                                 ? "It can still be found at: " + Generator.GeneratedDocumentTempFilePath : "")
                                          + "\nProblem: " + Problem.Message);
                }
            });
        }