public CustomQuery(QCustomParams queryParams, QArgs queryArgs = null, QArgsNegative queryArgsNegative = null)
 {
     QueryParams = queryParams;
     QueryArgs = queryArgs;
     QueryArgsNegative = queryArgsNegative;
     //if (QueryArgsNegative != null)
     //	QueryArgsNegative.TagName = "queryArgsNegative";
 }
 public GeneralQuery(string queryParams, string queryArgs)
 {
     XmlDocument queryArgsDoc = new XmlDocument();
     queryArgsDoc.LoadXml(queryArgs);
     XmlDocument queryParamsDoc = new XmlDocument();
     queryParamsDoc.LoadXml(queryArgs);
     QueryArgs = new QArgs(queryArgsDoc.DocumentNode);
     QueryParams = new QGeneralParams(queryParamsDoc.DocumentNode);
 }
 public GeneralQuery(string queryStr)
 {
     XmlDocument queryDoc = new XmlDocument();
     queryDoc.LoadXml(queryStr);
     var queryNode = queryDoc.DocumentNode.SelectSingleNode("/query");
     Debug.Assert(queryNode != null);
     string type = queryNode.GetAttributeValue("type", "");
     Debug.Assert(type == "generalQuery");
     var queryParamsNode = queryNode.SelectSingleNode("./params");
     var queryArgsNode = queryNode.SelectSingleNode("./queryArgs");
     QueryArgs = new QArgs(queryArgsNode);
     QueryParams = new QGeneralParams(queryParamsNode);
 }
        private void extractCandidatesUsingClusteringToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (_computingCandidates)
                {
                    ButtonGetCandidates.Text = "Please wait...";
                    _stopComputingCandidates = true;
                    return;
                }

                // these items should be ignored from computing kmeans or hkmeans
                HashSet<int> ignoredTagsHash = new HashSet<int> { GetTagId(-1, _tagNameConcepts), GetTagId(-1, _tagNameCustomSources) };
                ignoredTagsHash.Remove(TagInfoBase.InvalidTagId);
                QArgs args = null;
                if (ignoredTagsHash.Count > 0)
                    args = new QArgs(null, new[] { new QTagIdCond(ignoredTagsHash) });

                string requestId;
                CandidatesClusters candidateSettings = new CandidatesClusters(this);
                if (candidateSettings.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ListViewCandidates.Items.Clear();
                    int count = int.Parse(candidateSettings.TextBoxCandidateCount.Text);
                    StatusText.Text = "Computing new candidates...";
                    QKeywordMethod method = candidateSettings.GetConceptExtractionMethod();
                    if (candidateSettings.RadioTags.Checked)
                    {
                        StatusProgressBar.Minimum = 0;
                        StatusProgressBar.Maximum = candidateSettings.SelectedTags.Count;
                        _tagIdsToProcess = new Queue<int>(candidateSettings.SelectedTags);
                        _tagIdsToProcessCount = candidateSettings.SelectedTags.Count;
                        _keywordsForTagMethod = method.ToString();
                        _keywordsForTagCount = candidateSettings.GetConceptCount();
                        _computingCandidates = true;
                        RequestKeywordsForNextTagId();
                    }
                    else if (candidateSettings.RadioKMeans.Checked)
                    {
                        int k = int.Parse(candidateSettings.TextBoxKMeans.Text);
                        CustomQuery query = new CustomQuery(new QKwdKMeansParam() { K = k, KeywordCount = count, KeywordMethod = method }, args);
                        string request = Defaults.BuildRequest(PublisherName, "Query", query.ToString(), out requestId);
                        SendRequest(request, requestId, "kmeans");
                    }
                    else if (candidateSettings.RadioHKMeans.Checked)
                    {
                        int min = int.Parse(candidateSettings.TextBoxHKMeansMin.Text);
                        int max = int.Parse(candidateSettings.TextBoxHKMeansMax.Text);
                        CustomQuery query = new CustomQuery(new QKwdHKMeansParam() { MnDocsPerCluster = min, MxDocsPerCluster = max, KeywordCount = count, KeywordMethod = method }, args);
                        string request = Defaults.BuildRequest(PublisherName, "Query", query.ToString(), out requestId);
                        SendRequest(request, requestId, "hkmeans");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception while computing candidates: " + ex.Message);
            }
        }
 /// <summary>
 /// return the item data for the first item that exists in the thread.
 /// typically this is used to find who is the creator of the email or forum thread
 /// </summary>
 /// <param name="thread">string data representing the thread</param>
 /// <param name="itemType">what is the itemType of the item</param>
 /// <returns></returns>
 private HtmlNode GetItemDataForFirstPost(string thread, int itemType = -1)
 {
     QArgs args = new QArgs(new QThreadStrCond(thread));
     if (itemType != -1)
         args.AddCondition(new QItemTypeCond(itemType));
     GeneralQuery query = new GeneralQuery(new QGeneralParams() { ResultData = QResultData.itemData, MaxCount = 1, IncludeAttachments = false, SortBy = QResultSorting.dateAsc }, args);
     string ret = MailData.MinerQuery(query);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(ret);
     HtmlNode node = doc.DocumentNode.SelectSingleNode("//item");
     if (node == null)
         return null;
     return node;
 }
        private HtmlNode GetItemDataForBugDescription(string issueTrackerUrl, string bugId)
        {
            int bugTagId = GetTagIdForBugId(issueTrackerUrl, bugId);
            if (bugTagId == TagInfoBase.InvalidTagId)
                return null;
            QArgs args = new QArgs(new QTagIdCond(bugTagId));
            args.AddCondition(new QItemTypeCond((int)ItemType.BugDescription));
            // sort by itemIdAsc. in this way we will get the first item in the thread
            GeneralQuery query = new GeneralQuery(new QGeneralParams() { MaxCount = 1, SortBy = QResultSorting.itemIdAsc, IncludeAttachments = false }, args);

            string ret = MailData.MinerQuery(query);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(ret);
            HtmlNode node = doc.DocumentNode.SelectSingleNode("//item");
            if (node == null)
                return null;
            return node;
        }
 public GeneralQuery(QGeneralParams queryParams, QArgs queryArgs)
 {
     QueryParams = queryParams;
     QueryArgs = queryArgs;
 }
 public static QArgs GetQArgsForPersonEmails(IEnumerable<IPersonInfo> persons, string roles)
 {
     List<int> accounts = new List<int>();
     foreach (var person in persons)
         accounts.AddRange(person.GetEmailIds());
     QAccountCond accountCond = new QAccountCond(from id in accounts select new QAccountCond.QAccount(id, roles));
     QArgs args = new QArgs(accountCond);
     return args;
 }
 public static QArgs GetQArgsForPersonEmails(IPersonInfo person, string roles)
 {
     QAccountCond accountCond = new QAccountCond(from id in person.GetEmailIds() select new QAccountCond.QAccount(id, roles));
     QArgs args = new QArgs(accountCond);
     return args;
 }