コード例 #1
0
ファイル: LineSr.cs プロジェクト: RemSoftDev/SportBetting
        public SyncList <MatchLn> QuickSearchMatches(DelegateFilterMatches dfm)
        {
            Debug.Assert(dfm != null);

            SyncList <MatchLn> lResult     = new SyncList <MatchLn>();
            SyncList <MatchLn> lAllMatches = m_diAll.Matches.ToSyncList();

            foreach (var match in lAllMatches)
            {
                if (dfm(match))
                {
                    lResult.Add(match);
                }
            }

            return(lResult);
        }
コード例 #2
0
ファイル: LineSr.cs プロジェクト: RemSoftDev/SportBetting
        public void SearchMatches(SyncList <IMatchVw> lMatchesToSync, string sSearch, string sLanguage, DelegateFilterMatches dfm)
        {
            CheckTime ct = new CheckTime(false, "SearchMatches('{0}', '{1}') entered", sSearch, sLanguage);

            lock (m_oReadLocker)
            {
                if (lMatchesToSync != null)
                {
                    HashSet <IMatchVw> hsMatches   = new HashSet <IMatchVw>();
                    SyncList <MatchLn> lAllMatches = m_diAll.Matches.ToSyncList();

                    if (!string.IsNullOrEmpty(sSearch))
                    {
                        ct.AddEvent("Search by string in {0} matches", lAllMatches.Count);

                        IdentityList ilGroups      = new IdentityList();
                        IdentityList ilCompetitors = new IdentityList();

                        m_diAll.TaggedStrings.SearchRelatedStrings(sSearch, sLanguage, ilGroups, ilCompetitors);

                        int  iCode     = 0;
                        bool bIsNumber = int.TryParse(sSearch, out iCode) && 0 < iCode && iCode < MAX_MATCH_CODE;

                        if (ilCompetitors.Count > 0 || bIsNumber)
                        {
                            foreach (var mtch in lAllMatches)
                            {
#if DEBUG || TRACE_ID_FROM_FILE
                                if (TraceHelper.TraceFromFileLongValues("MatchIds.txt", (long)mtch.MatchId, new TraceHelper.DelegateLongFromRegistryFound(MatchIdFromFileFound), mtch))
                                {
                                    // Put breakpoint here to catch certain match by mtch.MatchId
                                }
#endif
                                string sCode = mtch.Code.Value.ToString("G");

                                if (sCode.IndexOf(sSearch, StringComparison.OrdinalIgnoreCase) >= 0 || ilCompetitors.Contains(mtch.HomeCompetitorId.Value) || ilCompetitors.Contains(mtch.AwayCompetitorId.Value))
                                {
                                    SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                                }
                                //else
                                //{
                                //    SyncList<GroupLn> lGroups = LineSr.Instance.AllObjects.MatchesToGroups.GetMatchGroups(mtch.MatchId);

                                //    foreach (GroupLn group in lGroups)
                                //    {
                                //        if (ilGroups.Contains(group.GroupId))
                                //        {
                                //            SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                                //        }
                                //    }
                                //}
                            }
                        }
                    }
                    else
                    {
                        ct.AddEvent("Search directly in {0} matches", lAllMatches.Count);

                        foreach (var mtch in lAllMatches)
                        {
#if DEBUG || TRACE_ID_FROM_FILE
                            if (TraceHelper.TraceFromFileLongValues("MatchIds.txt", (long)mtch.MatchId, new TraceHelper.DelegateLongFromRegistryFound(MatchIdFromFileFound), mtch))
                            {
                                // Put breakpoint here to catch certain match by mtch.MatchId
                            }
#endif
                            SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                        }
                    }

                    ct.AddEvent("Search Completed");

                    for (int i = 0; i < lMatchesToSync.Count;)
                    {
                        IMatchVw matchView = lMatchesToSync[i];

                        if (!hsMatches.Contains(matchView))
                        {
                            lMatchesToSync.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }

                    ct.AddEvent("Remove Completed");
                }
            }

            ct.AddEvent("Completed (Found {0} match(es))", lMatchesToSync.Count);
            ct.Info(m_logger);
        }
コード例 #3
0
ファイル: LineSr.cs プロジェクト: RemSoftDev/SportBetting
        private static void SearchMatchImp(HashSet <IMatchVw> hsMatches, SyncList <IMatchVw> lMatchesToSync, MatchLn mtch, DelegateFilterMatches dfm)
        {
            if (dfm == null || dfm(mtch))
            {
                hsMatches.Add(mtch.MatchView);

                if (!lMatchesToSync.Contains(mtch.MatchView))
                {
                    lMatchesToSync.Add(mtch.MatchView);
                }
            }
        }
コード例 #4
0
ファイル: LineSr.cs プロジェクト: RemSoftDev/SportBetting
        public void SearchMatches(SortableObservableCollection <IMatchVw> ocMatches, string sSearch, string sLanguage, DelegateFilterMatches dfm, Comparison <IMatchVw> comparison)
        {
            SyncList <IMatchVw> lMatchesToSync = ocMatches.ToSyncList();

            SearchMatches(lMatchesToSync, sSearch, sLanguage, dfm);

            if (comparison != null)
            {
                lMatchesToSync.Sort(comparison);
            }
            ocMatches.ApplyChanges(lMatchesToSync);
        }