Пример #1
0
        public static void RemoveSocialMediaChannelThemes()
        {
            MediaService mediaService = (MediaService)ApplicationContext.Current.Services.MediaService;
            var          rootFolder   = mediaService.GetMediaOfMediaType(1031).Where(x => x.Name == SOCIAL_MEDIA_THEME_FOLDER_NAME).FirstOrDefault();

            mediaService.Delete(rootFolder);
        }
        private void CleanupProcessedImages()
        {
            var processedImages = MediaRepository
                                  .GetMany(i => i.State == MediaState.Processed, i => i.Id)
                                  .ToArray();

            MediaService.Delete(processedImages);
            UnitOfWork.Commit();
        }
Пример #3
0
        public static void RemoveSocialMediaChannelTheme(string theme)
        {
            string        themesPath   = HttpContext.Current.Server.MapPath(SOCIAL_MEDIA_CHANNELS_FOLDER);
            string        newThemePath = Path.Combine(themesPath, theme);
            DirectoryInfo newThemeDir  = new DirectoryInfo(newThemePath);
            MediaService  mediaService = (MediaService)ApplicationContext.Current.Services.MediaService;

            //Get the media type id
            int mediaTypeId = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(SOCIAL_MEDIA_THEME_ALIAS).Id;

            FileInfo infoFile = newThemeDir.GetFiles("info.txt")[0];
            string   themeNick, themeName;

            using (StreamReader reader = new StreamReader(infoFile.FullName))
            {
                themeNick = reader.ReadLine();
                themeName = reader.ReadLine();
            }

            var currTheme = mediaService.GetMediaOfMediaType(mediaTypeId).Where(x => x.GetValue("themeName").ToString() == themeName).FirstOrDefault();

            mediaService.Delete(currTheme);
        }