protected void RefreshLogbookData()
        {
            mvLayouts.ActiveViewIndex = (int)PrintOptions1.Options.Layout;
            pnlResults.Visible        = true;
            lblCoverDate.Text         = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintViewCoverSheetDateTemplate, DateTime.Now);

            PrintingOptions po = PrintOptions1.Options;

            // Set any global font appropriately.
            pnlResults.Style["font-size"] = po.Size == PrintingOptions.FontSize.Normal ? "9pt" : String.Format(CultureInfo.InvariantCulture, po.Size == PrintingOptions.FontSize.Small ? "7pt" : "11pt");

            // Make sure that any PDF and section information is up-to-date, and that the PrintOptions property is set up correctly
            po.Sections    = printingSections;
            po.PDFSettings = pdfOptions;
            PrintOptions   = po;

            // Make sure copy link is up-to-date
            lnkPermalink.NavigateUrl = PermaLink(po, mfbSearchForm1.Restriction);

            mvLayouts.Visible       = po.Sections.IncludeFlights;
            pnlEndorsements.Visible = po.Sections.Endorsements != PrintingSections.EndorsementsLevel.None;
            rptImages.Visible       = po.Sections.Endorsements == PrintingSections.EndorsementsLevel.DigitalAndPhotos;
            pnlTotals.Visible       = po.Sections.IncludeTotals;
            pnlCover.Visible        = po.Sections.IncludeCoverPage;

            IList <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), CurrentUser.UserName, string.Empty, SortDirection.Ascending, CurrentUser.UsesHHMM, CurrentUser.UsesUTCDateOfFlight);
            PrintLayout pl = LogbookPrintedPage.LayoutLogbook(CurrentUser, lstFlights, ActiveTemplate, po, SuppressFooter);

            Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();
        }
        protected void RefreshFlightsList()
        {
            IList <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(new FlightQuery(User.Identity.Name)), User.Identity.Name, "Date", SortDirection.Descending, false, false);

            rptSelectedFlights.DataSource = lstFlights;
            rptSelectedFlights.DataBind();
        }
Esempio n. 3
0
        /// <summary>
        /// Performs the computation on the milestones to see what progress has been made for each.  We MUST use LogbookEntryDisplays, so we override the base class (which uses ExaminerFlightRow)
        /// </summary>
        /// <returns>The resulting milestones.</returns>
        /// <exception cref="MyFlightbookException"></exception>
        public override Collection <MilestoneItem> Refresh()
        {
            if (String.IsNullOrEmpty(Username))
            {
                throw new MyFlightbookException("Cannot compute milestones on an empty user!");
            }

            StringBuilder sbRoutes = new StringBuilder();
            Profile       pf       = Profile.GetUser(Username);

            IList <LogbookEntryDisplay> lst = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryBase.QueryCommand(new FlightQuery(Username)), Username, string.Empty, System.Web.UI.WebControls.SortDirection.Descending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

            // Set up the airport list once for DB efficiency
            foreach (LogbookEntryDisplay led in lst)
            {
                sbRoutes.AppendFormat(CultureInfo.InvariantCulture, "{0} ", led.Route);
            }
            AirportListOfRoutes = new AirportList(sbRoutes.ToString());

            IDictionary <string, CannedQuery> d = UserQueries;

            foreach (LogbookEntryDisplay led in lst)
            {
                foreach (CustomRatingProgressItem cpi in ProgressItems)
                {
                    cpi.ExamineFlight(led, d);
                }
            }
            ;

            return(Milestones);
        }
Esempio n. 4
0
        protected void btnCheckAll_Click(object sender, EventArgs e)
        {
            UInt32 selectedOptions = SelectedOptions;

            if (selectedOptions == 0)
            {
                lblErr.Text = Resources.FlightLint.errNoOptionsSelected;
                return;
            }

            FlightQuery fq = new FlightQuery(Page.User.Identity.Name);

            if (mfbDateLastCheck.Date.HasValue())
            {
                fq.DateRange = FlightQuery.DateRanges.Custom;
                fq.DateMin   = mfbDateLastCheck.Date;
            }
            DBHelperCommandArgs            dbhq = LogbookEntryBase.QueryCommand(fq, fAsc: true);
            IEnumerable <LogbookEntryBase> rgle = LogbookEntryDisplay.GetFlightsForQuery(dbhq, Page.User.Identity.Name, "Date", SortDirection.Ascending, false, false);

            BindFlights(new FlightLint().CheckFlights(rgle, Page.User.Identity.Name, selectedOptions, mfbDateLastCheck.Date), rgle.Count());

            Response.Cookies[szCookieLastCheck].Value   = DateTime.Now.YMDString();
            Response.Cookies[szCookieLastCheck].Expires = DateTime.Now.AddYears(5);
        }
Esempio n. 5
0
    protected void RefreshFlightsList(int idFlight)
    {
        List <LogbookEntryDisplay> lstFlights = new List <LogbookEntryDisplay>();


        if (idFlight != LogbookEntry.idFlightNew)
        {
            LogbookEntryDisplay le = new LogbookEntryDisplay(idFlight, User.Identity.Name);
            if (!le.IsNewFlight && le.CanRequestSig)   // it loaded (is owned by the user) and signable
            {
                lstFlights.Add(le);
            }
        }
        if (lstFlights.Count == 0)
        {
            lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(new FlightQuery(User.Identity.Name)), User.Identity.Name, "Date", SortDirection.Descending, false, false);
            lstFlights.RemoveAll(le => !le.CanRequestSig);
        }

        rptSelectedFlights.DataSource = lstFlights;
        rptSelectedFlights.DataBind();

        // if only one flight, check it by default.
        if (lstFlights.Count == 1)
        {
            ((CheckBox)rptSelectedFlights.Items[0].FindControl("ckFlight")).Checked = true;
        }
    }
Esempio n. 6
0
    protected void RefreshLogbookData()
    {
        mvLayouts.ActiveViewIndex = (int)PrintOptions1.Options.Layout;
        pnlResults.Visible        = true;

        IList <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), CurrentUser.UserName, string.Empty, SortDirection.Ascending, CurrentUser.UsesHHMM, CurrentUser.UsesUTCDateOfFlight);
        PrintLayout pl = LogbookPrintedPage.LayoutLogbook(CurrentUser, lstFlights, ActiveTemplate, PrintOptions1.Options, SuppressFooter);

        Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();
    }
Esempio n. 7
0
    protected void RefreshFlightsList(string[] rgFlightIds)
    {
        if (rgFlightIds == null)
        {
            throw new ArgumentNullException(nameof(rgFlightIds));
        }

        HashSet <int> lstIds = new HashSet <int>();

        foreach (string sz in rgFlightIds)
        {
            if (int.TryParse(sz, NumberStyles.Integer, CultureInfo.InvariantCulture, out int idFlight))
            {
                lstIds.Add(idFlight);
            }
        }

        bool fPreSelected = false;  // true if the flights should be pre-selected (i.e., passed in)

        List <LogbookEntryDisplay> lstFlights = new List <LogbookEntryDisplay>();

        foreach (int idFlight in lstIds)
        {
            LogbookEntryDisplay le = new LogbookEntryDisplay(idFlight, User.Identity.Name);
            if (!le.IsNewFlight && le.CanRequestSig)   // it loaded (is owned by the user) and signable
            {
                lstFlights.Add(le);
            }
            fPreSelected = (lstFlights.Count > 0);
        }
        if (lstFlights.Count == 0)
        {
            lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(new FlightQuery(User.Identity.Name)), User.Identity.Name, "Date", SortDirection.Descending, false, false);
            lstFlights.RemoveAll(le => !le.CanRequestSig);
        }

        rptSelectedFlights.DataSource = lstFlights;
        rptSelectedFlights.DataBind();

        // Select the items that were passed in.
        if (fPreSelected)
        {
            foreach (RepeaterItem ri in rptSelectedFlights.Items)
            {
                ((CheckBox)ri.FindControl("ckFlight")).Checked = true;
            }
        }
    }
Esempio n. 8
0
    protected void RefreshLogbookData()
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        PrintingOptions      printingOptions = PrintOptions1.Options;

        mvLayouts.ActiveViewIndex = (int)printingOptions.Layout;
        List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

        IPrintingTemplate pt = ActiveTemplate;

        PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser);
        bool        fCanIncludeImages = pl.SupportsImages;

        List <int> lstPropsToExclude = new List <int>(printingOptions.ExcludedPropertyIDs);
        string     szPropSeparator   = printingOptions.PropertySeparatorText;

        // set up properties per flight, and compute rough lineheight
        foreach (LogbookEntryDisplay led in lstFlights)
        {
            // Fix up properties according to the printing options
            List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties);
            lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID));

            led.CustomProperties    = lstProps.ToArray();
            led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator);

            if (printingOptions.IncludeImages)
            {
                led.PopulateImages(true);
            }

            led.RowHeight = pl.RowHeight(led);
        }

        Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();

        pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions.FlightsPerPage, printingOptions.OptionalColumns), CurrentUser, printingOptions.IncludeImages, !SuppressFooter, printingOptions.OptionalColumns);

        pnlResults.Visible = true;
    }
Esempio n. 9
0
    protected void RefreshLogbookData()
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        PrintingOptions      printingOptions = PrintOptions1.Options;

        mvLayouts.ActiveViewIndex = (int)printingOptions.Layout;
        List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

        IPrintingTemplate pt = ActiveTemplate;

        PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser);
        bool        fCanIncludeImages = pl.SupportsImages;

        // Exclude both excluded properties and properties that have been moved to their own columns
        HashSet <int> lstPropsToExclude    = new HashSet <int>(printingOptions.ExcludedPropertyIDs);
        HashSet <int> lstPropsInOwnColumns = new HashSet <int>();

        foreach (OptionalColumn oc in printingOptions.OptionalColumns)
        {
            if (oc.ColumnType == OptionalColumnType.CustomProp)
            {
                lstPropsInOwnColumns.Add(oc.IDPropType);
            }
        }
        string szPropSeparator = printingOptions.PropertySeparatorText;

        // set up properties per flight, and compute rough lineheight
        foreach (LogbookEntryDisplay led in lstFlights)
        {
            // Fix up properties according to the printing options
            List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties);

            // And fix up model as well.
            switch (printingOptions.DisplayMode)
            {
            case PrintingOptions.ModelDisplayMode.Full:
                break;

            case PrintingOptions.ModelDisplayMode.Short:
                led.ModelDisplay = led.ShortModelName;
                break;

            case PrintingOptions.ModelDisplayMode.ICAO:
                led.ModelDisplay = led.FamilyName;
                break;
            }


            // Remove from the total property set all explicitly excluded properties...
            lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID));

            // ...and then additionally exclude from the display any that's in its own column to avoid redundancy.
            lstProps.RemoveAll(cfp => lstPropsInOwnColumns.Contains(cfp.PropTypeID));
            led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator);

            if (printingOptions.IncludeImages)
            {
                led.PopulateImages(true);
            }

            if (!printingOptions.IncludeSignatures)
            {
                led.CFISignatureState = LogbookEntryBase.SignatureState.None;
            }
            led.RowHeight = pl.RowHeight(led);
        }

        Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();

        pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions), CurrentUser, printingOptions, !SuppressFooter);

        pnlResults.Visible = true;
    }
Esempio n. 10
0
    public void UpdateData()
    {
        if (User.Length > 0)
        {
            IEnumerable <Aircraft> rgac = new UserAircraft(User).GetAircraftForUser();
            AircraftForUser.Clear();
            foreach (Aircraft ac in rgac)
            {
                AircraftForUser[ac.AircraftID] = ac;
            }

            IEnumerable <LogbookEntryDisplay> rgle = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(Restriction), User, "Date", SortDirection.Descending, false, false);
            gvFlightLogs.DataSource = rgle;

            // See whether or not to show catclassoverride column
            bool fShowAltCatClass = false;
            foreach (LogbookEntryDisplay le in rgle)
            {
                fShowAltCatClass |= le.IsOverridden;
            }

            if (!fShowAltCatClass)
            {
                foreach (DataControlField dcf in gvFlightLogs.Columns)
                {
                    if (dcf.HeaderText.CompareCurrentCultureIgnoreCase("Alternate Cat/Class") == 0)
                    {
                        gvFlightLogs.Columns.Remove(dcf);
                        break;
                    }
                }
            }

            // Generate the set of properties used by the user
            int cColumns = gvFlightLogs.Columns.Count;
            PropertyColumnMap.Clear();
            HashSet <CustomPropertyType> hscpt = new HashSet <CustomPropertyType>();
            foreach (LogbookEntryBase le in rgle)
            {
                foreach (CustomFlightProperty cfp in le.CustomProperties)
                {
                    if (!hscpt.Contains(cfp.PropertyType))
                    {
                        hscpt.Add(cfp.PropertyType);
                    }
                }
            }

            // Now sort that alphabetically and add them
            List <CustomPropertyType> lst = new List <CustomPropertyType>(hscpt);
            lst.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            foreach (CustomPropertyType cpt in lst)
            {
                PropertyColumnMap[cpt.PropTypeID] = cColumns++;
                BoundField bf = new BoundField()
                {
                    HeaderText       = cpt.Title,
                    HtmlEncode       = false,
                    DataField        = string.Empty,
                    DataFormatString = string.Empty
                };
                gvFlightLogs.Columns.Add(bf);
            }

            if (OrderString != null && OrderString.Length > 0)
            {
                char[]    delimit  = { ',' };
                string[]  rgszCols = OrderString.Split(delimit);
                ArrayList alCols   = new ArrayList();

                // identify the requested front columns
                foreach (string szcol in rgszCols)
                {
                    if (int.TryParse(szcol, NumberStyles.Integer, CultureInfo.InvariantCulture, out int col))
                    {
                        if (col < gvFlightLogs.Columns.Count)
                        {
                            alCols.Add(col);
                        }
                    }
                }

                int[] rgCols = (int[])alCols.ToArray(typeof(int));

                // pull those columns to the left; this creates a duplicate column and shifts everything right by one...
                int iCol = 0;
                for (iCol = 0; iCol < rgCols.Length; iCol++)
                {
                    gvFlightLogs.Columns.Insert(iCol, gvFlightLogs.Columns[rgCols[iCol] + iCol]);
                }

                // And then remove the duplicates, from right to left
                Array.Sort(rgCols);
                for (int i = rgCols.Length - 1; i >= 0; i--)
                {
                    gvFlightLogs.Columns.RemoveAt(rgCols[i] + iCol);
                }
            }

            gvFlightLogs.DataBind();
        }
    }
        protected string RefreshFlightsList(string[] rgFlightIds)
        {
            if (rgFlightIds == null)
            {
                throw new ArgumentNullException(nameof(rgFlightIds));
            }

            HashSet <int> lstIds = new HashSet <int>();

            foreach (string sz in rgFlightIds)
            {
                if (int.TryParse(sz, NumberStyles.Integer, CultureInfo.InvariantCulture, out int idFlight))
                {
                    lstIds.Add(idFlight);
                }
            }

            bool fPreSelected = false;  // true if the flights should be pre-selected (i.e., passed in)

            List <LogbookEntryDisplay> lstFlights = new List <LogbookEntryDisplay>();

            foreach (int idFlight in lstIds)
            {
                LogbookEntryDisplay le = new LogbookEntryDisplay(idFlight, User.Identity.Name);
                if (!le.IsNewFlight && le.CanRequestSig)   // it loaded (is owned by the user) and signable
                {
                    lstFlights.Add(le);
                }
                fPreSelected = (lstFlights.Count > 0);
            }
            if (lstFlights.Count == 0)
            {
                lstFlights = new List <LogbookEntryDisplay>(LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(new FlightQuery(User.Identity.Name)), User.Identity.Name, "Date", SortDirection.Descending, false, false));
                lstFlights.RemoveAll(le => !le.CanRequestSig);
            }

            rptSelectedFlights.DataSource = lstFlights;
            rptSelectedFlights.DataBind();

            // Select the items that were passed in.
            if (fPreSelected)
            {
                foreach (RepeaterItem ri in rptSelectedFlights.Items)
                {
                    ((CheckBox)ri.FindControl("ckFlight")).Checked = true;
                }
            }

            // See if there's an obvious best-guess instructor name and return that.
            HashSet <string> hs = new HashSet <string>();

            foreach (LogbookEntryBase le in lstFlights)
            {
                if (le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropInstructorName))
                {
                    hs.Add(le.CustomProperties[CustomPropertyType.KnownProperties.IDPropInstructorName].TextValue.ToUpper(CultureInfo.CurrentCulture));
                }
            }
            hs.RemoveWhere(s => String.IsNullOrEmpty(s));   // SHOULD be a no-op.
            return((hs.Count == 1) ? String.Join(string.Empty, hs) : string.Empty);
        }