Esempio n. 1
0
        protected void btnShowYql_Clicked(object sender, EventArgs e)
        {
            YamsterMessageQuery query = BuildQuery();
            string xml = query.SaveToXmlString();

            using (var window = new EditYqlWindow(xml))
            {
                Utilities.RunWindowAsDialog(window);
            }
        }
Esempio n. 2
0
        protected void btnSearch_Clicked(object sender, EventArgs e)
        {
            YamsterMessageQuery query = BuildQuery();

            this.messageView.LoadQuery(query);

            var results = this.messageView.GetMessagesInView()
                          .OrderByDescending(x => x.CreatedDate)
                          .ToList();

            ctlMessageViewer.LoadMessages(results);

            lblSearchResults.Text    = string.Format("{0} yams matched your search.", results.Count);
            lblSearchResults.Visible = true;
        }
Esempio n. 3
0
        YamsterMessageQuery BuildQuery()
        {
            var predicateNodes = new List <YqlNode>();

            var sentByUsers = ctlSentByUserEntry.ParseUserList();

            if (sentByUsers.Count > 0)
            {
                var sentByNodes = new List <YqlNode>();
                foreach (YamsterUser user in sentByUsers)
                {
                    sentByNodes.Add(
                        new YqlOperationNode(YqlOperation.Equal,
                                             new YqlUserPropertyNode(YqlUserProperty.Id,
                                                                     new YqlMessagePropertyNode(YqlMessageProperty.Sender)
                                                                     ),
                                             new YqlValueNode(user.UserId)
                                             )
                        );
                }
                predicateNodes.Add(
                    new YqlOperationNode(YqlOperation.Or, sentByNodes.ToArray())
                    );
            }

            var mentioningUsers = ctlMentioningUserEntry.ParseUserList();

            if (mentioningUsers.Count > 0)
            {
                var mentioningNodes = new List <YqlNode>();
                foreach (YamsterUser user in mentioningUsers)
                {
                    // "in reply to" X
                    mentioningNodes.Add(
                        new YqlOperationNode(YqlOperation.Equal,
                                             new YqlMessagePropertyNode(YqlMessageProperty.UserIdRepliedTo),
                                             new YqlValueNode(user.UserId)
                                             )
                        );
                    // "CC:" to X
                    mentioningNodes.Add(
                        new YqlListContainsNode(
                            new YqlMessagePropertyNode(YqlMessageProperty.NotifiedUsers),
                            new YqlValueNode(user.UserId)
                            )
                        );
                }
                predicateNodes.Add(
                    new YqlOperationNode(YqlOperation.Or, mentioningNodes.ToArray())
                    );
            }

            var likedByUsers = ctlLikedByUserEntry.ParseUserList();

            if (likedByUsers.Count > 0)
            {
                var likedByNodes = new List <YqlNode>();
                foreach (YamsterUser user in likedByUsers)
                {
                    likedByNodes.Add(
                        new YqlListContainsNode(
                            new YqlMessagePropertyNode(YqlMessageProperty.LikingUsers),
                            new YqlValueNode(user.UserId)
                            )
                        );
                }
                predicateNodes.Add(
                    new YqlOperationNode(YqlOperation.Or, likedByNodes.ToArray())
                    );
            }

            YqlTextMatchNode textMatchNode = new YqlTextMatchNode(
                new YqlMessagePropertyNode(YqlMessageProperty.Body),
                txtSearch.Text,
                wholeWords: chkWholeWords.Active,
                matchAllWords: rbMatchAll.Active
                );

            predicateNodes.Add(textMatchNode);

            YamsterMessageQuery query = new YamsterMessageQuery(
                "Search",
                new YqlOperationNode(YqlOperation.And, predicateNodes.ToArray())
                );

            return(query);
        }