protected void SetUpBadgesForRow(LogbookEntryDisplay le, GridViewRow row)
    {
        if (row == null)
        {
            throw new ArgumentNullException(nameof(row));
        }
        if (le == null)
        {
            throw new ArgumentNullException(nameof(le));
        }

        if (Pilot != null && Pilot.AchievementStatus == Achievement.ComputeStatus.UpToDate)
        {
            Repeater rptBadges = (Repeater)row.FindControl("rptBadges");
            if (CachedBadgesByFlight.ContainsKey(le.FlightID))
            {
                IEnumerable <Badge> badges = CachedBadgesByFlight[le.FlightID];
                if (badges != null)
                {
                    rptBadges.DataSource = badges;
                    rptBadges.DataBind();
                }
            }
        }
    }
    protected void gvFlightLogs_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            int cCols = e.Row.Cells.Count;

            for (int i = cCols - 1; i >= 1; i--)
            {
                e.Row.Cells.RemoveAt(i);
            }
            e.Row.Cells[0].ColumnSpan = cCols;
        }
        else if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LogbookEntryDisplay le = (LogbookEntryDisplay)e.Row.DataItem;

            SetUpContextMenuForRow(le, e.Row);
            SetUpBadgesForRow(le, e.Row);
            SetUpSelectionForRow(le, e.Row);
            SetUpImagesForRow(le, e.Row);
            SetStyleForRow(le, e.Row);
        }
    }
    protected void fmvLE_DataBound(object sender, EventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }

        FormView              fv          = sender as FormView;
        LogbookEntryDisplay   le          = (LogbookEntryDisplay)fv.DataItem;
        Controls_mfbImageList mfbilFlight = (Controls_mfbImageList)fv.FindControl("mfbilFlight");

        mfbilFlight.Key = le.FlightID.ToString(CultureInfo.InvariantCulture);
        mfbilFlight.Refresh();
        mfbGoogleMapManager1.Map.Images = mfbilFlight.Images.ImageArray;

        Controls_mfbVideoEntry ve = (Controls_mfbVideoEntry)fv.FindControl("mfbVideoEntry1");

        ve.Videos.Clear();
        foreach (VideoRef vr in le.Videos)
        {
            ve.Videos.Add(vr);
        }

        Controls_mfbAirportServices aptSvc = (Controls_mfbAirportServices)fv.FindControl("mfbAirportServices1");

        aptSvc.GoogleMapID = mfbGoogleMapManager1.MapID;
        aptSvc.SetAirports(RoutesList.MasterList.GetNormalizedAirports());

        ((Controls_mfbSignature)fv.FindControl("mfbSignature")).Flight = le;
    }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
    protected void gvFlightLogs_Sorting(Object sender, GridViewSortEventArgs e)
    {
        if (sender == null)
        {
            throw new ArgumentNullException("sender");
        }
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }

        GridView gv = (GridView)sender;
        List <LogbookEntryDisplay> lst = (List <LogbookEntryDisplay>)gv.DataSource;

        if (lst != null)
        {
            if (HasPrevSort)
            {
                string        PrevSortExpr = LastSortExpr;
                SortDirection PrevSortDir  = LastSortDir;

                if (PrevSortExpr == e.SortExpression)
                {
                    e.SortDirection = (PrevSortDir == SortDirection.Ascending) ? SortDirection.Descending : SortDirection.Ascending;
                }
            }

            LastSortExpr = e.SortExpression;
            LastSortDir  = e.SortDirection;

            LogbookEntryDisplay.SortLogbook(lst, LastSortExpr, LastSortDir);
            BindData();
        }
    }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
    protected void fmvLE_DataBound(object sender, EventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }
        if (sender == null)
        {
            throw new ArgumentNullException(nameof(sender));
        }
        if (!(sender is FormView fv))
        {
            throw new InvalidCastException("Sender is not a formview!");
        }

        LogbookEntryDisplay le = (LogbookEntryDisplay)fv.DataItem;

        BindImages(fv.FindControl("mfbilFlight"), le, mfbGoogleMapManager1);

        BindVideoEntries(fv.FindControl("mfbVideoEntry1"), le);

        BindAirportServices(fv.FindControl("mfbAirportServices1"), mfbGoogleMapManager1, CurrentFlight.Route);

        BindSignature(fv.FindControl("mfbSignature"), le);

        BindBadges(Viewer, le.FlightID, fv.FindControl("rptBadges"));
    }
Exemplo n.º 8
0
        protected void Refresh()
        {
            bool fRestrictionIsDefault = Restriction.IsDefault;

            mfbLogbook1.DetailsParam = fRestrictionIsDefault ? string.Empty : "fq=" + HttpUtility.UrlEncode(Restriction.ToBase64CompressedJSONString());
            mfbLogbook1.User         = Page.User.Identity.Name;
            mfbLogbook1.Restriction  = Restriction;
            mfbLogbook1.RefreshData();
            if (mfbChartTotals1.Visible)
            {
                mfbChartTotals1.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook1.Data, Restriction.UserName);
                mfbChartTotals1.Refresh();
            }
            if (mfbTotalSummary1.Visible)
            {
                mfbTotalSummary1.CustomRestriction = Restriction;
            }
            ResolvePrintLink();
            pnlFilter.Visible = !fRestrictionIsDefault && IsNewFlight;
            mfbQueryDescriptor1.DataSource   = fRestrictionIsDefault ? null : Restriction;
            apcFilter.LabelControl.Font.Bold = !fRestrictionIsDefault;
            apcFilter.IsEnhanced             = !fRestrictionIsDefault;

            if (!IsNewFlight)
            {
                mfbLogbook1.GetNeighbors(FlightID, out int prevFlightID, out int nextFlightID);
                mfbEditFlight1.SetPrevFlight(prevFlightID);
                mfbEditFlight1.SetNextFlight(nextFlightID);
            }

            mfbQueryDescriptor1.DataBind();
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
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;
        }
    }
Exemplo n.º 12
0
    protected void UpdateForUser(string szUser)
    {
        FlightQuery r = Restriction;

        mfbTotalSummary.Username = mfbCurrency.UserName = mfbLogbook.User = szUser;

        if (CurrentShareKey.CanViewTotals)
        {
            mfbTotalSummary.CustomRestriction = mfbLogbook.Restriction = r;
        }

        bool fRestrictionIsDefault = r.IsDefault;

        mfbQueryDescriptor.DataSource = fRestrictionIsDefault ? null : r;
        mfbQueryDescriptor.DataBind();
        apcFilter.LabelControl.Font.Bold = !fRestrictionIsDefault;
        apcFilter.IsEnhanced             = !fRestrictionIsDefault;
        pnlFilter.Visible = !fRestrictionIsDefault;

        if (CurrentShareKey.CanViewFlights)
        {
            mfbLogbook.RefreshData();
        }

        mfbChartTotals.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook.Data, r.UserName);
        mfbChartTotals.Refresh();

        if (CurrentShareKey.CanViewVisitedAirports)
        {
            RefreshVisitedAirports();
        }
    }
Exemplo n.º 13
0
        public override int RowHeight(LogbookEntryDisplay le)
        {
            if (le == null)
            {
                throw new ArgumentNullException("le");
            }
            // Very rough computation: look at customproperties + comments, shoot for ~50chars/line, 2 lines/flight, so divide by 100
            // Signature can be about 3 lines tall
            int sigHeight = le.CFISignatureState == LogbookEntry.SignatureState.None ? 0 : (le.HasDigitizedSig ? 2 : 1);
            int imgHeight = le.FlightImages != null && le.FlightImages.Length > 0 ? 3 : 0;

            // see how many rows of times we have - IF the user shows them
            int times = 0;

            if (CurrentUser != null && CurrentUser.DisplayTimesByDefault)
            {
                times  = String.IsNullOrEmpty(le.EngineTimeDisplay) ? 0 : 1;
                times += String.IsNullOrEmpty(le.FlightTimeDisplay) ? 0 : 1;
                times += String.IsNullOrEmpty(le.HobbsDisplay) ? 0 : 1;

                // if there are 1 or 2 rows of times, add 1 to rowheight.  If 3, add 2.
                times = (times + 1) / 2;
            }

            return(Math.Max(1 + imgHeight + sigHeight + times, (le.RedactedComment.Length + le.CustPropertyDisplay.Length) / 100));
        }
 private void SetUpSelectionForRow(LogbookEntryDisplay le, GridViewRow row)
 {
     if (IsInSelectMode && IsViewingOwnFlights)
     {
         ((CheckBox)row.FindControl("ckSelected")).Attributes["onclick"] = String.Format(CultureInfo.InvariantCulture, "javascript:toggleSelectedFlight('{0}');", le.FlightID);
         BoundItems.Add(le.FlightID);
     }
 }
Exemplo n.º 15
0
 protected static void BindSignature(Control c, LogbookEntryDisplay le)
 {
     if (!(c is Controls_mfbSignature sig))
     {
         throw new ArgumentNullException(nameof(c));
     }
     sig.Flight = le ?? throw new ArgumentNullException(nameof(le));
 }
 protected void DeleteFlight(int id)
 {
     LogbookEntryDisplay.FDeleteEntry(id, this.User);
     FlushCache();
     BindData(Data);
     RefreshNumFlights();
     ItemDeleted?.Invoke(this, new LogbookEventArgs(id));
 }
Exemplo n.º 17
0
        public static string[] SuggestTraining(string prefixText, int count)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated || String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
            {
                throw new MyFlightbookException("Unauthenticated call to SuggestTraining");
            }

            return(LogbookEntryDisplay.SuggestTraining(prefixText, count));
        }
Exemplo n.º 18
0
 public override int RowHeight(LogbookEntryDisplay le)
 {
     if (le == null)
     {
         throw new ArgumentNullException("le");
     }
     // Very rough computation: look at customproperties + comments, shoot for ~50chars/line, 2 lines/flight, so divide by 100
     return(Math.Max(1, (le.RedactedComment.Length + le.CustPropertyDisplay.Length) / 100));
 }
Exemplo n.º 19
0
    protected void mfbFlightContextMenu_DeleteFlight(object sender, LogbookEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }

        LogbookEntryDisplay.FDeleteEntry(e.FlightID, Page.User.Identity.Name);
        Response.Redirect(TargetPage);
    }
Exemplo n.º 20
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();
    }
    private void SetUpContextMenuForRow(LogbookEntryDisplay le, GridViewRow row)
    {
        // Wire up the drop-menu.  We have to do this here because it is an iNamingContainer and can't access the gridviewrow
        Controls_mfbFlightContextMenu cm = (Controls_mfbFlightContextMenu)row.FindControl("popmenu1").FindControl("mfbFlightContextMenu");

        string szEditContext = EditContextParams(gvFlightLogs.PageIndex);

        cm.EditTargetFormatString = (EditPageUrlFormatString == null) ? string.Empty : (EditPageUrlFormatString + (String.IsNullOrEmpty(szEditContext) ? string.Empty : (EditPageUrlFormatString.Contains("?") ? "&" : "?" + szEditContext)));
        cm.Flight = le;
    }
Exemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.tabTraining;

        if (!IsPostBack)
        {
            hdnStudent.Value = Page.User.Identity.Name; //default
            string            szStudent = util.GetStringParam(Request, "student");
            CFIStudentMap     sm        = new CFIStudentMap(Page.User.Identity.Name);
            InstructorStudent student   = CFIStudentMap.GetInstructorStudent(sm.Students, szStudent);
            if (student == null)
            {
                lblErr.Text = Resources.SignOff.ViewStudentNoSuchStudent;
            }
            else
            {
                if (!student.CanViewLogbook)
                {
                    lblErr.Text = Master.Title = Resources.SignOff.ViewStudentLogbookUnauthorized;
                }
                else
                {
                    // If we're here, we are authorized
                    lblHeader.Text   = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.ViewStudentLogbookHeader, student.UserFullName);
                    hdnStudent.Value = student.UserName;
                    Restriction      = new FlightQuery(student.UserName);

                    if (mfbLogbook1.CanResignValidFlights = student.CanAddLogbook)
                    {
                        mfbEditFlight.FlightUser = student.UserName;
                        mfbEditFlight.SetUpNewOrEdit(LogbookEntry.idFlightNew);
                    }
                    else
                    {
                        apcNewFlight.Visible = false;
                    }

                    if (!String.IsNullOrEmpty(hdnStudent.Value))
                    {
                        UpdateForUser(hdnStudent.Value);
                    }

                    mfbSearchForm.Username = printOptions.UserName = student.UserName;
                    ResolvePrintLink();
                }
            }

            pnlLogbook.Visible = (lblErr.Text.Length == 0);
        }

        if (pnlLogbook.Visible && mfbChartTotals.Visible)
        {
            mfbChartTotals.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook1.Data, hdnStudent.Value);   // do this every time, since charttotals doesn't persist its data.
        }
    }
Exemplo n.º 23
0
    private LogbookEntryDisplay LoadFlight(int idFlight)
    {
        // Check to see if the requested flight belongs to the current user, or if they're authorized.
        // It's an extra database hit (or more, if viewing a student flight), but will let us figure out next/previous
        string szFlightOwner = LogbookEntry.OwnerForFlight(idFlight);

        if (String.IsNullOrEmpty(szFlightOwner))
        {
            throw new MyFlightbookException(Resources.LogbookEntry.errNoSuchFlight);
        }

        bool fIsAdmin = (util.GetIntParam(Request, "a", 0) != 0 && MyFlightbook.Profile.GetUser(Page.User.Identity.Name).CanSupport);

        // Check that you own the flight, or are admin.  If not either of these, check to see if you are authorized
        if (String.Compare(szFlightOwner, Page.User.Identity.Name, StringComparison.OrdinalIgnoreCase) != 0 && !fIsAdmin)
        {
            // check for authorized by student
            CFIStudentMap     sm      = new CFIStudentMap(Page.User.Identity.Name);
            InstructorStudent student = sm.GetInstructorStudent(sm.Students, szFlightOwner);
            if (student == null || !student.CanViewLogbook)
            {
                throw new MyFlightbookException(Resources.SignOff.ViewStudentLogbookUnauthorized);
            }

            // At this point, we're viewing a student's flight.  Change the return link.
            mvReturn.SetActiveView(vwReturnStudent);
            lnkReturnStudent.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/StudentLogbook.aspx?student={0}", szFlightOwner);
            lnkReturnStudent.Text        = String.Format(CultureInfo.CurrentCulture, Resources.Profile.ReturnToStudent, MyFlightbook.Profile.GetUser(szFlightOwner).UserFullName);
            popmenu.Visible = false;
        }

        // If we're here, we're authorized
        LogbookEntryDisplay led = new LogbookEntryDisplay(idFlight, szFlightOwner, LogbookEntry.LoadTelemetryOption.LoadAll);

        if (!led.HasFlightData)
        {
            led.FlightData = string.Empty;
        }

        if (String.IsNullOrEmpty(led.FlightData))
        {
            apcChart.Visible = apcDownload.Visible = apcRaw.Visible = false;
        }

        lblFlightDate.Text     = led.Date.ToShortDateString();
        lblFlightAircraft.Text = led.TailNumDisplay ?? string.Empty;
        lblCatClass.Text       = String.Format(CultureInfo.CurrentCulture, "({0})", led.CatClassDisplay);
        lblCatClass.CssClass   = led.IsOverridden ? "ExceptionData" : string.Empty;
        litDesc.Text           = led.CommentWithReplacedApproaches;
        lblRoute.Text          = led.Route.ToUpper(CultureInfo.CurrentCulture);

        Page.Title = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.FlightDetailsTitle, led.Date);

        return(led);
    }
Exemplo n.º 24
0
    private void SetUpImagesForRow(LogbookEntryDisplay le, GridViewRow row)
    {
        // Bind to images.
        Controls_mfbImageList mfbIl = (Controls_mfbImageList)row.FindControl("mfbilFlights");

        if (!SuppressImages)
        {
            // Flight images
            mfbIl.Key = le.FlightID.ToString(CultureInfo.InvariantCulture);
            mfbIl.Refresh();
            if (!le.FlightImages.Any()) // populate images, so that flight coloring can work
            {
                foreach (MyFlightbook.Image.MFBImageInfo mfbii in mfbIl.Images.ImageArray)
                {
                    le.FlightImages.Add(mfbii);
                }
            }

            // wire up images
            if (mfbIl.Images.ImageArray.Count > 0 || le.Videos.Count > 0)
            {
                row.FindControl("pnlImagesHover").Visible = true;
            }
            else
            {
                row.FindControl("pnlFlightImages").Visible = false;
            }

            Aircraft ac = AircraftForUser.Find(a => a.AircraftID == le.AircraftID);
            string   szInstTypeDescription = ac == null ? string.Empty : AircraftInstance.ShortNameForInstanceType(ac.InstanceType);
            ((Label)row.FindControl("lblInstanceTypeDesc")).Text = szInstTypeDescription;

            // And aircraft
            // for efficiency, see if we've already done this tail number; re-use if already done
            if (!m_dictAircraftHoverIDs.ContainsKey(le.AircraftID))
            {
                if (ac != null)
                {
                    mfbilAircraft.DefaultImage = ac.DefaultImage;
                }

                mfbilAircraft.Key = le.AircraftID.ToString(CultureInfo.InvariantCulture);
                mfbilAircraft.Refresh();

                // cache the attributes string - there's a bit of computation involved in it.
                string szAttributes = ((Label)row.FindControl("lblModelAttributes")).Text.EscapeHTML();

                // and the image table.
                m_dictAircraftHoverIDs[le.AircraftID] = szInstTypeDescription + " " + szAttributes + mfbilAircraft.AsHTMLTable();
            }

            row.FindControl("plcTail").Controls.Add(new LiteralControl(m_dictAircraftHoverIDs[le.AircraftID]));
        }
    }
Exemplo n.º 25
0
    protected void apcAnalysis_ControlClicked(object sender, EventArgs e)
    {
        apcAnalysis.LazyLoad = false;
        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcAnalysis.ID);

        mfbAccordionProxyExtender.SetJavascriptForControl(apcAnalysis, true, idx);
        AccordionCtrl.SelectedIndex = idx;

        mfbChartTotals.Visible          = true;
        mfbChartTotals.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook1.Data, hdnStudent.Value);
        mfbChartTotals.Refresh();
    }
Exemplo n.º 26
0
        /// <summary>
        /// If we have a subtotal group that is striped (e.g., "ASEL", "AMEL", "[All]"), removes everything but the "[All]" group
        /// </summary>
        /// <param name="d"></param>
        private static void RemoveStripedSubtotals(IDictionary <string, LogbookEntryDisplay> d)
        {
            if (d == null || d.Count <= 1 || !d.ContainsKey(Resources.LogbookEntry.PrintTotalsAllCatClass))
            {
                return;
            }

            LogbookEntryDisplay led = d[Resources.LogbookEntry.PrintTotalsAllCatClass];

            d.Clear();
            d[Resources.LogbookEntry.PrintTotalsAllCatClass] = led;
        }
Exemplo n.º 27
0
        public override int RowHeight(LogbookEntryDisplay le)
        {
            if (le == null)
            {
                throw new ArgumentNullException("le");
            }
            // Very rough computation: look at customproperties + comments, shoot for ~120chars/line
            int linesOfText = (int)Math.Ceiling(le.RedactedComment.Length / 120.0) + (int)Math.Ceiling(le.CustPropertyDisplay.Length / 120.0);
            int routeLine   = le.Airports.Count() > 2 ? 1 : 0;

            return(Math.Max(1, (linesOfText + routeLine + 1) / 2));
        }
Exemplo n.º 28
0
    protected void SortGridview(GridView gv, List <LogbookEntryDisplay> lst)
    {
        if (!String.IsNullOrEmpty(LastSortExpr))
        {
            foreach (DataControlField dcf in gv.Columns)
            {
                dcf.HeaderStyle.CssClass = "headerBase" + ((dcf.SortExpression.CompareCurrentCultureIgnoreCase(LastSortExpr) == 0) ? (LastSortDir == SortDirection.Ascending ? " headerSortAsc" : " headerSortDesc") : string.Empty);
            }
        }

        LogbookEntryDisplay.SortLogbook(lst, LastSortExpr, LastSortDir);
        BindData(lst);
    }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
    public IList <LogbookEntryDisplay> CondenseFlights(IEnumerable <LogbookEntryDisplay> lstIn)
    {
        List <LogbookEntryDisplay> lstOut = new List <LogbookEntryDisplay>();

        if (lstIn == null)
        {
            throw new ArgumentNullException(nameof(lstIn));
        }

        LogbookEntryDisplay ledCurrent = null;

        foreach (LogbookEntryDisplay ledSrc in lstIn)
        {
            if (ledCurrent == null)
            {
                ledCurrent         = ledSrc;
                ledSrc.FlightCount = 1;
            }
            else if (ledSrc.Date.Date.CompareTo(ledCurrent.Date.Date) != 0 || ledSrc.CatClassDisplay.CompareCurrentCultureIgnoreCase(ledCurrent.CatClassDisplay) != 0)
            {
                lstOut.Add(ledCurrent);
                ledCurrent         = ledSrc;
                ledSrc.FlightCount = 1;
            }
            else
            {
                ledCurrent.AddFrom(ledSrc);
                List <string> lst = new List <string>()
                {
                    ledCurrent.Route, ledSrc.Route
                };
                lst.RemoveAll(sz => String.IsNullOrWhiteSpace(sz));
                ledCurrent.Route = String.Join(" / ", lst);
                lst = new List <string>()
                {
                    ledCurrent.Comment, ledSrc.Comment
                };
                lst.RemoveAll(sz => String.IsNullOrWhiteSpace(sz));
                ledCurrent.Comment = String.Join(" / ", lst);
                ledSrc.FlightCount++;
            }
        }
        if (ledCurrent != null)
        {
            lstOut.Add(ledCurrent);
        }

        return(lstOut);
    }