/// <summary>
    /// Recreates the combobox and propedit controls so that they exist for postback events.
    /// </summary>
    protected void RecreateControls()
    {
        if (plcHolderProps.Controls.Count > 0)  // don't do this if we've already set them up.
        {
            return;
        }

        List <CustomPropertyType> lstAll = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes());

        foreach (int idPropType in ActivePropTypes)
        {
            CustomPropertyType   cpt = lstAll.Find(c => c.PropTypeID == idPropType);
            CustomFlightProperty cfp = new CustomFlightProperty(cpt);
            if (ExistingPropIDs.ContainsKey(idPropType))
            {
                cfp.PropID = ExistingPropIDs[idPropType];
            }
            InsertEditProp(cfp);
            lstAll.Remove(cpt); // since it's here, make sure it isn't in the list of available types; we'll bind this below.
        }

        // recreate combo box - huge viewstate, so we just recreate it each time.
        // This loses the selected value, so we have to grab that directly from the form.
        cmbPropsToAdd.DataSource = lstAll;
        cmbPropsToAdd.DataBind();
        if (IsPostBack)
        {
            cmbPropsToAdd.SelectedValue = Request.Form[cmbPropsToAdd.UniqueID];
        }
    }
Esempio n. 2
0
 protected void UpdateBlacklist(bool fForceDB = false)
 {
     rptUsedProps.DataSource = Array.FindAll(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name, fForceDB), cpt => cpt.IsFavorite);
     rptUsedProps.DataBind();
     rptBlackList.DataSource = CustomPropertyType.GetCustomPropertyTypes(m_pf.BlacklistedProperties);
     rptBlackList.DataBind();
 }
Esempio n. 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         gvProps.DataSource = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : null);
         gvProps.DataBind();
     }
 }
Esempio n. 4
0
    protected void ToForm()
    {
        CustomCurrency cc = Currency;

        hdnCCId.Value              = cc.ID.ToString(CultureInfo.InvariantCulture);
        txtRuleName.Text           = cc.DisplayName;
        cmbLimitType.SelectedValue = cc.CurrencyLimitType.ToString();
        if (cc.EventType.IsIntegerOnly())
        {
            decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Integer;
            decMinEvents.IntValue    = (int)cc.RequiredEvents;
        }
        else
        {
            decMinEvents.EditingMode = Controls_mfbDecimalEdit.EditMode.Decimal;
            decMinEvents.Value       = cc.RequiredEvents;
        }

        cmbEventTypes.SelectedValue = ((int)cc.EventType).ToString(CultureInfo.InvariantCulture);
        SelectedTimespanType        = cc.TimespanType;
        txtTimeFrame.Text           = cc.TimespanType.IsAligned() ? string.Empty : cc.ExpirationSpan.ToString(CultureInfo.InvariantCulture);

        foreach (ListItem li in lstModels.Items)
        {
            li.Selected = cc.ModelsRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture));
        }
        foreach (ListItem li in lstAircraft.Items)
        {
            li.Selected = cc.AircraftRestriction.Contains(Convert.ToInt32(li.Value, CultureInfo.InvariantCulture));
        }
        cmbCategory.SelectedValue = cc.CategoryRestriction;
        cmbCatClass.SelectedValue = cc.CatClassRestriction.ToString();

        txtAirport.Text       = cc.AirportRestriction;
        txtContainedText.Text = cc.TextRestriction;
        if (cc.PropertyRestriction != null)
        {
            HashSet <int> hsPropsChecked = new HashSet <int>(cc.PropertyRestriction);
            foreach (ListItem li in lstProps.Items)
            {
                int propID = Convert.ToInt32(li.Value, CultureInfo.InvariantCulture);
                li.Selected = cc.PropertyRestriction.Contains(propID);
                hsPropsChecked.Remove(propID);
            }

            // Add in any properties that were not found above!  (I.e., blacklisted or otherwise not favorite)
            IEnumerable <CustomPropertyType> rgBlackListProps = CustomPropertyType.GetCustomPropertyTypes(hsPropsChecked);
            foreach (CustomPropertyType cpt in rgBlackListProps)
            {
                lstProps.Items.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture))
                {
                    Selected = true
                });
            }
        }

        btnAddCurrencyRule.Visible = cc.ID <= 0;    // only show the add button if we're doing a new currency.
    }
Esempio n. 5
0
    private bool fHasBeenSetUp = false; // have we already been initialized for the user?

    protected void SetUpForUser()
    {
        if (fHasBeenSetUp)
        {
            return;
        }

        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        UserAircraft ua = new UserAircraft(Username);

        Aircraft[] rgac       = ua.GetAircraftForUser();
        Aircraft[] rgacActive = Array.FindAll(rgac, aircraft => !aircraft.HideFromSelection);

        // Hide inactive aircraft unless
        // (a) all aircraft are active, or
        // (b) the current query references inactive aircraft
        // (c) pnlshowAllAircraft is invisible (indicating that it has been clicked)
        bool fShowAll = !pnlShowAllAircraft.Visible || rgacActive.Length == rgac.Length || Array.Exists(Restriction.AircraftList, ac => ac.HideFromSelection);

        if (fShowAll)
        {
            pnlShowAllAircraft.Visible = false;
        }
        cklAircraft.DataSource = fShowAll ? rgac : rgacActive;
        cklAircraft.DataBind();

        cklMakes.DataSource = MakeModel.ModelsForAircraft(rgac);
        cklMakes.DataBind();

        cklCatClass.DataSource = CategoryClass.CategoryClasses();
        cklCatClass.DataBind();

        CustomPropertyType[]      rgCpt = CustomPropertyType.GetCustomPropertyTypes(Username);
        List <CustomPropertyType> al    = new List <CustomPropertyType>();

        foreach (CustomPropertyType cpt in rgCpt)
        {
            if (cpt.IsFavorite)
            {
                al.Add(cpt);
            }
        }

        if (al.Count == 0)
        {
            pnlCustomProps.Visible = CustomPropsHeader.Visible = false;
        }
        else
        {
            cklCustomProps.DataSource = al;
            cklCustomProps.DataBind();
        }
        fHasBeenSetUp = true;
    }
    protected void UpdateBlacklist(bool fForceDB = false)
    {
        rptUsedProps.DataSource = Array.FindAll(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name, fForceDB), cpt => cpt.IsFavorite);
        rptUsedProps.DataBind();
        List <CustomPropertyType> lstBlacklist = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(m_pf.BlacklistedProperties));

        lstBlacklist.Sort((cpt1, cpt2) => { return(cpt1.SortKey.CompareCurrentCultureIgnoreCase(cpt2.SortKey)); });
        rptBlackList.DataSource = lstBlacklist;
        rptBlackList.DataBind();
    }
Esempio n. 7
0
        /// <summary>
        /// Computes the overall currency
        /// </summary>
        protected override void ComputeComposite()
        {
            // Compute currency according to 61.57(c)(1)-(5) and 61.57(e)
            // including each one's expiration.  The one that expires latest is the expiration date if you are current, the one that
            // expired most recently is the expiration date since when you were not current.

            // 61.57(c)(1) (66-HIT in airplane, flight simulator, ATD, or FTD) OR an IPC.
            FlightCurrency fcIFR = fcIPCOrCheckride.OR(fcIFRApproach.AND(fcIFRHold));

            CompositeCurrencyState = fcIFR.CurrentState;
            CompositeExpiration    = fcIFR.ExpirationDate;

            if (fcIPCOrCheckride.IsCurrent() && fcIPCOrCheckride.ExpirationDate.CompareTo(CompositeExpiration) >= 0)
            {
                Query.HasHolds = Query.HasApproaches = false;
                Query.PropertiesConjunction = GroupConjunction.Any;
                Query.PropertyTypes.Clear();
                foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes())
                {
                    if (cpt.IsIPC)
                    {
                        Query.PropertyTypes.Add(cpt);
                    }
                }
            }

            if (CompositeCurrencyState == CurrencyState.NotCurrent)
            {
                // if more than 6 calendar months have passed since expiration, an IPC is required.
                // otherwise, just assume 66-HIT.
                if (DateTime.Compare(CompositeExpiration.AddCalendarMonths(6).Date, DateTime.Now.Date) > 0)
                {
                    CompositeDiscrepancy = String.Format(CultureInfo.CurrentCulture, Resources.Currency.DiscrepancyTemplateIFR,
                                                         fcIFRHold.Discrepancy,
                                                         (fcIFRHold.Discrepancy == 1) ? Resources.Currency.Hold : Resources.Currency.Holds,
                                                         fcIFRApproach.Discrepancy,
                                                         (fcIFRApproach.Discrepancy == 1) ? Resources.Totals.Approach : Resources.Totals.Approaches);
                }
                else
                {
                    CompositeDiscrepancy = Resources.Currency.IPCRequired;
                }
            }
            else
            {
                // Check to see if IPC is required by looking for > 6 month gap in IFR currency.
                // For now, we won't make you un-current, but we'll warn.
                // (IPC above, though, is un-current).
                CurrencyPeriod[] rgcpMissingIPC = fcIFR.FindCurrencyGap(fcIPCOrCheckride.MostRecentEventDate, 6);

                CompositeDiscrepancy = rgcpMissingIPC != null
                    ? String.Format(CultureInfo.CurrentCulture, Resources.Currency.IPCMayBeRequired, rgcpMissingIPC[0].EndDate.ToShortDateString(), rgcpMissingIPC[1].StartDate.ToShortDateString())
                    : string.Empty;
            }
        }
Esempio n. 8
0
        public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse.

            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            // Build up the list of RosterBuster objects first
            List <RosterBuster> lstRb = new List <RosterBuster>();

            foreach (Match ctMatch in Matches)
            {
                GroupCollection gc = ctMatch.Groups;

                try
                {
                    DateTime dtStart = Convert.ToDateTime(gc["StartDate"].Value, CultureInfo.CurrentCulture);
                    DateTime dtEnd   = Convert.ToDateTime(gc["EndDate"].Value, CultureInfo.CurrentCulture);
                    int      hStart  = Convert.ToInt32(gc["startZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture);
                    int      mStart  = Convert.ToInt32(gc["startZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture);
                    int      hEnd    = Convert.ToInt32(gc["endZ"].Value.Substring(0, 2), CultureInfo.InvariantCulture);
                    int      mEnd    = Convert.ToInt32(gc["endZ"].Value.Substring(2, 2), CultureInfo.InvariantCulture);

                    DateTime dtStartUtc = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hStart, mStart, 0, DateTimeKind.Utc);
                    DateTime dtEndUtc   = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, hEnd, mEnd, 0, DateTimeKind.Utc);

                    if (dtEndUtc.CompareTo(dtStartUtc) < 0)
                    {
                        dtEndUtc = dtEndUtc.AddDays(1);
                    }

                    lstRb.Add(new RosterBuster()
                    {
                        FlightDate   = dtStart,
                        FlightNumber = gc["FlightNum"].Value,
                        BlockOut     = dtStartUtc,
                        BlockIn      = dtEndUtc,
                        Route        = gc["route"].Value,
                        TimeZone     = gc["Timezone"].Value
                    });
                }
                catch (FormatException) { }
            }

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (RosterBuster rb in lstRb)
                {
                    CSVImporter.WriteEntryToDataTable(rb.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
Esempio n. 9
0
 public MRUPropertyTemplate(string szuser) : this()
 {
     m_propertyTypes.Clear();
     CustomPropertyType[] rgTypes = CustomPropertyType.GetCustomPropertyTypes(szuser);
     foreach (CustomPropertyType cpt in rgTypes)
     {
         if (cpt.IsFavorite)
         {
             m_propertyTypes.Add(cpt.PropTypeID);
         }
     }
 }
Esempio n. 10
0
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            for (int i = 3; i <= 20; i++)
            {
                cmbFlightsPerPage.Items.Add(new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintViewXPerPage, i), i.ToString(CultureInfo.InvariantCulture))
                {
                    Selected = (i == 15)
                });
            }

            MyFlightbook.Profile      pf        = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
            List <CustomPropertyType> rgcptUser = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name));
            rgcptUser.RemoveAll(cpt => !cpt.IsFavorite && !pf.BlacklistedProperties.Contains(cpt.PropTypeID));
            List <CustomPropertyType> rgcptUserOptionalColumns = rgcptUser.FindAll(cpt => (cpt.Type == CFPPropertyType.cfpDecimal || cpt.Type == CFPPropertyType.cfpInteger) && !cpt.IsNoSum);
            rgcptUser.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            cklProperties.DataSource = rgcptUser;
            cklProperties.DataBind();
            expPropertiesToExclude.Visible = rgcptUser.Count > 0;

            // By default, exclude "Additional flight remarks"
            foreach (ListItem li in cklProperties.Items)
            {
                if (Convert.ToInt32(li.Value, CultureInfo.InvariantCulture) == (int)CustomPropertyType.KnownProperties.IDPropAdditionalFlightRemarks)
                {
                    li.Selected = true;
                }
            }

            List <ListItem> lstOptionalColumnDropdowns = new List <ListItem>()
            {
                new ListItem(Resources.LocalizedText.PrintViewOptionalColumnNone, string.Empty),
                new ListItem(Resources.Makes.IsComplex, OptionalColumnType.Complex.ToString()),
                new ListItem(Resources.Makes.IsRetract, OptionalColumnType.Retract.ToString()),
                new ListItem(Resources.Makes.IsTailwheel, OptionalColumnType.Tailwheel.ToString()),
                new ListItem(Resources.Makes.IsHighPerf, OptionalColumnType.HighPerf.ToString()),
                new ListItem(Resources.Makes.IsTurboprop, OptionalColumnType.TurboProp.ToString()),
                new ListItem(Resources.Makes.IsTurbine, OptionalColumnType.Turbine.ToString()),
                new ListItem(Resources.Makes.IsJet, OptionalColumnType.Jet.ToString()),
            };
            rgcptUserOptionalColumns.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            foreach (CustomPropertyType cpt in rgcptUserOptionalColumns)
            {
                lstOptionalColumnDropdowns.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)));
            }
            foreach (DropDownList ddl in OptionalColumnDropDowns)
            {
                ddl.DataSource = lstOptionalColumnDropdowns;
                ddl.DataBind();
            }
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Enabled)
        {
            return;
        }

        rgCPT = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : ""); // this is cached so we can do it on every call, postback or not

        if (!IsPostBack)
        {
            ListItem li;

            Boolean fFavorites = rgCPT[0].IsFavorite;
            if (fFavorites)
            {
                li = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PropertyGroupSeparator, Resources.LocalizedText.FlightPropertiesFrequentlyUsed), "-1");
                li.Attributes.Add("style", "font-weight: bold");
                cmbCustomPropertyTypes.Items.Add(li);
            }

            foreach (CustomPropertyType cpt in rgCPT)
            {
                if (fFavorites && !cpt.IsFavorite) // transition to non-favorites
                {
                    fFavorites = false;
                    li         = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PropertyGroupSeparator, Resources.LocalizedText.FlightPropertiesOtherProperties), "-1");
                    li.Attributes.Add("style", "font-weight: bold");
                    cmbCustomPropertyTypes.Items.Add(li);
                }

                li = new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture));

                cmbCustomPropertyTypes.Items.Add(li);
            }

            if (FlightProperties == null)
            {
                FlightProperties = new List <CustomFlightProperty>();
            }

            InitNewProperty();
        }
        else
        {
            if (ViewState[szVSKeyCFP] != null)
            {
                FlightProperties = (List <CustomFlightProperty>)ViewState[szVSKeyCFP];
            }
        }

        ShowCorrectEntryForPropertyType();
    }
Esempio n. 12
0
        public TemplatePropTypeBundle(string szUser) : this()
        {
            UserProperties = CustomPropertyType.GetCustomPropertyTypes(szUser);
            // For serialization to work with propertytemplates, the objects need to actually be propertytemplates, not subclasses.
            List <PropertyTemplate>        lst  = new List <PropertyTemplate>();
            IEnumerable <PropertyTemplate> rgpt = UserPropertyTemplate.TemplatesForUser(szUser, true);

            foreach (PropertyTemplate pt in rgpt)
            {
                lst.Add(new PropertyTemplate(pt));
            }
            UserTemplates = lst.ToArray();
        }
Esempio n. 13
0
        public static IEnumerable <CustomRatingProgress> CustomRatingsForUser(string szUser)
        {
            if (szUser == null)
            {
                throw new ArgumentNullException(nameof(szUser));
            }

            Profile pf = Profile.GetUser(szUser);

            // build a map of all histogrammable values for naming
            List <HistogramableValue> lst = new List <HistogramableValue>(LogbookEntryDisplay.HistogramableValues);

            foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes())
            {
                HistogramableValue hv = LogbookEntryDisplay.HistogramableValueForPropertyType(cpt);
                if (hv != null)
                {
                    lst.Add(hv);
                }
            }

            Dictionary <string, HistogramableValue> d = new Dictionary <string, HistogramableValue>();

            foreach (HistogramableValue hv in lst)
            {
                d[hv.DataField] = hv;
            }

            // MUST use the pf.GetPreferenceForKey with one argument because you need the serialize/deserialize to get the correct type conversion.
            IEnumerable <CustomRatingProgress> rgProgressForUser = pf.GetPreferenceForKey <IEnumerable <CustomRatingProgress> >(szPrefKeyCustomRatings);

            if (rgProgressForUser == null)
            {
                return(Array.Empty <CustomRatingProgress>());
            }

            foreach (CustomRatingProgress crp in rgProgressForUser)
            {
                crp.Username = szUser;
                foreach (CustomRatingProgressItem crpi in crp.ProgressItems)
                {
                    crpi.FieldFriendlyName = d.TryGetValue(crpi.FieldName, out HistogramableValue hv) ? hv.DataName : crpi.FieldName;
                }

                List <CustomRatingProgressItem> lstItems = new List <CustomRatingProgressItem>(crp.ProgressItems);
                lstItems.Sort((crpi1, crpi2) => { return(crpi1.FARRef.CompareCurrentCultureIgnoreCase(crpi2.FARRef)); });
                crp.ProgressItems = lstItems;
            }

            return(rgProgressForUser);
        }
    protected void SegregateProperties(bool fStripDefault = false)
    {
        List <CustomPropertyType> lstRemainingProps = new List <CustomPropertyType>();

        ActiveProperties.Clear();
        ActivePropTypes.Clear();

        PropertyTemplate ptMerged = PropertyTemplate.MergedTemplate(ActiveTemplates);

        // this is cached so we can do it on every call, postback or not
        CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Username : string.Empty);

        foreach (CustomPropertyType cpt in rgCptAll)
        {
            // see if this either has a value or is in one of the active templates.
            // if it doesn't have a value but is in a template, give it a value.
            CustomFlightProperty fp = Properties.Find(cfp => cfp.PropTypeID == cpt.PropTypeID);

            // To be included, it must be EITHER
            // a) in the merged set of templates OR
            // b) in the set of properties with a non-default value (fp != null && !fp.IsDefaultValue) OR
            // c) in the set of properties with a default value (fp != null && (!fStripDefault && fp.IsDefaultValue)
            bool fInclude = ptMerged.ContainsProperty(cpt.PropTypeID) || (fp != null && (!fStripDefault || !fp.IsDefaultValue));
            if (fp == null)
            {
                fp = new CustomFlightProperty(cpt);
            }

            if (!fInclude)
            {
                lstRemainingProps.Add(cpt);
            }
            else
            {
                ActiveProperties.Add(fp);
                ActivePropTypes.Add(fp.PropTypeID);
            }
        }

        ActiveProperties.Sort((cfp1, cfp2) => { return(cfp1.PropertyType.SortKey.CompareCurrentCultureIgnoreCase(cfp2.PropertyType.SortKey)); });

        ListItem li = cmbPropsToAdd.Items[0];

        cmbPropsToAdd.Items.Clear();
        cmbPropsToAdd.Items.Add(li);
        cmbPropsToAdd.SelectedValue = string.Empty;    // reset the selection
        cmbPropsToAdd.DataSource    = lstRemainingProps;
        cmbPropsToAdd.DataBind();
    }
Esempio n. 15
0
    /// <summary>
    /// Updates the flight query with the requested flight properties
    /// </summary>
    private void CustomPropsFromForm()
    {
        if (cklCustomProps.SelectedIndex >= 0)
        {
            List <CustomPropertyType> lstCpt   = new List <CustomPropertyType>();
            CustomPropertyType[]      rgcptAll = CustomPropertyType.GetCustomPropertyTypes();

            foreach (ListItem li in cklCustomProps.Items)
            {
                if (li.Selected)
                {
                    lstCpt.Add(Array.Find <CustomPropertyType>(rgcptAll, cpt => cpt.PropTypeID == Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)));
                }
            }

            m_fq.PropertyTypes = lstCpt.ToArray();
        }
    }
Esempio n. 16
0
    /// <summary>
    /// Updates the flight query with the requested flight properties
    /// </summary>
    private void CustomPropsFromForm()
    {
        if (cklCustomProps.SelectedIndex >= 0)
        {
            m_fq.PropertyTypes.Clear();
            CustomPropertyType[] rgcptAll = CustomPropertyType.GetCustomPropertyTypes();

            foreach (ListItem li in cklCustomProps.Items)
            {
                if (li.Selected)
                {
                    m_fq.PropertyTypes.Add(Array.Find <CustomPropertyType>(rgcptAll, cpt => cpt.PropTypeID == Convert.ToInt32(li.Value, CultureInfo.InvariantCulture)));
                }
            }

            m_fq.PropertiesConjunction = (GroupConjunction)Enum.Parse(typeof(GroupConjunction), cmbPropertiesConjunction.SelectedValue);
        }
    }
    protected void cmbPropsToAdd_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(cmbPropsToAdd.SelectedValue))
        {
            return;
        }
        int idPropType = Convert.ToInt32(cmbPropsToAdd.SelectedValue, CultureInfo.InvariantCulture);

        CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Username : string.Empty);
        CustomPropertyType   cpt      = rgCptAll.First((cpt2) => { return(cpt2.PropTypeID == idPropType); });

        if (cpt == null)
        {
            throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Custom property type with id {0} not found!", idPropType));
        }

        RefreshList(new CustomFlightProperty(cpt));
    }
Esempio n. 18
0
        public override string CSVFromDataTable(DataTable dt)
        {
            if (dt == null)
            {
                throw new ArgumentNullException("dt");
            }
            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = dt.Locale;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (DataRow dr in dt.Rows)
                {
                    ForeFlight ltp = new ForeFlight(dr, dictAircraft, rgcpt);
                    CSVImporter.WriteEntryToDataTable(ltp.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
Esempio n. 19
0
    protected void UpdateLists()
    {
        UserPropertyTemplate      pt     = ActiveTemplate;
        List <CustomPropertyType> lstAll = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes());

        List <CustomPropertyType> lstIncluded   = lstAll.FindAll(cpt => pt.ContainsProperty(cpt));
        IEnumerable <int>         includedProps = lstIncluded.Select(cpt => cpt.PropTypeID);

        rptTemplateProps.DataSource = lstIncluded;
        rptTemplateProps.DataBind();

        lstAll.RemoveAll(cpt => pt.ContainsProperty(cpt));
        IEnumerable <int> availableProps = lstAll.Select(cpt => cpt.PropTypeID);

        rptAvailableProps.DataSource = lstAll;
        rptAvailableProps.DataBind();

        hdnAvailableProps.Value = JsonConvert.SerializeObject(availableProps);
        hdnUsedProps.Value      = JsonConvert.SerializeObject(includedProps);
    }
Esempio n. 20
0
        public override string CSVFromDataTable(DataTable dt)
        {
            if (dt == null)
            {
                throw new ArgumentNullException("dt");
            }
            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            NormalizeColumnNames(dt);
            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = dt.Locale;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (DataRow dr in dt.Rows)
                {
                    eLogSite els = new eLogSite(dr, rgcpt);
                    CSVImporter.WriteEntryToDataTable(els.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }
    protected void SegregateProperties()
    {
        List <CustomPropertyType> lstRemainingProps = new List <CustomPropertyType>();

        ActiveProperties.Clear();
        ActivePropTypes.Clear();

        // this is cached so we can do it on every call, postback or not
        CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : string.Empty);

        foreach (CustomPropertyType cpt in rgCptAll)
        {
            CustomFlightProperty fp = Properties.Find(cfp => cfp.PropTypeID == cpt.PropTypeID);
            if (fp == null && cpt.IsFavorite)
            {
                fp = new CustomFlightProperty(cpt);
            }
            if (fp == null)
            {
                lstRemainingProps.Add(cpt);
            }
            else
            {
                ActiveProperties.Add(fp);
                ActivePropTypes.Add(fp.PropTypeID);
            }
        }

        ActiveProperties.Sort((cfp1, cfp2) => { return(cfp1.PropertyType.SortKey.CompareCurrentCultureIgnoreCase(cfp2.PropertyType.SortKey)); });

        ListItem li = cmbPropsToAdd.Items[0];

        cmbPropsToAdd.Items.Clear();
        cmbPropsToAdd.Items.Add(li);
        cmbPropsToAdd.SelectedValue = string.Empty;    // reset the selection
        cmbPropsToAdd.DataSource    = lstRemainingProps;
        cmbPropsToAdd.DataBind();
    }
    protected void cmbPropsToAdd_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(cmbPropsToAdd.SelectedValue))
        {
            return;
        }
        int idPropType = Convert.ToInt32(cmbPropsToAdd.SelectedValue);

        CustomPropertyType[] rgCptAll = CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : string.Empty);
        CustomPropertyType   cpt      = rgCptAll.First((cpt2) => { return(cpt2.PropTypeID == idPropType); });

        if (cpt == null)
        {
            throw new MyFlightbookException(String.Format("Custom property type with id {0} not found!", idPropType));
        }

        Properties = PropertiesFromPropSet;             // Pick up any changes from the existing child controls, to preserve across postback
        Properties.Add(new CustomFlightProperty(cpt));
        SegregateProperties();                          // add the new property to the list
        PopulateControls();                             // And re-populate.
        txtFilter.Text = string.Empty;
        CollapsiblePanelExtender1.Collapsed = true;
    }
Esempio n. 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TableRow tr = new TableRow();

        tblAdditionalProps.Rows.Add(tr);
        CustomPropertyType[] rgCpt = CustomPropertyType.GetCustomPropertyTypes("");
        int cRows = (rgCpt.Length + cColumnsOfProps - 1) / cColumnsOfProps;

        for (int iRow = 0; iRow < cRows; iRow++)
        {
            for (int iCol = 0; iCol < cColumnsOfProps; iCol++)
            {
                int iProp = (iCol * cRows) + iRow;
                if (iProp < rgCpt.Length)
                {
                    AddProp(rgCpt[iProp], tr);
                }
                else
                {
                    // add blank cells to pad out the row.
                    tr.Cells.Add(new TableCell());
                }
            }
            tr = new TableRow();
            tblAdditionalProps.Rows.Add(tr);
            tr.Style["vertical-align"] = "top";
        }

        if (tr.Cells.Count == 0)
        {
            tblAdditionalProps.Rows.Remove(tr);
        }

        this.Master.SelectedTab = tabID.tabLogbook;
        this.Title = lblImportHeader.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LogbookEntry.importTableHeader, Branding.CurrentBrand.AppName);
        litTableMainFields.Text = Branding.ReBrand(Resources.LogbookEntry.ImportTableDescription);
    }
    private bool fHasBeenSetUp; // have we already been initialized for the user?

    protected void SetUpPropertiesForUser(bool fIncludeAll)
    {
        CustomPropertyType[]      rgCpt = CustomPropertyType.GetCustomPropertyTypes(Username);
        List <CustomPropertyType> al    = new List <CustomPropertyType>(rgCpt);
        int cAllProps = al.Count;

        HashSet <int> hsBlackList = fIncludeAll ? new HashSet <int>(Profile.GetUser(Username).BlocklistedProperties) : new HashSet <int>();

        // Props to include are favorites OR it's in the query OR (Include ALL and in blacklist)
        // So remove anything that is NOT favorite AND NOT in the query AND NOT (include all and in blacklist)
        al.RemoveAll(cpt => !cpt.IsFavorite && !(m_fq != null && m_fq.PropertyTypes.Contains(cpt)) && !(fIncludeAll && hsBlackList.Contains(cpt.PropTypeID)));

        lnkShowAllProps.Visible = !fIncludeAll && cAllProps > al.Count;

        if (al.Count == 0)
        {
            pnlCustomProps.Visible = false;
        }
        else
        {
            cklCustomProps.DataSource = al;
            cklCustomProps.DataBind();
        }
    }
        protected void SetPropsForUser()
        {
            MyFlightbook.Profile      pf        = MyFlightbook.Profile.GetUser(UserName);
            List <CustomPropertyType> rgcptUser = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(pf.UserName));

            rgcptUser.RemoveAll(cpt => !cpt.IsFavorite && !pf.BlocklistedProperties.Contains(cpt.PropTypeID));
            List <CustomPropertyType> rgcptUserOptionalColumns = rgcptUser.FindAll(cpt => (cpt.Type == CFPPropertyType.cfpDecimal || cpt.Type == CFPPropertyType.cfpInteger) && !cpt.IsNoSum);

            rgcptUser.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            cklProperties.DataSource = rgcptUser;
            cklProperties.DataBind();
            ckCheckAll.Visible             = rgcptUser.Count > 4;
            expPropertiesToExclude.Visible = rgcptUser.Count > 0;

            // By default, exclude "Additional flight remarks"
            foreach (ListItem li in cklProperties.Items)
            {
                if (Convert.ToInt32(li.Value, CultureInfo.InvariantCulture) == (int)CustomPropertyType.KnownProperties.IDPropAdditionalFlightRemarks)
                {
                    li.Selected = true;
                }
            }

            List <ListItem> lstOptionalColumnDropdowns = new List <ListItem>()
            {
                new ListItem(Resources.LocalizedText.PrintViewOptionalColumnNone, string.Empty),
                new ListItem(Resources.Makes.IsComplex, OptionalColumnType.Complex.ToString()),
                new ListItem(Resources.Makes.IsRetract, OptionalColumnType.Retract.ToString()),
                new ListItem(Resources.Makes.IsTailwheel, OptionalColumnType.Tailwheel.ToString()),
                new ListItem(Resources.Makes.IsHighPerf, OptionalColumnType.HighPerf.ToString()),
                new ListItem(Resources.Makes.IsTAA, OptionalColumnType.TAA.ToString()),
                new ListItem(Resources.Makes.IsTurboprop, OptionalColumnType.TurboProp.ToString()),
                new ListItem(Resources.Makes.IsTurbine, OptionalColumnType.Turbine.ToString()),
                new ListItem(Resources.Makes.IsJet, OptionalColumnType.Jet.ToString()),
                new ListItem(Resources.LogbookEntry.PrintHeaderCrossCountry, OptionalColumnType.CrossCountry.ToString()),
                new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ATD), OptionalColumnType.ATD.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.FTD), OptionalColumnType.FTD.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.FFS), OptionalColumnType.FFS.ToString()),
                new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ASEL), OptionalColumnType.ASEL.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.AMEL), OptionalColumnType.AMEL.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ASES), OptionalColumnType.ASES.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.AMES), OptionalColumnType.AMES.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.Glider), OptionalColumnType.Glider.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.Helicopter), OptionalColumnType.Helicopter.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.Gyroplane), OptionalColumnType.Gyroplane.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.HotAirBalloon), OptionalColumnType.HotAirBalloon.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.GasBalloon), OptionalColumnType.GasBalloon.ToString()),
                new ListItem(OptionalColumn.TitleForType(OptionalColumnType.UAS), OptionalColumnType.UAS.ToString()),
            };

            if (rgcptUserOptionalColumns.Count > 0)
            {
                lstOptionalColumnDropdowns.Add(new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty));
            }
            rgcptUserOptionalColumns.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            foreach (CustomPropertyType cpt in rgcptUserOptionalColumns)
            {
                lstOptionalColumnDropdowns.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)));
            }

            foreach (DropDownList ddl in OptionalColumnDropDowns)
            {
                ddl.DataSource = lstOptionalColumnDropdowns;
                ddl.DataBind();
            }
        }
Esempio n. 26
0
    private void InitForm()
    {
        if (!m_fNeedsInit)
        {
            return;
        }

        m_fNeedsInit = false;

        foreach (CustomCurrencyTimespanType t in Enum.GetValues(typeof(CustomCurrencyTimespanType)))
        {
            cmbMonthsDays.Items.Add(new ListItem(t.DisplayString(), t.ToString()));
        }

        UserAircraft           ua    = new UserAircraft(Page.User.Identity.Name);
        IEnumerable <Aircraft> lstAc = ua.GetAircraftForUser();

        lstAircraft.DataSource = lstAc;
        lstAircraft.DataBind();

        List <ListItem> lstCurrencyEvents = new List <ListItem>();

        foreach (var value in Enum.GetValues(typeof(CustomCurrency.CustomCurrencyEventType)))
        {
            lstCurrencyEvents.Add(new ListItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CustomCurrency.EventTypeLabel(1, (CustomCurrency.CustomCurrencyEventType)value)), ((int)value).ToString(CultureInfo.CurrentCulture)));
        }

        lstCurrencyEvents.Sort(delegate(ListItem a, ListItem b) { return(a.Text.CompareCurrentCultureIgnoreCase(b.Text)); });
        foreach (ListItem li in lstCurrencyEvents)
        {
            cmbEventTypes.Items.Add(li);
        }

        lstModels.DataSource = MakeModel.ModelsForAircraft(lstAc);
        lstModels.DataBind();

        IEnumerable <CategoryClass> rgCatClass = CategoryClass.CategoryClasses();

        cmbCatClass.DataSource = rgCatClass;
        cmbCatClass.DataBind();

        List <CustomPropertyType> lstCpt = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name));

        lstCpt.RemoveAll(cpt => !cpt.IsFavorite);
        lstProps.DataSource = lstCpt;
        lstProps.DataBind();

        // Get the categories (as opposed to catclass); this is something of a hack, but it avoids an extra DB call
        Dictionary <string, string> dictCategories = new Dictionary <string, string>();

        foreach (CategoryClass cc in rgCatClass)
        {
            dictCategories[cc.Category] = cc.Category;
        }
        List <string> lst = new List <string>(dictCategories.Keys);

        lst.Sort();
        foreach (string category in lst)
        {
            cmbCategory.Items.Add(new ListItem(category, category));
        }
    }
Esempio n. 27
0
        /// <summary>
        /// Computes the overall currency
        /// </summary>
        protected void RefreshCurrency()
        {
            // Compute currency according to 61.57(c)(1)-(5) and 61.57(e)
            // including each one's expiration.  The one that expires latest is the expiration date if you are current, the one that
            // expired most recently is the expiration date since when you were not current.

            if (m_fCacheValid)
            {
                return;
            }

            // This is ((61.57(c)(1) OR (2) OR (3) OR (4) OR (5) OR 61.57(e)), each of which is the AND of several currencies.

            // 61.57(c)(1) (66-HIT in airplane)
            FlightCurrency fc6157c1 = fcIFRApproach.AND(fcIFRHold);

            // 61.57(c)(2) (66-HIT in an FTD or flight simulator)
            FlightCurrency fc6157c2 = fcFTDApproach.AND(fcFTDHold);

            // 61.57(c)(3) - ATD
            FlightCurrency fc6157c3 = fcATDHold.AND(fcATDApproach).AND(fcUnusualAttitudesAsc).AND(fcUnusualAttitudesDesc).AND(fcInstrumentHours);

            // 61.57(c)(4) - Combo STRICT - 6 approaches/hold in an ATD PLUS an approach/hold in an airplane PLUS an approach/hold in an FTD
            FlightCurrency fc6157c4 = fcATDAppch6Month.AND(fcATDHold6Month).AND(fcIFRHold).AND(fcAirplaneApproach6Month).AND(fcFTDApproach6Month).AND(fcFTDHold);

            // 61.57(c)(4) - Combo LOOSE - any combination that yields 66-HIT, but require at least one aircraft approach and hold.
            // FlightCurrency fc6157c4Loose = fcComboApproach6Month.AND(fcAirplaneApproach6Month).AND(fcIFRHold.OR(fcATDHold6Month).OR(fcFTDHold));

            // 61.57(c)(5) - combo meal, but seems redundant with (c)(2)/(3).  I.e., if you've met this, you've met (2) or (3).

            // 61.57 (e) - IPC; no need to AND anything together for this one.

            FlightCurrency fcIFR = fc6157c1.OR(fc6157c2).OR(fc6157c3).OR(fc6157c4).OR(fcIPCOrCheckride);

            /*
             * if (m_fUseLoose6157c4)
             *  fcIFR = fcIFR.OR(fc6157c4Loose);
             */

            m_csCurrent    = fcIFR.CurrentState;
            m_dtExpiration = fcIFR.ExpirationDate;

            if (fcIPCOrCheckride.IsCurrent() && fcIPCOrCheckride.ExpirationDate.CompareTo(m_dtExpiration) >= 0)
            {
                Query.HasHolds = Query.HasApproaches = false;
                Query.PropertiesConjunction = GroupConjunction.Any;
                Query.PropertyTypes.Clear();
                foreach (CustomPropertyType cpt in CustomPropertyType.GetCustomPropertyTypes())
                {
                    if (cpt.IsIPC)
                    {
                        Query.PropertyTypes.Add(cpt);
                    }
                }
            }

            if (m_csCurrent == CurrencyState.NotCurrent)
            {
                // if more than 6 calendar months have passed since expiration, an IPC is required.
                // otherwise, just assume 66-HIT.
                if (DateTime.Compare(m_dtExpiration.AddCalendarMonths(6).Date, DateTime.Now.Date) > 0)
                {
                    m_szDiscrepancy = String.Format(CultureInfo.CurrentCulture, Resources.Currency.DiscrepancyTemplateIFR,
                                                    fcIFRHold.Discrepancy,
                                                    (fcIFRHold.Discrepancy == 1) ? Resources.Currency.Hold : Resources.Currency.Holds,
                                                    fcIFRApproach.Discrepancy,
                                                    (fcIFRApproach.Discrepancy == 1) ? Resources.Totals.Approach : Resources.Totals.Approaches);
                }
                else
                {
                    m_szDiscrepancy = Resources.Currency.IPCRequired;
                }
            }
            else
            {
                // Check to see if IPC is required by looking for > 6 month gap in IFR currency.
                // For now, we won't make you un-current, but we'll warn.
                // (IPC above, though, is un-current).
                CurrencyPeriod[] rgcpMissingIPC = fcIFR.FindCurrencyGap(fcIPCOrCheckride.MostRecentEventDate, 6);

                if (rgcpMissingIPC != null)
                {
                    m_szDiscrepancy = String.Format(CultureInfo.CurrentCulture, Resources.Currency.IPCMayBeRequired, rgcpMissingIPC[0].EndDate.ToShortDateString(), rgcpMissingIPC[1].StartDate.ToShortDateString());
                }
                else
                {
                    m_szDiscrepancy = string.Empty;
                }
            }

            m_fCacheValid = true;
        }
Esempio n. 28
0
        public override string CSVFromDataTable(DataTable dt)
        {
            // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse.

            IEnumerable <CustomPropertyType> rgcpt = CustomPropertyType.GetCustomPropertyTypes();

            // Build up the list of CrewTrac objects first; we'll then fill in cross-country time.
            List <CrewTrac> lstCt = new List <CrewTrac>();

            foreach (Match ctMatch in Matches)
            {
                GroupCollection gc = ctMatch.Groups;

                string szEmployees = gc["employees"].Value;
                // replace runs of 2 or more spaces with a tab for better finding boundaries (e.g., multiple employees).
                while (szEmployees.Contains("  "))
                {
                    szEmployees = szEmployees.Replace("  ", "\t");
                }

                MatchCollection mcEmployees = regCrewMember.Matches(szEmployees);

                List <CrewTracEmployee> lst = new List <CrewTracEmployee>();
                foreach (Match empMatch in mcEmployees)
                {
                    GroupCollection gcEmployee         = empMatch.Groups;
                    CrewTracEmployee.CrewTracRole role = CrewTracEmployee.CrewTracRole.CA;
                    if (!Enum.TryParse <CrewTracEmployee.CrewTracRole>(gcEmployee["pos"].Value, out role))
                    {
                        role = CrewTracEmployee.CrewTracRole.CA;
                    }
                    lst.Add(new CrewTracEmployee()
                    {
                        Role = role, Name = gcEmployee["empname"].Value
                    });
                }

                try
                {
                    CrewTrac ct = new CrewTrac()
                    {
                        FlightNumber = String.IsNullOrEmpty(gc["flightnum"].Value) ? 0 : Convert.ToInt32(gc["flightnum"].Value, CultureInfo.CurrentCulture),
                        Date         = Convert.ToDateTime(gc["date"].Value, CultureInfo.CurrentCulture),
                        From         = gc["from"].Value,
                        To           = gc["to"].Value,
                        BlockHours   = gc["block"].Value.DecimalFromHHMM(),
                        Tail         = gc["tail"].Value,
                        Model        = gc["model"].Value,
                        Landings     = String.IsNullOrEmpty(gc["landings"].Value) ? 0 : Convert.ToInt32(gc["landings"].Value, CultureInfo.CurrentCulture),
                        Employees    = lst
                    };
                    lstCt.Add(ct);
                }
                catch (FormatException) { }
            }

            // Build up a list of airports so that we can determine cross-country time.
            StringBuilder sbRoutes = new StringBuilder();

            foreach (CrewTrac ct in lstCt)
            {
                sbRoutes.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}", ct.From, ct.To);
            }
            AirportList alRoutes = new AirportList(sbRoutes.ToString());

            foreach (CrewTrac ct in lstCt)
            {
                AirportList alFlight = alRoutes.CloneSubset(ct.From + " " + ct.To);
                if (alFlight.MaxDistanceForRoute() > 50.0)
                {
                    ct.CrossCountry = ct.BlockHours;
                }
            }

            using (DataTable dtDst = new DataTable())
            {
                dtDst.Locale = CultureInfo.CurrentCulture;
                CSVImporter.InitializeDataTable(dtDst);
                foreach (CrewTrac ct in lstCt)
                {
                    CSVImporter.WriteEntryToDataTable(ct.ToLogbookEntry(), dtDst);
                }
                return(CsvWriter.WriteToString(dtDst, true, true));
            }
        }