private void DescribeLevelRating(Checkride er, RatingLevel newLevel) { er.Level = newLevel; switch (er.Level) { case RatingLevel.Sport: er.LicenseKind = LicenseKind.Sport; currentLevel = AddToDictionary(currentLevel, newLevel, dictSport, er); break; case RatingLevel.Recreational: er.LicenseKind = LicenseKind.Recreational; currentLevel = AddToDictionary(currentLevel, newLevel, dictRecreational, er); break; case RatingLevel.Private: er.LicenseKind = LicenseKind.Private; currentLevel = AddToDictionary(currentLevel, newLevel, dictPrivate, er); break; case RatingLevel.Commercial: er.LicenseKind = LicenseKind.Commercial; currentLevel = AddToDictionary(currentLevel, newLevel, dictCommercial, er); break; case RatingLevel.ATP: er.LicenseKind = LicenseKind.ATP; currentLevel = AddToDictionary(currentLevel, newLevel, dictATP, er); break; default: break; } }
public IDictionary <string, object> AsKeyValuePairs() { return(new Dictionary <string, object> { ["Checkrides"] = Checkride.AsPublicList(Checkrides), ["Certificates"] = PilotLicense.AsPublicList(Licenses) }); }
public CheckrideBadge(Checkride cr) : base() { m_cr = cr; if (cr != null) { ID = BadgeID.ComputedRating; IDFlightEarned = cr.FlightID; DateEarned = cr.DateEarned; Level = AchievementLevel.Achieved; // by definition, we have already achieved this. } }
internal PilotLicense(Checkride cr) : this() { if (cr != null) { LicenseKind = cr.LicenseKind; // Merge all CFII/MEI into CFI if (cr.LicenseKind == LicenseKind.CFII || cr.LicenseKind == LicenseKind.MEI) { LicenseKind = LicenseKind.CFI; } } }
/// <summary> /// Looks at all the checkrides for the user in the database and describes them and determines what ratings you likely hold. /// I.e., computes the Checkrides and Ratings properties. /// </summary> private void ComputeRatings() { List <Checkride> lst = new List <Checkride>(); if (String.IsNullOrEmpty(Username)) { m_lstCheckrides = new List <Checkride>(); return; } DBHelper dbh = new DBHelper(@"SELECT cpt.idproptype, f.date, f.idflight, m.typename, cc.Category, cc.Class, cc.idCatClass FROM flightproperties fp INNER JOIN custompropertytypes cpt ON fp.idproptype = cpt.idproptype INNER JOIN flights f ON fp.idflight = f.idflight INNER JOIN aircraft ac ON f.idaircraft = ac.idaircraft INNER JOIN models m ON ac.idmodel = m.idmodel INNER JOIN categoryclass cc ON m.idcategoryclass = cc.idcatclass WHERE fp.idproptype IN (39 , 40, 42, 43, 45, 89, 131, 161, 176, 177, 225, 623) AND f.username = ?userName ORDER BY date ASC"); dbh.ReadRows((comm) => { comm.Parameters.AddWithValue("userName", Username); }, (dr) => { Checkride cr = new Checkride() { FlightID = Convert.ToInt32(dr["idflight"], CultureInfo.InvariantCulture), DateEarned = Convert.ToDateTime(dr["date"], CultureInfo.InvariantCulture), CheckrideProperty = (CustomPropertyType.KnownProperties)Convert.ToInt32(dr["idproptype"], CultureInfo.InvariantCulture) }; string szType = (string)dr["typename"]; string szCategory = (string)dr["Category"]; switch (cr.CheckrideProperty) { case CustomPropertyType.KnownProperties.IDPropCheckrideIFR: cr.Privilege = szCategory; break; case CustomPropertyType.KnownProperties.IDPropCheckrideCFI: case CustomPropertyType.KnownProperties.IDPropCheckrideMEI: { // CFI ratings are category/class, but not land/sea class, just single/multi. CategoryClass.CatClassID ccid = (CategoryClass.CatClassID)Convert.ToInt32(dr["idCatClass"], CultureInfo.InvariantCulture); switch (ccid) { case CategoryClass.CatClassID.AMEL: case CategoryClass.CatClassID.AMES: cr.Privilege = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2}", szCategory, Resources.Achievements.PrivilegeMultiEngine, szType).Trim(); break; case CategoryClass.CatClassID.ASEL: case CategoryClass.CatClassID.ASES: cr.Privilege = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2}", szCategory, Resources.Achievements.PrivilegeSingleEngine, szType).Trim(); break; default: cr.Privilege = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2}", dr["Category"], dr["Class"], String.IsNullOrEmpty(szType) ? string.Empty : String.Format(CultureInfo.CurrentCulture, Resources.Achievements.ratingTypeTemplate, szType)).Trim(); break; } } break; case CustomPropertyType.KnownProperties.IDPropCheckrideCFII: cr.Privilege = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LocalizedJoinWithSpace, Resources.Achievements.PrivilegeCFII, szCategory); break; case CustomPropertyType.KnownProperties.IDPropNightRating: cr.Privilege = Resources.Achievements.PrivilegeNight; break; default: cr.Privilege = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2}", dr["Category"], dr["Class"], String.IsNullOrEmpty(szType) ? string.Empty : String.Format(CultureInfo.CurrentCulture, Resources.Achievements.ratingTypeTemplate, szType)).Trim(); break; } lst.Add(cr); }); // We now have a set of checkrides - now we need to figure out how they applied. DescribeRatings(lst); ComputeNetCertificates(); }
private static RatingLevel AddToDictionary(RatingLevel currentLevel, RatingLevel newLevel, Dictionary <string, Checkride> dict, Checkride er) { newLevel = ((int)newLevel > (int)currentLevel) ? newLevel : currentLevel; if (!dict.ContainsKey(er.Privilege)) { er.CheckrideType = (dict.Count == 0) ? CheckrideType.NewRating : CheckrideType.AdditionalPrivilege; dict[er.Privilege] = er; } return(newLevel); }
public int CompareTo(Object obj) { Checkride cr = obj as Checkride; return(cr == null ? -1 : DateEarned.CompareTo(cr.DateEarned)); }