예제 #1
0
        public static string NameForGroup(this TotalsGroup group)
        {
            switch (group)
            {
            default:
            case TotalsGroup.None:
                return(string.Empty);

            case TotalsGroup.CategoryClass:
                return(Resources.Totals.TotalGroupCategoryClass);

            case TotalsGroup.Capabilities:
                return(Resources.Totals.TotalGroupCapabilities);

            case TotalsGroup.CoreFields:
                return(Resources.Totals.TotalGroupCoreFields);

            case TotalsGroup.ICAO:
                return(Resources.Totals.TotalGroupICAO);

            case TotalsGroup.Model:
                return(Resources.Totals.TotalGroupModel);

            case TotalsGroup.Properties:
                return(Resources.Totals.TotalGroupProperties);

            case TotalsGroup.Total:
                return(Resources.Totals.TotalGroupTotal);
            }
        }
예제 #2
0
        private void ComputeTotalsByCatClass(MySqlCommand comm, Profile pf)
        {
            // first get the totals by catclass
            Hashtable htCct = new Hashtable();

            try
            {
                using (MySqlDataReader dr = comm.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        string szModelDisplay    = (string)dr["ModelDisplay"];
                        string szCatClassDisplay = (string)dr["CatClassDisplay"];
                        string szFamilyDisplay   = (string)dr["FamilyDisplay"];

                        string szCatClass             = dr["CatClass"].ToString();
                        int    idModel                = Convert.ToInt32(dr["idmodel"], CultureInfo.InvariantCulture);
                        string szTypeName             = dr["typename"].ToString();
                        CategoryClass.CatClassID ccid = (CategoryClass.CatClassID)Convert.ToInt32(dr["idCatClass"], CultureInfo.InvariantCulture);
                        Decimal decTotal              = (Decimal)util.ReadNullableField(dr, "Total", 0.0M);
                        Int32   cLandings             = Convert.ToInt32(util.ReadNullableField(dr, "cLandings", 0), CultureInfo.InvariantCulture);
                        Int32   cApproaches           = Convert.ToInt32(util.ReadNullableField(dr, "cApproaches", 0), CultureInfo.InvariantCulture);
                        Int32   cFSDayLandings        = Convert.ToInt32(util.ReadNullableField(dr, "cFullStopLandings", 0), CultureInfo.InvariantCulture);
                        Int32   cFSNightLandings      = Convert.ToInt32(util.ReadNullableField(dr, "cNightLandings", 0), CultureInfo.InvariantCulture);

                        string szDesc = SubDescFromLandings(cLandings, cFSDayLandings, cFSNightLandings, cApproaches);

                        // keep track of the subtotal.
                        CatClassTotal cct = (CatClassTotal)htCct[szCatClass];
                        if (cct == null)
                        {
                            htCct[szCatClass] = cct = new CatClassTotal(szCatClass, ccid);
                        }
                        cct.AddTotals(decTotal, cLandings, cFSDayLandings, cFSNightLandings, cApproaches);

                        FlightQuery fq = null;

                        // don't link to a query for type-totals, since there's no clean query for that.  But if this is a clean catclass (e.g., "AMEL") it should match and we can query it.
                        fq = new FlightQuery(Restriction);
                        string      szTitle = string.Empty;
                        TotalsGroup group   = TotalsGroup.None;
                        switch (pf.TotalsGroupingMode)
                        {
                        case TotalsGrouping.CatClass:
                            AddCatClassToQuery(fq, cct.CatClass, szTypeName);
                            szTitle = szCatClassDisplay;
                            group   = TotalsGroup.CategoryClass;
                            break;

                        case TotalsGrouping.Model:
                            AddModelToQuery(fq, idModel);
                            szTitle = szModelDisplay;
                            group   = TotalsGroup.Model;
                            break;

                        case TotalsGrouping.Family:
                            fq.ModelName = szFamilyDisplay;
                            szTitle      = szFamilyDisplay;
                            group        = TotalsGroup.ICAO;
                            break;
                        }

                        AddToList(new TotalsItem(szTitle, decTotal, szDesc)
                        {
                            Query = fq, Group = group
                        });
                    }
                }
            }
            catch (MySqlException ex)
            {
                throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Exception in UserTotals Data Bind while reading data by catclass: {0}", comm.CommandText), ex, pf.UserName);
            }

            // Add in any catclass subtotals
            foreach (CatClassTotal cct in htCct.Values)
            {
                FlightQuery fq = AddCatClassToQuery(new FlightQuery(Restriction), cct.CatClass, string.Empty);
                if (pf.TotalsGroupingMode != TotalsGrouping.CatClass || !cct.IsRedundant)
                {
                    if (pf.TotalsGroupingMode == TotalsGrouping.CatClass)
                    {
                        // If you have a mix of type-rated and non-type-rated aircraft, then the subtotal for non-typerated doesn't have a type specifier; it's just naked "AMEL", for example.
                        // So Find and fix up the query for that item
                        CategoryClass ccTarget = cct.CatClass;
                        foreach (TotalsItem ti in Totals)
                        {
                            FlightQuery q = ti.Query;
                            if (q != null && q.CatClasses != null && q.CatClasses.Length == 1 && q.CatClasses[0].IdCatClass == ccTarget.IdCatClass && (q.TypeNames == null || q.TypeNames.Length == 0))
                            {
                                q.TypeNames = new string[1] {
                                    string.Empty
                                }
                            }
                            ;
                        }
                    }

                    AddToList(new TotalsItem(cct.DisplayName, cct.Total, SubDescFromLandings(cct.TotalLandings, cct.TotalFSDayLandings, cct.TotalFSNightLandings, cct.TotalApproaches), pf.TotalsGroupingMode == TotalsGrouping.CatClass ? TotalsItem.SortMode.CatClass : TotalsItem.SortMode.Model)
                    {
                        Query = fq, Group = TotalsGroup.CategoryClass
                    });
                }
            }
        }
예제 #3
0
 public TotalsItemCollection(TotalsGroup group)
 {
     Group = group;
     Items = new List <TotalsItem>();
 }