/** Generators Save Dialogue Boxes ****************************************/

        private void CallbackSaveGeneratorSitemapXml(object sender, EventArgs e)
        {
            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.Filter           = "Sitemap XML files (*.xml)|*.xml|All files (*.*)|*.*";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "xml";
            Dialog.AddExtension     = true;
            Dialog.FileName         = "Macroscope-Sitemap.xml";

            MacroscopeSitemapGenerator SitemapGenerator;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Pathname = Dialog.FileName;

                Cursor.Current = Cursors.WaitCursor;

                SitemapGenerator = new MacroscopeSitemapGenerator(
                    NewDocCollection: this.JobMaster.GetDocCollection()
                    );

                try
                {
                    SitemapGenerator.WriteSitemapXml(NewPath: Pathname);
                }
                catch (XmlException ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                }
                catch (MacroscopeSitemapException ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            else
            {
                this.DialogueBoxError("Error saving Sitemap XML", "Could not open file.");
            }

            if (Dialog != null)
            {
                Dialog.Dispose();
            }
        }
        /** Generators Save Dialogue Boxes ****************************************/

        private void CallbackSaveGeneratorSitemapXml(object sender, EventArgs e)
        {
            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.Filter           = "Sitemap XML files (*.xml)|*.xml|All files (*.*)|*.*";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "xml";
            Dialog.AddExtension     = true;
            Dialog.FileName         = "Macroscope-Sitemap.xml";

            MacroscopeSitemapGenerator SitemapGenerator;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Pathname = Dialog.FileName;

                SitemapGenerator = new MacroscopeSitemapGenerator(
                    NewDocCollection: this.JobMaster.GetDocCollection()
                    );

                try
                {
                    if (Macroscope.MemoryGuard(RequiredMegabytes: 256))
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        SitemapGenerator.WriteSitemapXml(NewPath: Pathname);
                        Cursor.Current = Cursors.Default;
                    }
                }
                catch (MacroscopeInsufficientMemoryException ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                    GC.Collect();
                }
                catch (XmlException ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Sitemap XML", ex.Message);
                    GC.Collect();
                }
            }

            Dialog.Dispose();

            GC.Collect();
        }
 public void TestWriteSitemapXml()
 {
     foreach (string Url in this.Urls)
     {
         MacroscopeJobMaster          JobMaster        = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE);
         MacroscopeDocumentCollection DocCollection    = new MacroscopeDocumentCollection(JobMaster: JobMaster);
         MacroscopeSitemapGenerator   SitemapGenerator = new MacroscopeSitemapGenerator(NewDocCollection: DocCollection);
         DocCollection.AddDocument(new MacroscopeDocument(JobMaster.SetStartUrl(Url: Url)));
         string Filename = string.Join(".", Path.GetTempFileName(), ".xml");
         SitemapGenerator.WriteSitemapXml(NewPath: Filename);
         Assert.IsTrue(File.Exists(Filename));
         if (File.Exists(Filename))
         {
             File.Delete(Filename);
         }
     }
 }
        public void TestWriteSitemapXmlWithEmptyDocCollection()
        {
            MacroscopeJobMaster          JobMaster        = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE);
            MacroscopeDocumentCollection DocCollection    = new MacroscopeDocumentCollection(JobMaster: JobMaster);
            MacroscopeSitemapGenerator   SitemapGenerator = new MacroscopeSitemapGenerator(NewDocCollection: DocCollection);
            string Filename = string.Join(".", Path.GetTempFileName(), ".xml");

            try
            {
                SitemapGenerator.WriteSitemapXml(NewPath: Filename);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.GetType(), new MacroscopeSitemapException().GetType());
            }
            Assert.IsFalse(File.Exists(Filename));
            if (File.Exists(Filename))
            {
                File.Delete(Filename);
            }
        }