Beispiel #1
0
        /// <summary>
        /// Generate a CSV file as a string from Filter page user inputs
        /// </summary>
        /// <param name="versionFilter">list of version keys in the order they appear in VersionManager.SelectionViewModel</param>
        /// <param name="classFilter">List of content class names</param>
        /// <param name="filters">List of filters</param>
        /// <param name="pagingSpec">Specification of paging</param>
        /// <returns>A CSV as a string</returns>
        public string GenerateCsv(List <string> versionFilter, string[] classFilter, List <ListFilter> filters, PagingSpec pagingSpec)
        {
            var results = RunFilter(versionFilter, classFilter, filters, pagingSpec);

            StringBuilder sb = new StringBuilder();

            foreach (var row in results)
            {
                sb.AppendFormat("\"{0}\"", BaseContent.ContentClassDisplayName(row.Item2.Type));
                sb.AppendFormat(",\"{0}\"", row.Item2.DisplayTitle().Replace("\"", ""));
                sb.AppendFormat(",\"{0}\"", row.Item2.Url);
                foreach (var filt in filters.Where(f => f.Show))
                {
                    sb.Append(",");

                    string vals = filt.GetShowText(row) ?? "";
                    if (vals.Contains("|"))
                    {
                        bool innerFirst = true;
                        foreach (string val in vals.Split('|'))
                        {
                            if (innerFirst)
                            {
                                innerFirst = false;
                            }
                            else
                            {
                                sb.Append(",");
                            }

                            sb.AppendFormat("\"{0}\"", val.Replace("\"", ""));
                        }
                    }
                    else
                    {
                        sb.AppendFormat("\"{0}\"", vals.Replace("\"", ""));
                    }
                }
                sb.AppendLine();
            }

            return(sb.ToString());
        }
Beispiel #2
0
 public ImageVideo()
 {
     BaseContent.InitialiseProperties(this);
 }