Пример #1
0
 public static Models.Network.MiningFleet SelectFleet(int miningFleetKey)
 {
     using (var conn = ConnectionFactory()) {
         conn.Open();
         var fleet = conn.QueryFirst <Models.Network.MiningFleet>(@" SELECT * FROM MiningFleets WHERE MiningFleetKey = @MiningFleetKey", new { MiningFleetKey = miningFleetKey });
         fleet.FleetMembers =
             conn.Query <Models.Network.MiningFleetMember>(@"
             SELECT DISTINCT mfm.UserKey, u.CharacterName, u.CharacterId, mfm.MiningFleetMemberKey, mfm.MiningFleetKey FROM MiningFleetMembers mfm
             JOIN Users u ON mfm.userkey = u.UserKey
             WHERE MiningFleetKey = @MiningFleetKey", new{ MiningFleetKey = miningFleetKey }).ToList();
         foreach (var member in fleet.FleetMembers)
         {
             if (fleet.IsActive)
             {
                 member.MemberMiningLedger = MiningLedger.SelectActiveFleetProductionByUser(member.UserKey, miningFleetKey);
             }
             else
             {
                 member.MemberMiningLedger = MiningLedger.SelectFinishedFleetProductionByUser(member.UserKey, miningFleetKey);
             }
         }
         fleet.FleetBoss = SelectFleetBoss(miningFleetKey);
         return(fleet);
     }
 }
Пример #2
0
        public static Models.Network.MiningFleetMember SelectFleetMember(int fleetKey, int userKey)
        {
            using (var conn = ConnectionFactory()) {
                conn.Open();
                //Ideally I would like to not have to pull in the whole fleet here to do this.
                var fleet = conn.QueryFirst <Models.MiningFleet>(@" SELECT * FROM MiningFleets WHERE MiningFleetKey = @MiningFleetKey", new { MiningFleetKey = fleetKey });

                //TODO: Check to see if the user is in the fleet when adding stuff
                var member = conn.QuerySingle <Models.Network.MiningFleetMember>(@"
                SELECT mfm.UserKey, u.CharacterName, u.CharacterId, mfm.MiningFleetMemberKey, mfm.MiningFleetKey, mfm.IsActive as MemberIsActive
                FROM MiningFleetMembers mfm
                JOIN Users u ON mfm.userkey = u.UserKey
                WHERE mfm.MiningFleetKey = @MiningFleetKey AND mfm.UserKey = @UserKey", new{ MiningFleetKey = fleetKey, UserKey = userKey });
                if (fleet.IsActive)
                {
                    member.MemberMiningLedger = MiningLedger.SelectActiveFleetProductionByUser(member.UserKey, fleetKey);
                }
                else
                {
                    member.MemberMiningLedger = MiningLedger.SelectFinishedFleetProductionByUser(member.UserKey, fleetKey);
                }
                return(member);
            }
        }