public FileResult Export(StringResourceSearchQuery searchQuery)
        {
            var resources = _provider.AllResources.GetResourcesByKeyAndValue(searchQuery);
            var data = new List<List<string>>
                           {
                               new List<string>
                                   {
                                       "Key",
                                       "Value",
                                       "Culture",
                                       "SiteId"
                                   }
                           };
            foreach (var source in resources.OrderBy(resource => resource.Key))
            {
                var row = new List<string>();
                AddToRow(row, source.Key);
                AddToRow(row, source.Value);
                AddToRow(row, source.UICulture);
                AddToRow(row, source.Site == null ? string.Empty : source.Site.Id.ToString());
                data.Add(row);
            }
            string result = string.Join(Environment.NewLine, data.Select(list => string.Join(",", list)));

            return new FileContentResult(Encoding.Default.GetBytes(result), "text/csv")
            {
                FileDownloadName =
                    "MrCMS-ResourceData-" + CurrentRequestData.Now +
                    ".csv"
            };
        }
Example #2
0
 public ViewResult Index(StringResourceSearchQuery searchQuery)
 {
     ViewData["results"] = _stringResourceAdminService.Search(searchQuery);
     ViewData["language-options"] = _stringResourceAdminService.SearchLanguageOptions();
     ViewData["site-options"] = _stringResourceAdminService.SearchSiteOptions();
     return View(searchQuery);
 }
        public IPagedList<StringResource> Search(StringResourceSearchQuery searchQuery)
        {
            IEnumerable<StringResource> resources =
                _provider.AllResources.GetResourcesByKeyAndValue(searchQuery);
            if (searchQuery.Language == DefaultLanguage)
            {
                resources = resources.Where(resource => resource.UICulture == null);
            }
            else if (!string.IsNullOrWhiteSpace(searchQuery.Language))
            {
                resources = resources.Where(resource => resource.UICulture == searchQuery.Language);
            }

            if (searchQuery.SiteId.HasValue)
            {
                if (searchQuery.SiteId == -1)
                {
                    resources = resources.Where(resource => resource.Site == null);
                }
                else if (searchQuery.SiteId > 0)
                {
                    resources =
                        resources.Where(resource => resource.Site != null && resource.Site.Id == searchQuery.SiteId);
                }
            }

            return new PagedList<StringResource>(resources.OrderBy(resource => resource.DisplayKey), searchQuery.Page,
                _siteSettings.DefaultPageSize);
        }
        public static IEnumerable<StringResource> GetResourcesByKeyAndValue(
            this IEnumerable<StringResource> resourcesForQuery, StringResourceSearchQuery searchQuery)
        {
            IEnumerable<StringResource> resources = resourcesForQuery;

            if (!string.IsNullOrWhiteSpace(searchQuery.Key))
            {
                resources =
                    resources.Where(
                        resource => resource.Key.Contains(searchQuery.Key, StringComparison.OrdinalIgnoreCase));
            }

            if (!string.IsNullOrWhiteSpace(searchQuery.Value))
            {
                resources =
                    resources.Where(
                        resource => resource.Value.Contains(searchQuery.Value, StringComparison.OrdinalIgnoreCase));
            }
            return resources;
        }
Example #5
0
 public FileResult Export(StringResourceSearchQuery searchQuery)
 {
     return _stringResourceUpdateService.Export(searchQuery);
 }