Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Log = new List <string>();
            Control.CheckForIllegalCrossThreadCalls = false;
            this.AddLog("Program loading...");

            this.AddLog("Keywords loading...");
            KeywordContext.Load();
            this.AddLog("WebSites loading...");
            WebSiteContext.Load();
            this.UpdateKeywordList();
            this.AddLog("UI Components loading...");
            this.LoadDataGrids();
            this.AddLog("Bot settings are loaded, Bot is diseabled!");
            this.BotIsActive = false;


            cbWebSite.DataSource    = WebSiteContext.Sites;
            cbWebSite.DisplayMember = "Name";
            cbWebSite.ValueMember   = "Id";

            cbBotStatus.DataSource = Enum.GetValues(typeof(BotStatusEnum));

            BotTimer.Interval = 15000;
            BotTimer.Tick    += new EventHandler(timer_Tick);
            BotTimer.Start();

            this.AddLog("Program succesfully loaded!");
        }
Exemple #2
0
 public FormatterParams(TextFormatter formatter, IValueProvider valueProvider)
 {
     this.formatter     = formatter;
     this.valueProvider = valueProvider;
     additionnalRules   = null;
     context            = KeywordContext.FightSolo;
 }
Exemple #3
0
        private void btnRemoveKeyword_Click(object sender, EventArgs e)
        {
            string text = this.lstSearchKeywords.SelectedItem.ToString();

            if (text != "")
            {
                KeywordContext.RemoveKeyword(text);
                this.UpdateKeywordList();
            }
        }
Exemple #4
0
        private void btnAddKeyword_Click(object sender, EventArgs e)
        {
            this.txtKeyword.Text = this.txtKeyword.Text.Trim();

            if (this.txtKeyword.Text != "")
            {
                KeywordContext.AddKeyword(this.txtKeyword.Text);

                this.UpdateKeywordList();
            }

            this.txtKeyword.Text = "";
        }
Exemple #5
0
        private void Search()
        {
            if (KeywordContext.Keywords.Count > 0)
            {
                this.AddLog("A Keyword Searcing...");
                var result = SC.HPScanAds(KeywordContext.TakeKeyword(), 3);

                if (result != null && result.Count > 0)
                {
                    SearchResults.AddRange(result);
                    UpdateKeywordList();
                }
                this.AddLog("Keyword Search Copleted!");
            }
        }
Exemple #6
0
        public static void PopulateSynonyms(Dictionary <string, List <string> > synonymLookup)
        {
            SPSecurity.RunWithElevatedPrivileges(
                delegate
            {
                try
                {
                    var ssaProxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.Current);
                    if (ssaProxy.FASTAdminProxy != null)
                    {
                        var fastProxy = ssaProxy.FASTAdminProxy;

                        KeywordContext keywordContext = fastProxy.KeywordContext;
                        SearchSettingGroupCollection searchSettingGroupCollection = keywordContext.SearchSettingGroups;

                        DateTime currentDate = DateTime.Now;

                        foreach (SearchSettingGroup searchSettingGroup in searchSettingGroupCollection)
                        {
                            foreach (Keyword keyword in searchSettingGroup.Keywords)
                            {
                                foreach (Synonym synonym in keyword.Synonyms)
                                {
                                    if (synonym.StartDate < currentDate || synonym.EndDate > currentDate)
                                    {
                                        continue;
                                    }

                                    AddSynonym(keyword.Term, synonym.Term, synonymLookup);
                                    if (synonym.ExpansionType == SynonymExpansionType.TwoWay)
                                    {
                                        AddSynonym(synonym.Term, keyword.Term, synonymLookup);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (SecurityException secEx)
                {
                    Logger.Instance.Error("Failed to populated synonyms", secEx, DiagnosticsCategories.eCaseSearch);
                    throw secEx;
                }
            }
                );
        }
Exemple #7
0
        public KeywordContext keyword()
        {
            KeywordContext _localctx = new KeywordContext(Context, State);

            EnterRule(_localctx, 4, RULE_keyword);
            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 53; Match(String);
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
 public bool IsValidFor(KeywordContext context)
 {
     return(((int)context & (int)conditionMask) == (int)conditionMask);
 }
 public override SymbolBase VisitKeyword([NotNull] KeywordContext context) =>
 new KeywordSymbol(context.GetText());
        public static string CreateBestBetXml(List <string> queryWords, bool exactMatchOnTerms)
        {
            List <string> bestBets = new List <string>();
            List <string> termDefs = new List <string>();

            SPSecurity.RunWithElevatedPrivileges(
                delegate
            {
                var ssaProxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.Current);
                if (ssaProxy.FASTAdminProxy != null)
                {
                    var fastProxy = ssaProxy.FASTAdminProxy;

                    KeywordContext keywordContext = fastProxy.KeywordContext;
                    SearchSettingGroupCollection searchSettingGroupCollection = keywordContext.SearchSettingGroups;

                    DateTime currentDate = DateTime.Now;

                    string fullQuery = string.Join(" ", queryWords.ToArray());

                    foreach (SearchSettingGroup searchSettingGroup in searchSettingGroupCollection)
                    {
                        foreach (Keyword keyword in searchSettingGroup.Keywords)
                        {
                            List <string> terms = exactMatchOnTerms ? GetFullTermAndSynonymWords(keyword) : GetPartialTermAndSynonymWords(keyword);

                            foreach (string bestBetTerms in terms)
                            {
                                //TODO: fullquery - check any combination with exact match on the best bet

                                if (!_reNonChar.IsMatch(bestBetTerms))     //a-z only
                                {
                                    Regex reBoundaryMatch = new Regex(@"\b" + bestBetTerms + @"\b");
                                    if (!reBoundaryMatch.IsMatch(fullQuery))
                                    {
                                        continue;
                                    }
                                }

                                if (!queryWords.Contains(bestBetTerms))
                                {
                                    continue;
                                }

                                string termDef = GetTermDefXml(keyword);
                                if (!string.IsNullOrEmpty(termDef) && !termDefs.Contains(termDef))
                                {
                                    termDefs.Add(termDef);
                                }

                                foreach (BestBet bestBet in keyword.BestBets)
                                {
                                    if (bestBet.StartDate < currentDate || bestBet.EndDate > currentDate)
                                    {
                                        continue;
                                    }

                                    string xml = BuildBestBetXml(keyword, bestBet);
                                    if (!bestBets.Contains(xml))
                                    {
                                        bestBets.Add(xml);
                                    }
                                }
                            }
                        }
                    }
                }
            }
                );

            return("<All_Results>" + string.Join("", termDefs.ToArray()) + "<BestBetResults>" + string.Join("", bestBets.ToArray()) + "</BestBetResults></All_Results>");
        }
Exemple #11
0
 public static bool IsValidFor(this KeywordCondition c, KeywordContext context)
 {
     return(((int)context & (int)c) == (int)c);
 }
Exemple #12
0
 public KeywordController(KeywordContext context)
 {
     Database = context;
 }
Exemple #13
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     //searchTask.Dispose();
     //t.Stop();
     KeywordContext.Save();
 }