Exemplo n.º 1
0
        private StringBuilder BuildTextFromList(FormattedList <string> texts, string separator)
        {
            var stringBuilder = new StringBuilder();

            foreach (var text in texts)
            {
                if (stringBuilder.Length != 0)
                {
                    stringBuilder.Append(separator);
                }

                stringBuilder.Append(text);
            }
            return(stringBuilder);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Apply the search terms to all the columns in the data set
        /// </summary>
        /// <returns>Data set as FormattedList</returns>
        public FormattedList Filter(bool sort = true)
        {
            var formattedList = new FormattedList();

            //  What are the columns in the data set
            formattedList.Import(this.properties.Select(x => x.Name + ",")
                                 .ToArray());

            //  Return same sEcho that was posted.  Prevents XSS attacks.
            formattedList.sEcho = this.echo;

            //  Return count of all records
            formattedList.iTotalRecords = this.queryable.Count();

            //  Filtered Data
            var records = this.queryable.Where(GenericSearchFilter());

            if (sort)
            {
                records = ApplySort(records);
            }


            //  What is filtered data set count now.  This is NOT the
            //  count of what is returned to client
            formattedList.iTotalDisplayRecords = (records.FirstOrDefault() == null) ? 0 : records.Count();

            //  Take a page
            var pagedRecords = records.Skip(this.displayStart)
                               .Take(this.displayLength);

            //  Convert to List of List<string>
            var aaData  = new List <List <string> >();
            var thisRec = new List <string>();

            pagedRecords.ToList()
            .ForEach(rec => aaData.Add(rec.PropertiesToList()));
            formattedList.aaData = aaData;

            return(formattedList);
        }
Exemplo n.º 3
0
        private void OnCreateAndUpdateButtonClicked(object sender, RoutedEventArgs e)
        {
            var historicPeriod = (TimelineHistoricPeriod)Enum.Parse(typeof(TimelineHistoricPeriod), HistoricPeriodComboBox.SelectedValue.ToString());

            var title = TitleTextBox.Text;

            var works = new List <string>();

            ParseText(WorksTextBox.Text, ref works, '/');

            var links = new List <string>();

            ParseText(RelatedLinksTextBox.Text, ref links, '/');

            var now = DateTime.Now;

            LastModifiedLabel.Content = now.ToString();

            var newTimelineEvent = new TimelineEvent()
            {
                Title        = title,
                Description  = DescriptionTextBox.Text,
                Geography    = GeographyTextBox.Text,
                Start        = StartTextBox.Text,
                End          = EndTextBox.Text,
                Period       = historicPeriod,
                Type         = TypeTextBox.Text,
                WikiLink     = WikiLinkTextBox.Text,
                Works        = FormattedList <string> .CreateFormattedList(works),
                RelatedLinks = FormattedList <string> .CreateFormattedList(links),
                LastModified = now
            };

            // Update the model
            HistoricPeriodsModel.Instance.AddEntry(newTimelineEvent);
        }