Пример #1
0
        private void findBestPosts(string i_Expression)
        {
            lock (m_LockPostsSearch)
            {
                List <PostWrapper> postsWrappers = new List <PostWrapper>();
                foreach (Post post in LoginForm.s_LoggedInUser.Posts)
                {
                    if (isPostTypeSelected(post.Type.Value))
                    {
                        eDate eDate = getDateRange();
                        if (post != null &&
                            isLegalDate(post, eDate))
                        {
                            if (i_Expression != string.Empty)
                            {
                                if (post.Message != null && post.Message.Contains(i_Expression))
                                {
                                    postsWrappers.Add(new PostWrapper(post));
                                }
                            }
                            else
                            {
                                postsWrappers.Add(new PostWrapper(post));
                            }
                        }
                    }
                }

                postsWrappers.Sort((x, y) => comparePostWrappers(x.Post, y.Post));
                postsWrappers.Reverse();
                int maxPossibleRange = Math.Min(postsWrappers.Count, (int)numericUpDownDisplayResults.Value);
                List <PostWrapper> subPostWrappers = postsWrappers.GetRange(0, maxPossibleRange);
                listBoxResult.Invoke(new Action(
                                         () =>
                {
                    listBoxResult.Items.Clear();
                    foreach (PostWrapper pw in subPostWrappers)
                    {
                        listBoxResult.Items.Add(pw);
                    }
                }));
            }
        }
Пример #2
0
 private static bool isLegalDate(Post post, eDate eDate)
 {
     return(eDate.Equals(eDate.AllTime) || post.CreatedTime >= DateTime.Now.AddDays((int)eDate * -1));
 }
Пример #3
0
 public DateFormat(eDate i_eDate)
 {
     this.eDate = i_eDate;
 }