Exemple #1
0
        private void CreateSnapshotOverVersion(int tabId, TabVersion snapshotTabVersion, TabVersion deletedTabVersion = null)
        {
            var snapShotTabVersionDetails = GetVersionModulesDetails(tabId, snapshotTabVersion.Version).ToArray();
            var existingTabVersionDetails = _tabVersionDetailController.GetTabVersionDetails(snapshotTabVersion.TabVersionId).ToArray();

            for (var i = existingTabVersionDetails.Count(); i > 0; i--)
            {
                var existingDetail = existingTabVersionDetails.ElementAtOrDefault(i - 1);

                if (deletedTabVersion == null)
                {
                    if (snapShotTabVersionDetails.All(tvd => tvd.TabVersionDetailId != existingDetail.TabVersionDetailId))
                    {
                        _tabVersionDetailController.DeleteTabVersionDetail(existingDetail.TabVersionId,
                                                                           existingDetail.TabVersionDetailId);
                    }
                }
                else if (existingDetail.Action == TabVersionDetailAction.Deleted)
                {
                    IEnumerable <TabVersionDetail> deletedTabVersionDetails = _tabVersionDetailController.GetTabVersionDetails(deletedTabVersion.TabVersionId);
                    var moduleAddedAndDeleted = deletedTabVersionDetails.Any(
                        deleteDetail =>
                        deleteDetail.ModuleId == existingDetail.ModuleId &&
                        deleteDetail.Action == TabVersionDetailAction.Added);
                    if (moduleAddedAndDeleted)
                    {
                        _tabVersionDetailController.DeleteTabVersionDetail(existingDetail.TabVersionId,
                                                                           existingDetail.TabVersionDetailId);
                    }
                }
            }

            UpdateDeletedTabDetails(snapshotTabVersion, deletedTabVersion, snapShotTabVersionDetails);
        }
Exemple #2
0
        private void DiscardVersion(int tabId, TabVersion tabVersion)
        {
            var unPublishedDetails = _tabVersionDetailController.GetTabVersionDetails(tabVersion.TabVersionId);

            var currentPublishedVersion = GetCurrentVersion(tabId);

            TabVersionDetail[] publishedChanges = null;

            if (currentPublishedVersion != null)
            {
                publishedChanges = GetVersionModulesDetails(tabId, GetCurrentVersion(tabId).Version).ToArray();
            }

            foreach (var unPublishedDetail in unPublishedDetails)
            {
                if (publishedChanges == null)
                {
                    DiscardDetailWithoutPublishedTabVersions(tabId, unPublishedDetail);
                }
                else
                {
                    DiscardDetailWithPublishedTabVersions(tabId, unPublishedDetail, publishedChanges);
                }
            }

            _tabVersionController.DeleteTabVersion(tabId, tabVersion.TabVersionId);
        }
Exemple #3
0
        private void DeleteTmpVersionIfExists(int tabId, TabVersion versionToDelete)
        {
            var tmpVersion = _tabVersionController.GetTabVersions(tabId).OrderByDescending(tv => tv.Version).FirstOrDefault();

            if (tmpVersion != null && tmpVersion.Version > versionToDelete.Version)
            {
                _tabVersionController.DeleteTabVersion(tabId, tmpVersion.TabVersionId);
            }
        }
Exemple #4
0
 private TabVersionDetail GetResetTabVersionDetail(TabVersion tabVersion)
 {
     return(new TabVersionDetail
     {
         PaneName = "none_resetAction",
         TabVersionId = tabVersion.TabVersionId,
         Action = TabVersionDetailAction.Reset,
         ModuleId = Null.NullInteger,
         ModuleVersion = Null.NullInteger
     });
 }
Exemple #5
0
        private void DeleteOldVersions(IEnumerable <TabVersion> tabVersionsOrdered, TabVersion snapShotTabVersion)
        {
            var oldVersions = tabVersionsOrdered.Where(tv => tv.Version < snapShotTabVersion.Version).ToArray();

            for (var i = oldVersions.Count(); i > 0; i--)
            {
                var oldVersion        = oldVersions.ElementAtOrDefault(i - 1);
                var oldVersionDetails = _tabVersionDetailController.GetTabVersionDetails(oldVersion.TabVersionId).ToArray();
                for (var j = oldVersionDetails.Count(); j > 0; j--)
                {
                    var oldVersionDetail = oldVersionDetails.ElementAtOrDefault(j - 1);
                    _tabVersionDetailController.DeleteTabVersionDetail(oldVersionDetail.TabVersionId, oldVersionDetail.TabVersionDetailId);
                }
                _tabVersionController.DeleteTabVersion(oldVersion.TabId, oldVersion.TabVersionId);
            }
        }
        private void UpdateDeletedTabDetails(TabVersion snapshotTabVersion, TabVersion deletedTabVersion,
                                             TabVersionDetail[] snapShotTabVersionDetails)
        {
            var tabVersionDetailsToBeUpdated = deletedTabVersion != null?_tabVersionDetailController.GetTabVersionDetails(deletedTabVersion.TabVersionId).ToArray()
                                                   : snapShotTabVersionDetails;

            foreach (var tabVersionDetail in tabVersionDetailsToBeUpdated)
            {
                var detailInSnapshot =
                    snapShotTabVersionDetails.Any(
                        snapshotDetail => snapshotDetail.TabVersionDetailId == tabVersionDetail.TabVersionDetailId);
                var deleteOrResetAction = tabVersionDetail.Action == TabVersionDetailAction.Deleted || tabVersionDetail.Action == TabVersionDetailAction.Reset;
                if (detailInSnapshot ||
                    deleteOrResetAction)
                {
                    tabVersionDetail.TabVersionId = snapshotTabVersion.TabVersionId;
                    _tabVersionDetailController.SaveTabVersionDetail(tabVersionDetail);
                }
            }
        }
Exemple #7
0
 public void SaveTabVersion(TabVersion tabVersion, int createdByUserID, int modifiedByUserID)
 {
     tabVersion.TabVersionId = Provider.SaveTabVersion(tabVersion.TabVersionId, tabVersion.TabId, tabVersion.TimeStamp, tabVersion.Version, tabVersion.IsPublished, createdByUserID, modifiedByUserID);
     ClearCache(tabVersion.TabId);
 }
Exemple #8
0
 public void SaveTabVersion(TabVersion tabVersion, int createdByUserID)
 {
     SaveTabVersion(tabVersion, createdByUserID, createdByUserID);
 }
Exemple #9
0
 public void SaveTabVersion(TabVersion tabVersion)
 {
     SaveTabVersion(tabVersion, tabVersion.CreatedByUserID, tabVersion.LastModifiedByUserID);
 }
        private static void ProcessDeletionDetail(ModuleInfo module, int moduleVersion, int userId, TabVersion targetVersion)
        {
            if (IsHostModule(module))
            {
                return;
            }

            var existingTabDetail =
                TabVersionDetailController.Instance.GetTabVersionDetails(targetVersion.TabVersionId)
                .SingleOrDefault(tvd => tvd.ModuleId == module.ModuleID);

            if (existingTabDetail != null)
            {
                TabVersionDetailController.Instance.DeleteTabVersionDetail(existingTabDetail.TabVersionId,
                                                                           existingTabDetail.TabVersionDetailId);

                //When a module is added in the same version, then we should do nothing with it
                if (existingTabDetail.Action == TabVersionDetailAction.Added)
                {
                    return;
                }
            }

            //Do not add module to Tab Version Details if it has been hard deleted
            ModuleInfo moduleInfo = ModuleController.Instance.GetModule(module.ModuleID, module.TabID, false);

            if (moduleInfo != null)
            {
                var tabVersionDetail = CreateNewTabVersionDetailObjectFromModule(targetVersion.TabVersionId, module,
                                                                                 moduleVersion, TabVersionDetailAction.Deleted);
                TabVersionDetailController.Instance.SaveTabVersionDetail(tabVersionDetail, userId);
            }
        }
        private static void ProcessAdditionDetail(ModuleInfo module, int moduleVersion, int userId, TabVersion targetVersion)
        {
            if (IsHostModule(module))
            {
                return;
            }

            //Module could be restored in the same version
            var existingTabDetails =
                TabVersionDetailController.Instance.GetTabVersionDetails(targetVersion.TabVersionId)
                .Where(tvd => tvd.ModuleId == module.ModuleID);

            foreach (var existingTabDetail in existingTabDetails)
            {
                TabVersionDetailController.Instance.DeleteTabVersionDetail(existingTabDetail.TabVersionId,
                                                                           existingTabDetail.TabVersionDetailId);
            }

            var tabVersionDetail = CreateNewTabVersionDetailObjectFromModule(targetVersion.TabVersionId, module,
                                                                             moduleVersion, TabVersionDetailAction.Added);

            TabVersionDetailController.Instance.SaveTabVersionDetail(tabVersionDetail, userId);
        }
Exemple #12
0
        private TabVersion PublishVersion(int portalId, int tabId, int createdByUserID, TabVersion tabVersion)
        {
            var unPublishedDetails = _tabVersionDetailController.GetTabVersionDetails(tabVersion.TabVersionId);

            foreach (var unPublishedDetail in unPublishedDetails)
            {
                if (unPublishedDetail.ModuleVersion != Null.NullInteger)
                {
                    PublishDetail(tabId, unPublishedDetail);
                }
            }

            tabVersion.IsPublished = true;
            _tabVersionController.SaveTabVersion(tabVersion, tabVersion.CreatedByUserID, createdByUserID);
            var tab = TabController.Instance.GetTab(tabId, portalId);

            if (!tab.HasBeenPublished)
            {
                TabController.Instance.MarkAsPublished(tab);
            }
            _moduleController.ClearCache(tabId);
            return(tabVersion);
        }