// Constructor
 public CCreatorRecordIndividual( CGedcom gedcom, IProgressCallback progress, string sW3cfile, CIndividualRecord ir, CCreatorIndexIndividuals indiIndexCreator, CPaintbox paintbox )
     : base(gedcom, progress, sW3cfile)
 {
     m_ir = ir;
       m_indiIndexCreator = indiIndexCreator;
       m_paintbox = paintbox;
       m_htFirstFoundEvent = new Hashtable();
       m_sBirthdaySourceRefs = "";
       m_sDeathdaySourceRefs = "";
       m_sNameTitle = "";
       m_bUnknownName = false;
       m_sName = m_ir.Name;
       m_sNameSuffix = m_ir.NameSuffix;
       m_sFirstName = "";
       m_sSurname = "";
       m_sOccupation = "";
       m_bConcealed = m_ir.Visibility() == CIndividualRecord.EVisibility.Restricted;
       m_alEventList = new ArrayList();
       m_alAttributeList = new ArrayList();
       m_alReferenceList = new ArrayList();
       m_alOccupations = new ArrayList();
       m_sPreviousChildLink = "";
       m_sNextChildLink = "";
       m_alOtherNames = new ArrayList();
       m_qdateInferredBirthday = null;
       m_dateActualBirthday = null;
       m_qdateInferredDeathday = null;
       m_dateActualDeathday = null;
       m_alParents = new ArrayList();
 }
예제 #2
0
        // The heart of GEDmill is here.
        public void Create()
        {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Note, "CWebsite::Create()" );

              // 1 means the process was aborted, for signalling back to calling thread. 2 means file nError.
              CThreadError threaderror = new CThreadError( 1, "No error" );

              try
              {
            // The value to indicate in the progress bar to show how much of the website creation is complete.
            int nProgress = 0;

            // The maximum value of the progress bar, i.e. when website creation is fully complete.
            int nProgressMax =
            1  // Site-wide multimedia files
              + 1  // W3C Sticker
              + 1  // Background image
              + 1  // Style sheet
              + m_gedcom.CountIndividuals
              + 1  // Individuals Index
              + m_gedcom.CountSources
              + 1  // Front page
              + 1  // Help page
              + 1  // CD ROM (Doesn't matter here that CD ROM autorun might not be included.)
              + 1; // Scripts (Doesn't matter here that scripts might not be included.)

            // The paintbox with which to draw the mini tree
            CPaintbox paintbox = new CPaintbox(MainForm.s_config);
            paintbox.SetBackgroundImage(MainForm.s_config.m_sBackgroundImage);

            // Object to keep count of number of files created etc.
            CStats stats = new CStats();

            // Here goes....

            // Start the progress indicator.
            m_progressWindow.Begin( 0, nProgressMax );
            if (m_progressWindow.IsAborting)
            {
            return;
            }
            // Copy the images to use in place of non-pic multimedia files.
            m_progressWindow.SetText("Copying multimedia");
            CopyIcons();
            if (m_progressWindow.IsAborting)
            {
            return;
            } m_progressWindow.StepTo(++nProgress);

            // Copy the W3C sticker file.
            m_progressWindow.SetText("Copying W3C sticker");
            string sW3CFilename = "";
            if (MainForm.s_config.m_bIncludeValiditySticker)
            {
              sW3CFilename = CopyW3CSticker();
            }
            if (m_progressWindow.IsAborting)
            {
            return;
            } m_progressWindow.StepTo(++nProgress);

            // Create the index creator for use by the individuals records creator.
            CCreatorIndexIndividuals indiIndexCreator = new CCreatorIndexIndividuals( m_gedcom, m_progressWindow, sW3CFilename );

            // Copy the image for the background of the webpages.
            m_progressWindow.SetText("Copying background image");
            string sBackgroundImageFilename = CopyBackgroundImage();
            if (m_progressWindow.IsAborting)
            {
            return;
            }
            m_progressWindow.StepTo( ++nProgress );

            // Create the style sheet
            m_progressWindow.SetText("Creating style sheet");
            string cssFilename = String.Concat( MainForm.s_config.m_sOutputFolder, "\\", MainForm.s_config.m_sStylesheetFilename, ".css" );
            if( MainForm.s_config.m_sStylesheetFilename.Length>0 && (!MainForm.s_config.m_bPreserveStylesheet || !File.Exists( cssFilename ) ) )
            {
              CCreatorStylesheet csc = new CCreatorStylesheet( m_gedcom, m_progressWindow, sW3CFilename, cssFilename, sBackgroundImageFilename );
              csc.Create();
            }

            if (m_progressWindow.IsAborting)
            {
            return;
            }

            m_progressWindow.StepTo( ++nProgress );

            // Create the pages for the individual records.
            m_progressWindow.SetText("Creating individual pages");
            foreach (CIndividualRecord ir in m_gedcom.m_alIndividualRecords)
            {
              CCreatorRecordIndividual ipc = new CCreatorRecordIndividual( m_gedcom, m_progressWindow, sW3CFilename, ir, indiIndexCreator, paintbox );
              if (ipc.Create( stats ))
              {
            stats.m_unIndividuals++;
              }
              if (m_progressWindow.IsAborting)
              {
              return;
              }

              m_progressWindow.StepTo(++nProgress);
            }

            // Create the index for the individual records pages.
            m_progressWindow.SetText("Creating individuals index");
            indiIndexCreator.Create();
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            m_progressWindow.StepTo(++nProgress);

            // Clear list of copied files, so that source images get copied afresh
            // and so get resized differently to any indi images based on the same file.
            CCreator.ClearCopiedFilesList();

            // Create the pages for the source records.
            m_progressWindow.SetText( "Creating source pages" );
            foreach( CSourceRecord sr in m_gedcom.m_alSourceRecords )
            {
              if( sr != null && sr.ContainsAnyInformation() )
              {
            CCreatorRecordSource spc = new CCreatorRecordSource( m_gedcom, m_progressWindow, sW3CFilename, sr );
            if( spc.Create( stats ) )
            {
              stats.m_unSources++;
            }
              }
              if (m_progressWindow.IsAborting)
              {
              return;
              }

              m_progressWindow.StepTo(++nProgress);
            }
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            // Create the front page
            m_progressWindow.SetText("Creating front page");
            string front_page_filename = String.Concat(MainForm.s_config.m_sOutputFolder, "\\", MainForm.s_config.m_sFrontPageFilename, ".", MainForm.s_config.m_sHtmlExtension);
            if( MainForm.s_config.m_sFrontPageFilename.Length>0 && (!MainForm.s_config.m_bPreserveFrontPage || !File.Exists( front_page_filename ) ) )
            {
              CCreatorFrontPage fpc = new CCreatorFrontPage( m_gedcom, m_progressWindow, sW3CFilename, stats );
              fpc.Create();
            }
            m_progressWindow.StepTo( ++nProgress );
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            // Create the help page
            m_progressWindow.SetText("Creating help page");
            string help_page_filename = String.Concat(MainForm.s_config.m_sOutputFolder, "\\", "help.", MainForm.s_config.m_sHtmlExtension);
            if( MainForm.s_config.m_bIncludeHelppage )
            {
              CCreatorHelppage hpc = new CCreatorHelppage( m_gedcom, m_progressWindow, sW3CFilename );
              hpc.Create();
            }
            m_progressWindow.StepTo( ++nProgress );
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            // Copy the CD ROM autorun file
            m_progressWindow.SetText( "Creating CD-ROM files" );
            if( MainForm.s_config.m_bCreateCDROMFiles )
            {
              CreateCDROMFiles( m_gedcom );
            }
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            m_progressWindow.StepTo(++nProgress);

            // Copy the Javascript
            m_progressWindow.SetText( "Creating Javascript file" );
            if( MainForm.s_config.m_bAllowMultipleImages ) // Currently (10Dec08) the only thing that uses javascript is the multiple images feature.
            {
              CreateJavascriptFiles( m_gedcom );
            }
            if (m_progressWindow.IsAborting)
            {
            return;
            }

            m_progressWindow.StepTo(++nProgress);

            // Done
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Note, "Finished" );
            m_progressWindow.SetText( "Done" );
            threaderror.m_nError = 0;
            threaderror.m_sMessage = "";
              }
              catch( ArgumentException e )
              {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Error, "Caught Argument Exception : " + e.ToString() );

            threaderror.m_nError = 2; // 2 => abnormal abort.
            threaderror.m_sMessage = "";
              }
              catch( IOException e )
              {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Error, "Caught IO Exception : " + e.ToString() );

            threaderror.m_nError = 2; // 2 => abnormal abort.
            threaderror.m_sMessage = "";
              }
              catch( NullReferenceException e )
              {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Error, "Caught NullReference Exception : " + e.ToString() );

            threaderror.m_nError = 2; // 2 => abnormal abort.
            threaderror.m_sMessage = "";
              }
              catch( CHTMLException e )
              {
            threaderror.m_nError = 2; // 2 => abnormal abort.
            threaderror.m_sMessage = e.Message;
              }
              catch( Exception e )
              {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Error, "Caught Exception : " + e.ToString() );

            threaderror.m_nError = 2; // 2 => abnormal abort.
            threaderror.m_sMessage = "";
              }
              finally
              {
            LogFile.TheLogFile.WriteLine( LogFile.DT_HTML, LogFile.EDebugLevel.Note, "Thread ending..." );

            if( m_progressWindow != null )
            {
              m_progressWindow.End( threaderror );
            }
              }
        }