internal static Preservation Convert(this BibDSModel.Preservation pre, int level = 0, int deeplevel = 5, params Type[] ignoredTypes)
        {
            if (pre == null || level > deeplevel)
            {
                return(null);
            }

            var docs = new BindingList <Document>();

            var retval = new Preservation
            {
                //Archive = pre.Archive.Convert(level + 1, deeplevel),
                CloseContent            = pre.CloseContent,
                CloseDate               = pre.CloseDate,
                Documents               = docs,
                EndDate                 = pre.EndDate,
                IdArchive               = pre.IdArchive,
                IdPreservation          = pre.IdPreservation,
                IdPreservationTaskGroup = pre.IdPreservationTaskGroup,
                IdPreservationUser      = pre.IdPreservationUser,
                IndexHash               = pre.IndexHash,
                Label                     = pre.Label,
                LastVerifiedDate          = pre.LastVerifiedDate,
                Path                      = pre.Path,
                StartDate                 = pre.StartDate,
                PreservationDate          = pre.PreservationDate,
                PreservationSize          = pre.PreservationSize,
                IdDocumentCloseFile       = pre.IdDocumentClose,
                IdDocumentIndexFile       = pre.IdDocumentIndex,
                IdDocumentIndexFileXML    = pre.IdDocumentIndexXml,
                IdDocumentIndexFileXSLT   = pre.IdDocumentIndexXSLT,
                IdDocumentSignedCloseFile = pre.IdDocumentCloseSigned,
                IdDocumentSignedIndexFile = pre.IdDocumentIndedSigned,
                LastSectionalValue        = pre.LastSectionalValue,
                IdArchiveBiblosStore      = pre.IdArchiveBiblosStore,
                LockOnDocumentInsert      = pre.LockOnDocumentInsert
                                            //TaskGroup = pre.PreservationTaskGroup.Convert(level + 1, deeplevel),
                                            //Task = pre.PreservationTask.Convert(level + 1, deeplevel),
                                            //User = pre.PreservationUser.Convert(level + 1, deeplevel),
                                            //PreservationJournalings = pre.PreservationJournaling.Convert(level, deeplevel),
            };

            if (ignoredTypes == null)
            {
                ignoredTypes = new Type[0];
            }

            if (!ignoredTypes.Contains(typeof(DocumentArchive)))
            {
                retval.Archive = pre.Archive.Convert(level + 1, deeplevel);
            }

            if (!ignoredTypes.Contains(typeof(PreservationTaskGroup)))
            {
                retval.TaskGroup = pre.PreservationTaskGroup.Convert(level + 1, deeplevel);
            }

            if (!ignoredTypes.Contains(typeof(PreservationTask)))
            {
                retval.Task = pre.PreservationTask.Convert(level + 1, deeplevel);
            }

            if (!ignoredTypes.Contains(typeof(PreservationUser)))
            {
                retval.User = pre.PreservationUser.Convert(level + 1, deeplevel);
            }

            if (!ignoredTypes.Contains(typeof(PreservationJournaling)))
            {
                retval.PreservationJournalings = pre.PreservationJournaling.Convert(level, deeplevel);
            }

            if (!ignoredTypes.Contains(typeof(Document)))
            {
                foreach (var d in pre.PreservationDocuments)
                {
                    docs.Add(d.Document.Convert(level + 1, deeplevel, null));
                }
                retval.Documents = docs;
            }

            retval.ClearModifiedField();
            return(retval);
        }
        internal static BibDSModel.Preservation Convert(this Preservation pre, BibDSModel.BiblosDS2010Entities db, BibDSModel.Preservation original = null, int level = 0, int deeplevel = 5)
        {
            if (pre == null || level > deeplevel)
            {
                return(null);
            }

            var retval = (original == null) ? new BibDSModel.Preservation() : original;

            // retval.Archive = pre.Archive.ConvertPreservation(db);
            // retval.Archive = pre.Archive;
            retval.CloseContent       = pre.CloseContent;
            retval.CloseDate          = pre.CloseDate;
            retval.IndexHash          = pre.IndexHash;
            retval.Label              = pre.Label;
            retval.LastVerifiedDate   = pre.LastVerifiedDate;
            retval.Path               = pre.Path;
            retval.PreservationDate   = pre.PreservationDate;
            retval.IdPreservationUser = pre.IdPreservationUser;
            retval.IdPreservation     = pre.IdPreservation;

            //var journaling = pre.PreservationJournalings.Convert(db, (original != null) ? original.PreservationJournaling : null, level, deeplevel);
            //foreach (var journal in journaling)
            //{
            //    retval.PreservationJournaling.Add(journal);
            //}

            return(retval);
        }