示例#1
0
        /// <summary>
        /// Gets the slide from the SlideId using RelationshipId
        /// </summary>
        /// <param name="slideId">The slide identifier.</param>
        /// <returns></returns>
        internal SlidePart GetSlide(SlideId slideId)
        {
            ParameterHelpers.NotNull <SlideId>(slideId, "slideId");

            if (PresentationPart != null)
            {
                return((SlidePart)PresentationPart.GetPartById(slideId.RelationshipId));
            }
            return(null);
        }
示例#2
0
        public void Run(Document document, Stream excelStream)
        {
            ParameterHelpers.NotNull <Document>(document, "document");
            Document = document;

            if (!Document.IsLoaded)
            {
                throw new InvalidOperationException("You need to call Load() method of the document before running the generator.");
            }

            Logger logger = LogManager.GetLogger("Generator");

            try
            {
                logger.Debug("------------------------------------------------------------------------------------------------------------------------------------");
                logger.Debug("Step 1: Loading data");
                AddTiming(2, "Starting Excel loading");
                IList <DataElement> data = ImportData(excelStream, logger);

                logger.Debug("------------------------------------------------------------------------------------------------------------------------------------");
                logger.Debug("Step 2: Loading and parsing slides");
                GetSlides(logger);
                AddTiming(3, "Slides parsed");

                logger.Debug("------------------------------------------------------------------------------------------------------------------------------------");
                logger.Debug("Step 3: Processing data");
                ProcessData(logger, data);
                AddTiming(4, "Data processed");

                logger.Debug("------------------------------------------------------------------------------------------------------------------------------------");
                logger.Debug("Step 4: Generating content");
                AddTiming(5, "Starting generation");
                ProcessSlides(logger, data);

                logger.Debug("------------------------------------------------------------------------------------------------------------------------------------");
                logger.Debug("Done");
                ReportProgress("Finishing...", 1, 1);
                Document.SaveAndClose();
                AddTiming(6, "Output saved");
                ReportProgress("Done!", 0, 0, true);
            }
            catch (Exception ex)
            {
                logger.Debug("Error, processing stopped");
                logger.Debug(ex.ToString());
                throw;
            }
        }