コード例 #1
0
 public TurnBasedMatch(string kind, string matchId, string applicationId, string variant, string status,
                       string userMatchStatus, List <TurnBasedMatchParticipant> participants,
                       TurnBasedMatchModification creationDetails, TurnBasedMatchModification lastUpdateDetails,
                       TurnBasedAutoMatchingCriteria autoMatchingCriteria, TurnBasedMatchData data, ParticipantResult results,
                       string inviterId, string withParticipantId, string description, string pendingParticipantId, string matchVersion,
                       string rematchId, string matchNumber, TurnBasedMatchData previousMatchData)
 {
     Kind                 = kind;
     MatchId              = matchId;
     ApplicationId        = applicationId;
     Variant              = variant;
     Status               = status;
     UserMatchStatus      = userMatchStatus;
     Participants         = participants;
     CreationDetails      = creationDetails;
     LastUpdateDetails    = lastUpdateDetails;
     AutoMatchingCriteria = autoMatchingCriteria;
     Data                 = data;
     Results              = results;
     InviterId            = inviterId;
     WithParticipantId    = withParticipantId;
     Description          = description;
     PendingParticipantId = pendingParticipantId;
     MatchVersion         = matchVersion;
     RematchId            = rematchId;
     MatchNumber          = matchNumber;
     PreviousMatchData    = previousMatchData;
 }
コード例 #2
0
        public void CompareNonFinalistWithSameIRMOnBib_WithSmallerBibBeingSmallest()
        {
            ParticipantResultComparer comparer = new ParticipantResultComparer();

            Participant p1 = new Participant()
            {
                Id = 0, PersonInfo = new Person()
                {
                    Country = "C", Id = 1, Name = "p1"
                }
            };
            Participant p2 = new Participant()
            {
                Id = 5, PersonInfo = new Person()
                {
                    Country = "C", Id = 4, Name = "p2"
                }
            };
            ParticipantResult prAbandon1  = new ParticipantResult(p1, EndingEventType.Abandon);
            ParticipantResult prFault1    = new ParticipantResult(p1, EndingEventType.Fault);
            ParticipantResult prWithdraw1 = new ParticipantResult(p1, EndingEventType.Withdrawn);
            ParticipantResult prAbandon2  = new ParticipantResult(p2, EndingEventType.Abandon);
            ParticipantResult prFault2    = new ParticipantResult(p2, EndingEventType.Fault);
            ParticipantResult prWithdraw2 = new ParticipantResult(p2, EndingEventType.Withdrawn);

            int comparisonResult = comparer.Compare(prAbandon1, prAbandon2);

            Assert.AreEqual(-1, comparisonResult);

            comparisonResult = comparer.Compare(prFault1, prFault2);
            Assert.AreEqual(-1, comparisonResult);

            comparisonResult = comparer.Compare(prWithdraw1, prWithdraw2);
            Assert.AreEqual(-1, comparisonResult);
        }
コード例 #3
0
        public int Compare(object x, object y)
        {
            ParticipantResult pr1 = x as ParticipantResult;
            ParticipantResult pr2 = y as ParticipantResult;

            if (pr1 == null || pr2 == null)
            {
                throw new ArgumentException($"cannot compare {(x == null ? "NULL" : x.GetType().ToString())} with {(y == null ? "NULL" : y.GetType().ToString())}, expected type: {typeof(ParticipantResult)}");
            }

            int comparisonResult = priorities[(int)pr1.Irm] < priorities[(int)pr2.Irm]
                                        ? 1
                                        : priorities[(int)pr1.Irm] > priorities[(int)pr2.Irm]
                                            ? -1
                                            : 0;

            if (comparisonResult == 0 &&
                pr1.NetTime.HasValue)
            {
                comparisonResult = pr1.NetTime <pr2.NetTime
                                        ? -1
                                                : pr1.NetTime> pr2.NetTime
                                            ? 1
                                            : 0;
            }

            if (comparisonResult == 0)
            {
                comparisonResult = pr1.Id < pr2.Id ? -1 : 1;
            }

            return(comparisonResult);
        }
コード例 #4
0
 /// <summary>
 /// Sets the result for a given participant. A result is whether they won,
 /// lost or tied and, optionally, their placement (1st, 2nd, ...).
 /// </summary>
 /// <param name="participantId">Participant identifier.</param>
 /// <param name="result">Result. May be Win, Loss, Tie or None.</param>
 /// <param name="placement">Placement. Use 0 for unset, 1 for 1st, 2 for 2nd, etc.</param>
 public void SetParticipantResult(string participantId, ParticipantResult result, int placement) {
     if (!mParticipantIds.Contains(participantId)) {
         mParticipantIds.Add(participantId);
     }
     mPlacements[participantId] = placement;
     mResults[participantId] = result;
 }
コード例 #5
0
        public void CompareCompetitor_OnIrmType()
        {
            ParticipantResultComparer comparer = new ParticipantResultComparer();

            Participant p = new Participant()
            {
                Id = 0, PersonInfo = new Person()
                {
                    Country = "C", Id = 4, Name = "p"
                }
            };
            ParticipantResult prFinished = new ParticipantResult(p, EndingEventType.None, 1.5);
            ParticipantResult prAbandon  = new ParticipantResult(p, EndingEventType.Abandon);
            ParticipantResult prFault    = new ParticipantResult(p, EndingEventType.Fault);
            ParticipantResult prWithdraw = new ParticipantResult(p, EndingEventType.Withdrawn);

            int comparisonResult = comparer.Compare(prFinished, prAbandon);

            Assert.AreEqual(-1, comparisonResult);
            comparisonResult = comparer.Compare(prFinished, prFault);
            Assert.AreEqual(-1, comparisonResult);
            comparisonResult = comparer.Compare(prFinished, prWithdraw);
            Assert.AreEqual(-1, comparisonResult);

            comparisonResult = comparer.Compare(prAbandon, prFault);
            Assert.AreEqual(-1, comparisonResult);

            comparisonResult = comparer.Compare(prAbandon, prWithdraw);
            Assert.AreEqual(-1, comparisonResult);

            comparisonResult = comparer.Compare(prFault, prWithdraw);
            Assert.AreEqual(-1, comparisonResult);
        }
コード例 #6
0
        public void CompareFinalistWithSameTimeOnBib_WithSmallerBibBeingSmallest()
        {
            ParticipantResultComparer comparer = new ParticipantResultComparer();

            Participant p1 = new Participant()
            {
                Id = 6, PersonInfo = new Person()
                {
                    Country = "C", Id = 4, Name = "p1"
                }
            };
            ParticipantResult pr1 = new ParticipantResult(p1, EndingEventType.None, 1.7);
            Participant       p2  = new Participant()
            {
                Id = 1, PersonInfo = new Person()
                {
                    Country = "C", Id = 1, Name = "p2"
                }
            };
            ParticipantResult pr2 = new ParticipantResult(p2, EndingEventType.None, 1.7);

            int comparisonResult = comparer.Compare(pr1, pr2);

            Assert.AreEqual(1, comparisonResult);
        }
コード例 #7
0
 public void SetParticipantResult(string participantId, ParticipantResult result, uint placement)
 {
     if (!this.mParticipantIds.Contains(participantId))
     {
         this.mParticipantIds.Add(participantId);
     }
     this.mPlacements[participantId] = placement;
     this.mResults[participantId]    = result;
 }
コード例 #8
0
        /// <summary>
        /// Sets a result for the given participant. Do not call this method with a
        /// <see cref="ParticipantResult.CustomPlacement"/> result, instead use
        /// <see cref="SetParticipantPlacement"/> if you want to give the participant
        /// a result with a custom placement.
        /// </summary>
        public void SetParticipantResult(string participantId, ParticipantResult result)
        {
            if (result == ParticipantResult.CustomPlacement)
            {
                Debug.Log("Do not set ParticipantResult.CustomPlacement directly. Use SetParticipantPlacement method instead.");
            }

            SetParticipantResultAndPlacement(participantId, result, PlacementUnset);
        }
コード例 #9
0
 /// <summary>
 /// Sets the result for a given participant. A result is whether they won,
 /// lost or tied and, optionally, their placement (1st, 2nd, ...).
 /// </summary>
 /// <param name="participantId">Participant identifier.</param>
 /// <param name="result">Result. May be Win, Loss, Tie or None.</param>
 /// <param name="placement">Placement. Use 0 for unset, 1 for 1st, 2 for 2nd, etc.</param>
 public void SetParticipantResult(string participantId, ParticipantResult result, int placement)
 {
     if (!mParticipantIds.Contains(participantId))
     {
         mParticipantIds.Add(participantId);
     }
     mPlacements[participantId] = placement;
     mResults[participantId]    = result;
 }
コード例 #10
0
 private async Task <IParticipant> GetPlayer(int?playerID)
 {
     if (playerID.HasValue)
     {
         ParticipantResult participantResult = await new ParticipantQuery(result.tournament_subdomain_id, new ParticipantID(playerID.Value, playerID.Value)).call(caller);
         return(new ParticipantObject(participantResult));
     }
     else
     {
         throw new ParticipantNotAssigned();
     }
 }
コード例 #11
0
 private async Task <Participant> getPlayer(Nullable <int> playerID)
 {
     if (playerID.HasValue)
     {
         ParticipantResult participantResult = await new ParticipantQuery(result.tournament_id, playerID.Value).call(caller);
         return(new ParticipantObject(participantResult));
     }
     else
     {
         throw new ParticipantNotAssigned();
     }
 }
コード例 #12
0
 /// <summary>
 /// <see cref="SetParticipantResult(string,ParticipantResult,int)"/>
 /// </summary>
 public void SetParticipantResult(string participantId, ParticipantResult result)
 {
     SetParticipantResult(participantId, result, PlacementUnset);
 }
コード例 #13
0
 public ParticipantObject(ParticipantResult result)
 {
     this.result = result;
 }
コード例 #14
0
 public void SetParticipantResult(string participantId, ParticipantResult result)
 {
     this.SetParticipantResult(participantId, result, 0);
 }
コード例 #15
0
    private TurnBasedMatch ParseMatch(string results)
    {
        string matchKind       = "";
        string id              = "";
        string applicationId   = "";
        string variant         = "";
        string status          = "";
        string userMatchStatus = "";
        List <TurnBasedMatchParticipant> ppp = new List <TurnBasedMatchParticipant>();

        string creationDetailsKind                    = "";
        string creationDetailsParticipantId           = "";
        long   creationDetailsModifiedTimestampMillis = 0;
        TurnBasedMatchModification creationDetails    = new TurnBasedMatchModification(creationDetailsKind, creationDetailsParticipantId,
                                                                                       creationDetailsModifiedTimestampMillis);
        string lastUpdateDetailsKind                 = "";
        string lastUpdateParticipantId               = "";
        long   lastUpdateModifiedTimestampMillis     = 0;
        TurnBasedMatchModification lastUpdateDetails = new TurnBasedMatchModification(lastUpdateDetailsKind, lastUpdateParticipantId,
                                                                                      lastUpdateModifiedTimestampMillis);
        string autoMatchingCriteriaKind = "";
        int    autoMatchingCriteriaMinAutoMatchingPlayers  = 0;
        int    autoMatchingCriteriaMaxAutoMatchingPlayers  = 0;
        int    autoMatchingCriteriaExclusiveBitmask        = 0;
        TurnBasedAutoMatchingCriteria autoMatchingCriteria = new TurnBasedAutoMatchingCriteria(autoMatchingCriteriaKind,
                                                                                               autoMatchingCriteriaMinAutoMatchingPlayers,
                                                                                               autoMatchingCriteriaMaxAutoMatchingPlayers,
                                                                                               autoMatchingCriteriaExclusiveBitmask);
        string dataKind                      = "";
        bool   dataDataAvailable             = false;
        TurnBasedMatchDataStructure dataData = new TurnBasedMatchDataStructure(null);
        TurnBasedMatchData          data     = new TurnBasedMatchData(dataKind, dataDataAvailable, dataData);

        string            myResultsKind          = "";
        string            myResultsParticipantId = "";
        string            myResultsResult        = "";
        string            myResultsPlacing       = "";
        ParticipantResult myResults            = new ParticipantResult(myResultsKind, myResultsParticipantId, myResultsResult, myResultsPlacing);
        string            inviterId            = "";
        string            withParticipantId    = "";
        string            description          = "";
        string            pendingParticipantId = "";
        string            matchVersion         = "";
        string            rematchId            = "";
        string            matchNumber          = "";

        string previousMatchDataKind                      = "";
        bool   previousMatchDataDataAvailable             = false;
        TurnBasedMatchDataStructure previousMatchDataData = new TurnBasedMatchDataStructure(null);
        TurnBasedMatchData          previousMatchData     = new TurnBasedMatchData(previousMatchDataKind, previousMatchDataDataAvailable,
                                                                                   previousMatchDataData);

        Dictionary <string, System.Object> resp = MiniJSON.Json.Deserialize(results) as Dictionary <string, System.Object>;

        System.Object ooo;
        resp.TryGetValue("match", out ooo);
        Dictionary <string, System.Object> ddd = (Dictionary <string, System.Object>)ooo;

        Debug.Log(ddd.ToString());
        foreach (KeyValuePair <string, System.Object> matchData in ddd)
        {
            if (matchData.Key == "kind")
            {
                if (matchData.Value != null)
                {
                    matchKind = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "matchId")
            {
                if (matchData.Value != null)
                {
                    id = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "applicationId")
            {
                if (matchData.Value != null)
                {
                    applicationId = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "variant")
            {
                if (matchData.Value != null)
                {
                    variant = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "status")
            {
                if (matchData.Value != null)
                {
                    status = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "userMatchStatus")
            {
                if (matchData.Value != null)
                {
                    userMatchStatus = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "participants")
            {
                ppp = new List <TurnBasedMatchParticipant>();

                List <System.Object> participants = new List <System.Object>();              // = matchData.Value as List<System.Object>;
                if (matchData.Value != null)
                {
                    participants = matchData.Value as List <System.Object>;
                }
                foreach (System.Object o in participants)
                {
                    Dictionary <string, System.Object> participantData = (Dictionary <string, System.Object>)o;
                    System.Object v;
                    participantData.TryGetValue("id", out v);
                    string playerId = "";
                    if (v != null)
                    {
                        playerId = (string)v;
                    }

                    participantData.TryGetValue("kind", out v);
                    string k = "";
                    if (v != null)
                    {
                        k = (string)v;
                    }

                    participantData.TryGetValue("autoMatched", out v);
                    bool autoMatched = false;
                    if (v != null)
                    {
                        autoMatched = bool.Parse((string)v);
                    }

                    participantData.TryGetValue("status", out v);
                    string playerStatus = "";
                    if (v != null)
                    {
                        playerStatus = (string)v;
                    }

                    participantData.TryGetValue("player", out v);
                    Dictionary <string, System.Object> playerD = new Dictionary <string, System.Object>();                  // = (Dictionary<string, System.Object>) v;
                    if (v != null)
                    {
                        playerD = (Dictionary <string, System.Object>)v;
                    }

                    string kind           = "";
                    string participantId  = "";
                    string avatarImageUrl = "";
                    foreach (KeyValuePair <string, System.Object> playerData in playerD)
                    {
                        if (playerData.Key == "kind")
                        {
                            if (playerData.Value != null)
                            {
                                kind = (string)playerData.Value;
                            }
                        }
                        else if (playerData.Key == "participantId")
                        {
                            if (playerData.Value != null)
                            {
                                participantId = (string)playerData.Value;
                            }
                        }
                        else if (playerData.Key == "avatarImageUrl")
                        {
                            if (playerData.Value != null)
                            {
                                avatarImageUrl = (string)playerData.Value;
                            }
                        }
                    }
                    Player player = new Player("player", participantId, avatarImageUrl);
                    TurnBasedMatchParticipant p = new TurnBasedMatchParticipant(k, playerId, player, autoMatched, playerStatus);
                    ppp.Add(p);
                }
            }
            else if (matchData.Key == "creationDetails")
            {
                string kind                    = "";
                string participantId           = "";
                long   modifiedTimestampMillis = 0;

                Dictionary <string, System.Object> details = new Dictionary <string, System.Object>();              // = matchData.Value as Dictionary<string, System.Object>;

                if (matchData.Value != null)
                {
                    details = matchData.Value as Dictionary <string, System.Object>;
                }

                foreach (KeyValuePair <string, System.Object> p in details)
                {
                    if (p.Key == "kind")
                    {
                        if (p.Value != null)
                        {
                            kind = (string)p.Value;
                        }
                    }
                    else if (p.Key == "participantId")
                    {
                        if (p.Value != null)
                        {
                            participantId = (string)p.Value;
                        }
                    }
                    else if (p.Key == "modifiedTimeStampMillis")
                    {
                        if (p.Value != null)
                        {
                            modifiedTimestampMillis = (long)p.Value;
                        }
                    }
                }
                creationDetails = new TurnBasedMatchModification(kind, participantId, modifiedTimestampMillis);
            }
            else if (matchData.Key == "lastUpdateDetails")
            {
                string kind                    = "";
                string participantId           = "";
                long   modifiedTimestampMillis = 0;

                Dictionary <string, System.Object> details = new Dictionary <string, System.Object>();              // = matchData.Value as Dictionary<string, System.Object>;
                if (matchData.Value != null)
                {
                    details = matchData.Value as Dictionary <string, System.Object>;
                }

                foreach (KeyValuePair <string, System.Object> p in details)
                {
                    if (p.Key == "kind")
                    {
                        if (p.Value != null)
                        {
                            kind = (string)p.Value;
                        }
                    }
                    else if (p.Key == "participantId")
                    {
                        if (p.Value != null)
                        {
                            participantId = (string)p.Value;
                        }
                    }
                    else if (p.Key == "modifiedTimeStampMillis")
                    {
                        if (p.Value != null)
                        {
                            modifiedTimestampMillis = (long)p.Value;
                        }
                    }
                }
                lastUpdateDetails = new TurnBasedMatchModification(kind, participantId, modifiedTimestampMillis);
            }
            else if (matchData.Key == "autoMatchingCriteria")
            {
                string kind = "";
                int    minAutoMatchingPlayers = 0;
                int    maxAutoMatchingPlayers = 0;
                int    exclusiveBitmask       = 0;

                Dictionary <string, System.Object> criteria = new Dictionary <string, System.Object>();              // = matchData.Value as Dictionary<string, System.Object>;
                if (matchData.Value != null)
                {
                    criteria = matchData.Value as Dictionary <string, System.Object>;
                }
                foreach (KeyValuePair <string, System.Object> p in criteria)
                {
                    if (p.Key == "kind")
                    {
                        if (String.Compare((string)p.Value, "\"null\"") == 0)
                        {
                            kind = (string)p.Value;
                        }
                    }
                    else if (p.Key == "minAutoMatchingPlayers")
                    {
                        if (String.Compare((string)p.Value, "\"null\"") == 0)
                        {
                            minAutoMatchingPlayers = int.Parse((string)p.Value);
                        }
                    }
                    else if (p.Key == "maxAutoMatchingPlayers")
                    {
                        if (String.Compare((string)p.Value, "\"null\"") == 0)
                        {
                            maxAutoMatchingPlayers = int.Parse((string)p.Value);
                        }
                    }
                    else if (p.Key == "exclusiveBitmask")
                    {
                        if (String.Compare((string)p.Value, "\"null\"") == 0)
                        {
                            exclusiveBitmask = int.Parse((string)p.Value);
                        }
                    }
                }
                autoMatchingCriteria = new TurnBasedAutoMatchingCriteria(kind, minAutoMatchingPlayers, maxAutoMatchingPlayers,
                                                                         exclusiveBitmask);
            }
            else if (matchData.Key == "data")
            {
                string kind          = "";
                bool   dataAvailable = false;
                TurnBasedMatchDataStructure theData = new TurnBasedMatchDataStructure(null);

                if (matchData.Value != null)
                {
                    Dictionary <string, System.Object> d = matchData.Value as Dictionary <string, System.Object>;

                    foreach (KeyValuePair <string, System.Object> p in d)
                    {
                        if (p.Key == "kind")
                        {
                            if (String.Compare((string)p.Value, "\"null\"") == 0)
                            {
                                kind = (string)p.Value;
                            }
                        }
                        else if (p.Key == "dataAvailable")
                        {
                            if (String.Compare((string)p.Value, "\"null\"") == 0)
                            {
                                dataAvailable = bool.Parse((string)p.Value);
                            }
                        }
                        else if (p.Key == "data")
                        {
                            if (p.Value != null)
                            {
                                theData = new TurnBasedMatchDataStructure((Dictionary <string, System.Object>)p.Value);
                            }
                        }
                    }
                }

                data = new TurnBasedMatchData(kind, dataAvailable, theData);
            }
            else if (matchData.Key == "results")
            {
                string kind          = "";
                string participantId = "";
                string result        = "";
                string placing       = "";

                if (matchData.Value != null)
                {
                    List <System.Object> l = matchData.Value as List <System.Object>;
                    if (l != null)
                    {
                        foreach (System.Object o in l)
                        {
                            Dictionary <string, System.Object> d = o as Dictionary <string, System.Object>;
                            if (d != null)
                            {
                                foreach (KeyValuePair <string, System.Object> p in d)
                                {
                                    if (p.Key == "kind")
                                    {
                                        if (p.Value != null)
                                        {
                                            kind = (string)p.Value;
                                        }
                                    }
                                    else if (p.Key == "participantId")
                                    {
                                        if (p.Value != null)
                                        {
                                            participantId = (string)p.Value;
                                        }
                                    }
                                    else if (p.Key == "result")
                                    {
                                        if (p.Value != null)
                                        {
                                            result = (string)p.Value;
                                        }
                                    }
                                    else if (p.Key == "placing")
                                    {
                                        if (p.Value != null)
                                        {
                                            placing = (string)p.Value;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                myResults = new ParticipantResult(kind, participantId, result, placing);
            }
            else if (matchData.Key == "inviterId")
            {
                if (matchData.Value != null)
                {
                    inviterId = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "withParticipantId")
            {
                if (matchData.Value != null)
                {
                    withParticipantId = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "description")
            {
                if (matchData.Value != null)
                {
                    description = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "pendingParticipantId")
            {
                if (matchData.Value != null)
                {
                    pendingParticipantId = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "matchVersion")
            {
                if (matchData.Value != null)
                {
                    matchVersion = matchData.Value.ToString();
                }
            }
            else if (matchData.Key == "rematchId")
            {
                if (matchData.Value != null)
                {
                    rematchId = matchData.Key.ToString();
                }
            }
            else if (matchData.Key == "matchNumber")
            {
                if (matchData.Value != null)
                {
                    matchNumber = matchData.Key.ToString();
                }
            }
            else if (matchData.Key == "previousMatchData")
            {
                string kind          = "";
                bool   dataAvailable = false;
                TurnBasedMatchDataStructure theData = new TurnBasedMatchDataStructure(null);

                Dictionary <string, System.Object> d = new Dictionary <string, System.Object>();              // = matchData.Value as Dictionary<string, System.Object>;
                if (matchData.Value != null)
                {
                    d = matchData.Value as Dictionary <string, System.Object>;
                }
                foreach (KeyValuePair <string, System.Object> p in d)
                {
                    if (p.Key == "kind")
                    {
                        kind = (string)p.Value;
                    }
                    else if (p.Key == "dataAvailable")
                    {
                        dataAvailable = bool.Parse((string)p.Value);
                    }
                    else if (p.Key == "data")
                    {
                        theData = new TurnBasedMatchDataStructure((Dictionary <string, System.Object>)p.Value);
                    }
                }

                previousMatchData = new TurnBasedMatchData(kind, dataAvailable, theData);
            }
        }

        return(new TurnBasedMatch(matchKind, id, applicationId, variant, status, userMatchStatus,
                                  ppp, creationDetails, lastUpdateDetails, autoMatchingCriteria,
                                  data, myResults, inviterId, withParticipantId, description, pendingParticipantId,
                                  matchVersion, rematchId, matchNumber, previousMatchData));
    }
コード例 #16
0
        public List <ParticipantDivision> GetResults(string _competitionCode)
        {
            const string SQL = @"
                SELECT e.EnName         AS LastName, 
	                e.EnFirstName       AS FirstName,
	                c.ClDescription     AS Class,
                    c.ClId              AS ClassCode,
                    c.ClSex             AS ClassSex,
                    d.DivDescription	AS Division,
                    d.DivId             AS DivisionCode,
                    q.QuSession			AS SessionNumber,
                    q.QuTarget			AS BaleNumber,
                    q.QuLetter			AS TargetPosition,    
                    co.CoName			AS TeamName,
                    q.QuD1Score         AS Round1Score,
                    q.QuD1Hits          AS Round1Hits,
                    q.QuD1Rank			AS Round1Rank,
                    q.QuD2Score			AS Round2Score,
                    q.QuD2Hits			AS Round2Hits,
                    q.QuD2Rank			AS Round2Rank,
                    q.QuScore			AS TotalScore,
                    q.QuHits			AS TotalHits,
                    Q.QuGold			AS Total10,
                    Q.QuXnine			AS Total9,
                    Q.QuClRank			AS TotalRank
                FROM Entries e
                JOIN qualifications q on e.EnId = q.QuId
                JOIN classes c on e.EnTournament = c.ClTournament AND e.EnClass = c.ClId
                JOIN divisions d on e.EnTournament = d.DivTournament AND e.EnDivision = d.DivId
                JOIN countries co on e.EnTournament = co.CoTournament AND e.EnCountry = co.COId
                JOIN tournament t on e.EnTournament = t.ToId
                WHERE t.ToCode = @compCode
                AND e.EnIndClEvent = 1
                AND e.EnStatus = 0
                AND q.QuClRank != 0
                ORDER BY d.DivViewOrder, c.ClViewOrder, q.QuClRank ";

            var table = m_db.GetData(SQL, "compCode", _competitionCode);

            Dictionary <string, ParticipantDivision> dDict = new Dictionary <string, ParticipantDivision>();
            Dictionary <string, ParticipantClass>    cDict = new Dictionary <string, ParticipantClass>();

            List <ParticipantDivision> divisions = new List <ParticipantDivision>();

            foreach (DataRow row in table.Rows)
            {
                string className    = row.GetString("Class");
                string classCode    = row.GetString("ClassCode").ToLower();
                string divisionName = row.GetString("Division");
                string divisionCode = row.GetString("DivisionCode").ToLower();
                byte   classSex     = row.GetTinyInt("ClassSex");

                ParticipantDivision pDivision;
                ParticipantClass    pClass;

                if (!dDict.ContainsKey(divisionCode))
                {
                    pDivision = new ParticipantDivision
                    {
                        DivisionName = divisionName,
                        DivisionCode = divisionCode
                    };

                    divisions.Add(pDivision);
                    dDict.Add(divisionCode, pDivision);
                }
                else
                {
                    pDivision = dDict[divisionCode];
                }

                string tempName = divisionCode + "|" + classCode;
                if (!cDict.ContainsKey(tempName))
                {
                    pClass = new ParticipantClass
                    {
                        ClassName = className,
                        ClassCode = classCode,
                        ClassSex  = (classSex == 0) ? "m" : "f"
                    };

                    cDict.Add(tempName, pClass);
                    pDivision.ParticipantClasses.Add(pClass);
                }
                else
                {
                    pClass = cDict[tempName];
                }

                ParticipantResult p = new ParticipantResult
                {
                    FirstName      = row.GetString("FirstName"),
                    LastName       = row.GetString("LastName"),
                    Session        = Convert.ToInt32(row.GetByte("SessionNumber")),
                    BaleNumber     = row.GetInt("BaleNumber"),
                    TargetPosition = row.GetString("TargetPosition"),
                    Team           = row.GetString("TeamName"),
                    Round1Score    = row.GetShort("Round1Score"),
                    Round1Hits     = row.GetShort("Round1Hits"),
                    Round1Rank     = row.GetShort("Round1Rank"),
                    Round2Score    = row.GetShort("Round2Score"),
                    Round2Hits     = row.GetShort("Round2Hits"),
                    Round2Rank     = row.GetShort("Round2Rank"),
                    TotalScore     = row.GetInt("TotalScore"),
                    TotalHits      = row.GetInt("TotalHits"),
                    TotalRank      = row.GetShort("TotalRank"),
                    TotalTens      = row.GetInt("Total10"),
                    TotalNines     = row.GetInt("Total9")
                };

                pClass.Participants.Add(p);
            }

            return(divisions);
        }
コード例 #17
0
ファイル: MatchOutcome.cs プロジェクト: JoshuaHassler/PMG
 /// <summary>
 /// <see cref="SetParticipantResult(string,ParticipantResult,int)"/>
 /// </summary>
 public void SetParticipantResult(string participantId, ParticipantResult result) {
     SetParticipantResult(participantId, result, PlacementUnset);
 }
コード例 #18
0
 public void SetParticipantResult(string participantId, ParticipantResult result)
 {
     SetParticipantResult(participantId, result, 0u);
 }