コード例 #1
0
ファイル: DoDBase.cs プロジェクト: Tengfei0311/gcd
        public virtual XmlNode Serialize(XmlNode nodParent)
        {
            XmlNode nodDoD = nodParent.AppendChild(nodParent.OwnerDocument.CreateElement("DoD"));

            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("Name")).InnerText   = Name;
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("Folder")).InnerText = ProjectManager.Project.GetRelativePath(Folder.FullName);
            SerializeSurface(nodDoD, NewSurface, "NewSurface");
            SerializeSurface(nodDoD, OldSurface, "OldSurface");

            if (AOIMask != null)
            {
                nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("AOI")).InnerText = AOIMask.Name;
            }

            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("RawDoD")).InnerText       = ProjectManager.Project.GetRelativePath(RawDoD.Raster.GISFileInfo);
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("ThrDoD")).InnerText       = ProjectManager.Project.GetRelativePath(ThrDoD.Raster.GISFileInfo);
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("ThrErr")).InnerText       = ProjectManager.Project.GetRelativePath(ThrErr.Raster.GISFileInfo);
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("RawHistogram")).InnerText = ProjectManager.Project.GetRelativePath(Histograms.Raw.Path);
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("ThrHistogram")).InnerText = ProjectManager.Project.GetRelativePath(Histograms.Thr.Path);
            nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("SummaryXML")).InnerText   = ProjectManager.Project.GetRelativePath(SummaryXML);

            SerializeDoDStatistics(nodParent.OwnerDocument, nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("Statistics")), Statistics);

            if (BudgetSegregations.Count > 0)
            {
                XmlNode nodBS = nodDoD.AppendChild(nodParent.OwnerDocument.CreateElement("BudgetSegregations"));
                BudgetSegregations.ForEach(x => x.Serialize(nodBS));
            }

            if (LinearExtractions.Count > 0)
            {
                XmlNode nodLE = nodDoD.AppendChild(nodDoD.OwnerDocument.CreateElement("LinearExtractions"));
                LinearExtractions.ForEach(x => x.Serialize(nodLE));
            }

            // Return this so inherited classes can append to it.
            return(nodDoD);
        }
コード例 #2
0
ファイル: DoDBase.cs プロジェクト: Tengfei0311/gcd
        public override void Delete()
        {
            RemoveLayersFromMap();

            // recursively check all files under the DoD are not locked. Throws exception if they are
            // Do this before attempting to delete any files so you don't end up in partial dataset
            CheckFilesInUse(Folder);

            try
            {
                // This is the safest way to delete from a list while iterating through it.
                for (int i = BudgetSegregations.Count - 1; i >= 0; i--)
                {
                    BudgetSegregations[i].Delete();
                }
            }
            finally
            {
                BudgetSegregations.Clear();
            }

            // Delete the raw and thresholded rasters
            RawDoD.Delete();
            ThrDoD.Delete();
            ThrErr.Delete();

            // Now delete all the meta files associated with the DoD
            foreach (FileInfo file in RawDoD.Raster.GISFileInfo.Directory.GetFiles("*.*", SearchOption.AllDirectories))
            {
                try
                {
                    file.Delete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unable to delete file " + file.FullName);
                    Console.WriteLine(ex.Message);
                }
            }

            // Delete the figures folder
            DirectoryInfo dirFigs = FiguresFolderPath(Folder);

            try
            {
                System.IO.Directory.Delete(dirFigs.FullName, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to delete DoD figures folder " + dirFigs.FullName);
                Console.WriteLine(ex.Message);
            }

            // Try to delete the DoD folder
            try
            {
                Folder.Delete();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to delete DoD folder  " + Folder.FullName);
                Console.WriteLine(ex.Message);
            }

            // If there are no more DoDs try to delete the parent change detection folder "CD"
            if (Folder.Parent.GetDirectories().Length < 1)
            {
                Folder.Parent.Delete();
            }

            // If there are no more analyses then delete this folder
            if (Folder.Parent.Parent.GetDirectories().Length < 1)
            {
                Folder.Parent.Parent.Delete();
            }

            // Remove the DoD from the project
            ProjectManager.Project.DoDs.Remove(this);
            ProjectManager.Project.Save();
        }
コード例 #3
0
ファイル: DoDBase.cs プロジェクト: Tengfei0311/gcd
 public bool IsBudgetSegNameUnique(string name, BudgetSegregation ignore)
 {
     return(!BudgetSegregations.Any(x => x != ignore && string.Compare(name, x.Name, true) == 0));
 }