示例#1
0
 public static void DeleteAllCache()
 {
     FileCacheHelper.DeleteCacheDir("html");
 }
示例#2
0
 public static Return GetSettingsCache(string setting)
 {
     return(FileCacheHelper.GetFromCache("settings/" + setting));
 }
示例#3
0
 public static void DeleteSettingsCache()
 {
     FileCacheHelper.DeleteCacheDir("settings");
 }
示例#4
0
 public static void SaveSettingsCache(string setting, string html)
 {
     FileCacheHelper.SaveToCache("settings/" + setting, html);
 }
示例#5
0
 public static void DeleteGenerateNavCache()
 {
     FileCacheHelper.DeleteCacheDir("generatenav");
 }
示例#6
0
 public static Return GetGenerateNavCache()
 {
     return(FileCacheHelper.GetFromCache("generatenav"));
 }
示例#7
0
 public static void SaveGenerateToNav(string html)
 {
     FileCacheHelper.SaveToCache("generatenav", html);
 }
示例#8
0
        public Return PublishLive()
        {
            var returnObj    = new Return();
            var liveVersion  = BaseMapper.GetObjectFromContext((MediaDetail)this.Media.GetLiveMediaDetail());
            var selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)this);

            selectedItem.HistoryVersionNumber  = 0;
            selectedItem.HistoryForMediaDetail = null;
            selectedItem.IsDraft     = false;
            selectedItem.PublishDate = DateTime.Now;
            //selectedItem.ShowInMenu = true;

            IEnumerable <MediaDetail> items = new List <MediaDetail>();

            if (liveVersion != null)
            {
                items = liveVersion.History.ToList();

                foreach (var item in items)
                {
                    if (item.ID != selectedItem.ID)
                    {
                        var tmpItem = BaseMapper.GetObjectFromContext(item);
                        item.HistoryForMediaDetailID = selectedItem.ID;
                    }
                }
            }

            foreach (var fieldAssociation in selectedItem.FieldAssociations)
            {
                var index = 1;
                foreach (var history in fieldAssociation.MediaDetail.History)
                {
                    history.HistoryForMediaDetail = fieldAssociation.MediaDetail;
                    history.HistoryVersionNumber  = 1;

                    index++;
                }

                fieldAssociation.MediaDetail.HistoryForMediaDetail = null;
                fieldAssociation.MediaDetail.HistoryVersionNumber  = 0;
            }

            foreach (var field in selectedItem.Fields)
            {
                foreach (var fieldAssociation in field.FieldAssociations)
                {
                    var index = 1;

                    foreach (var mediaDetail in fieldAssociation.MediaDetail.Media.MediaDetails)
                    {
                        mediaDetail.HistoryForMediaDetail = fieldAssociation.MediaDetail;
                        mediaDetail.HistoryVersionNumber  = 1;

                        index++;
                    }

                    fieldAssociation.MediaDetail.HistoryForMediaDetail = null;
                    fieldAssociation.MediaDetail.HistoryVersionNumber  = 0;
                }

                if (liveVersion != null)
                {
                    field.FrontEndSubmissions = liveVersion.LoadField(field.FieldCode)?.FrontEndSubmissions;
                }
            }

            foreach (var mediaTypeField in selectedItem.MediaType.Fields)
            {
                if (!selectedItem.Fields.Any(i => i.FieldCode == mediaTypeField.FieldCode))
                {
                    var mediaDetailField = new MediaDetailField();
                    mediaDetailField.CopyFrom(mediaTypeField);

                    mediaDetailField.UseMediaTypeFieldFrontEndLayout = true;
                    mediaDetailField.UseMediaTypeFieldDescription    = true;

                    mediaDetailField.MediaTypeField = mediaTypeField;

                    mediaDetailField.DateCreated = mediaDetailField.DateLastModified = DateTime.Now;

                    mediaDetailField.OrderIndex = selectedItem.Fields.Count;
                    selectedItem.Fields.Add(mediaDetailField);
                }
            }


            if (liveVersion != null)
            {
                if (items.Any())
                {
                    liveVersion.HistoryVersionNumber = items.OrderByDescending(i => i.HistoryVersionNumber).FirstOrDefault().HistoryVersionNumber + 1;
                }
                else
                {
                    liveVersion.HistoryVersionNumber = 1;
                }

                liveVersion.HistoryForMediaDetail = (MediaDetail)selectedItem;


                var associations = BaseMapper.GetDataModel().FieldAssociations.Where(i => i.AssociatedMediaDetailID == liveVersion.ID);

                foreach (var association in associations)
                {
                    association.MediaDetail = (MediaDetail)selectedItem;
                }
            }

            returnObj = MediaDetailsMapper.Update(selectedItem);

            if (!returnObj.IsError)
            {
                if (liveVersion != null)
                {
                    liveVersion.HistoryForMediaDetailID = selectedItem.ID;
                    returnObj = MediaDetailsMapper.Update(liveVersion);
                }

                if (!returnObj.IsError)
                {
                    ContextHelper.Clear(ContextType.Cache);
                    FileCacheHelper.ClearAllCache();

                    return(returnObj);
                }
                else
                {
                    return(returnObj);
                }
            }
            else
            {
                return(returnObj);
            }
        }