Exemple #1
0
        internal MatchResults MatchWith(Method?method, Uri?uri)
        {
            if (_method.Equals(method))
            {
                if (uri == null || !uri.IsAbsoluteUri || uri.Scheme != "http" && uri.Scheme != "https")
                {
                    throw new ArgumentException(
                              "In order to match on Uri, it has to be an absolute uri for http or https scheme", nameof(uri));
                }

                var path             = uri.AbsolutePath;
                var pathCurrentIndex = 0;
                var totalSegments    = _matchable.TotalSegments;
                var running          = new RunningMatchSegments(totalSegments);
                for (var idx = 0; idx < totalSegments; ++idx)
                {
                    var segment = _matchable.PathSegment(idx);
                    if (segment.IsPathParameter)
                    {
                        running.KeepParameterSegment(pathCurrentIndex);
                        pathCurrentIndex = IndexOfNextSegmentStart(pathCurrentIndex, path);
                    }
                    else
                    {
                        var indexOfSegment = path.IndexOf(segment.Value, pathCurrentIndex, StringComparison.InvariantCulture);
                        if (indexOfSegment == -1 || (pathCurrentIndex == 0 && indexOfSegment != 0))
                        {
                            return(UnmatchedResults);
                        }
                        var lastIndex = segment.LastIndexOf(indexOfSegment);
                        running.KeepPathSegment(indexOfSegment, lastIndex);
                        pathCurrentIndex = lastIndex;
                    }
                }
                int nextPathSegmentIndex = IndexOfNextSegmentStart(pathCurrentIndex, path);
                if (nextPathSegmentIndex != path.Length)
                {
                    if (nextPathSegmentIndex < path.Length - 1)
                    {
                        return(UnmatchedResults);
                    }
                }
                var matchResults = new MatchResults(this, running, ParameterNames, path);
                return(matchResults);
            }
            return(UnmatchedResults);
        }
Exemple #2
0
        private void ViewResultsButton_Click(object sender, RoutedEventArgs e)
        {
            var openQueueResultsDialog = new OpenFileDialog();

            openQueueResultsDialog.Filter           = CustomCommands.QueueResultsFilenameFilter;
            openQueueResultsDialog.InitialDirectory = Options.CurrentUserOptions.CurrentMatchQueueResultsPath;

            if (openQueueResultsDialog.ShowDialog() == true)
            {
                try
                {
                    DarwinDatabase resultsDB;
                    DatabaseFin    databaseFin;
                    MatchResults   results = _vm.LoadMatchResults(openQueueResultsDialog.FileName, out resultsDB, out databaseFin);

                    if (resultsDB == null || databaseFin == null || results == null)
                    {
                        throw new Exception("Missing object");
                    }

                    if (resultsDB.Filename.ToLower() != _vm.MatchingQueue.Database.Filename.ToLower())
                    {
                        MessageBox.Show(this,
                                        "Warning: This queue was run against a different database " + Environment.NewLine +
                                        "the currently loaded database.  The database used for the queue " + Environment.NewLine +
                                        "is being loaded to view the results.  This will not change the " + Environment.NewLine +
                                        "database you have loaded.",
                                        "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    var matchingResultsWindowVM = new MatchingResultsWindowViewModel(
                        databaseFin,
                        results,
                        resultsDB);
                    var matchingResultsWindow = new MatchingResultsWindow(matchingResultsWindowVM);
                    matchingResultsWindow.Show();
                }
                catch (Exception ex)
                {
                    Trace.Write(ex);
                    MessageBox.Show(this, "There was a problem loading your results.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemple #3
0
        private List <FaceMatch> SearchCollectionForSourceImageFaces()
        {
            List <FaceMatch> result = new List <FaceMatch>();

            Console.WriteLine("Searching target collection for matching source faces...");

            foreach (var entry in DataSet.SourceImages)
            {
                Console.WriteLine("Attempting to match image {0}.", entry.Key);
                MemoryStream stream = new MemoryStream();
                entry.Value.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);

                Image requestImage = new Image()
                {
                    Bytes = stream
                };

                SearchFacesByImageRequest request = new SearchFacesByImageRequest()
                {
                    Image        = requestImage,
                    CollectionId = CollectionName
                };

                var watch = Stopwatch.StartNew();
                SearchFacesByImageResponse response = Client.SearchFacesByImage(request);
                watch.Stop();
                TimingResults.Add(new TimingModel("SearchCollectionForSourceImageFaces", entry.Key, watch.ElapsedMilliseconds));
                MatchResults.Add(response);

                if (response.FaceMatches.Count > 0)
                {
                    Console.WriteLine("Matching target face found for {0} with a confidence level of {1}.", entry.Key, response.SearchedFaceConfidence);
                }
                else
                {
                    Console.WriteLine("No matching target face found for {0}.", entry.Key);
                }

                result.AddRange(response.FaceMatches);
            }

            Console.WriteLine("{0} out of {1} faces successfully matched.", result.Count, DataSet.SourceImages.Count);
            return(result);
        }
Exemple #4
0
        public void CanCreateWithoutMatches()
        {
            var removedItem  = new TestClassDefinition();
            var removedItems = new List <IClassDefinition>
            {
                removedItem
            };
            var addedItem  = new TestClassDefinition();
            var addedItems = new List <IClassDefinition>
            {
                addedItem
            };

            var sut = new MatchResults <IClassDefinition>(removedItems, addedItems);

            sut.MatchingItems.Should().BeEmpty();
            sut.ItemsRemoved.Should().BeEquivalentTo(removedItems);
            sut.ItemsAdded.Should().BeEquivalentTo(addedItems);
        }
        public static MatchResults Evaluate(ConditionCollection conditions, RewriteContext context, BackReferenceCollection backReferences)
        {
            BackReferenceCollection prevBackReferences = null;
            MatchResults            condResult         = null;
            var orSucceeded = false;

            foreach (var condition in conditions)
            {
                if (orSucceeded && conditions.Grouping == LogicalGrouping.MatchAny)
                {
                    continue;
                }

                if (orSucceeded)
                {
                    orSucceeded = false;
                    continue;
                }

                condResult = condition.Evaluate(context, backReferences, prevBackReferences);
                var currentBackReferences = condResult.BackReferences;
                if (conditions.Grouping == LogicalGrouping.MatchAny)
                {
                    orSucceeded = condResult.Success;
                }
                else if (!condResult.Success)
                {
                    return(condResult);
                }

                if (condResult.Success && conditions.TrackAllCaptures && prevBackReferences != null)
                {
                    prevBackReferences.Add(currentBackReferences);
                    currentBackReferences = prevBackReferences;
                }

                prevBackReferences = currentBackReferences;
            }

            return(new MatchResults {
                BackReferences = prevBackReferences, Success = condResult.Success
            });
        }
Exemple #6
0
        public static MatchResults GetMatchResultsData(IntPtr processHandle, int endOfMatchObjectAddress)
        {
            MatchResults res = new MatchResults();
            int          matchresultsaddress = ReadMemInt32(processHandle, endOfMatchObjectAddress + 0x264) + 0x60;

            res.MapId = ReadMemInt32(processHandle, matchresultsaddress);
            res.ZoneRatingIncrease = ReadMemInt32(processHandle, matchresultsaddress + 0x4);
            res.EnemyID            = ReadMemInt32(processHandle, matchresultsaddress + 0x8);
            res.DifficultyID       = ReadMemInt32(processHandle, matchresultsaddress + 0xC);
            res.Waves                 = ReadMemInt32(processHandle, matchresultsaddress + 0x10);
            res.TotalMatchTime        = ReadMemInt32(processHandle, matchresultsaddress + 0x14);
            res.OverallRatingIncrease = ReadMemInt32(processHandle, matchresultsaddress + 0x18);
            res.Success               = ReadMemInt32(processHandle, matchresultsaddress + 0x1C);
            res.ZoneID                = ReadMemInt32(processHandle, matchresultsaddress + 0x20);
            ReadTeamScoreInfo(processHandle, out res.TeamScore, out res.TeamSize);
            int gri = GetFinalLocationFromOffset(processHandle, LOC_MPINFO, OFF_SECTOR1_GAMEREPLICATIONINFO);

            res.TeamMedals = ReadMedals(processHandle, gri + 0x2DC);
            return(res);
        }
Exemple #7
0
 internal MatchResults MatchWith(Method method, Uri uri)
 {
     if (_method.Equals(method))
     {
         var path             = uri.AbsolutePath;
         var pathCurrentIndex = 0;
         var totalSegments    = _matchable.TotalSegments;
         var running          = new RunningMatchSegments(totalSegments);
         for (var idx = 0; idx < totalSegments; ++idx)
         {
             var segment = _matchable.PathSegment(idx);
             if (segment.IsPathParameter)
             {
                 running.KeepParameterSegment(pathCurrentIndex);
                 pathCurrentIndex = IndexOfNextSegmentStart(pathCurrentIndex, path);
             }
             else
             {
                 var indexOfSegment = path.IndexOf(segment.Value, pathCurrentIndex);
                 if (indexOfSegment == -1 || (pathCurrentIndex == 0 && indexOfSegment != 0))
                 {
                     return(UnmatchedResults);
                 }
                 var lastIndex = segment.LastIndexOf(indexOfSegment);
                 running.KeepPathSegment(indexOfSegment, lastIndex);
                 pathCurrentIndex = lastIndex;
             }
         }
         int nextPathSegmentIndex = IndexOfNextSegmentStart(pathCurrentIndex, path);
         if (nextPathSegmentIndex != path.Length)
         {
             if (_disallowPathParametersWithSlash || nextPathSegmentIndex < path.Length - 1)
             {
                 return(UnmatchedResults);
             }
         }
         var matchResults = new MatchResults(this, running, ParameterNames, path, _disallowPathParametersWithSlash);
         return(matchResults);
     }
     return(UnmatchedResults);
 }
Exemple #8
0
        public MatchResults Process(Team team1, Team team2)
        {
            var results = new MatchResults()
            {
                Team1Results      = _team1Results,
                Team2Results      = _team2Results,
                Team1ScoreResults = _team1ScoreResults,
                Team2ScoreResults = _team2ScoreResults
            };

            if (team1 == null)
            {
                Logger.Error("Failed to process match: team1 is null");
                return(null);
            }

            if (team2 == null)
            {
                Logger.Error("Failed to process match: team2 is null");
                return(null);
            }

            IEnumerable <int> seasons = Constants.CSV_LIST_SEASONS.Split(',').Select(s => int.Parse(s));

            foreach (var season in seasons)
            {
                _team1Results.Add(season, new List <MatchCompareResult>());
                _team2Results.Add(season, new List <MatchCompareResult>());
                _team1ScoreResults.Add(season, new List <MatchCompareResult>());
                _team2ScoreResults.Add(season, new List <MatchCompareResult>());

                Season team1Season = team1.Seasons[season];
                Season team2Season = team2.Seasons[season];
                CompareSeason(season, team1Season, team2Season);
                LoadSeasonScores(season, team1Season, team2Season);
            }

            return(results);
        }
Exemple #9
0
        public void CalculateChangesReturnsResultFromComparer(SemVerChangeType changeType, bool expected)
        {
            var oldItem  = new TestClassDefinition();
            var oldItems = new List <IClassDefinition>
            {
                oldItem
            };
            var newItem  = new TestClassDefinition();
            var newItems = new List <IClassDefinition>
            {
                newItem
            };
            var match   = new ItemMatch <IClassDefinition>(oldItem, newItem);
            var matches = new List <ItemMatch <IClassDefinition> > {
                match
            };
            var options      = ComparerOptions.Default;
            var matchResults = new MatchResults <IClassDefinition>(matches, Array.Empty <IClassDefinition>(),
                                                                   Array.Empty <IClassDefinition>());
            var message = Guid.NewGuid().ToString();
            var result  = new ComparisonResult(changeType, oldItem, newItem, message);
            var results = new List <ComparisonResult> {
                result
            };

            Service <IEvaluator <IClassDefinition> >().FindMatches(oldItems, newItems).Returns(matchResults);
            Service <IItemComparer <IClassDefinition> >().CompareMatch(match, options).Returns(results);

            var actual = SUT.CalculateChanges(oldItems, newItems, options);

            if (expected)
            {
                actual.Should().BeEquivalentTo(results);
            }
            else
            {
                actual.Should().BeEmpty();
            }
        }
        public FinalResult ComputeWinner(MatchResults matchResults)
        {
            List <int> seasons = Constants.CSV_LIST_SEASONS.Split(',').Select(s => int.Parse(s)).OrderByDescending(x => x).ToList();

            int count = seasons.Count;

            foreach (var season in seasons)
            {
                CalculateSeasonResult(season, matchResults.Team1Results[season], matchResults.Team2Results[season], Math.Exp(count));
                CalculateSeasonScoreResult(season, matchResults.Team1ScoreResults[season], matchResults.Team2ScoreResults[season], Math.Exp(count));
                count--;
            }

            _finalResult.Winner = CalculateWinner();

            var finalScores = CalculateFinalScores();

            _finalResult.Team1Score = finalScores.team1Score;
            _finalResult.Team2Score = finalScores.team2Score;

            return(_finalResult);
        }
Exemple #11
0
        public virtual void ApplyRule(RewriteContext context)
        {
            // Due to the path string always having a leading slash,
            // remove it from the path before regex comparison
            var          path = context.HttpContext.Request.Path;
            MatchResults initMatchResults;

            if (path == PathString.Empty)
            {
                initMatchResults = InitialMatch.Evaluate(path.ToString(), context);
            }
            else
            {
                initMatchResults = InitialMatch.Evaluate(path.ToString().Substring(1), context);
            }

            if (!initMatchResults.Success)
            {
                context.Logger?.UrlRewriteNotMatchedRule(Name);
                return;
            }

            MatchResults condResult = null;

            if (Conditions != null)
            {
                condResult = ConditionEvaluator.Evaluate(Conditions, context, initMatchResults.BackReferences);
                if (!condResult.Success)
                {
                    context.Logger?.UrlRewriteNotMatchedRule(Name);
                    return;
                }
            }

            context.Logger?.UrlRewriteMatchedRule(Name);
            // at this point we know the rule passed, evaluate the replacement.
            Action.ApplyAction(context, initMatchResults?.BackReferences, condResult?.BackReferences);
        }
        static void TestGetMatchResults(Account account)
        {
            InsureAccount(account);

            Console.WriteLine("To GetMatchResults, please input symbol, such as btcbitcny, bchbtc, rcneth ...");
            Console.Write("  symbol     = ");
            string   symbol    = Console.ReadLine();
            DateTime startData = DateTime.Now.Date - new TimeSpan(7, 0, 0, 0);
            DateTime endData   = DateTime.Now.Date;

            Console.WriteLine("  start-date = {0:yyyy-MM-dd}", startData);
            Console.WriteLine("  end-date   = {0:yyyy-MM-dd}", endData);
            MatchResults matchResults = Api.GetMatchResults(account, symbol, startData, endData);

            if (matchResults == null)
            {
                Console.WriteLine("GetMatchResults Failed!");
                return;
            }

            Console.WriteLine("GetMatchResults Succeed:  ({0} items)", matchResults.items.Count);
            for (int i = 0; i < matchResults.items.Count; i++)
            {
                MatchResults.Item item = matchResults.items[i];
                Console.WriteLine("  {0}.\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}",
                                  i + 1,
                                  item.id,
                                  item.price,
                                  item.volume,
                                  item.fee,
                                  item.orderId,
                                  item.symbol,
                                  item.type,
                                  item.status,
                                  item.mtime,
                                  item.source);
            }
        }
        public void CalculateChangesReturnsResultsForAddedElementDefinitions(MethodModifiers modifiers,
                                                                             SemVerChangeType expected)
        {
            var oldItems = Array.Empty <IMethodDefinition>();
            var newItem  = new TestMethodDefinition().Set(x =>
            {
                x.IsVisible = true;
                x.Modifiers = modifiers;
            });
            var newItems = new List <IMethodDefinition>
            {
                newItem
            };
            var options      = ComparerOptions.Default;
            var matchResults = new MatchResults <IMethodDefinition>(Array.Empty <IMethodDefinition>(),
                                                                    newItems);

            Service <IMethodEvaluator>().FindMatches(oldItems, newItems).Returns(matchResults);

            var actual = SUT.CalculateChanges(oldItems, newItems, options).ToList();

            actual.Should().HaveCount(1);
            actual[0].ChangeType.Should().Be(expected);
        }
        public void CalculateChangesReturnsBreakingWhenAddingMethodToInterface()
        {
            var declaringType = new TestInterfaceDefinition();
            var oldItems      = Array.Empty <IMethodDefinition>();
            var newItem       = new TestMethodDefinition().Set(x =>
            {
                x.IsVisible     = true;
                x.DeclaringType = declaringType;
            });
            var newItems = new List <IMethodDefinition>
            {
                newItem
            };
            var options      = ComparerOptions.Default;
            var matchResults = new MatchResults <IMethodDefinition>(Array.Empty <IMethodDefinition>(),
                                                                    newItems);

            Service <IMethodEvaluator>().FindMatches(oldItems, newItems).Returns(matchResults);

            var actual = SUT.CalculateChanges(oldItems, newItems, options).ToList();

            actual.Should().HaveCount(1);
            actual[0].ChangeType.Should().Be(SemVerChangeType.Breaking);
        }
Exemple #15
0
        public void CompareMatchEvaluatesChildTypes()
        {
            var oldChildItem  = new TestClassDefinition().Set(x => x.Name = "OldChild");
            var oldChildItems = new List <IClassDefinition>
            {
                oldChildItem
            };
            var oldParentItem = new TestClassDefinition().Set(x =>
            {
                x.Name         = "OldParent";
                x.ChildClasses = oldChildItems;
                x.ChildTypes   = oldChildItems;
            });
            var oldParentItems = new List <IClassDefinition>
            {
                oldParentItem
            };
            var newChildItem  = new TestClassDefinition().Set(x => x.Name = "NewChild");
            var newChildItems = new List <IClassDefinition>
            {
                newChildItem
            };
            var newParentItem = new TestClassDefinition().Set(x =>
            {
                x.Name         = "NewParent";
                x.ChildClasses = newChildItems;
                x.ChildTypes   = newChildItems;
            });
            var newParentItems = new List <IClassDefinition>
            {
                newParentItem
            };
            var childMatch   = new ItemMatch <ITypeDefinition>(oldChildItem, newChildItem);
            var childMatches = new List <ItemMatch <ITypeDefinition> > {
                childMatch
            };
            var childMatchResults = new MatchResults <ITypeDefinition>(childMatches, Array.Empty <IClassDefinition>(),
                                                                       Array.Empty <IClassDefinition>());
            var childMessage = Guid.NewGuid().ToString();
            var childResult  = new ComparisonResult(SemVerChangeType.Breaking, oldChildItem, newChildItem, childMessage);
            var childResults = new List <ComparisonResult> {
                childResult
            };
            var parentMatch   = new ItemMatch <ITypeDefinition>(oldParentItem, newParentItem);
            var parentMatches = new List <ItemMatch <ITypeDefinition> > {
                parentMatch
            };
            var parentMatchResults = new MatchResults <ITypeDefinition>(parentMatches, Array.Empty <IClassDefinition>(),
                                                                        Array.Empty <IClassDefinition>());
            var parentMessage = Guid.NewGuid().ToString();
            var parentResult  =
                new ComparisonResult(SemVerChangeType.Breaking, oldParentItem, newParentItem, parentMessage);
            var parentResults = new List <ComparisonResult> {
                parentResult
            };
            var options = ComparerOptions.Default;

            Service <ITypeEvaluator>().FindMatches(
                Match.On <IEnumerable <ITypeDefinition> >(x => x.Should().BeEquivalentTo(oldParentItems)),
                Match.On <IEnumerable <ITypeDefinition> >(x => x.Should().BeEquivalentTo(newParentItems)))
            .Returns(parentMatchResults);
            Service <ITypeComparer>().CompareMatch(parentMatch, options).Returns(parentResults);
            Service <ITypeEvaluator>().FindMatches(
                Match.On <IEnumerable <ITypeDefinition> >(x => x.Should().BeEquivalentTo(oldChildItems)),
                Match.On <IEnumerable <ITypeDefinition> >(x => x.Should().BeEquivalentTo(newChildItems)))
            .Returns(childMatchResults);
            Service <ITypeComparer>().CompareMatch(childMatch, options).Returns(childResults);

            var actual = SUT.CalculateChanges(oldParentItems, newParentItems, options).ToList();

            actual.Should().HaveCount(2);
            actual.Should().Contain(parentResult);
            actual.Should().Contain(childResult);
        }
Exemple #16
0
 public virtual void Reset()
 {
     this.Buffer.Clear();
     this.IsMatched = MatchResults.Init;
 }
        public Dictionary <string, string> readGameData()
        {
            Process process = Process.GetProcessesByName("masseffect3").FirstOrDefault();

            if (process == null)
            {
                return(null);
            }

            IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, process.Id);
            int    lobbysetup    = ReadMemInt32(processHandle, LOC_LOBBYSETUP);

            if (lobbysetup == 0)
            {
                CloseHandle(processHandle);
                return(null);
            }

            bool isPlayingMatch = false;

            int sector1 = GetFinalLocationFromOffset(processHandle, LOC_MPINFO, OFF_SECTOR1_GAMEREPLICATIONINFO);

            if (sector1 == -1)
            {
                CloseHandle(processHandle);
                return(null);
            }

            int sector2 = GetFinalLocationFromOffset(processHandle, LOC_MPINFO, OFF_SECTOR2_WAVECOORDINATOR);

            if (sector2 == -1)
            {
            }

            int info = sector1 + 0x2F8;

            map   = ReadMemInt32(processHandle, info);
            enemy = ReadMemInt32(processHandle, info + 4);
            diff  = ReadMemInt32(processHandle, info + 8);

            if (map == -1)
            {
                map            = ReadMemInt32(processHandle, info + 16);
                enemy          = ReadMemInt32(processHandle, info + 20);
                diff           = ReadMemInt32(processHandle, info + 24);
                isPlayingMatch = (sector2 != -1);
            }

            int seconds = ReadMemInt32(processHandle, sector1 + 0x240);

            if (!isPlayingMatch)
            {
                CloseHandle(processHandle);
                return(null);
            }

            int wavenum = -1;

            wavenum = ReadMemInt32(processHandle, sector2 + 0x218);
            if (lastWave != wavenum + 1)
            {
                lastWave = wavenum + 1;
            }

            // Check if match has ended
            int endofmatchobj = GetEndOfMatchObjectAddress(processHandle);

            if (endofmatchobj == -1)
            {
                packetWasSent = false;
                CloseHandle(processHandle);
                return(null);
            }

            // match ended
            PlayerInfo   player  = GetLocalPlayerInfo(processHandle);
            MatchResults results = GetMatchResultsData(processHandle, endofmatchobj);
            Dictionary <string, string> packetData = new Dictionary <string, string>();

            packetData.Add("enemy", results.EnemyID.ToString());
            packetData.Add("map", results.MapId.ToString());
            packetData.Add("diff", results.DifficultyID.ToString());
            packetData.Add("wave", results.Waves.ToString());
            packetData.Add("success", results.Success.ToString());
            packetData.Add("class", player.ClassValue.ToString());
            packetData.Add("chara", player.CharValue.ToString());
            packetData.Add("weapon1", player.Weapon1Value.ToString());
            packetData.Add("weapon2", player.Weapon2Value.ToString());
            packetData.Add("playerscore", player.Score.ToString());
            packetData.Add("teamscore", results.TeamScore.ToString());
            packetData.Add("teamsize", results.TeamSize.ToString());
            packetData.Add("cobramissilesused", player.ConsumablesUsedCounts[0].ToString());
            packetData.Add("medigelsused", player.ConsumablesUsedCounts[1].ToString());
            packetData.Add("opssurvivalpacksused", player.ConsumablesUsedCounts[2].ToString());
            packetData.Add("thermalclippacksused", player.ConsumablesUsedCounts[3].ToString());
            packetData.Add("playermedals*", player.Medals);



            packetData.Add("teammedals*", results.TeamMedals);



            lastSec = seconds;
            CloseHandle(processHandle);
            return(packetData);
        }
Exemple #18
0
    public async Task <MatchResults> GetMatchResults(int matchId)
    {
        MatchResults result = await Get <MatchResults>($"https://api.swebowl.se/api/v1/matchResult/GetMatchResults?APIKey={apiKey}&matchId={matchId}&matchSchemeId=8M8BA");

        return(result);
    }
Exemple #19
0
 public void SetMatchResults(int leftWins, int rightWins, int leftBest, int rightBest, bool networked)
 {
     results = new MatchResults(leftWins, rightWins, leftBest, rightBest, networked);
 }
Exemple #20
0
        public void Start()
        {
            Console.WriteLine("Please Enter the First Team's Name:");
            string team1Name = Console.ReadLine();

            Console.WriteLine("Please Enter the Second Team's Name:");
            string team2Name = Console.ReadLine();

            // ********** FOR TESTING USE **********
            // Console.WriteLine("Please Enter test case:");
            // string team1Name = "";
            // string team2Name = "";
            // switch(Console.ReadLine())
            // {
            //     case "0":
            //         team1Name = "North Carolina";
            //         team2Name = "Gonzaga";
            //         break;
            //     case "1":
            //         team1Name = "SMU";
            //         team2Name = "USC";
            //         break;
            //     case "2":
            //         team1Name = "Wisconsin";
            //         team2Name = "Virginia Tech";
            //         break;
            //     case "3":
            //         team1Name = "Creighton";
            //         team2Name = "Rhode Island";
            //         break;
            //     case "4":
            //         team1Name = "Northwestern";
            //         team2Name = "Vanderbilt";
            //         break;
            //     case "5":
            //         team1Name = "Michigan";
            //         team2Name = "Oklahoma St";
            //         break;
            //     case "6":
            //         team1Name = "Minnesota";
            //         team2Name = "MTSU";
            //         break;
            // }

            FinalResult finalResult      = null;
            var         dataLoaderEngine = new DataLoaderEngine();
            var         matchEngine      = new MatchEngine();
            var         finalizerEngine  = new FinalizerEngine(team1Name, team2Name);

            if (dataLoaderEngine.Load(team1Name, team2Name))
            {
                MatchResults engineResult = matchEngine.Process(dataLoaderEngine.Team1, dataLoaderEngine.Team2);
                finalResult = finalizerEngine.ComputeWinner(engineResult);
            }

            if (finalResult == null || finalResult.Winner < 0 || finalResult.Winner > 1)
            {
                Logger.Error("Failed to decided a winner");
            }
            else
            {
                Console.WriteLine("The Winner is: " + (finalResult.Winner == 0 ? finalResult.Team1 : finalResult.Team2));
                //Console.WriteLine("The Winner is: " + (finalResult.Winner == 0 ? finalResult.Team1 : finalResult.Team2) + ". Score: " + finalResult.Team1Score + " - " + finalResult.Team2Score);
            }


            ProcessAnotherMatch();
        }
    /// <summary>
    /// Loads the potential matches.
    /// </summary>
    private void LoadPotentialMatches()
    {
        if (Mode.Value == "Load")
        {
            Mode.Value = "View";
            SetActiveFilters();
            if (UpdateIndex.Value == "True")
            {
                DuplicateProvider.RefreshIndexes(false);
                UpdateIndex.Value = "False";
            }
            DuplicateProvider.FindMatches();
            MatchResults matchResults = DuplicateProvider.GetMatchResults();
            if (matchResults != null)
            {
                DataTable dataTable        = GetPotentialMatchesLayout();
                DataTable accountDataTable = GetAccountLayout();

                ILead    lead;
                IContact contact;
                IAccount account;
                string   leadType    = GetLocalResourceObject("lblLeads.Caption").ToString();
                string   contactType = GetLocalResourceObject("lblContacts.Caption").ToString();

                matchResults.HydrateResults();
                foreach (MatchResultItem resultItem in matchResults.Items)
                {
                    if (resultItem.EntityType == typeof(ILead))
                    {
                        try
                        {
                            lead = resultItem.Data as ILead;
                            dataTable.Rows.Add(lead.Id.ToString(), "Lead", resultItem.Score, leadType, lead.Company, lead.FirstName,
                                               lead.LastName, lead.Title, lead.Email, lead.Address.LeadCtyStZip, lead.WorkPhone);
                        }
                        catch
                        {
                        }
                    }
                    else if (resultItem.EntityType == typeof(IContact))
                    {
                        try
                        {
                            contact = resultItem.Data as IContact;
                            dataTable.Rows.Add(contact.Id.ToString(), "Contact", resultItem.Score, contactType, contact.Account.AccountName,
                                               contact.FirstName, contact.LastName, contact.Title, contact.Email, contact.Address.CityStateZip,
                                               contact.WorkPhone);
                        }
                        catch
                        {
                        }
                    }
                    else if (resultItem.EntityType == typeof(IAccount))
                    {
                        try
                        {
                            account = resultItem.Data as IAccount;
                            accountDataTable.Rows.Add(account.Id.ToString(), resultItem.Score, account.AccountName,
                                                      account.MainPhone, account.WebAddress, account.Industry, account.Address.CityStateZip,
                                                      account.Type);
                        }
                        catch
                        {
                        }
                    }
                }
                grdMatches.DataSource        = dataTable;
                grdAccountMatches.DataSource = accountDataTable;
            }
            grdMatches.DataBind();
            grdAccountMatches.DataBind();
        }
        else
        {
            grdMatches.DataBind();
            grdAccountMatches.DataBind();
        }
    }